Changeset 3244102
- Timestamp:
- 02/20/2025 07:01:21 PM (5 weeks ago)
- Location:
- darkmeta-dark-mode/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
darkmeta-dark-mode/trunk/darkmeta-dark-mode.php
r3241981 r3244102 4 4 Plugin URI: https://darkmeta.devtheme.net/ 5 5 Description: 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. 16 Version: 1.0.2 7 7 Author: devthemenet 8 8 Author URI: https://devtheme.net … … 26 26 27 27 public function enqueue_scripts() { 28 if (!get_option('darkmeta_dark_mode_enabled', 1)) { 29 return; 30 } 31 28 32 wp_enqueue_style('darkmeta-dark-mode-style', plugin_dir_url(__FILE__) . 'assets/css/style.css'); 29 33 wp_enqueue_script('darkmeta-dark-mode-script', plugin_dir_url(__FILE__) . 'assets/js/script.js', ['jquery'], null, true); 34 30 35 $background_color = esc_attr(get_option('darkmeta_dark_mode_background_color', '#121212')); 31 36 $text_color = esc_attr(get_option('darkmeta_dark_mode_text_color', '#ffffff')); … … 46 51 47 52 public function add_toggle_button() { 53 if (!get_option('darkmeta_dark_mode_enabled', 1)) { 54 return; 55 } 56 48 57 $icon_light = esc_attr(get_option('darkmeta_dark_mode_icon_light', 'Light Mode')); 49 58 $icon_dark = esc_attr(get_option('darkmeta_dark_mode_icon_dark', 'Dark Mode')); … … 67 76 68 77 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' => '☾']); 116 83 } 117 84 118 119 120 85 public function render_settings_page() { 121 86 ?> … … 127 92 <table class="form-table"> 128 93 <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> 130 101 <td> 131 102 <input type="color" name="darkmeta_dark_mode_background_color" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_background_color', '#121212')); ?>"> … … 133 104 </tr> 134 105 <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> 136 107 <td> 137 108 <input type="color" name="darkmeta_dark_mode_text_color" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_text_color', '#ffffff')); ?>"> … … 139 110 </tr> 140 111 <tr> 141 <th scope="row"> <?php esc_html_e('Light Mode Icon', 'darkmeta-dark-mode'); ?></th>112 <th scope="row">Light Mode Icon</th> 142 113 <td> 143 <input type="text" name="darkmeta_dark_mode_icon_light" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_icon_light', '☼')); ?>" placeholder="<?php esc_attr_e('Enter icon HTML (e.g., ☼)', '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', '☼')); ?>"> 144 115 </td> 145 116 </tr> 146 117 <tr> 147 <th scope="row"> <?php esc_html_e('Dark Mode Icon', 'darkmeta-dark-mode'); ?></th>118 <th scope="row">Dark Mode Icon</th> 148 119 <td> 149 <input type="text" name="darkmeta_dark_mode_icon_dark" value="<?php echo esc_attr(get_option('darkmeta_dark_mode_icon_dark', '☾')); ?>" placeholder="<?php esc_attr_e('Enter icon HTML (e.g., ☾)', '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', '☾')); ?>"> 150 121 </td> 151 122 </tr> … … 162 133 // Activation Hook 163 134 function darkmeta_dark_mode_activate() { 164 // No file creation, settings saved in the database. 135 add_option('darkmeta_dark_mode_enabled', 1); 165 136 } 166 137 register_activation_hook(__FILE__, 'darkmeta_dark_mode_activate'); … … 168 139 // Deactivation Hook 169 140 function darkmeta_dark_mode_deactivate() { 170 delete_option('darkmeta_dark_mode_enabled');141 delete_option('darkmeta_dark_mode_enabled'); 171 142 } 172 143 register_deactivation_hook(__FILE__, 'darkmeta_dark_mode_deactivate'); -
darkmeta-dark-mode/trunk/readme.txt
r3243946 r3244102 7 7 Requires at least: 5.0 8 8 Tested up to: 6.7 9 Stable tag: 1.0. 19 Stable tag: 1.0.2 10 10 License: GPLv2 or later 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 15 15 == Description == 16 16 DarkMeta 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 18 17 19 18 [youtube https://www.youtube.com/watch?v=WeD8M927wK8] … … 69 68 == Changelog == 70 69 70 = 1.0.1 - 21 Feb, 2025 = 71 72 * Add: Added disable option. 73 71 74 = 1.0.1 - 17 Feb, 2025 = 72 75
Note: See TracChangeset
for help on using the changeset viewer.