load_default_settings(); if ( loftloader_is_customize() ) { $this->load_customize_controls(); add_action( 'customize_controls_init', array( $this, 'remove_sections' ), 1000 ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_scripts' ), 9999 ); add_action( 'customize_preview_init', array( $this, 'preview_scripts' ) ); } } private function load_default_settings() { require_once LOFTLOADER_ROOT . 'inc/configs/default-settings.php'; } public function load_customize_controls() { $config_dir = LOFTLOADER_ROOT . 'inc/configs/'; require_once $config_dir . 'customize-main.php'; require_once $config_dir . 'customize-range.php'; require_once $config_dir . 'customize-background.php'; require_once $config_dir . 'customize-loader.php'; require_once $config_dir . 'customize-promo.php'; require_once $config_dir . 'customize-more.php'; require_once $config_dir . 'customize-advanced.php'; } public function remove_sections() { global $wp_customize; foreach( $wp_customize->containers() as $id => $container ) { if ( $container instanceof WP_Customize_Panel ) { ( strpos( $id, 'loftloader_' ) === false ) ? $wp_customize->remove_panel( $id ) : ''; } else if ( $container instanceof WP_Customize_Section){ ( strpos( $id, 'loftloader_' ) === false ) ? $wp_customize->remove_section( $id ) : ''; } } } public function customize_scripts() { global $wp_scripts, $wp_styles; $js_url = LOFTLOADER_URI . 'assets/js/customize.min.js'; $js_dep = array('jquery', 'wp-color-picker', 'jquery-ui-slider', 'customize-controls', 'media-editor' ); $ui_css = LOFTLOADER_URI . 'assets/css/jquery-ui.css'; $loader_css = LOFTLOADER_URI . 'assets/css/loftloader-settings.min.css'; wp_register_script( 'loftloader-lite-customize', $js_url, $js_dep, LOFTLOADER_ASSET_VERSION ); wp_localize_script( 'loftloader-lite-customize', 'loftloader_lite_i18n', array( 'name' => esc_html__( 'LoftLoader Lite', 'loftloader' ) ) ); // Change the site title in string "You are customizing ..." wp_enqueue_script( 'loftloader-lite-customize' ); wp_enqueue_style( 'loftloader-lite-ui', $ui_css, array(), LOFTLOADER_ASSET_VERSION ); wp_enqueue_style( 'loftloader-lite-customize', $loader_css, array(), LOFTLOADER_ASSET_VERSION ); foreach ( $wp_scripts->registered as $h => $o ) { if ( strpos( $o->src, 'wp-content/themes' ) !== false ) { wp_dequeue_script( $h ); } if ( strpos( $o->src, 'wp-content/plugins/disable-blog/' ) !== false ) { wp_dequeue_script( $h ); } }; foreach ( $wp_styles->registered as $h => $o ) { if ( strpos($o->src, 'wp-content/themes') !== false ) { wp_dequeue_style( $h ); } }; } public function preview_scripts() { $js_url = LOFTLOADER_URI . 'assets/js/preview.min.js'; wp_register_script( 'loftloader-lite-preview', $js_url, array( 'jquery', 'customize-preview' ), LOFTLOADER_ASSET_VERSION, true ); wp_localize_script( 'loftloader-lite-preview', 'loftloader_lite', array( 'preview' => 'on' ) ); wp_enqueue_script( 'loftloader-lite-preview' ); } } new LoftLoader_Customize(); } if ( class_exists( 'WP_Customize_Setting' ) ) { /** * LoftLoader related customization api classes * * @since 2.0.0 */ // LoftLoader base section class, changed the json function to modify the customize action text class LoftLoader_Customize_Section extends WP_Customize_Section { public function json() { $array = parent::json(); $array['customizeAction'] = esc_html__( 'Setting', 'loftloader' ); return $array; } /** * render function for LoftLoader Switch section */ protected function render() { if ( 'loftloader_switch' === $this->type ) : $switch = $this->manager->get_setting('loftloader_main_switch')->value(); $classes = 'accordion-section control-section control-section-' . $this->type; ?>