Changeset 49633 for trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
- Timestamp:
- 11/17/2020 06:58:52 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
r49578 r49633 43 43 add_action( 'wp_footer', array( $this, 'the_switch' ) ); 44 44 45 // Add the switch in the editor.46 add_action( 'wp_ajax_tt1_dark_mode_editor_switch', array( $this, 'editor_ajax_callback' ) );47 48 45 // Add the privacy policy content. 49 46 add_action( 'admin_init', array( $this, 'add_privacy_policy_content' ) ); … … 146 143 $colors_section = $wp_customize->get_section( 'colors' ); 147 144 if ( is_object( $colors_section ) ) { 148 $colors_section->title = __( 'Colors & Dark Mode', 'twentytwentyone' ); 149 $colors_section->description = __( 'To access the Dark Mode settings, select a light background color.', 'twentytwentyone' ) . '<br><a href="https://wordpress.org/support/article/twenty-twenty-one/">' . __( 'Learn more about Dark Mode.', 'twentytwentyone' ) . '</a>'; 150 } 145 $colors_section->title = __( 'Colors & Dark Mode', 'twentytwentyone' ); 146 } 147 148 // Custom notice control. 149 include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound 150 151 $wp_customize->add_setting( 152 'respect_user_color_preference_notice', 153 array( 154 'capability' => 'edit_theme_options', 155 'default' => '', 156 'sanitize_callback' => '__return_empty_string', 157 ) 158 ); 159 160 $wp_customize->add_control( 161 new Twenty_Twenty_One_Customize_Notice_Control( 162 $wp_customize, 163 'respect_user_color_preference_notice', 164 array( 165 'section' => 'colors', 166 'priority' => 100, 167 'active_callback' => function() { 168 return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ); 169 }, 170 ) 171 ) 172 ); 151 173 152 174 $wp_customize->add_setting( … … 161 183 ); 162 184 185 $description = '<p>' . __( 'Dark Mode is a device setting. If a visitor to your site requests it, your site will be shown with a dark background and light text. <a href="https://wordpress.org/support/article/twenty-twenty-one/">Learn more about Dark Mode.</a>', 'twentytwentyone' ) . '</p>'; 186 $description .= '<p>' . __( 'Dark Mode can also be turned on and off with a button that you can find in the bottom right corner of the page.', 'twentytwentyone' ) . '</p>'; 187 163 188 $wp_customize->add_control( 164 189 'respect_user_color_preference', … … 167 192 'section' => 'colors', 168 193 'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ), 169 'description' => __( 'Respect visitor’s device dark mode settings.<br>Dark mode is a device setting. If a visitor to your site requests it, your site will be shown with a dark background and light text.<br><br>Dark Mode can also be turned on and off with a button that you can find in the bottom right corner of the page.', 'twentytwentyone' ), 194 'priority' => 110, 195 'description' => $description, 170 196 'active_callback' => function( $value ) { 171 197 return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ); … … 360 386 361 387 /** 362 * Print the dark-mode switch styles.363 *364 * @access public365 *366 * @since 1.0.0367 *368 * @return void369 */370 public function the_styles() {371 echo '<style>';372 include get_theme_file_path( 'assets/css/style-dark-mode.css' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude373 echo '</style>';374 }375 376 /**377 * Call the tt1_the_dark_mode_switch and exit.378 *379 * @access public380 *381 * @since 1.0.0382 *383 * @return void384 */385 public function editor_ajax_callback() {386 $this->the_html();387 $this->the_styles();388 wp_die();389 }390 391 /**392 388 * Adds information to the privacy policy. 393 389 *
Note: See TracChangeset
for help on using the changeset viewer.