From e4b63328e5e02c93eb6dd0b9e1b119fff1e9a0ba Mon Sep 17 00:00:00 2001 From: Vincent Rozenberg Date: Fri, 20 Sep 2024 11:23:31 +0200 Subject: [PATCH] Add files via upload --- readme.md | 72 +++++++++++++++++++++++ vincent-under-construction.php | 104 +++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 readme.md create mode 100644 vincent-under-construction.php diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..92f7081 --- /dev/null +++ b/readme.md @@ -0,0 +1,72 @@ +# Vincent's Under Construction + +A simple WordPress plugin that allows you to display an under construction page while your site is being developed or updated. + +## Description + +Vincent's Under Construction is a lightweight WordPress plugin that enables you to easily set up an "under construction" or "coming soon" page for your website. When activated, it redirects all non-logged-in users to a specified page, allowing you to work on your site without interruption. + +## Features + +- Easy to use admin interface +- Select any page as your under construction page +- Redirect all non-logged-in users to the under construction page +- Logged-in users can still access the entire site +- Settings link directly from the plugins page + +## Installation + +1. Download the plugin zip file +2. Log in to your WordPress admin panel +3. Go to Plugins > Add New +4. Click on the "Upload Plugin" button +5. Upload the zip file you downloaded +6. Activate the plugin through the 'Plugins' menu in WordPress + +## Usage + +1. After activation, go to the "Under Construction" menu item in your WordPress admin panel +2. Check the box to enable the under construction mode +3. Select the page you want to use as your under construction page from the dropdown menu +4. Save your settings + +## Requirements + +- WordPress 4.0 or higher +- PHP 5.6 or higher + +## Frequently Asked Questions + +**Q: Can logged-in users see the full site?** +A: Yes, logged-in users will have full access to the site. + +**Q: Can I customize the under construction page?** +A: Yes, you can create and design any page in WordPress and set it as your under construction page. + +## Changelog + +### 1.1 +- Added success alerts when settings are saved +- Improved settings sanitization +- Added settings link on plugins page + +### 1.0 +- Initial release + +## Support + +For support, feature requests, or bug reports, please open an issue on the [GitHub repository](https://github.com/your-github-username/vincents-under-construction). + +## License + +This project is licensed under the GPL v2 or later. + +## Author + +Vincent Rozenberg +- Website: [https://vincentrozenberg.com](https://vincentrozenberg.com) +- GitHub: [@vincentrozenberg](https://github.com/vincentrozenberg) + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. diff --git a/vincent-under-construction.php b/vincent-under-construction.php new file mode 100644 index 0000000..d01415f --- /dev/null +++ b/vincent-under-construction.php @@ -0,0 +1,104 @@ + +
+

Under Construction Settings

+ +
+

Settings saved.

+
+ +
+ +
+
+ '; +} + +// Callback for page selection +function suc_page_callback() { + $options = get_option('suc_settings'); + $pages = get_pages(); + echo ''; +} + +// Redirect to under construction page +function suc_redirect() { + $options = get_option('suc_settings'); + + if (isset($options['enabled']) && $options['enabled'] == 1 && !is_user_logged_in()) { + $under_construction_page = isset($options['page']) ? get_permalink($options['page']) : home_url(); + + if (!is_page($options['page'])) { + wp_redirect($under_construction_page); + exit; + } + } +} +add_action('template_redirect', 'suc_redirect'); + +// Add settings link on plugin page +function suc_settings_link($links) { + $settings_link = 'Settings'; + array_unshift($links, $settings_link); + return $links; +} +$plugin = plugin_basename(__FILE__); +add_filter("plugin_action_links_$plugin", 'suc_settings_link');