get_section( $section_id ); // Set Site Title & Tagline section priority //$section->priority = 10250; // Re-prioritize and rename the Widgets panel if ( ! isset( $wp_customize->get_panel( 'widgets' )->priority ) ) $wp_customize->add_panel( 'widgets' ); $wp_customize->get_panel( 'widgets' )->priority = 11900; $wp_customize->get_panel( 'widgets' )->title = __( 'Active Widget Areas (WP)', 'weaver-xtreme' ) . WEAVERX_REFRESH_ICON; // Re-prioritize and rename the Menus panel if ( ! isset( $wp_customize->get_panel( 'nav_menus' )->priority ) ) $wp_customize->add_panel( 'nav_menus' ); $wp_customize->get_panel( 'nav_menus' )->priority = 11910; $wp_customize->get_panel( 'nav_menus' )->title = __( 'Custom Menus Content (WP)', 'weaver-xtreme' ) . WEAVERX_REFRESH_ICON; // Move and rename Background Color control to Global section of Color panel $wp_customize->get_control( 'background_color' )->section = 'weaverx_color-wrapping'; $wp_customize->get_control( 'background_color' )->priority = 10799; $wp_customize->get_control( 'background_color' )->label = __( 'Site Background Color - WP Value', 'weaver-xtreme' ); $wp_customize->get_control( 'background_color' )->description = __('WordPress default Site BG color. This is a legacy option value, and is NOT RECOMMENDED. Please use the Weaver Xtreme Theme Site Background Color on the Layout → Core Site Layout and Styling menu.', 'weaver-xtreme'); } function weaverx_customize_preview_js() { // @@@ possibly add Loading message.... WeaverX_Restore_WX_Settings::controls_print_scripts(); weaverx_check_customizer_memory(); weaverx_check_support_plugin_version(); if ( weaverx_options_level() < 1) { // show if not set weaverx_alert(__('Thank you for using Weaver Xtreme 4!\r\n\r\n IMPORTANT NOTE -- New Theme Feature\r\n\r\nThis theme has 3 Customizer Option Interface Levels: Basic, Standard, and Full. If you are just getting started, using the Basic Level can simplify the learning curve.\r\n\r\nAfter the Customizer loads, please open the **General Options / Admin** panel, and then the **Set Options Interface Level** panel, and select an Interface Level.\r\n\r\nThis message will continue to be displayed until you select a level.', 'weaver-xtreme')); } } add_action('customize_controls_print_footer_scripts', 'weaverx_customize_preview_js'); /* * Customizer scripts */ function weaverx_enqueue_customizer_scripts(){ // Styles wp_enqueue_style( 'weaverx-customizer-jquery-ui', get_template_directory_uri() . '/admin/customizer/css/jquery-ui/jquery-ui-1.10.4.custom.css', array(), '1.10.4' ); wp_enqueue_style( 'weaverx-customizer-chosen', get_template_directory_uri() . '/admin/customizer/css/chosen/chosen.css', array(), '1.3.0' ); define('CUSTOMIZER_MENU','customizer-menu'); wp_enqueue_style( 'weaverx-customizer-menu', get_template_directory_uri() . "/admin/customizer/css/" . CUSTOMIZER_MENU .WEAVERX_MINIFY.".css", array(), WEAVERX_VERSION ); wp_enqueue_style( 'weaverx-customizer-sections', get_template_directory_uri() . "/admin/customizer/css/customizer-sections".WEAVERX_MINIFY.".css", array( 'weaverx-customizer-jquery-ui', 'weaverx-customizer-chosen' ), WEAVERX_VERSION ); // stylesheet for customizer wp_enqueue_style( 'dashicons' ); // Scripts wp_enqueue_script( 'weaverx-customizer-chosen', get_template_directory_uri() . '/admin/customizer/js/chosen.jquery.js', array( 'jquery', 'customize-controls' ), '1.3.0', true ); wp_enqueue_script( 'weaverx-customizer-menu', get_template_directory_uri() . '/admin/customizer/js/' . CUSTOMIZER_MENU . WEAVERX_MINIFY . '.js', array( ), WEAVERX_VERSION, true ); $cur_vers = weaverx_wp_version(); if (version_compare($cur_vers, '4.4', '<')) $wp_vers = '4.3'; else $wp_vers = '4.4'; $local = array( 'wp_vers' => $wp_vers, 'starting' => __('Start Here', 'weaver-xtreme'), 'intro' => __('Theme Introduction', 'weaver-xtreme'), 'subtheme' => __('Select Subthemes', 'weaver-xtreme'), 'help' => __('Theme Help', 'weaver-xtreme'), 'general' => __('General Options, Admin', 'weaver-xtreme'), 'tagline' => __('Site Identity', 'weaver-xtreme'), 'front_page' => __('Static Front Page', 'weaver-xtreme'), 'options_level' => __('Options Interface Level','weaver-xtreme'), 'general_admin' => __('Admin', 'weaver-xtreme'), 'save_settings' => __('Save Settings', 'weaver-xtreme'), 'restore_settings' => __('Restore Settings', 'weaver-xtreme'), 'general_saverestore' => __('Legacy Xtreme Admin', 'weaver-xtreme'), 'site_colors' => __('Colors', 'weaver-xtreme'), 'wrapping' => __('Wrapping Areas', 'weaver-xtreme'), 'links' => __('Links', 'weaver-xtreme'), 'header' => __('Header Area', 'weaver-xtreme'), 'menus' => __('Menus', 'weaver-xtreme'), 'info_bar' => __('Info Bar', 'weaver-xtreme'), 'content' => __('Content', 'weaver-xtreme'), 'post_specific' => __('Post Specific', 'weaver-xtreme'), 'sidebars' => __('Sidebars & Widget Areas', 'weaver-xtreme'), 'widgets' => __('Individual Widgets', 'weaver-xtreme'), 'footer' => __('Footer Area', 'weaver-xtreme'), 'spacing' => __('Spacing, Widths,+', 'weaver-xtreme'), 'site_widths' => __('Site Widths', 'weaver-xtreme'), 'style' => __('Style - Borders, etc.', 'weaver-xtreme'), 'global_typo' => __('Global Typography', 'weaver-xtreme'), 'global_style' => __('Global Style', 'weaver-xtreme'), 'typography' => __('Typography', 'weaver-xtreme'), 'visibility' => __('Visibility', 'weaver-xtreme'), 'global_vis' => __('Global Visibility', 'weaver-xtreme'), 'layout' => __('Layout', 'weaver-xtreme'), 'images' => __('Images', 'weaver-xtreme'), 'background' => __('Background', 'weaver-xtreme'), 'header_image' => __('Header Media (Content)', 'weaver-xtreme'), 'background_image' => __('WP Background', 'weaver-xtreme'), 'added_content' => __('Added Content', 'weaver-xtreme'), 'head_sec' => __('HEAD Section', 'weaver-xtreme'), 'injection' => __('HTML Injection Areas', 'weaver-xtreme'), 'custom' => __('Custom CSS', 'weaver-xtreme'), 'help_custom' => __('Custom CSS Help', 'weaver-xtreme'), 'global_css' => __('Global Custom CSS', 'weaver-xtreme'), 'what' => __('- WHAT -', 'weaver-xtreme'), 'where' => __('- WHERE -', 'weaver-xtreme'), 'sb_widg_content' => __('Active Widget Areas','weaver-xtreme'), 'custom_menus' => __('Custom Menus Content','weaver-xtreme'), 'global_spacing' => __('Global Spacing','weaver-xtreme'), 'global_admin' => __('Administration','weaver-xtreme'), 'global_opts' => __('Global Options','weaver-xtreme'), 'wp_settings' => __('WordPress Settings','weaver-xtreme'), 'html_inject' => __('HTML Injection Areas', 'weaver-xtreme'), 'loadingMsg' => __('Please wait. Customizer Loading...', 'weaver-xtreme'), 'helpURL' => get_template_directory_uri() . '/help/help.html#get-started', 'cust_help' => __('Weaver Xtreme Customizer Help','weaver-xtreme') ); wp_localize_script('weaverx-customizer-menu', 'wvrxCM', $local ); wp_enqueue_script( 'weaverx-customizer-sections', get_template_directory_uri() . '/admin/customizer/js/customizer-sections' . WEAVERX_MINIFY . '.js', array( 'jquery','customize-controls', 'weaverx-customizer-chosen' ), WEAVERX_VERSION, true ); // Save/Restore scripts WeaverX_Save_WX_Settings::enqueue_scripts(); // WeaverX_Restore_WX_Settings::enqueue_scripts(); } add_action('customize_save', 'weaverx_cz_save'); function weaverx_cz_save($class) { //weaverx_save_opts('customizer', true); // have to save things - generate css setting and file, for example. } add_action('customize_save_after', 'weaverx_cz_save_after'); function weaverx_cz_save_after($class) { weaverx_save_opts('customizer', true); // have to save things - generate css setting and file, for example. } if ( ! function_exists( 'weaverx_customizer_get_panels' ) ) : /** * Return an array of panel definitions. * * @since 1.3.0. * @return array The array of panel definitions. */ function weaverx_customizer_get_panels() { $panels = array( 'starting' => array( 'title' => __( 'Weaver Xtreme: Start Here', 'weaver-xtreme' ), 'priority' => 10100, 'description' => __( "How to get started with Weaver Xtreme." , 'weaver-xtreme' )), 'general' => array( 'title' => __( 'General Options & Admin', 'weaver-xtreme' ), 'priority' => 10200, 'description' => __( "General settings: Site Identity, Static Front Page, Admin Options, Help" , 'weaver-xtreme' )), 'layout' => array( 'title' => __( 'Layout', 'weaver-xtreme' ), 'priority' => 10300, 'description' => __( "Layout controls the overall look of your site. This includes the site width, full width layout option, sidebar layout, and more." , 'weaver-xtreme' ) ), 'typography' => array( 'title' => __( 'Typography', 'weaver-xtreme' ), 'priority' => 10400, 'description' => __( "Typography: font family, font size, bold, italic." , 'weaver-xtreme' )), 'images' => array( 'title' => __( 'Images', 'weaver-xtreme' ), 'priority' => 10500, 'description' => __( "Image Options: borders, placement, Featured Images, Header Images, Background Images." , 'weaver-xtreme' ) ), 'visibility' => array( 'title' => __( 'Visibility', 'weaver-xtreme' ), 'priority' => 10600, 'description' => __( "Specify visibility - hide various elements on various devices (desktop, tablets, phones)." , 'weaver-xtreme' ) ), 'site-colors' => array( 'title' => __( 'Colors', 'weaver-xtreme' ), 'priority' => 10700, 'description' => __( "Specify all colors used on site - both text and background colors. TIP: Clicking Default on the color picker will restore the original color set when you loaded the Customizer." , 'weaver-xtreme' )), 'spacing' => array( 'title' => __( 'Spacing, Widths, Alignment', 'weaver-xtreme' ), 'priority' => 10800, 'description' => __( "Set margins, padding, spacing, heights, and widths." , 'weaver-xtreme' ) ), 'style' => array( 'title' => __( 'Style (borders, etc.)', 'weaver-xtreme' ), 'priority' => 10900, 'description' => __( "Style: borders, shadows, rounded corners, list bullet style, icons. (Important note: using rounded corners usually requires specifying a BG color or border.)" , 'weaver-xtreme' ) ), 'content' => array( 'title' => __( 'Added Content (HTML Areas...)', 'weaver-xtreme' ), 'priority' => 11000, 'description' => __( "Specify added content: Define added content for HTML areas." , 'weaver-xtreme' ) ), 'custom' => array( 'title' => __( 'Custom CSS', 'weaver-xtreme' ), 'priority' => 11100, 'description' => __( 'Define Custom CSS rules for whole site or specific areas. Add HTML to several "injection areas" - useful for ads or custom third party scripts. Weaver Xtreme Plus also allows you to define PHP code for WP filters or actions.' , 'weaver-xtreme' ) ), 'page-builder' => array( 'title' => __( 'Page Builders', 'weaver-xtreme' ), 'priority' => 11200, 'description' => __( 'Options for integration with Page Builders.' , 'weaver-xtreme' ) ), // ultimate want to add per page/post options here, but can't do it because can't get current page or post ID to make controls selectively // display, or in fact access the custom options on a per page/post basis. //'per_page' => apply_filters('weaverx_add_per_page_customizer',array()), //'per_post' => apply_filters('weaverx_add_per_post_customizer',array()), ); /** * Filter the array of panel definitions for the Customizer. * * @since 1.3.0. * * @param array $panels The array of panel definitions. */ return $panels; } endif; if ( ! function_exists( 'weaverx_customizer_add_panels' ) ) : /** * Register Customizer panels */ function weaverx_customizer_add_panels( $wp_customize ) { $theme_prefix = 'weaverx_'; // Get panel definitions $panels = weaverx_customizer_get_panels(); // Add panels foreach ( $panels as $panel => $data ) { // Add panel if (!empty($data)) $wp_customize->add_panel( $theme_prefix . $panel, $data ); } } endif; if ( ! function_exists( 'weaverx_customizer_get_sections' ) ) : /** * Return the master array of Customizer sections * * @since 1.3.0. * * @return array The master array of Customizer sections */ function weaverx_customizer_get_sections() { // Add all the section definitions $pb = weaverx_customizer_define_pagebuilder_sections(); $content = weaverx_customizer_define_content_sections(); // get array for each section $custom = weaverx_customizer_define_custom_sections(); $general = weaverx_customizer_define_general_sections(); $image = weaverx_customizer_define_image_sections(); $layout = weaverx_customizer_define_layout_sections(); $colorscheme = weaverx_customizer_define_colorscheme_sections(); $spacing = weaverx_customizer_define_spacing_sections(); $starting = weaverx_customizer_define_starting_sections(); $style = weaverx_customizer_define_style_sections(); $typography = weaverx_customizer_define_typography_sections(); $visibility = weaverx_customizer_define_visibility_sections(); return array_merge($pb, $content, $custom, $general, $image, $layout, $colorscheme, $spacing, $starting, $style, $typography, $visibility ); // merge the arrays } endif; if ( ! function_exists( 'weaverx_customizer_add_sections' ) ) : /** * Add sections and controls to the customizer. * * Hooked to 'customize_register' via weaverx_customizer_init(). * * @since 1.0.0. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * @return void */ function weaverx_customizer_add_sections( $wp_customize ) { $theme_prefix = 'weaverx_'; $default_path = get_template_directory() . '/admin/customizer/sections'; $panels = weaverx_customizer_get_panels(); // Load section definition files foreach ( $panels as $panel => $data ) { $file = trailingslashit( $default_path ) . $panel . '.php'; if ( file_exists( $file ) ) { require_once( $file ); } } // Compile the section definitions $sections = weaverx_customizer_get_sections(); // Register each section and add its options $priority = array(); foreach ( $sections as $section => $data ) { // Get the non-prefixed ID of the current section's panel $panel = ( isset( $data['panel'] ) ) ? str_replace( $theme_prefix, '', $data['panel'] ) : 'none'; // Store the options if ( isset( $data['options'] ) ) { $options = $data['options']; unset( $data['options'] ); } // Determine the priority if ( ! isset( $data['priority'] ) ) { $panel_priority = ( 'none' !== $panel && isset( $panels[ $panel ]['priority'] ) ) ? $panels[ $panel ]['priority'] : 1000; // Create a separate priority counter for each panel, and one for sections without a panel if ( ! isset( $priority[ $panel ] ) ) { $priority[ $panel ] = new weaverx_cz_Prioritizer( $panel_priority, 10 ); } $data['priority'] = $priority[ $panel ]->add(); } // Register section $wp_customize->add_section( $theme_prefix . $section, $data ); // Add options to the section if ( isset( $options ) ) { weaverx_customizer_add_section_options( $theme_prefix . $section, $options ); unset( $options ); } } } endif; function weaverx_cz_settings_name($id) { $theme_opts = WEAVER_SETTINGS_NAME; //apply_filters('weaverx_options','weaverx_settingszzz'); return $theme_opts . '['. $id . ']'; //return $id; } if ( ! function_exists( 'weaverx_customizer_add_section_options' ) ) : /** * Register settings and controls for a section. */ function weaverx_customizer_add_section_options( $section, $args, $initial_priority = 100 ) { global $wp_customize; $priority = new weaverx_cz_Prioritizer( $initial_priority, 5 ); $theme_prefix = 'weaverx_'; foreach ( $args as $setting_id => $option ) { if ( isset( $option['setting'] ) ) { $defaults = array( 'type' => WEAVER_CUSTOMIZER_TYPE, //'option' or 'theme_mod' 'capability' => 'edit_theme_options', 'theme_supports' => '', 'default' => false, 'transport' => 'refresh', 'sanitize_callback' => WEAVERX_DEFAULT_SANITIZE, 'sanitize_js_callback' => '', ); $setting = wp_parse_args( $option['setting'], $defaults ); // Add the setting arguments in array to add_setting call so Theme Check can verify the presence of sanitize_callback // until a couple versions after the upgraded WP Customize Setting class, we will use our own sub-class to be sure // the preview doesn't take forever to render. The new version seems to fix the speed issue. $cur_vers = weaverx_wp_version(); //$class_setting = 'WeaverX_Customize_Setting'; //if (version_compare($cur_vers, '4.4', '<')) { // $class_setting = 'WeaverX_Customize_Setting'; //} else { // $class_setting = 'WP_Customize_Setting'; //} $wp_customize->add_setting( new WP_Customize_Setting( $wp_customize, weaverx_cz_settings_name( $setting_id ), array( 'type' => $setting['type'], 'capability' => $setting['capability'], 'theme_supports' => $setting['theme_supports'], 'default' => $setting['default'], 'transport' => $setting['transport'], 'sanitize_callback' => $setting['sanitize_callback'], 'sanitize_js_callback' => $setting['sanitize_js_callback'], ) )); } // Add control if ( isset( $option['control'] ) ) { $control_id = $theme_prefix . $setting_id; $defaults = array( 'section' => $section, 'priority' => $priority->add(), 'settings' => weaverx_cz_settings_name( $setting_id ), ); if ( ! isset( $option['setting'] ) ) { unset( $defaults['settings'] ); } $control = wp_parse_args( $option['control'], $defaults ); // Check for a specialized control class - create new instance if ( isset( $control['control_type'] ) ) { $class = $control['control_type']; if ( class_exists( $class ) ) { unset( $control['control_type'] ); // Dynamically generate a new class instance $class_instance = new $class( $wp_customize, $control_id, $control ); $wp_customize->add_control( $class_instance ); } else { if ( WEAVERX_DEV_MODE ) { echo '

MISSING CLASS DEFINITON: '. $class . '

'; } } } else { $wp_customize->add_control( $control_id, $control ); } } } return $priority->get(); } endif; if ( ! function_exists( 'weaverx_customizer_set_transport' ) ) : /** * Add postMessage support for certain built-in settings in the Theme Customizer. * * Allows these settings to update asynchronously in the Preview pane. */ function weaverx_customizer_set_transport( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } endif; if ( ! function_exists( 'weaverx_customizer_preview_script' ) ) : /** * Enqueue customizer preview script * * Hooked to 'customize_preview_init' via weaverx_customizer_init() * */ function weaverx_customizer_preview_script() { wp_enqueue_script( 'weaverx_cz-customizer-preview', get_template_directory_uri() . '/admin/customizer/js/customizer-preview' . WEAVERX_MINIFY . '.js', array( 'customize-preview' ), WEAVERX_VERSION, true ); $date = getdate(); $year = $date['year']; $cp = weaverx_getopt('copyright'); // so can restore default from customizer if (!$cp) { $cp = '©' . $year . ' - ' . esc_attr( get_bloginfo( 'name', 'display' ) ) . ''; } $local = array( 'copyright' => $cp, 'more_msg' => __( 'Continue reading →','weaver-xtreme') ); wp_localize_script('weaverx_cz-customizer-preview', 'wvrxPRE', $local ); } endif; // lib function weaverx_cz_is_old_plus() { if (function_exists('weaverxplus_plugin_installed')) { return version_compare( WEAVER_XPLUS_VERSION, '2.90', '<'); } else { return false; } } function weaverx_cz_is_plus( ) { return function_exists('weaverxplus_plugin_installed'); } function weaverx_cz_cache_opts() { if (!isset($GLOBALS['weaverx_cz_cache'])) $GLOBALS['weaverx_cz_cache'] = array(); $opt_func = WEAVER_GET_OPTION; $opts = $opt_func(WEAVER_SETTINGS_NAME ,array()); if (!isset($opts['themename'])) { $opts = weaverx_cz_getdefaults(); } $GLOBALS['weaverx_cz_cache'] = $opts; } function weaverx_cz_getdefaults() { $filename = apply_filters('weaverx_default_subtheme', get_template_directory() . WEAVERX_DEFAULT_THEME_FILE ); if ( ! weaverx_f_exists( $filename ) ) return array(); $contents = weaverx_f_get_contents($filename); // use either real (pro) or file (standard) version of function if (empty($contents)) return array(); if (substr($contents,0,10) != 'WXT-V01.00') return array(); $restore = array(); $restore = unserialize(substr($contents,10)); $ret = array(); $opts = $restore['weaverx_base']; // fetch base opts foreach ($opts as $opt => $val) { $ret[$opt] = $val; } do_action('weaverx_force_plus_inline_css', $ret); return $ret; } function weaverx_cz_getopt($opt) { if (!isset($GLOBALS['weaverx_cz_cache'][$opt])) { // handles changes to data structure return ''; } $val = $GLOBALS['weaverx_cz_cache'][$opt]; return $val ? $val : ''; } } // disable customizer? ?>