array( 'title' => __( 'General', 'bgbn' ), 'path' => $section_path ), 'stylekit' => array( 'title' => __( 'Style Kits', 'bgbn' ), 'path' => $section_path ), 'font' => array( 'title' => __( 'Fonts', 'bgbn' ), 'path' => $section_path ), 'color' => array( 'title' => __( 'Colors', 'bgbn' ), 'path' => $section_path ), 'header' => array( 'title' => __( 'Header', 'bgbn' ), 'path' => $section_path ), 'logo' => array( 'title' => __( 'Logo', 'bgbn' ), 'path' => $section_path ), 'main' => array( 'title' => __( 'Main', 'bgbn' ), 'path' => $section_path ), 'layout-blog' => array( 'title' => __( 'Layout: Blog (Posts Page)', 'bgbn' ), 'path' => $section_path ), 'layout-archive' => array( 'title' => __( 'Layout: Archives', 'bgbn' ), 'path' => $section_path ), 'layout-search' => array( 'title' => __( 'Layout: Search Results', 'bgbn' ), 'path' => $section_path ), 'layout-post' => array( 'title' => __( 'Layout: Posts', 'bgbn' ), 'path' => $section_path ), 'layout-page' => array( 'title' => __( 'Layout: Pages', 'bgbn' ), 'path' => $section_path ), 'footer' => array( 'title' => __( 'Footer', 'bgbn' ), 'path' => $section_path ), 'social' => array( 'title' => __( 'Social Profiles & RSS', 'bgbn' ), 'path' => $section_path ) ); if ( bgbn_is_plus() ) { unset( $sections['stylekit'] ); } $sections = apply_filters( 'bgbn_customizer_sections', $sections ); // Priority for first section $priority = new bgbn_Prioritizer( 0, 10 ); // Add and populate each section, if it exists foreach ( $sections as $section => $data ) { $file = trailingslashit( $data[ 'path' ] ) . $section . '.php'; if ( file_exists( $file ) ) { // First load the file require_once( $file ); // Custom priorities for built-in sections if ( 'font' === $section ) { $wp_customize->get_section( 'background_image' )->priority = $priority->add(); } if ( 'logo' === $section ) { $wp_customize->get_section( 'title_tagline' )->priority = $priority->add(); } if ( 'main' === $section ) { $wp_customize->get_section( 'nav' )->priority = $priority->add(); } if ( 'layout-blog' === $section ) { $wp_customize->get_section( 'static_front_page' )->priority = $priority->add(); } // Then add the section $section_callback = 'bgbn_customizer_'; $section_callback .= ( strpos( $section, '-' ) ) ? str_replace( '-', '_', $section ) : $section; if ( function_exists( $section_callback ) ) { $section_id = 'bgbn_' . esc_attr( $section ); // Sanitize the section title if ( ! isset( $data[ 'title' ] ) || ! $data[ 'title' ] ) { $data[ 'title' ] = ucfirst( esc_attr( $section ) ); } // Add section $wp_customize->add_section( $section_id, array( 'title' => $data[ 'title' ], 'priority' => $priority->add(), ) ); // Callback to populate the section call_user_func_array( $section_callback, array( $wp_customize, $section_id ) ); } } } } endif; if ( ! function_exists( 'bgbn_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. * * @since 1.0.0. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * @return void */ function bgbn_customizer_set_transport( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } endif; if ( ! function_exists( 'bgbn_customizer_preview_script' ) ) : /** * Enqueue customizer preview script * * Hooked to 'customize_preview_init' via bgbn_customizer_init() * * @since 1.0.0. * * @return void */ function bgbn_customizer_preview_script() { $path = '/inc/customizer/js/'; wp_enqueue_script( 'bgbn-customizer-preview', get_template_directory_uri() . $path . 'customizer-preview' . bgbn_SUFFIX . '.js', array( 'customize-preview' ), bgbn_VERSION, true ); } endif; if ( ! function_exists( 'bgbn_customizer_sections_script' ) ) : /** * Enqueue customizer sections script * * Hooked to 'customize_controls_enqueue_scripts' via bgbn_customizer_init() * * @since 1.0.0. * * @return void */ function bgbn_customizer_sections_script() { $path = '/inc/customizer/js/'; wp_enqueue_script( 'bgbn-customizer-sections', get_template_directory_uri() . $path . 'customizer-sections' . bgbn_SUFFIX . '.js', array( 'customize-controls' ), bgbn_VERSION, true ); } endif; if ( ! function_exists( 'bgbn_customizer_admin_styles' ) ) : /** * Styles for our Customizer sections and controls. Prints in the * * @since 1.0.0. * * @return void */ function bgbn_customizer_admin_styles() { ?> build(); if ( ! empty( $css ) ) { echo "\n\n\n\n"; } } endif; add_action( 'wp_head', 'bgbn_display_customizations', 11 ); if ( ! function_exists( 'bgbn_ajax_display_customizations' ) ) : /** * Generates the theme option CSS as an Ajax response * * @since 1.0.0. * * @return void */ function bgbn_ajax_display_customizations() { // bgbn sure this is an Ajax request if ( ! defined( 'DOING_AJAX' ) || true !== DOING_AJAX ) { return; } // Set the content type header( "Content-Type: text/css" ); // Echo the rules echo bgbn_get_css()->build(); // End the Ajax response die(); } endif; add_action( 'wp_ajax_bgbn-css', 'bgbn_ajax_display_customizations' ); if ( ! function_exists( 'bgbn_mce_css' ) ) : /** * bgbn sure theme option CSS is added to TinyMCE last, to override other styles. * * @since 1.0.0. * * @param string $stylesheets List of stylesheets added to TinyMCE. * @return string Modified list of stylesheets. */ function bgbn_mce_css( $stylesheets ) { if ( bgbn_get_css()->build() ) { $stylesheets .= ',' . add_query_arg( 'action', 'bgbn-css', admin_url( 'admin-ajax.php' ) ); } return $stylesheets; } endif; add_filter( 'mce_css', 'bgbn_mce_css', 99 );