get_section( $section_id ); // Bail if the section isn't registered if ( is_object( $section ) ) { $section->priority = 11890; // Set Static Front Page section priority } /** * Additional CSS - from WP - just hide this in Absolute Weaver */ // $wp_customize->remove_section( $section_id ); // 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; // 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; // Remove WP Background Color control $wp_customize->remove_control( 'background_color' ); } function absolute_weaver_customize_preview_js_action() { Absolute_Weaver_Restore_WV_Settings::controls_print_scripts(); absolute_weaver_check_customizer_memory(); } add_action( 'customize_controls_print_footer_scripts', 'absolute_weaver_customize_preview_js_action' ); /* * Customizer scripts */ function absolute_weaver_enqueue_customizer_scripts_action() { // Styles wp_enqueue_style( 'absolute-weaver-customizer-jquery-ui-css', get_template_directory_uri() . '/inc/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() . '/inc/admin/customizer/css/chosen/chosen.css', array(), '1.3.0' ); wp_enqueue_style( 'absolute-weaver-customizer-controls', get_template_directory_uri() . "/inc/admin/customizer/css/customizer-controls" . ABSOLUTE_WEAVER_MINIFY . ".css", array( 'absolute-weaver-customizer-jquery-ui-css', 'chosen-css' ), ABSOLUTE_WEAVER_VERSION ); // stylesheet for customizer wp_enqueue_style( 'dashicons' ); // Scripts wp_enqueue_script( 'chosen-jquery', get_template_directory_uri() . '/inc/admin/customizer/js/chosen.jquery.js', array( 'jquery', 'customize-controls' ), '1.3.0', true ); wp_enqueue_script( 'absolute-weaver-customizer-controls', get_template_directory_uri() . '/inc/admin/customizer/js/customizer-controls' . ABSOLUTE_WEAVER_MINIFY . '.js', array( 'jquery', 'customize-controls', 'chosen-jquery' ), ABSOLUTE_WEAVER_VERSION, true ); do_action( 'absolute_weaver_enqueue_load_scripts' ); // Load Subtheme script/css do_action( 'absolute_weaver_ts_enqueue_scripts' ); // Save/Restore Settings scripts } add_action( 'customize_save', 'absolute_weaver_cz_save_action' ); function absolute_weaver_cz_save_action( $class ) { //absolute_weaver_save_opts( 'customizer', true ); // have to save things - generate css setting and file, for example. } add_action( 'customize_save_after', 'absolute_weaver_cz_save_after_action' ); function absolute_weaver_cz_save_after_action( $class ) { absolute_weaver_save_opts( 'customizer', true ); // have to save things - generate css setting and file, for example. } /** * Return an array of panel definitions. * * @return array The array of panel definitions. * @since 1.3.0. */ function absolute_weaver_customizer_get_panels() { $panels = array( 'getplus' => array( 'title' => esc_html__( 'Get Absolute Weaver Plus', 'absolute-weaver' ), 'priority' => 10000, 'description' => esc_html__( 'Add advanced options and features to Absolute Weaver.', 'absolute-weaver' ), ), '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' ), ), 'colors' => array( 'title' => esc_html__( 'Colors', 'absolute-weaver' ), 'priority' => 10700, 'description' => absolute_weaver_markdown( __( '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' ), ), 'page-builder' => array( 'title' => esc_html__( 'Page Builders', 'absolute-weaver' ), 'priority' => 11000, 'description' => esc_html__( 'Options for integration with Page Builders.', 'absolute-weaver' ), ), 'content' => array( 'title' => esc_html__( 'Added Content (HTML Areas...)', 'absolute-weaver' ), 'priority' => 11100, 'description' => esc_html__( 'Specify added content: Define added content for HTML areas.', 'absolute-weaver' ), ), ); /** * Filter the array of panel definitions for the Customizer. * * @param array $panels The array of panel definitions. * * @since 1.3.0. * */ return $panels; } /** * Register Customizer panels */ function absolute_weaver_customizer_add_panels( $wp_customize ) { $theme_prefix = 'absolute_weaver_'; // Get panel definitions $panels = absolute_weaver_customizer_get_panels(); // Add panels foreach ( $panels as $panel => $data ) { // Add panel if ( ! empty( $data ) ) { $wp_customize->add_panel( $theme_prefix . $panel, $data ); } } } /** * Return the master array of Customizer sections * * @return array The master array of Customizer sections * @since 1.3.0. * */ function absolute_weaver_customizer_get_sections() { // Add all the section definitions return array_merge( absolute_weaver_customizer_define_starting_sections(), absolute_weaver_customizer_define_general_sections(), absolute_weaver_customizer_define_layout_sections(), absolute_weaver_customizer_define_typography_sections(), absolute_weaver_customizer_define_image_sections(), absolute_weaver_customizer_define_visibility_sections(), absolute_weaver_customizer_define_colorscheme_sections(), absolute_weaver_customizer_define_spacing_sections(), absolute_weaver_customizer_define_style_sections(), absolute_weaver_customizer_define_pagebuilder_sections(), absolute_weaver_customizer_define_content_sections() ); } /** * Add sections and controls to the customizer. * * Hooked to 'customize_register' via absolute_weaver_customizer_init(). * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * * @return void * @since 1.0.0. * */ function absolute_weaver_customizer_add_sections( $wp_customize ) { $theme_prefix = 'absolute_weaver_'; $default_path = get_template_directory() . '/inc/admin/customizer/sections'; $panels = absolute_weaver_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 = absolute_weaver_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 absolute_weaver_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 ) ) { absolute_weaver_customizer_add_section_options( $theme_prefix . $section, $options ); unset( $options ); } } } function absolute_weaver_cz_settings_name( $id ) { $theme_opts = 'absolute_weaver_settings'; return $theme_opts . '[' . $id . ']'; } /** * Register settings and controls for a section. */ function absolute_weaver_customizer_add_section_options( $section, $args, $initial_priority = 100 ) { global $wp_customize; $priority = new absolute_weaver_cz_Prioritizer( $initial_priority, 5 ); $theme_prefix = 'absolute_weaver_'; foreach ( $args as $setting_id => $option ) { if ( empty( $option ) ) { continue; } // skip any empty control definitions (can happen if Absolute Weaver Plus not active) if ( isset( $option['setting'] ) ) { $defaults = array( 'type' => 'theme_mod', // 'option' or 'theme_mod' 'capability' => 'edit_theme_options', 'theme_supports' => '', 'default' => false, 'transport' => 'refresh', 'sanitize_callback' => 'absolute_weaver_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, absolute_weaver_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' => absolute_weaver_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 ( defined('ABSOLUTE_WEAVER_DEV_MODE' ) && ABSOLUTE_WEAVER_DEV_MODE ) { echo '