Plugin Directory

Changeset 3440572


Ignore:
Timestamp:
01/15/2026 06:28:22 PM (3 months ago)
Author:
bdplugins
Message:

Release v1.0.2

Location:
site-under-construction
Files:
8 added
14 edited
6 copied

Legend:

Unmodified
Added
Removed
  • site-under-construction/tags/1.0.2/includes/class-constant.php

    r3439751 r3440572  
    99class Constant
    1010{
    11     public const VERSION = '1.0.1';
     11    public const VERSION = '1.0.2';
    1212    public const MIN_PHP_VERSION = '8.0';
    1313    public const MIN_WP_VERSION = '6.2';
     
    1717    public const PLUGIN_URL = BDPSUC_URL;
    1818
    19     public static function get_plugin_dir($path)
     19    public static function get_plugin_dir($path = '')
    2020    {
    2121        if ($path && str_starts_with($path, '/')) {
     
    2626    }
    2727
    28     public static function get_plugin_url($path)
     28    public static function get_plugin_url($path = '')
    2929    {
    3030        if ($path && str_starts_with($path, '/')) {
  • site-under-construction/tags/1.0.2/includes/class-plugin.php

    r3439751 r3440572  
    1818        add_action('admin_init', [self::class, 'register_settings']);
    1919        add_action('plugin_action_links_' . Constant::get_plugin_basename(), [self::class, 'add_settings_link']);
     20        add_action('admin_enqueue_scripts', [self::class, 'enqueue_admin_styles']);
     21
     22        register_activation_hook(BDPSUC_FILE, [self::class, 'activate']);
     23        register_deactivation_hook(BDPSUC_FILE, [self::class, 'deactivate']);
     24        register_uninstall_hook(BDPSUC_FILE, [self::class, 'uninstall']);
     25    }
     26
     27    /* ---------------------------------------------------------
     28     * Admin Styles
     29     * --------------------------------------------------------- */
     30    public static function enqueue_admin_styles($hook)
     31    {
     32        if ('tools_page_bdpsuc-coming-soon' !== $hook) {
     33            return;
     34        }
     35
     36        wp_enqueue_style(
     37            'bdpsuc-admin-styles',
     38            Constant::get_plugin_url('assets/css/admin.css'),
     39            [],
     40            Constant::get_version()
     41        );
    2042    }
    2143
     
    4062
    4163        $title       = $options['title'] ?? null;
     64        $heading    = $options['heading'] ?? null;
    4265        $description = $options['description'] ?? null;
    4366        $theme       = ($options['theme'] ?? null) ?: 'modern-productivity';
     67        $password_protect = !empty($options['password_protect']);
     68        $password    = ($options['password'] ?? null) ?: 'welcome123';
     69
     70
     71        if ($password_protect) {
     72            if (isset($_POST['suc_password'], $_POST['bdpsuc_password_nonce']) &&
     73                wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['bdpsuc_password_nonce'])), 'bdpsuc_password_nonce')) {
     74                $entered_password = sanitize_text_field(wp_unslash($_POST['suc_password']));
     75                if ($entered_password === $password) {
     76                    setcookie('bdpsuc_access_granted', md5($entered_password), time() + 3600, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true);
     77                    return; // Correct password, allow access
     78                }
     79            } else {
     80                if (isset($_COOKIE['bdpsuc_access_granted']) && $_COOKIE['bdpsuc_access_granted'] === md5($password)) {
     81                    return; // Access already granted via cookie
     82                }
     83            }
     84        }
     85        $nonce = wp_create_nonce('bdpsuc_password_nonce');
    4486
    4587        status_header(503);
     
    4789
    4890        bdpsucGetTemplate("themes/$theme", [
    49             'heading1' => esc_html($title),
     91            'title' => esc_html($title),
     92            'heading' => esc_html($heading),
    5093            'content'  => wp_kses_post($description),
     94            'password_protect' => $password_protect,
     95            'password' => $password,
     96            'nonce'    => $nonce,
    5197        ]);
    5298
     
    88134
    89135        self::add_field('enabled', __('Enable Coming Soon Mode', 'site-under-construction'), [self::class, 'field_enabled']);
    90         self::add_field('title', __('Message Title', 'site-under-construction'), [self::class, 'field_title']);
     136
     137        self::add_field('title', __('Page Title', 'site-under-construction'), [self::class, 'field_title']);
     138
     139        self::add_field('heading', __('Message Heading', 'site-under-construction'), [self::class, 'field_heading']);
     140
    91141        self::add_field('description', __('Message Description', 'site-under-construction'), [self::class, 'field_description']);
     142
    92143        self::add_field('theme', __('Coming Soon Theme', 'site-under-construction'), [self::class, 'field_theme']);
     144
     145        self::add_field('password_protect', __('Password Protection', 'site-under-construction'), [self::class, 'field_password_protect']);
    93146    }
    94147
     
    111164        $options = get_option(self::OPTION_NAME, []);
    112165        ?>
    113         <label>
    114             <input type="checkbox" name="<?= self::OPTION_NAME ?>[enabled]" value="1" <?php checked($options['enabled'] ?? false); ?>>
    115             <?php esc_html_e('Enable Coming Soon mode for visitors', 'site-under-construction'); ?>
    116         </label>
     166        <div class="bdpsuc-switch-wrapper">
     167            <label class="bdpsuc-switch-label">
     168                <input type="checkbox" name="<?= self::OPTION_NAME ?>[enabled]" value="1" <?php checked($options['enabled'] ?? false); ?>>
     169                <span class="bdpsuc-switch-slider"></span>
     170            </label>
     171            <p class="bdpsuc-switch-description"><?php esc_html_e('Enable Coming Soon mode for visitors', 'site-under-construction'); ?></p>
     172        </div>
    117173        <?php
    118174    }
     
    129185    }
    130186
     187    public static function field_heading()
     188    {
     189        $options = get_option(self::OPTION_NAME, []);
     190        ?>
     191        <input type="text"
     192            class="regular-text"
     193            name="<?= self::OPTION_NAME ?>[heading]"
     194            value="<?= esc_attr($options['heading'] ?? '') ?>">
     195        <?php
     196    }
     197
    131198    public static function field_description()
    132199    {
     
    143210        $theme   = $options['theme'] ?? 'modern-productivity';
    144211        ?>
    145         <select name="<?= self::OPTION_NAME ?>[theme]">
    146             <option value="simple-elegant" <?php selected($theme, 'simple-elegant'); ?>>
    147                 Simple Elegant
    148             </option>
    149             <option value="modern-productivity" <?php selected($theme, 'modern-productivity'); ?>>
    150                 Modern Productivity
    151             </option>
    152             <option value="modern-productivity-women" <?php selected($theme, 'modern-productivity-women'); ?>>
    153                 Modern Productivity (Women)
    154             </option>
    155             <option value="exclusive-hotel" <?php selected($theme, 'exclusive-hotel'); ?>>
    156                 Exclusive Hotel
    157             </option>
    158         </select>
     212        <?php
     213            $themeMap = [
     214                [
     215                    'name' => 'Simple Elegant',
     216                    'id'   => 'simple-elegant',
     217                    'img'  => 'simple-elegant.webp'
     218                ],
     219                [
     220                    'name' => 'Modern Productivity',
     221                    'id'   => 'modern-productivity',
     222                    'img'  => 'modern-productivity.webp'
     223                ],
     224                [
     225                    'name' => 'Modern Productivity (Women)',
     226                    'id'   => 'modern-productivity-women',
     227                    'img'  => 'modern-productivity-women.webp'
     228                ],
     229                [
     230                    'name' => 'Exclusive Hotel',
     231                    'id'   => 'exclusive-hotel',
     232                    'img'  => 'exclusive-hotel.webp'
     233                ],
     234            ];
     235        ?>
     236        <div class="bdpsuc-theme-card">
     237            <?php foreach ($themeMap as $themeOption) : ?>
     238            <label class="bdpsuc--radio">
     239                <input type="radio" name="<?= self::OPTION_NAME ?>[theme]" <?php checked($theme, $themeOption['id']); ?> value="<?= esc_attr($themeOption['id']) ?>">
     240                <div class="bdpsuc-radio-btn" style="background: url(<?= esc_url(Constant::get_plugin_url('assets/images/' . $themeOption['img'])) ?>) no-repeat center/cover;">
     241                    <i class="dashicons dashicons-yes"></i>
     242                    <span class="bdpsuc-theme-name"><?= esc_html($themeOption['name']) ?></span>
     243                </div>
     244            </label>
     245            <?php endforeach; ?>
     246        </div>
     247        <?php
     248    }
     249
     250    public static function field_password_protect()
     251    {
     252        $options = get_option(self::OPTION_NAME, []);
     253        ?>
     254        <div class="bdpsuc-switch-wrapper">
     255            <label class="bdpsuc-switch-label">
     256                <input type="checkbox" name="<?= self::OPTION_NAME ?>[password_protect]" value="1" <?php checked($options['password_protect'] ?? false); ?>>
     257                <span class="bdpsuc-switch-slider"></span>
     258            </label>
     259            <p class="description"><?php esc_html_e('Visitors will need to enter a password to access the site while Coming Soon mode is active.', 'site-under-construction'); ?></p>
     260        </div>
     261
     262        <br/>
     263        <div class="bdpsuc-password-field-wrapper">
     264            <input type="password"
     265            id="bdpsuc_password_field"
     266            name="<?= self::OPTION_NAME ?>[password]"
     267            value="<?= esc_attr($options['password'] ?? '') ?>"
     268            class="regular-text">
     269            <br/>
     270            <label for="bdpsuc_password_field"><?php esc_html_e('Enter the password! if not set password will be "welcome123"', 'site-under-construction'); ?></label>
     271        </div>
    159272        <?php
    160273    }
     
    187300            'enabled'     => !empty($input['enabled']),
    188301            'title'       => sanitize_text_field($input['title'] ?? ''),
     302            'heading'     => sanitize_text_field($input['heading'] ?? ''),
    189303            'description' => wp_kses_post($input['description'] ?? ''),
    190304            'theme'       => sanitize_key($input['theme'] ?? 'modern-productivity'),
     305            'password_protect' => !empty($input['password_protect']),
     306            'password'    => sanitize_text_field($input['password'] ?? ''),
    191307        ];
    192308    }
     
    199315        return $links;
    200316    }
     317
     318    /* ---------------------------------------------------------
     319     * Activation / Deactivation Hooks / Uninstall
     320     * --------------------------------------------------------- */
     321    public static function activate()
     322    {
     323        $default_options = [
     324            'enabled'     => false,
     325            'title'       => __('Site Under Construction', 'site-under-construction'),
     326            'heading'     => __('We\'ll be here soon!', 'site-under-construction'),
     327            'description' => __('Our website is currently under construction. We\'ll be here soon.', 'site-under-construction'),
     328            'theme'       => 'modern-productivity',
     329            'password_protect' => false,
     330            'password'    => '',
     331        ];
     332
     333        add_option(self::OPTION_NAME, $default_options);
     334
     335        if (!get_option('bdpsuc_installed')) {
     336            add_option('bdpsuc_installed', time());
     337        }
     338
     339        if (!get_option('bdpsuc_version')) {
     340            add_option('bdpsuc_version', Constant::get_version());
     341        }
     342
     343        update_option('bdpsuc_version', Constant::get_version());
     344    }
     345
     346    public static function deactivate()
     347    {
     348        // No actions needed on deactivation for now.
     349    }
     350
     351    public static function uninstall()
     352    {
     353        delete_option(self::OPTION_NAME);
     354        delete_option('bdpsuc_installed');
     355        delete_option('bdpsuc_version');
     356    }
    201357}
  • site-under-construction/tags/1.0.2/readme.txt

    r3439751 r3440572  
    11=== Site Under Construction ===
    22Contributors: bdplugins
    3 Tags: coming soon page, under construction mode, under construction, under construction page, coming soon mode
     3Tags: coming soon, under construction, maintenance mode, coming soon page, under maintenance
    44Requires at least: 6.2
    55Tested up to: 6.9
    66Requires PHP: 8.0
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A simple plugin to display a "Site Under Construction" page to visitors while administrators can view the site.
     11A simple and lightweight Coming Soon / Under Construction plugin that lets visitors see a maintenance page while administrators continue working on the site.
    1212
    1313== Description ==
    1414
    15 The **Site Under Construction** plugin allows you to quickly put your WordPress site into maintenance mode. When enabled, visitors will see a customizable "Site Under Construction" message, while administrators can continue to view and work on the site as usual.
     15**Site Under Construction** is a lightweight WordPress plugin designed to help you temporarily hide your website while it is under development, maintenance, or preparing for launch.
    1616
    17 Features:
    18 - Enable or disable the "Site Under Construction" mode with a checkbox.
    19 - Customize the message displayed to visitors.
    20 - Seamlessly integrates with the WordPress tools page.
    21 - Change 4 modern coming soon template.
     17Once enabled, visitors will see a clean and modern Coming Soon page, while logged-in administrators can access and manage the site normally. The plugin is easy to configure, performance-friendly, and follows WordPress coding standards.
     18
     19Whether you are redesigning a website or preparing for a launch, this plugin provides a simple and reliable solution.
     20
     21== Features ==
     22
     23* Enable or disable Coming Soon mode with a single click
     24* Customizable page title, heading, and description text
     25* Choose from 4 modern Coming Soon templates
     26* Optional password protection for visitor access
     27* Administrators automatically bypass the Coming Soon page
     28* Simple settings page under the WordPress Tools menu
     29* Lightweight, fast, and compatible with modern WordPress versions
    2230
    2331== Installation ==
    2432
    25 1. Upload the plugin folder to the `/wp-content/plugins/` directory, or install the plugin through the WordPress plugins screen directly.
    26 2. Activate the plugin through the 'Plugins' screen in WordPress.
    27 3. Go to 'Settings' -> 'General' to configure the "Coming Soon" settings.
     331. Upload the plugin folder to the `/wp-content/plugins/` directory 
     34   OR install the plugin directly from the WordPress Plugin Directory.
     352. Activate the plugin from the **Plugins** menu in WordPress.
     363. Go to **Tools → Coming Soon**.
     374. Enable Coming Soon mode and customize the page settings.
    2838
    2939== Frequently Asked Questions ==
    3040
    31 = Who will see the "Site Under Construction" message? =
    32 Visitors to your site who are not logged in as administrators will see the message. Administrators can view the site as usual.
     41= Who will see the Coming Soon page? =
     42All visitors who are not logged in as administrators will see the Coming Soon page. Administrators can access the website normally.
    3343
    34 = Can I customize the message? =
    35 Yes, you can customize the "Site Under Construction" message from the General Settings page.
     44= Can I customize the Coming Soon content? =
     45Yes. You can customize the page title, heading, description text, and select a template from the plugin settings.
    3646
    37 = How do I enable or disable the "Site Under Construction" mode? =
    38 You can enable or disable the mode by checking or unchecking the checkbox in the General Settings page.
     47= Does the plugin support password protection? =
     48Yes. You can enable password protection to allow visitors to access the site using a password while Coming Soon mode is active.
     49
     50= How do I disable Coming Soon mode? =
     51Simply uncheck the **Enable Coming Soon Mode** option from the plugin settings page and save your changes.
     52
     53== Screenshots ==
     54
     551. Coming Soon page frontend preview
     562. Plugin settings page
     573. Template selection options
     584. Password protection settings
    3959
    4060== Changelog ==
    41 = 1.0.1=
    42 * Added: Four new Coming Soon templates.
    43 * Added: Options to customize the Coming Soon description text.
    44 * Improved: Code optimization for better performance and maintainability.
     61
     62= 1.0.2 =
     63* Added: Password protection functionality
     64* Improved: Template selection user interface
     65
     66= 1.0.1 =
     67* Added: Four modern Coming Soon templates
     68* Added: Custom description text options
     69* Improved: Code optimization for better performance and maintainability
    4570
    4671= 1.0.0 =
    47 * Initial release with the ability to enable/disable the mode and customize the message.
     72* Initial release
     73* Enable/disable Coming Soon mode
     74* Customize page title, heading, and message
    4875
     76== Upgrade Notice ==
     77
     78= 1.0.2 =
     79This update adds password protection and improves the template selection interface. Recommended for all users.
  • site-under-construction/tags/1.0.2/site-under-construction.php

    r3439751 r3440572  
    66 * Plugin Name: Site Under Construction
    77 * Description: A simple plugin to display a "Site Under Construction" page to visitors while administrators can view the site.
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Requires PHP: 8.0
    1010 * Requires at least: 6.2
  • site-under-construction/tags/1.0.2/templates/themes/exclusive-hotel.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Hotel Exclusive';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'Hotel Exclusive';
     18$heading     = ($args['heading'] ?? null) ?: 'Hotel Exclusive';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We are working hard to bring you something amazing.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/exclusive-hotel.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    137141
    138142    <main>
    139         <h1><?php echo esc_html($heading1); ?></h1>
     143        <h1><?php echo esc_html($heading); ?></h1>
    140144
    141145        <p class="content">
    142146            <?php echo esc_html($content); ?>
    143147        </p>
     148       
     149        <?php if ($password_protect) : ?>
     150            <form method="post" action="" style="margin-top: 20px;">
     151                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     152                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     153                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; cursor: pointer;">Submit</button>
     154            </form>
     155        <?php endif; ?>
    144156
    145157        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/tags/1.0.2/templates/themes/modern-productivity-women.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Site Under Construction Plugin';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'We\'ll be here soon!';
     18$heading     = ($args['heading'] ?? null) ?: 'We\'ll be here soon!';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/modern-productivity-women.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    126130
    127131    <main class="container">
    128         <h1><?php echo esc_html($heading1); ?></h1>
     132        <h1><?php echo esc_html($heading); ?></h1>
    129133
    130134        <p class="content">
    131135            <?php echo esc_html($content); ?>
    132136        </p>
     137
     138        <?php if ($password_protect) : ?>
     139            <form method="post" action="" style="margin-top: 20px;">
     140                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     141                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     142                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; cursor: pointer; background-color: #222;">Submit</button>
     143            </form>
     144        <?php endif; ?>
    133145
    134146        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/tags/1.0.2/templates/themes/modern-productivity.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Site Under Construction Plugin';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'We\'ll be here soon!';
     18$heading     = ($args['heading'] ?? null) ?: 'We\'ll be here soon!';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/modern-productivity.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    126130
    127131    <main class="container">
    128         <h1><?php echo esc_html($heading1); ?></h1>
     132        <h1><?php echo esc_html($heading); ?></h1>
    129133
    130134        <p class="content">
    131135            <?php echo esc_html($content); ?>
    132136        </p>
     137
     138        <?php if ($password_protect) : ?>
     139            <form method="post" action="" style="margin-top: 20px;">
     140                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     141                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     142                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; background-color: #222; cursor: pointer;">Submit</button>
     143            </form>
     144        <?php endif; ?>
    133145
    134146        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/tags/1.0.2/templates/themes/simple-elegant.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Site Under Construction Plugin';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'We’ll be here soon';
     18$heading     = ($args['heading'] ?? null) ?: 'We’ll be here soon';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We are working hard to bring you something amazing.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/simple-elegant.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    137141
    138142    <main>
    139         <h1><?php echo esc_html($heading1); ?></h1>
     143        <h1><?php echo esc_html($heading); ?></h1>
    140144
    141145        <p class="content">
    142146            <?php echo esc_html($content); ?>
    143147        </p>
     148       
     149        <?php if ($password_protect) : ?>
     150            <form method="post" action="" style="margin-top: 20px;">
     151                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     152                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     153                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; cursor: pointer;">Submit</button>
     154            </form>
     155        <?php endif; ?>
    144156
    145157        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/trunk/includes/class-constant.php

    r3439751 r3440572  
    99class Constant
    1010{
    11     public const VERSION = '1.0.1';
     11    public const VERSION = '1.0.2';
    1212    public const MIN_PHP_VERSION = '8.0';
    1313    public const MIN_WP_VERSION = '6.2';
     
    1717    public const PLUGIN_URL = BDPSUC_URL;
    1818
    19     public static function get_plugin_dir($path)
     19    public static function get_plugin_dir($path = '')
    2020    {
    2121        if ($path && str_starts_with($path, '/')) {
     
    2626    }
    2727
    28     public static function get_plugin_url($path)
     28    public static function get_plugin_url($path = '')
    2929    {
    3030        if ($path && str_starts_with($path, '/')) {
  • site-under-construction/trunk/includes/class-plugin.php

    r3439751 r3440572  
    1818        add_action('admin_init', [self::class, 'register_settings']);
    1919        add_action('plugin_action_links_' . Constant::get_plugin_basename(), [self::class, 'add_settings_link']);
     20        add_action('admin_enqueue_scripts', [self::class, 'enqueue_admin_styles']);
     21
     22        register_activation_hook(BDPSUC_FILE, [self::class, 'activate']);
     23        register_deactivation_hook(BDPSUC_FILE, [self::class, 'deactivate']);
     24        register_uninstall_hook(BDPSUC_FILE, [self::class, 'uninstall']);
     25    }
     26
     27    /* ---------------------------------------------------------
     28     * Admin Styles
     29     * --------------------------------------------------------- */
     30    public static function enqueue_admin_styles($hook)
     31    {
     32        if ('tools_page_bdpsuc-coming-soon' !== $hook) {
     33            return;
     34        }
     35
     36        wp_enqueue_style(
     37            'bdpsuc-admin-styles',
     38            Constant::get_plugin_url('assets/css/admin.css'),
     39            [],
     40            Constant::get_version()
     41        );
    2042    }
    2143
     
    4062
    4163        $title       = $options['title'] ?? null;
     64        $heading    = $options['heading'] ?? null;
    4265        $description = $options['description'] ?? null;
    4366        $theme       = ($options['theme'] ?? null) ?: 'modern-productivity';
     67        $password_protect = !empty($options['password_protect']);
     68        $password    = ($options['password'] ?? null) ?: 'welcome123';
     69
     70
     71        if ($password_protect) {
     72            if (isset($_POST['suc_password'], $_POST['bdpsuc_password_nonce']) &&
     73                wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['bdpsuc_password_nonce'])), 'bdpsuc_password_nonce')) {
     74                $entered_password = sanitize_text_field(wp_unslash($_POST['suc_password']));
     75                if ($entered_password === $password) {
     76                    setcookie('bdpsuc_access_granted', md5($entered_password), time() + 3600, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true);
     77                    return; // Correct password, allow access
     78                }
     79            } else {
     80                if (isset($_COOKIE['bdpsuc_access_granted']) && $_COOKIE['bdpsuc_access_granted'] === md5($password)) {
     81                    return; // Access already granted via cookie
     82                }
     83            }
     84        }
     85        $nonce = wp_create_nonce('bdpsuc_password_nonce');
    4486
    4587        status_header(503);
     
    4789
    4890        bdpsucGetTemplate("themes/$theme", [
    49             'heading1' => esc_html($title),
     91            'title' => esc_html($title),
     92            'heading' => esc_html($heading),
    5093            'content'  => wp_kses_post($description),
     94            'password_protect' => $password_protect,
     95            'password' => $password,
     96            'nonce'    => $nonce,
    5197        ]);
    5298
     
    88134
    89135        self::add_field('enabled', __('Enable Coming Soon Mode', 'site-under-construction'), [self::class, 'field_enabled']);
    90         self::add_field('title', __('Message Title', 'site-under-construction'), [self::class, 'field_title']);
     136
     137        self::add_field('title', __('Page Title', 'site-under-construction'), [self::class, 'field_title']);
     138
     139        self::add_field('heading', __('Message Heading', 'site-under-construction'), [self::class, 'field_heading']);
     140
    91141        self::add_field('description', __('Message Description', 'site-under-construction'), [self::class, 'field_description']);
     142
    92143        self::add_field('theme', __('Coming Soon Theme', 'site-under-construction'), [self::class, 'field_theme']);
     144
     145        self::add_field('password_protect', __('Password Protection', 'site-under-construction'), [self::class, 'field_password_protect']);
    93146    }
    94147
     
    111164        $options = get_option(self::OPTION_NAME, []);
    112165        ?>
    113         <label>
    114             <input type="checkbox" name="<?= self::OPTION_NAME ?>[enabled]" value="1" <?php checked($options['enabled'] ?? false); ?>>
    115             <?php esc_html_e('Enable Coming Soon mode for visitors', 'site-under-construction'); ?>
    116         </label>
     166        <div class="bdpsuc-switch-wrapper">
     167            <label class="bdpsuc-switch-label">
     168                <input type="checkbox" name="<?= self::OPTION_NAME ?>[enabled]" value="1" <?php checked($options['enabled'] ?? false); ?>>
     169                <span class="bdpsuc-switch-slider"></span>
     170            </label>
     171            <p class="bdpsuc-switch-description"><?php esc_html_e('Enable Coming Soon mode for visitors', 'site-under-construction'); ?></p>
     172        </div>
    117173        <?php
    118174    }
     
    129185    }
    130186
     187    public static function field_heading()
     188    {
     189        $options = get_option(self::OPTION_NAME, []);
     190        ?>
     191        <input type="text"
     192            class="regular-text"
     193            name="<?= self::OPTION_NAME ?>[heading]"
     194            value="<?= esc_attr($options['heading'] ?? '') ?>">
     195        <?php
     196    }
     197
    131198    public static function field_description()
    132199    {
     
    143210        $theme   = $options['theme'] ?? 'modern-productivity';
    144211        ?>
    145         <select name="<?= self::OPTION_NAME ?>[theme]">
    146             <option value="simple-elegant" <?php selected($theme, 'simple-elegant'); ?>>
    147                 Simple Elegant
    148             </option>
    149             <option value="modern-productivity" <?php selected($theme, 'modern-productivity'); ?>>
    150                 Modern Productivity
    151             </option>
    152             <option value="modern-productivity-women" <?php selected($theme, 'modern-productivity-women'); ?>>
    153                 Modern Productivity (Women)
    154             </option>
    155             <option value="exclusive-hotel" <?php selected($theme, 'exclusive-hotel'); ?>>
    156                 Exclusive Hotel
    157             </option>
    158         </select>
     212        <?php
     213            $themeMap = [
     214                [
     215                    'name' => 'Simple Elegant',
     216                    'id'   => 'simple-elegant',
     217                    'img'  => 'simple-elegant.webp'
     218                ],
     219                [
     220                    'name' => 'Modern Productivity',
     221                    'id'   => 'modern-productivity',
     222                    'img'  => 'modern-productivity.webp'
     223                ],
     224                [
     225                    'name' => 'Modern Productivity (Women)',
     226                    'id'   => 'modern-productivity-women',
     227                    'img'  => 'modern-productivity-women.webp'
     228                ],
     229                [
     230                    'name' => 'Exclusive Hotel',
     231                    'id'   => 'exclusive-hotel',
     232                    'img'  => 'exclusive-hotel.webp'
     233                ],
     234            ];
     235        ?>
     236        <div class="bdpsuc-theme-card">
     237            <?php foreach ($themeMap as $themeOption) : ?>
     238            <label class="bdpsuc--radio">
     239                <input type="radio" name="<?= self::OPTION_NAME ?>[theme]" <?php checked($theme, $themeOption['id']); ?> value="<?= esc_attr($themeOption['id']) ?>">
     240                <div class="bdpsuc-radio-btn" style="background: url(<?= esc_url(Constant::get_plugin_url('assets/images/' . $themeOption['img'])) ?>) no-repeat center/cover;">
     241                    <i class="dashicons dashicons-yes"></i>
     242                    <span class="bdpsuc-theme-name"><?= esc_html($themeOption['name']) ?></span>
     243                </div>
     244            </label>
     245            <?php endforeach; ?>
     246        </div>
     247        <?php
     248    }
     249
     250    public static function field_password_protect()
     251    {
     252        $options = get_option(self::OPTION_NAME, []);
     253        ?>
     254        <div class="bdpsuc-switch-wrapper">
     255            <label class="bdpsuc-switch-label">
     256                <input type="checkbox" name="<?= self::OPTION_NAME ?>[password_protect]" value="1" <?php checked($options['password_protect'] ?? false); ?>>
     257                <span class="bdpsuc-switch-slider"></span>
     258            </label>
     259            <p class="description"><?php esc_html_e('Visitors will need to enter a password to access the site while Coming Soon mode is active.', 'site-under-construction'); ?></p>
     260        </div>
     261
     262        <br/>
     263        <div class="bdpsuc-password-field-wrapper">
     264            <input type="password"
     265            id="bdpsuc_password_field"
     266            name="<?= self::OPTION_NAME ?>[password]"
     267            value="<?= esc_attr($options['password'] ?? '') ?>"
     268            class="regular-text">
     269            <br/>
     270            <label for="bdpsuc_password_field"><?php esc_html_e('Enter the password! if not set password will be "welcome123"', 'site-under-construction'); ?></label>
     271        </div>
    159272        <?php
    160273    }
     
    187300            'enabled'     => !empty($input['enabled']),
    188301            'title'       => sanitize_text_field($input['title'] ?? ''),
     302            'heading'     => sanitize_text_field($input['heading'] ?? ''),
    189303            'description' => wp_kses_post($input['description'] ?? ''),
    190304            'theme'       => sanitize_key($input['theme'] ?? 'modern-productivity'),
     305            'password_protect' => !empty($input['password_protect']),
     306            'password'    => sanitize_text_field($input['password'] ?? ''),
    191307        ];
    192308    }
     
    199315        return $links;
    200316    }
     317
     318    /* ---------------------------------------------------------
     319     * Activation / Deactivation Hooks / Uninstall
     320     * --------------------------------------------------------- */
     321    public static function activate()
     322    {
     323        $default_options = [
     324            'enabled'     => false,
     325            'title'       => __('Site Under Construction', 'site-under-construction'),
     326            'heading'     => __('We\'ll be here soon!', 'site-under-construction'),
     327            'description' => __('Our website is currently under construction. We\'ll be here soon.', 'site-under-construction'),
     328            'theme'       => 'modern-productivity',
     329            'password_protect' => false,
     330            'password'    => '',
     331        ];
     332
     333        add_option(self::OPTION_NAME, $default_options);
     334
     335        if (!get_option('bdpsuc_installed')) {
     336            add_option('bdpsuc_installed', time());
     337        }
     338
     339        if (!get_option('bdpsuc_version')) {
     340            add_option('bdpsuc_version', Constant::get_version());
     341        }
     342
     343        update_option('bdpsuc_version', Constant::get_version());
     344    }
     345
     346    public static function deactivate()
     347    {
     348        // No actions needed on deactivation for now.
     349    }
     350
     351    public static function uninstall()
     352    {
     353        delete_option(self::OPTION_NAME);
     354        delete_option('bdpsuc_installed');
     355        delete_option('bdpsuc_version');
     356    }
    201357}
  • site-under-construction/trunk/readme.txt

    r3439751 r3440572  
    11=== Site Under Construction ===
    22Contributors: bdplugins
    3 Tags: coming soon page, under construction mode, under construction, under construction page, coming soon mode
     3Tags: coming soon, under construction, maintenance mode, coming soon page, under maintenance
    44Requires at least: 6.2
    55Tested up to: 6.9
    66Requires PHP: 8.0
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A simple plugin to display a "Site Under Construction" page to visitors while administrators can view the site.
     11A simple and lightweight Coming Soon / Under Construction plugin that lets visitors see a maintenance page while administrators continue working on the site.
    1212
    1313== Description ==
    1414
    15 The **Site Under Construction** plugin allows you to quickly put your WordPress site into maintenance mode. When enabled, visitors will see a customizable "Site Under Construction" message, while administrators can continue to view and work on the site as usual.
     15**Site Under Construction** is a lightweight WordPress plugin designed to help you temporarily hide your website while it is under development, maintenance, or preparing for launch.
    1616
    17 Features:
    18 - Enable or disable the "Site Under Construction" mode with a checkbox.
    19 - Customize the message displayed to visitors.
    20 - Seamlessly integrates with the WordPress tools page.
    21 - Change 4 modern coming soon template.
     17Once enabled, visitors will see a clean and modern Coming Soon page, while logged-in administrators can access and manage the site normally. The plugin is easy to configure, performance-friendly, and follows WordPress coding standards.
     18
     19Whether you are redesigning a website or preparing for a launch, this plugin provides a simple and reliable solution.
     20
     21== Features ==
     22
     23* Enable or disable Coming Soon mode with a single click
     24* Customizable page title, heading, and description text
     25* Choose from 4 modern Coming Soon templates
     26* Optional password protection for visitor access
     27* Administrators automatically bypass the Coming Soon page
     28* Simple settings page under the WordPress Tools menu
     29* Lightweight, fast, and compatible with modern WordPress versions
    2230
    2331== Installation ==
    2432
    25 1. Upload the plugin folder to the `/wp-content/plugins/` directory, or install the plugin through the WordPress plugins screen directly.
    26 2. Activate the plugin through the 'Plugins' screen in WordPress.
    27 3. Go to 'Settings' -> 'General' to configure the "Coming Soon" settings.
     331. Upload the plugin folder to the `/wp-content/plugins/` directory 
     34   OR install the plugin directly from the WordPress Plugin Directory.
     352. Activate the plugin from the **Plugins** menu in WordPress.
     363. Go to **Tools → Coming Soon**.
     374. Enable Coming Soon mode and customize the page settings.
    2838
    2939== Frequently Asked Questions ==
    3040
    31 = Who will see the "Site Under Construction" message? =
    32 Visitors to your site who are not logged in as administrators will see the message. Administrators can view the site as usual.
     41= Who will see the Coming Soon page? =
     42All visitors who are not logged in as administrators will see the Coming Soon page. Administrators can access the website normally.
    3343
    34 = Can I customize the message? =
    35 Yes, you can customize the "Site Under Construction" message from the General Settings page.
     44= Can I customize the Coming Soon content? =
     45Yes. You can customize the page title, heading, description text, and select a template from the plugin settings.
    3646
    37 = How do I enable or disable the "Site Under Construction" mode? =
    38 You can enable or disable the mode by checking or unchecking the checkbox in the General Settings page.
     47= Does the plugin support password protection? =
     48Yes. You can enable password protection to allow visitors to access the site using a password while Coming Soon mode is active.
     49
     50= How do I disable Coming Soon mode? =
     51Simply uncheck the **Enable Coming Soon Mode** option from the plugin settings page and save your changes.
     52
     53== Screenshots ==
     54
     551. Coming Soon page frontend preview
     562. Plugin settings page
     573. Template selection options
     584. Password protection settings
    3959
    4060== Changelog ==
    41 = 1.0.1=
    42 * Added: Four new Coming Soon templates.
    43 * Added: Options to customize the Coming Soon description text.
    44 * Improved: Code optimization for better performance and maintainability.
     61
     62= 1.0.2 =
     63* Added: Password protection functionality
     64* Improved: Template selection user interface
     65
     66= 1.0.1 =
     67* Added: Four modern Coming Soon templates
     68* Added: Custom description text options
     69* Improved: Code optimization for better performance and maintainability
    4570
    4671= 1.0.0 =
    47 * Initial release with the ability to enable/disable the mode and customize the message.
     72* Initial release
     73* Enable/disable Coming Soon mode
     74* Customize page title, heading, and message
    4875
     76== Upgrade Notice ==
     77
     78= 1.0.2 =
     79This update adds password protection and improves the template selection interface. Recommended for all users.
  • site-under-construction/trunk/site-under-construction.php

    r3439751 r3440572  
    66 * Plugin Name: Site Under Construction
    77 * Description: A simple plugin to display a "Site Under Construction" page to visitors while administrators can view the site.
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Requires PHP: 8.0
    1010 * Requires at least: 6.2
  • site-under-construction/trunk/templates/themes/exclusive-hotel.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Hotel Exclusive';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'Hotel Exclusive';
     18$heading     = ($args['heading'] ?? null) ?: 'Hotel Exclusive';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We are working hard to bring you something amazing.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/exclusive-hotel.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    137141
    138142    <main>
    139         <h1><?php echo esc_html($heading1); ?></h1>
     143        <h1><?php echo esc_html($heading); ?></h1>
    140144
    141145        <p class="content">
    142146            <?php echo esc_html($content); ?>
    143147        </p>
     148       
     149        <?php if ($password_protect) : ?>
     150            <form method="post" action="" style="margin-top: 20px;">
     151                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     152                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     153                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; cursor: pointer;">Submit</button>
     154            </form>
     155        <?php endif; ?>
    144156
    145157        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/trunk/templates/themes/modern-productivity-women.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Site Under Construction Plugin';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'We\'ll be here soon!';
     18$heading     = ($args['heading'] ?? null) ?: 'We\'ll be here soon!';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/modern-productivity-women.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    126130
    127131    <main class="container">
    128         <h1><?php echo esc_html($heading1); ?></h1>
     132        <h1><?php echo esc_html($heading); ?></h1>
    129133
    130134        <p class="content">
    131135            <?php echo esc_html($content); ?>
    132136        </p>
     137
     138        <?php if ($password_protect) : ?>
     139            <form method="post" action="" style="margin-top: 20px;">
     140                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     141                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     142                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; cursor: pointer; background-color: #222;">Submit</button>
     143            </form>
     144        <?php endif; ?>
    133145
    134146        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/trunk/templates/themes/modern-productivity.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Site Under Construction Plugin';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'We\'ll be here soon!';
     18$heading     = ($args['heading'] ?? null) ?: 'We\'ll be here soon!';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/modern-productivity.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    126130
    127131    <main class="container">
    128         <h1><?php echo esc_html($heading1); ?></h1>
     132        <h1><?php echo esc_html($heading); ?></h1>
    129133
    130134        <p class="content">
    131135            <?php echo esc_html($content); ?>
    132136        </p>
     137
     138        <?php if ($password_protect) : ?>
     139            <form method="post" action="" style="margin-top: 20px;">
     140                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     141                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     142                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; background-color: #222; cursor: pointer;">Submit</button>
     143            </form>
     144        <?php endif; ?>
    133145
    134146        <?php if (! empty($social_icons)) : ?>
  • site-under-construction/trunk/templates/themes/simple-elegant.php

    r3439751 r3440572  
    1616$description  = ($args['description'] ?? null) ?: 'Our website is currently under construction. We\'ll be here soon.';
    1717$generator    = ($args['generator'] ?? null) ?: 'Site Under Construction Plugin';
    18 $heading1     = ($args['heading1'] ?? null) ?: 'We’ll be here soon';
     18$heading     = ($args['heading'] ?? null) ?: 'We’ll be here soon';
    1919$content      = ($args['content'] ?? null) ?: 'Our website is currently under construction. We are working hard to bring you something amazing.';
    2020$social_icons = $args['social_icons'] ?? [];
    2121$image_url    = ($args['image_url'] ?? null) ?: Constant::get_plugin_url('assets/images/simple-elegant.webp');
     22
     23$password_protect = $args['password_protect'] ?? false;
     24$password         = ($args['password'] ?? null) ?: 'welcome123';
     25$nonce        = $args['nonce'] ?? '';
    2226
    2327$footer       = $args['footer'] ?? '';
     
    137141
    138142    <main>
    139         <h1><?php echo esc_html($heading1); ?></h1>
     143        <h1><?php echo esc_html($heading); ?></h1>
    140144
    141145        <p class="content">
    142146            <?php echo esc_html($content); ?>
    143147        </p>
     148       
     149        <?php if ($password_protect) : ?>
     150            <form method="post" action="" style="margin-top: 20px;">
     151                <input type="hidden" name="bdpsuc_password_nonce" value="<?php echo esc_attr($nonce); ?>">
     152                <input type="password" name="suc_password" placeholder="Enter Password" required style="padding: 10px; font-size: 16px; border: none; border-radius: 4px;">
     153                <button type="submit" style="padding: 10px 20px; font-size: 16px; border: none; border-radius: 4px; background-color: var(--accent); color: #fff; cursor: pointer;">Submit</button>
     154            </form>
     155        <?php endif; ?>
    144156
    145157        <?php if (! empty($social_icons)) : ?>
Note: See TracChangeset for help on using the changeset viewer.