mirror of
https://ghproxy.net/https://github.com/AlxMedia/boxstyle.git
synced 2025-08-26 16:44:24 +08:00
Missing pluggable function
This commit is contained in:
parent
180f011f18
commit
f779575568
1 changed files with 21 additions and 17 deletions
|
@ -210,26 +210,30 @@ add_action( 'wp_enqueue_scripts', 'boxstyle_styles' );
|
|||
|
||||
/* Light & dark mode switch
|
||||
/* ------------------------------------ */
|
||||
function boxstyle_switch() {
|
||||
if ( ! function_exists( 'boxstyle_switch' ) ) {
|
||||
|
||||
if ( get_theme_mod('light-dark-switch','off') =='on' ) {
|
||||
|
||||
$current_mode = 'light';
|
||||
if ( isset( $_COOKIE['theme_mode'] ) && ! empty( $_COOKIE['theme_mode'] ) ) {
|
||||
$current_mode = $_COOKIE['theme_mode'];
|
||||
}
|
||||
if ( in_array( $current_mode, array( 'light', 'dark' ) ) ) {
|
||||
wp_enqueue_style( 'boxstyle-scheme', get_template_directory_uri() . '/' . esc_attr( $current_mode ) . '.css' );
|
||||
}
|
||||
wp_enqueue_script( 'boxstyle-cookie', get_template_directory_uri() . '/js/cookie.min.js', array(), '2.2.0', true );
|
||||
wp_enqueue_script( 'boxstyle-switch', get_template_directory_uri() . '/js/switch.js', array( 'jquery' ), '2.0', true );
|
||||
$data = array(
|
||||
'template_directory_uri' => get_template_directory_uri(),
|
||||
'stylesheet_directory_uri' => get_stylesheet_directory_uri(),
|
||||
);
|
||||
wp_localize_script( 'boxstyle-switch', 'boxstyleObject', $data );
|
||||
function boxstyle_switch() {
|
||||
|
||||
if ( get_theme_mod('light-dark-switch','off') =='on' ) {
|
||||
|
||||
$current_mode = 'light';
|
||||
if ( isset( $_COOKIE['theme_mode'] ) && ! empty( $_COOKIE['theme_mode'] ) ) {
|
||||
$current_mode = $_COOKIE['theme_mode'];
|
||||
}
|
||||
if ( in_array( $current_mode, array( 'light', 'dark' ) ) ) {
|
||||
wp_enqueue_style( 'boxstyle-scheme', get_template_directory_uri() . '/' . esc_attr( $current_mode ) . '.css' );
|
||||
}
|
||||
wp_enqueue_script( 'boxstyle-cookie', get_template_directory_uri() . '/js/cookie.min.js', array(), '2.2.0', true );
|
||||
wp_enqueue_script( 'boxstyle-switch', get_template_directory_uri() . '/js/switch.js', array( 'jquery' ), '2.0', true );
|
||||
$data = array(
|
||||
'template_directory_uri' => get_template_directory_uri(),
|
||||
'stylesheet_directory_uri' => get_stylesheet_directory_uri(),
|
||||
);
|
||||
wp_localize_script( 'boxstyle-switch', 'boxstyleObject', $data );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'boxstyle_switch' );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue