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 = esc_html__( 'Active Widget Areas (WP)', 'absolute-weaver' ) . AWEAVER_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 = esc_html__( 'Custom Menus Content (WP)', 'absolute-weaver' ) . AWEAVER_REFRESH_ICON; // Remove WP Background Color control $wp_customize->remove_control( 'background_color' ); } function aweaver_customize_preview_js() { // @@@ possibly add Loading message.... AWeaver_Restore_WV_Settings::controls_print_scripts(); aweaver_check_customizer_memory(); } add_action( 'customize_controls_print_footer_scripts', 'aweaver_customize_preview_js' ); /* * Customizer scripts */ function aweaver_enqueue_customizer_scripts() { // Styles wp_enqueue_style( 'weavera-customizer-jquery-ui-css', get_template_directory_uri() . '/admin/customizer/css/jquery-ui/jquery-ui-1.10.4.custom.css', array(), '1.10.4' ); wp_enqueue_style( 'chosen-css', get_template_directory_uri() . '/admin/customizer/css/chosen/chosen.css', array(), '1.3.0' ); wp_enqueue_style( 'weavera-customizer-sections', get_template_directory_uri() . "/admin/customizer/css/customizer-sections" . AWEAVER_MINIFY . ".css", array( 'weavera-customizer-jquery-ui', 'weavera-customizer-chosen' ), AWEAVER_VERSION ); // stylesheet for customizer wp_enqueue_style( 'dashicons' ); // Scripts wp_enqueue_script( 'chosen-jquery', get_template_directory_uri() . '/admin/customizer/js/chosen.jquery.js', array( 'jquery', 'customize-controls' ), '1.3.0', true ); wp_enqueue_script( 'aweaver-customizer-sections', get_template_directory_uri() . '/admin/customizer/js/customizer-sections' . AWEAVER_MINIFY . '.js', array( 'jquery', 'customize-controls', 'aweaver-customizer-chosen' ), AWEAVER_VERSION, true ); do_action( 'aweaver_ts_enqueue_scripts' ); // Save/Restore scripts } add_action( 'customize_save', 'aweaver_cz_save' ); function aweaver_cz_save( $class ) { //aweaver_save_opts( 'customizer', true ); // have to save things - generate css setting and file, for example. } add_action( 'customize_save_after', 'aweaver_cz_save_after' ); function aweaver_cz_save_after( $class ) { aweaver_save_opts( 'customizer', true ); // have to save things - generate css setting and file, for example. } if ( ! function_exists( 'aweaver_customizer_get_panels' ) ) : /** * Return an array of panel definitions. * * @since 1.3.0. * @return array The array of panel definitions. */ function aweaver_customizer_get_panels() { $panels = array( 'starting' => array( 'title' => esc_html__( 'Absolute Weaver: Start Here', 'absolute-weaver' ), 'priority' => 10100, 'description' => esc_html__( 'How to get started with Absolute Weaver.', 'absolute-weaver' ), ), 'general' => array( 'title' => esc_html__( 'General Options & Admin', 'absolute-weaver' ), 'priority' => 10200, 'description' => esc_html__( 'General settings: Site Identity, Static Front Page, Admin Options, Help', 'absolute-weaver' ), ), 'layout' => array( 'title' => esc_html__( 'Layout', 'absolute-weaver' ), 'priority' => 10300, 'description' => esc_html__( 'Layout controls the overall look of your site. This includes sidebar and widget area layout, content and post display layout, and menu layout.', 'absolute-weaver' ), ), 'typography' => array( 'title' => esc_html__( 'Typography', 'absolute-weaver' ), 'priority' => 10400, 'description' => esc_html__( 'Typography: font family, font size, bold, italic.', 'absolute-weaver' ), ), 'images' => array( 'title' => esc_html__( 'Images', 'absolute-weaver' ), 'priority' => 10500, 'description' => esc_html__( 'Image Options: borders, placement, Featured Images, Header Images, Background Images.', 'absolute-weaver' ), ), 'visibility' => array( 'title' => esc_html__( 'Visibility', 'absolute-weaver' ), 'priority' => 10600, 'description' => esc_html__( 'Specify visibility - hide various elements on various devices ( desktop, tablets, phones ).', 'absolute-weaver' ), ), 'site-colors' => array( 'title' => esc_html__( 'Colors', 'absolute-weaver' ), 'priority' => 10700, 'description' => aweaver_filter_text( __( '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.', 'absolute-weaver' ) ), ), 'spacing' => array( 'title' => esc_html__( 'Spacing, Widths, Alignment', 'absolute-weaver' ), 'priority' => 10800, 'description' => esc_html__( 'Set margins, padding, spacing, heights, and widths.', 'absolute-weaver' ), ), 'style' => array( 'title' => esc_html__( 'Style (borders, etc.)', 'absolute-weaver' ), 'priority' => 10900, 'description' => esc_html__( 'Style: borders, shadows, rounded corners, list bullet style, icons. (Important note: using rounded corners usually requires specifying a BG color or border.)', 'absolute-weaver' ), ), 'content' => array( 'title' => esc_html__( 'Added Content (HTML Areas...)', 'absolute-weaver' ), 'priority' => 11000, 'description' => esc_html__( 'Specify added content: Define added content for HTML areas.', 'absolute-weaver' ), ), 'custom' => array( 'title' => esc_html__( 'Custom CSS', 'absolute-weaver' ), 'priority' => 11100, 'description' => esc_html__( 'Define Global rules for whole site.', 'absolute-weaver' ), ), 'page-builder' => array( 'title' => esc_html__( 'Page Builders', 'absolute-weaver' ), 'priority' => 11200, 'description' => esc_html__( 'Options for integration with Page Builders.', 'absolute-weaver' ), ), ); /** * 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( 'aweaver_customizer_add_panels' ) ) : /** * Register Customizer panels */ function aweaver_customizer_add_panels( $wp_customize ) { $theme_prefix = 'aweaver_'; // Get panel definitions $panels = aweaver_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( 'aweaver_customizer_get_sections' ) ) : /** * Return the master array of Customizer sections * * @since 1.3.0. * * @return array The master array of Customizer sections */ function aweaver_customizer_get_sections() { // Add all the section definitions $pb = aweaver_customizer_define_pagebuilder_sections(); $content = aweaver_customizer_define_content_sections(); // get array for each section $custom = aweaver_customizer_define_custom_sections(); $general = aweaver_customizer_define_general_sections(); $image = aweaver_customizer_define_image_sections(); $layout = aweaver_customizer_define_layout_sections(); $colorscheme = aweaver_customizer_define_colorscheme_sections(); $spacing = aweaver_customizer_define_spacing_sections(); $starting = aweaver_customizer_define_starting_sections(); $style = aweaver_customizer_define_style_sections(); $typography = aweaver_customizer_define_typography_sections(); $visibility = aweaver_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( 'aweaver_customizer_add_sections' ) ) : /** * Add sections and controls to the customizer. * * Hooked to 'customize_register' via aweaver_customizer_init(). * * @since 1.0.0. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * * @return void */ function aweaver_customizer_add_sections( $wp_customize ) { $theme_prefix = 'aweaver_'; $default_path = get_template_directory() . '/admin/customizer/sections'; $panels = aweaver_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 ); // ( Not a template file ) } } // Compile the section definitions $sections = aweaver_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 aweaver_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 ) ) { aweaver_customizer_add_section_options( $theme_prefix . $section, $options ); unset( $options ); } } } endif; function aweaver_cz_settings_name( $id ) { $theme_opts = AWEAVER_SETTINGS_NAME; //apply_filters( 'aweaver_options','aweaver_settings' ); return $theme_opts . '[' . $id . ']'; //return $id; } if ( ! function_exists( 'aweaver_customizer_add_section_options' ) ) : /** * Register settings and controls for a section. */ function aweaver_customizer_add_section_options( $section, $args, $initial_priority = 100 ) { global $wp_customize; $priority = new aweaver_cz_Prioritizer( $initial_priority, 5 ); $theme_prefix = 'aweaver_'; foreach ( $args as $setting_id => $option ) { if ( isset( $option['setting'] ) ) { $defaults = array( 'type' => AWEAVER_CUSTOMIZER_TYPE, //'option' or 'theme_mod' 'capability' => 'edit_theme_options', 'theme_supports' => '', 'default' => false, 'transport' => 'refresh', 'sanitize_callback' => AWEAVER_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 $wp_customize->add_setting( new WP_Customize_Setting( $wp_customize, aweaver_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' => aweaver_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 ( AWEAVER_DEV_MODE ) { echo '

MISSING CLASS DEFINITION: ' . esc_html( $class ) . '

'; } } } else { $wp_customize->add_control( $control_id, $control ); } } } return $priority->get(); } endif; if ( ! function_exists( 'aweaver_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 aweaver_customizer_set_transport( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } endif; if ( ! function_exists( 'aweaver_customizer_preview_script' ) ) : /** * Enqueue customizer preview script * * Hooked to 'customize_preview_init' via aweaver_customizer_init() * */ function aweaver_customizer_preview_script() { wp_enqueue_script( 'aweavercustomizer-preview', get_template_directory_uri() . '/admin/customizer/js/customizer-preview' . AWEAVER_MINIFY . '.js', array( 'customize-preview' ), AWEAVER_VERSION, true ); $date = getdate(); $year = $date['year']; $cp = aweaver_getopt( 'copyright' ); // so can restore default from customizer if ( ! $cp ) { $cp = '©' . $year . ' - ' . esc_attr( get_bloginfo( 'name', 'display' ) ) . ''; } $local = array( 'copyright' => $cp, 'more_msg' => esc_html__( 'Continue reading →', 'absolute-weaver' ), ); wp_localize_script( 'aweaver_cz-customizer-preview', 'wvrxPRE', $local ); do_action( 'aweaver_check_updates', 'customizer' ); } endif; // lib function aweaver_cz_is_plus() { return AWEAVER_DEV_MODE || function_exists( 'aweaverplus_plugin_installed' ); } function aweaver_cz_cache_opts() { if ( ! isset( $GLOBALS['aweaver_cz_cache'] ) ) { $GLOBALS['aweaver_cz_cache'] = array(); } $opt_func = AWEAVER_GET_OPTION; $opts = $opt_func( AWEAVER_SETTINGS_NAME, array() ); if ( ! isset( $opts['themename'] ) ) { $opts = aweaver_cz_getdefaults(); } $GLOBALS['aweaver_cz_cache'] = $opts; } function aweaver_cz_getdefaults() { $filename = apply_filters( 'aweaver_default_subtheme', get_template_directory() . AWEAVER_DEFAULT_THEME_FILE ); if ( ! aweaver_f_exists( $filename ) ) { return array(); } $contents = aweaver_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' && substr( $contents, 0, 10 ) != 'WVA-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( 'aweaver_force_plus_inline_css', $ret ); return $ret; } function aweaver_cz_getopt( $opt ) { if ( ! isset( $GLOBALS['aweaver_cz_cache'][ $opt ] ) ) { // handles changes to data structure return ''; } $val = $GLOBALS['aweaver_cz_cache'][ $opt ]; return $val ? $val : ''; } } // disable customizer?