Plugin Directory

Changeset 3244102


Ignore:
Timestamp:
02/20/2025 07:01:21 PM (5 weeks ago)
Author:
devthemenet
Message:

Added disable option.

Location:
darkmeta-dark-mode/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • darkmeta-dark-mode/trunk/darkmeta-dark-mode.php

    r3241981 r3244102  
    44Plugin URI: https://darkmeta.devtheme.net/
    55Description: DarkMeta Dark Mode WP Plugin is a lightweight plugin that allows you to add dark mode functionality to your WordPress website. Users can toggle between light and dark themes using a simple button, and their preferences are saved for future visits.
    6 Version: 1.0.1
     6Version: 1.0.2
    77Author: devthemenet
    88Author URI: https://devtheme.net
     
    2626
    2727    public function enqueue_scripts() {
     28        if (!get_option('darkmeta_dark_mode_enabled', 1)) {
     29            return;
     30        }
     31       
    2832        wp_enqueue_style('darkmeta-dark-mode-style', plugin_dir_url(__FILE__) . 'assets/css/style.css');
    2933        wp_enqueue_script('darkmeta-dark-mode-script', plugin_dir_url(__FILE__) . 'assets/js/script.js', ['jquery'], null, true);
     34       
    3035        $background_color = esc_attr(get_option('darkmeta_dark_mode_background_color', '#121212'));
    3136        $text_color = esc_attr(get_option('darkmeta_dark_mode_text_color', '#ffffff'));
     
    4651
    4752    public function add_toggle_button() {
     53        if (!get_option('darkmeta_dark_mode_enabled', 1)) {
     54            return;
     55        }
     56       
    4857        $icon_light = esc_attr(get_option('darkmeta_dark_mode_icon_light', 'Light Mode'));
    4958        $icon_dark = esc_attr(get_option('darkmeta_dark_mode_icon_dark', 'Dark Mode'));
     
    6776
    6877    public function register_settings() {
    69         register_setting(
    70             'darkmeta_dark_mode_settings',
    71             'darkmeta_dark_mode_background_color',
    72             [
    73                 'type' => 'string',
    74                 'sanitize_callback' => 'sanitize_hex_color',
    75                 'default' => '#121212',
    76                 'show_in_rest' => true
    77             ]
    78         );
    79    
    80         register_setting(
    81             'darkmeta_dark_mode_settings',
    82             'darkmeta_dark_mode_text_color',
    83             [
    84                 'type' => 'string',
    85                 'sanitize_callback' => 'sanitize_hex_color',
    86                 'default' => '#ffffff',
    87                 'show_in_rest' => true
    88             ]
    89         );
    90    
    91         register_setting(
    92             'darkmeta_dark_mode_settings',
    93             'darkmeta_dark_mode_icon_light',
    94             [
    95                 'type' => 'string',
    96                 'sanitize_callback' => function ($input) {
    97                     return wp_strip_all_tags(sanitize_text_field($input));
    98                 },
    99                 'default' => '☼',
    100                 'show_in_rest' => true
    101             ]
    102         );
    103    
    104         register_setting(
    105             'darkmeta_dark_mode_settings',
    106             'darkmeta_dark_mode_icon_dark',
    107             [
    108                 'type' => 'string',
    109                 'sanitize_callback' => function ($input) {
    110                     return wp_strip_all_tags(sanitize_text_field($input));
    111                 },
    112                 'default' => '☾',
    113                 'show_in_rest' => true
    114             ]
    115         );
     78        register_setting('darkmeta_dark_mode_settings', 'darkmeta_dark_mode_enabled', ['type' => 'boolean', 'sanitize_callback' => 'absint', 'default' => 1]);
     79        register_setting('darkmeta_dark_mode_settings', 'darkmeta_dark_mode_background_color', ['type' => 'string', 'sanitize_callback' => 'sanitize_hex_color', 'default' => '#121212']);
     80        register_setting('darkmeta_dark_mode_settings', 'darkmeta_dark_mode_text_color', ['type' => 'string', 'sanitize_callback' => 'sanitize_hex_color', 'default' => '#ffffff']);
     81        register_setting('darkmeta_dark_mode_settings', 'darkmeta_dark_mode_icon_light', ['type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'default' => '☼']);
     82        register_setting('darkmeta_dark_mode_settings', 'darkmeta_dark_mode_icon_dark', ['type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'default' => '☾']);
    11683    }
    11784   
    118    
    119 
    12085    public function render_settings_page() {
    12186        ?>
     
    12792            <table class="form-table">
    12893                <tr>
    129                     <th scope="row"><?php esc_html_e('Dark Mode Background Color', 'darkmeta-dark-mode'); ?></th>
     94                    <th scope="row">Enable Dark Mode</th>
     95                    <td>
     96                        <input type="checkbox" name="darkmeta_dark_mode_enabled" value="1" <?php checked(1, get_option('darkmeta_dark_mode_enabled', 1)); ?>>
     97                    </td>
     98                </tr>
     99                <tr>
     100                    <th scope="row">Dark Mode Background Color</th>
    130101                    <td>
    131102                        <input type="color" name="darkmeta_dark_mode_background_color" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_background_color', '#121212')); ?>">
     
    133104                </tr>
    134105                <tr>
    135                     <th scope="row"><?php esc_html_e('Dark Mode Text Color', 'darkmeta-dark-mode'); ?></th>
     106                    <th scope="row">Dark Mode Text Color</th>
    136107                    <td>
    137108                        <input type="color" name="darkmeta_dark_mode_text_color" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_text_color', '#ffffff')); ?>">
     
    139110                </tr>
    140111                <tr>
    141                     <th scope="row"><?php esc_html_e('Light Mode Icon', 'darkmeta-dark-mode'); ?></th>
     112                    <th scope="row">Light Mode Icon</th>
    142113                    <td>
    143                         <input type="text" name="darkmeta_dark_mode_icon_light" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_icon_light', '&#9788;')); ?>" placeholder="<?php esc_attr_e('Enter icon HTML (e.g., &#9788;)', 'darkmeta-dark-mode'); ?>">
     114                        <input type="text" name="darkmeta_dark_mode_icon_light" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_icon_light', '&#9788;')); ?>">
    144115                    </td>
    145116                </tr>
    146117                <tr>
    147                     <th scope="row"><?php esc_html_e('Dark Mode Icon', 'darkmeta-dark-mode'); ?></th>
     118                    <th scope="row">Dark Mode Icon</th>
    148119                    <td>
    149                         <input type="text" name="darkmeta_dark_mode_icon_dark" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_icon_dark', '&#9790;')); ?>" placeholder="<?php esc_attr_e('Enter icon HTML (e.g., &#9790;)', 'darkmeta-dark-mode'); ?>">
     120                        <input type="text" name="darkmeta_dark_mode_icon_dark" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_icon_dark', '&#9790;')); ?>">
    150121                    </td>
    151122                </tr>
     
    162133// Activation Hook
    163134function darkmeta_dark_mode_activate() {
    164 // No file creation, settings saved in the database.
     135    add_option('darkmeta_dark_mode_enabled', 1);
    165136}
    166137register_activation_hook(__FILE__, 'darkmeta_dark_mode_activate');
     
    168139// Deactivation Hook
    169140function darkmeta_dark_mode_deactivate() {
    170 delete_option('darkmeta_dark_mode_enabled');
     141    delete_option('darkmeta_dark_mode_enabled');
    171142}
    172143register_deactivation_hook(__FILE__, 'darkmeta_dark_mode_deactivate');
  • darkmeta-dark-mode/trunk/readme.txt

    r3243946 r3244102  
    77Requires at least: 5.0
    88Tested up to: 6.7
    9 Stable tag: 1.0.1
     9Stable tag: 1.0.2
    1010License: GPLv2 or later
    1111License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1515== Description ==
    1616DarkMeta Dark Mode is a lightweight and customizable WordPress plugin that allows users to switch between light and dark mode seamlessly. This enhances user experience, reduces eye strain, and improves website accessibility.
    17 
    1817
    1918[youtube https://www.youtube.com/watch?v=WeD8M927wK8]
     
    6968== Changelog ==
    7069
     70= 1.0.1 - 21 Feb, 2025 =
     71
     72* Add: Added disable option.
     73
    7174= 1.0.1 - 17 Feb, 2025 =
    7275
Note: See TracChangeset for help on using the changeset viewer.