add_panel( 'blackwhite_lite_options_panel', array( 'priority' => 200, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => esc_html__( 'Theme Options', 'blackwhite-lite' ), 'description' => '', ) ); $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } add_action( 'customize_register', 'blackwhite_lite_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function blackwhite_lite_customize_preview_js() { wp_enqueue_script( 'blackwhite_lite_customizer', get_template_directory_uri() . '/inc/customizer/js/customizer.js', array( 'customize-preview' ), '20160530', true ); } add_action( 'customize_preview_init', 'blackwhite_lite_customize_preview_js' ); /** * Embed JS file for Customizer Controls * */ function blackwhite_lite_customize_controls_js() { wp_enqueue_script( 'blackwhite-customizer-controls', get_template_directory_uri() . '/inc/customizer/js/customizer-controls.js', array(), '20160530', true ); // Localize the script wp_localize_script( 'blackwhite-customizer-controls', 'blackwhite_lite_theme_links', array( 'title' => esc_html__( 'Theme Links', 'blackwhite-lite' ), 'themeURL' => esc_url( __( 'https://themecountry.com/themes/blackwhite/', 'blackwhite-lite' ) . '?utm_source=customizer&utm_medium=textlink&utm_campaign=blackwhite&utm_content=theme-page' ), 'themeLabel' => esc_html__( 'Theme Page', 'blackwhite-lite' ), 'docuURL' => esc_url( __( 'https://themecountry.com/docs/blackwhite-documentation/', 'blackwhite-lite' ) . '?utm_source=customizer&utm_medium=textlink&utm_campaign=blackwhite&utm_content=documentation' ), 'docuLabel' => esc_html__( 'Theme Documentation', 'blackwhite-lite' ), 'rateURL' => esc_url( 'http://wordpress.org/support/view/theme-reviews/blackwhite?filter=5' ), 'rateLabel' => esc_html__( 'Rate this theme', 'blackwhite-lite' ), ) ); } add_action( 'customize_controls_enqueue_scripts', 'blackwhite_lite_customize_controls_js' ); /** * Embed CSS styles for the theme options in the Customizer * */ function blackwhite_lite_customize_preview_css() { wp_enqueue_style( 'blackwhite-customizer-css', get_template_directory_uri() . '/inc/customizer/css/customizer.css', array(), '20160530' ); } add_action( 'customize_controls_print_styles', 'blackwhite_lite_customize_preview_css' ); /** * Returns theme options * * Uses sane defaults in case the user has not configured any theme options yet. */ function blackwhite_lite_theme_options() { // Merge Theme Options Array from Database with Default Options Array $theme_options = wp_parse_args( // Get saved theme options from WP database get_option( 'blackwhite_lite_theme_options', array() ), // Merge with Default Options if setting was not saved yet blackwhite_lite_default_options() ); // Return theme options return $theme_options; } /** * Returns the default settings of the theme * * @return array */ function blackwhite_lite_default_options() { $default_options = array( 'site_title' => true, 'layout' => 'right-sidebar', 'sticky_header' => false, 'post_layout_archives' => 'left', 'post_content' => 'excerpt', 'excerpt_length' => 20, 'excerpt_more' => ' [...]', 'post_navigation' => true, 'related_posts' => 'cat', 'disable_slide' => false, 'back_to_top' => true, 'paging' => 'paging-default', ); return $default_options; }