get_template(); } /** * Warn in admin if the theme is not supported. */ public static function admin_theme_notice() { if ( self::is_target_theme() || ! current_user_can( 'switch_themes' ) ) { return; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( $screen && 'plugins' !== $screen->id ) { return; } echo '

'; echo esc_html__( 'TT5 Light/Dark Toggle is active but Twenty Twenty-Five is not the current theme. The toggle only appears with that theme.', 'tt5-light-dark-toggle' ); echo '

'; } /** * Prevent flash of wrong theme by applying class before paint. */ public static function inline_preference_script() { $scheme = self::get_initial_scheme(); $storage_key = esc_js( TT5_LDT_STORAGE ); $cookie_name = esc_js( TT5_LDT_COOKIE ); ?> admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'tt5_ldt_save' ), 'storageKey' => TT5_LDT_STORAGE, 'cookieName' => TT5_LDT_COOKIE, 'cookiePath' => COOKIEPATH ? COOKIEPATH : '/', 'cookieDomain' => COOKIE_DOMAIN, 'isLoggedIn' => is_user_logged_in(), 'i18n' => array( 'light' => __( 'Switch to light mode', 'tt5-light-dark-toggle' ), 'dark' => __( 'Switch to dark mode', 'tt5-light-dark-toggle' ), 'lightLabel' => __( 'Light mode', 'tt5-light-dark-toggle' ), 'darkLabel' => __( 'Dark mode', 'tt5-light-dark-toggle' ), ), ) ); } /** * Output floating toggle button. */ public static function render_toggle() { $saved = self::get_initial_scheme(); $is_dark = 'dark' === $saved; ?> 'Invalid scheme' ), 400 ); } if ( is_user_logged_in() ) { update_user_meta( get_current_user_id(), TT5_LDT_STORAGE, $scheme ); } wp_send_json_success(); } /** * Optional profile field (read-only info). * * @param WP_User $user User object. */ public static function render_profile_field( $user ) { $value = get_user_meta( $user->ID, TT5_LDT_STORAGE, true ); if ( ! $value ) { return; } ?>