'boxed', //boxed, full_width 'site_width' => '1280', 'header_layout' => 'logo_left', //logo_left, logo_center 'fixed_navbar' => 'fixed', //static, fixed 'mobile_menu_position' => 'left', //left, right 'sidebar_config' => 'right', //left, right, both, none 'back_to_top_show' => 'show', //show, hide 'archive_type' => 'grid', //grid, full_width 'archive_content_display' => 'excerpt', //excerpt, full, 'archive_thumb' => 'show', //show, hide 'default_thumb' => trailingslashit(IP_THEME_URL) . 'assets/image/default-thumb.jpg', 'archive_cat_link' => 'show', //show, hide 'archive_read_more' => 'hide', //show, hide 'single_cat_link' => 'show', //show , hide 'single_tag_link' => 'show', //show , hide 'single_date' => 'show', //show, hide 'single_author' => 'show', //show, hide 'prev_next_nav' => 'show', //show, hide 'grid_col_number' => 3, 'excerpt_length' => 25, 'footer_col_count' => 4, // 1-6 'mobile_hide_footer' => 'show', // show, hide ); } } if (!function_exists('ip_theme_get_custom_css_values')) { /** * Values to be used to generate custom css according to customizer setting * * @return array */ function ip_theme_get_custom_css_values() { $values = array( 'site-width' => get_option(IP_THEME . 'site_width', ip_theme_get_default_options()['site_width']) . 'px', 'break-mobile' => '767px', 'break-tablet' => '992px', 'body-bg' => ($body_bg = get_theme_mod( 'background_color', false )) ? '#' . $body_bg : '#efefef', 'header-bg' => ($header_bg = get_option(IP_THEME . 'header_bg')) ? $header_bg : '#fff', 'navbar-bg' => ($navbar_bg = get_option(IP_THEME . 'navbar_bg')) ? $navbar_bg : '#4f9fff', 'navbar-color' => ($navbar_color = get_option(IP_THEME . 'navbar_color')) ? $navbar_color : '#fff', 'footer-bg' => ($footer_bg = get_option(IP_THEME . 'footer_bg')) ? $footer_bg : '#f6f6f6', 'footer-color' => ($footer_color = get_option(IP_THEME . 'footer_color')) ? $footer_color : '#5f5f5f', 'content-bg' => ($content_bg = get_option(IP_THEME . 'content_bg')) ? $content_bg : '#ffffff', 'primary-color' => ($primary_color = get_option(IP_THEME . 'primary_color')) ? $primary_color : '#4f9fef', 'heading-color' => ($heading_color = get_option(IP_THEME . 'heading_color')) ? $heading_color : '#094870', 'text-color' => ($text_color = get_option(IP_THEME . 'text_color')) ? $text_color : '#5f5f5f', ); $values['body-font-size'] = ( $body_font_size = get_option( IP_THEME . 'font_size' ) ) ? $body_font_size . 'px' : '14px'; $values['body-font-size_tablet'] = ( $body_font_size ) ? $body_font_size . 'px' : '14px'; $values['body-font-size_mobile'] = ( $body_font_size ) ? $body_font_size . 'px' : '14px'; $values['h1-font-size'] = '32px'; $values['h1-font-size_tablet'] = '32px'; $values['h1-font-size_mobile'] = '26px';; $values['h2-font-size'] = '26px'; $values['h2-font-size_tablet'] = '26px'; $values['h2-font-size_mobile'] = '20px'; $values['single-title-size'] = ( $single_title_size = get_option( IP_THEME . 'single_title_size' ) ) ? $single_title_size . 'px' : '32px'; $values['archive-title-size'] = ( $archive_title_size = get_option( IP_THEME . 'archive_title_size' ) ) ? $archive_title_size . 'px' : '24px'; $values['navbar-font-size'] = ( $navbar_font_size = get_option( IP_THEME . 'navbar_font_size' ) ) ? $navbar_font_size . 'px' : '14px'; $values['navbar-height'] = ( $navbar_height = get_option( IP_THEME . 'navbar_height' ) ) ? $navbar_height . 'px' : '54px'; return apply_filters('ip_theme_get_custom_css_values', $values); } } if (!function_exists('ip_theme_block_editor_setup')) { /** * Add theme settings to Wordpress Block Editor * * @return void */ function ip_theme_block_editor_setup() { $css = ip_theme_get_custom_css_values(); //Add color palette to block editor add_theme_support('editor-color-palette', array( array( 'name' => __('Navigation bar background', 'bizflow'), 'slug' => 'color-navbar-bg', 'color' => $css['navbar-bg'] ), array( 'name' => __('Navigation bar color', 'bizflow'), 'slug' => 'color-navbar-color', 'color' => $css['navbar-color'] ), array( 'name' => __('Primary Color', 'bizflow'), 'slug' => 'color-primary-color', 'color' => $css['primary-color'] ), array( 'name' => __('Heading Color', 'bizflow'), 'slug' => 'color-heading-color', 'color' => $css['heading-color'] ), array( 'name' => __('Text Color', 'bizflow'), 'slug' => 'color-text-color', 'color' => $css['text-color'] ) )); } add_action('after_setup_theme', 'ip_theme_block_editor_setup'); } if (!function_exists('ip_theme_custom_content_width')) { /** * Calculate content width based on sidebar and container configuration * * @return void */ function ip_theme_custom_content_width() { $sidebar_config = get_option(IP_THEME . 'sidebar_config', ip_theme_get_default_options()['sidebar_config']); $site_width = get_option(IP_THEME . 'site_width', ip_theme_get_default_options()['site_width']); //Sidebar width 25% if ($sidebar_config == 'left' || $sidebar_config == 'right') { $GLOBALS['content_width'] = intval(($site_width - 50) * 0.75); } else if ($sidebar_config == 'both') { $GLOBALS['content_width'] = intval(($site_width - 50) * 0.5); } } add_action('after_setup_theme', 'ip_theme_custom_content_width', 20); } if (!function_exists('ip_theme_customize_add_supports')) { /** * Add theme support for custom logo, custom background * * @return void */ function ip_theme_customize_add_supports() { add_theme_support('custom-logo', array( 'height' => 100, 'width' => 400, 'flex-width' => true, 'header-text' => array('site-title', 'site-description'), )); //add_theme_support('custom-header'); //add_theme_support('header-text'); add_theme_support('custom-background', array( 'default-color' => '', 'default-image' => '', 'default-repeat' => 'no-repeat', 'default-position-x' => 'left', 'default-position-y' => 'top', 'default-size' => 'cover', 'default-attachment' => 'scroll', 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '', 'admin-preview-callback' => '' )); } add_action('after_setup_theme', 'ip_theme_customize_add_supports'); } if (!function_exists('ip_theme_admin_customize_style')) { /** * Admin style for custom customizer controls * * @return void */ function ip_theme_admin_customize_style() { wp_enqueue_style('ip-admin-style'); } add_action('admin_enqueue_scripts', 'ip_theme_admin_customize_style', 99999); } if (!function_exists('ip_theme_customizer_preview')) { /** * Add style and JavaScript to customizer preview * Handles changes on the fly, the ones registed with 'postMessage' * * @return void */ function ip_theme_customizer_preview() { wp_register_style('ip-theme-customizer-style', IP_THEME_URL . '/assets/css/customizer-admin_style.css', time()); wp_enqueue_style('ip-theme-customizer-style'); wp_register_script('ip-theme-customizer-script', IP_THEME_URL . '/assets/js/theme-customizer.js', array('jquery'), time(), true); wp_enqueue_script('ip-theme-customizer-script'); } add_action('customize_preview_init', 'ip_theme_customizer_preview'); } if (!function_exists('ip_theme_customize_init')) { /** * Run functions at customizer initialization * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_theme_customize_init($wp_customize) { //Change transport method, chnages made will be handles via JavaScript without reloading $wp_customize->get_setting('blogname')->transport = 'postMessage'; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; //Initialize custom customize control classes require_once IP_THEME_PATH . 'inc/customize/class-customize_range_control.php'; $wp_customize->register_control_type('Ip_customize_range_control'); require_once IP_THEME_PATH . 'inc/customize/class-customize_radio_image_control.php'; $wp_customize->register_control_type('Ip_customize_radio_image_control'); } add_action('customize_register', 'ip_theme_customize_init'); } if (!function_exists('ip_register_customization_layout_options')) { /** * Customizer options to control site layout * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_register_customization_layout_options($wp_customize) { $wp_customize->add_section(IP_THEME . 'layout_section', array( 'title' => __('Site layout', 'bizflow'), 'description' => __('Control the layout of the site', 'bizflow'), 'priority' => 20 )); $wp_customize->add_setting(IP_THEME . 'site_layout', array('default' => 'boxed', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control(new Ip_customize_radio_image_control( $wp_customize, IP_THEME . 'site_layout', array( 'label' => __('Site layout', 'bizflow'), 'description' => __('Site layout : Choose between content inside a box or full width', 'bizflow'), 'section' => IP_THEME . 'layout_section', 'settings' => IP_THEME . 'site_layout', 'context' => IP_THEME, 'choices' => array( 'boxed' => array( 'image' => IP_THEME_URL . '/assets/image/layout-boxed.png', 'label' => __('Boxed content', 'bizflow') ), 'fullwidth' => array( 'image' => IP_THEME_URL . '/assets/image/layout-fullwidth.png', 'label' => __('Full width', 'bizflow') ) ) ) )); $wp_customize->add_setting(IP_THEME . 'site_width', array('default' => '1280', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'absint')); $wp_customize->add_control( IP_THEME . 'site_width', array( 'label' => __('Content box width', 'bizflow'), 'description' => __('Content width: Applicable only if boxed layout is selected', 'bizflow'), 'section' => IP_THEME . 'layout_section', 'settings' => IP_THEME . 'site_width', 'type' => 'number', 'max' => 1800, 'min' => 900, ) ); $wp_customize->add_setting(IP_THEME . 'sidebar_config', array('default' => 'left', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control(new Ip_customize_radio_image_control( $wp_customize, IP_THEME . 'sidebar_config', array( 'label' => __('Configure Sidebar', 'bizflow'), 'description' => __('Sidebar configuration: Choose from four options of Left, Right, Both or None', 'bizflow'), 'section' => IP_THEME . 'layout_section', 'settings' => IP_THEME . 'sidebar_config', 'context' => IP_THEME, 'choices' => array( 'left' => array( 'image' => IP_THEME_URL . '/assets/image/sidebar-left.png', 'label' => __('Left', 'bizflow') ), 'right' => array( 'image' => IP_THEME_URL . '/assets/image/sidebar-right.png', 'label' => __('Right', 'bizflow') ), 'both' => array( 'image' => IP_THEME_URL . '/assets/image/sidebar-both.png', 'label' => __('Both', 'bizflow') ), 'none' => array( 'image' => IP_THEME_URL . '/assets/image/layout-fullwidth.png', 'label' => __('None', 'bizflow') ), ) ) )); $wp_customize->add_setting(IP_THEME . 'back_to_top_show', array('default' => 'show', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'back_to_top_show', array( 'label' => __('Back to Top button', 'bizflow'), 'description' => __('Show back to top button', 'bizflow'), 'section' => IP_THEME . 'layout_section', 'settings' => IP_THEME . 'back_to_top_show', 'type' => 'radio', 'choices' => array( 'show' => __('Yes', 'bizflow'), 'hide' => __('No', 'bizflow') ) ) ); } add_action('customize_register', 'ip_register_customization_layout_options'); } if (!function_exists('ip_register_customization_color_options')) { /** * Customizer options to adjust colors * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_register_customization_color_options($wp_customize) { $wp_customize->add_setting(IP_THEME . 'text_color', array('default' => '#5f5f5f', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'text_color', array( 'label' => __('Text color', 'bizflow'), 'description' => __('Global color for text', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'text_color', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'content_bg', array('default' => '#ffffff', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'content_bg', array( 'label' => __('Content area background color', 'bizflow'), 'description' => __('Content area background color', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'content_bg', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'header_bg', array('default' => '#ffffff', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'header_bg', array( 'label' => __('Header background color', 'bizflow'), 'description' => __('Header background color', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'header_bg', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'footer_bg', array('default' => '#ffffff', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'footer_bg', array( 'label' => __('Footer background color', 'bizflow'), 'description' => __('Footer background color', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'footer_bg', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'footer_color', array('default' => '#5f5f5f', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'footer_color', array( 'label' => __('Footer text color', 'bizflow'), 'description' => __('Footer text color', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'footer_color', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'primary_color', array('default' => '#191919', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'primary_color', array( 'label' => __('Primary color', 'bizflow'), 'description' => __('Primary color: Used for links, buttons etc', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'primary_color', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'navbar_bg', array('default' => '#191919', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'navbar_bg', array( 'label' => __('Navigation bar background color', 'bizflow'), 'description' => __('Navigation bar background color', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'navbar_bg', 'context' => IP_THEME, ) )); $wp_customize->add_setting(IP_THEME . 'navbar_color', array('default' => '#ffffff', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, IP_THEME . 'navbar_color', array( 'label' => __('Navigation bar link color', 'bizflow'), 'description' => __('Navigation bar link color', 'bizflow'), 'section' => 'colors', 'settings' => IP_THEME . 'navbar_color', 'context' => IP_THEME, ) )); } add_action('customize_register', 'ip_register_customization_color_options'); } if (!function_exists('ip_register_customization_header_options')) { /** * Customizer options to control header appearence * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_register_customization_header_options($wp_customize) { $wp_customize->add_section(IP_THEME . 'header_section', array( 'title' => __('Header', 'bizflow'), 'description' => __('Customize header appearence', 'bizflow'), 'priority' => 40 )); $wp_customize->add_setting(IP_THEME . 'header_layout', array('default' => 'logo_left', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control(new Ip_customize_radio_image_control( $wp_customize, IP_THEME . 'header_layout', array( 'label' => __('Logo position', 'bizflow'), 'description' => __('Logo position: Choose logo position', 'bizflow'), 'section' => IP_THEME . 'header_section', 'settings' => IP_THEME . 'header_layout', 'context' => IP_THEME, 'choices' => array( 'logo_left' => array( 'image' => IP_THEME_URL . '/assets/image/logo-left.png', 'label' => __('Left', 'bizflow') ), 'logo_center' => array( 'image' => IP_THEME_URL . '/assets/image/logo-center.png', 'label' => __('Center', 'bizflow') ) ) ) )); $wp_customize->add_setting(IP_THEME . 'header_bg_img', array('default' => '', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_cropped_image')); if (version_compare(get_bloginfo('version'), '4.3', '<=')) { $wp_customize->add_control(new WP_Customize_Cropped_Image_Control( $wp_customize, IP_THEME . 'header_bg_img', array( 'label' => __('Header background image', 'bizflow'), 'description' => __('Header background image: Overrides header background color', 'bizflow'), 'section' => IP_THEME . 'header_section', 'settings' => IP_THEME . 'header_bg_img', 'context' => IP_THEME, 'height' => 324, 'width' => 1280, 'flex_width' => true, 'flex_height' => true ) )); } else { $wp_customize->add_control(new WP_Customize_Image_Control( $wp_customize, IP_THEME . 'header_bg_img', array( 'label' => __('Header background image', 'bizflow'), 'description' => __('Header background image: Overrides header background color', 'bizflow'), 'section' => IP_THEME . 'header_section', 'settings' => IP_THEME . 'header_bg_img', 'context' => IP_THEME ) )); } $wp_customize->add_setting(IP_THEME . 'fixed_navbar', array('default' => 'static', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'fixed_navbar', array( 'label' => __('Fixed Navigation Bar', 'bizflow'), 'description' => __('Fix Main navigation bar while scrolling', 'bizflow'), 'section' => IP_THEME . 'header_section', 'settings' => IP_THEME . 'fixed_navbar', 'type' => 'radio', 'choices' => array( 'fixed' => __('Yes', 'bizflow'), 'static' => __('No', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'navbar_height', array('default' => '54', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_range')); $wp_customize->add_control( new Ip_customize_range_control( $wp_customize, IP_THEME . 'navbar_height', array( 'label' => __('Navigation bar height', 'bizflow'), 'description' => __('Height of main navigation bar (in px)', 'bizflow'), 'section' => IP_THEME . 'header_section', 'settings' => IP_THEME . 'navbar_height', 'context' => IP_THEME, 'min' => 54, 'max' => 124, ) ) ); $wp_customize->add_setting(IP_THEME . 'mobile_menu_position', array('default' => 'left', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'mobile_menu_position', array( 'label' => __('Mobile menu position', 'bizflow'), 'description' => __('Where mobile menu is docked', 'bizflow'), 'section' => IP_THEME . 'header_section', 'settings' => IP_THEME . 'mobile_menu_position', 'type' => 'radio', 'choices' => array( 'left' => __('Left', 'bizflow'), 'right' => __('Right', 'bizflow') ) ) ); } add_action('customize_register', 'ip_register_customization_header_options'); } if (!function_exists('ip_register_customization_footer_options')) { /** * Customizer options to manage footer appearence * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_register_customization_footer_options($wp_customize) { $wp_customize->add_section(IP_THEME . 'footer_section', array( 'title' => __('Footer', 'bizflow'), 'description' => __('Customize footer appearence', 'bizflow'), 'priority' => 50 )); $wp_customize->add_setting(IP_THEME . 'footer_col_count', array('default' => '4', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'absint')); $wp_customize->add_control( IP_THEME . 'footer_col_count', array( 'label' => __('Footer column number', 'bizflow'), 'description' => __('Footer columns: Select 0 to hide all columns', 'bizflow'), 'section' => IP_THEME . 'footer_section', 'settings' => IP_THEME . 'footer_col_count', 'type' => 'select', 'choices' => array( 0, 1, 2, 3, 4, 5, 6 ) ) ); $wp_customize->add_setting(IP_THEME . 'copyright_text', array('default' => wp_sprintf('All copyright reserved %s, %d', get_bloginfo('name'), date('Y', time())), 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'wp_kses_post')); $wp_customize->add_control( IP_THEME . 'copyright_text', array( 'label' => __('Copyright text', 'bizflow'), 'description' => __('Copyright text', 'bizflow'), 'section' => IP_THEME . 'footer_section', 'settings' => IP_THEME . 'copyright_text', 'type' => 'textarea' ) ); $wp_customize->add_setting(IP_THEME . 'mobile_hide_footer', array('default' => 'show', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'mobile_hide_footer', array( 'label' => __('Hide Footer for Mobile', 'bizflow'), 'description' => __('Hide footer content on mobile for a more app like appearence', 'bizflow'), 'section' => IP_THEME . 'footer_section', 'settings' => IP_THEME . 'mobile_hide_footer', 'type' => 'radio', 'choices' => array( 'show' => __('No', 'bizflow'), 'hide' => __('Yes', 'bizflow') ) ) ); } add_action('customize_register', 'ip_register_customization_footer_options'); } if (!function_exists('ip_register_customization_post_options')) { /** * Customizer options to manage post (both single and archive) appearence * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_register_customization_post_options($wp_customize) { $wp_customize->add_section(IP_THEME . 'post_section', array( 'title' => __('Post', 'bizflow'), 'description' => __('Posts display settings', 'bizflow'), 'priority' => 59 )); $wp_customize->add_setting(IP_THEME . 'archive_content_display', array('default' => 'excerpt', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'archive_content_display', array( 'label' => __('Posts display', 'bizflow'), 'description' => __('Posts content display type on blog homepage and archive pages', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'archive_content_display', 'type' => 'select', 'choices' => array( 'excerpt' => __('Excerpt', 'bizflow'), 'full' => __('Full Content', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'archive_type', array('default' => 'grid', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'archive_type', array( 'label' => __('Posts display', 'bizflow'), 'description' => __('Posts display type on blog homepage and archive pages', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'archive_type', 'type' => 'select', 'choices' => array( 'grid' => __('Grid', 'bizflow'), 'list' => __('List', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'excerpt_length', array('default' => '25', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'absint')); $wp_customize->add_control( IP_THEME . 'excerpt_length', array( 'label' => __('Excerpt length', 'bizflow'), 'description' => __('Words in excerpt when generating from content', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'excerpt_length', 'type' => 'number', 'active_callback' => 'ip_condition_should_show_excerpt_length' ) ); $wp_customize->add_setting(IP_THEME . 'grid_col_number', array('default' => 4, 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'absint')); $wp_customize->add_control( IP_THEME . 'grid_col_number', array( 'label' => __('Posts per row', 'bizflow'), 'description' => __('Posts per row on blog homepage and archive pages', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'grid_col_number', 'type' => 'select', 'choices' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4 ), 'active_callback' => 'ip_condition_should_show_grid_col' ) ); $wp_customize->add_setting(IP_THEME . 'archive_thumb', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'archive_thumb', array( 'label' => __('Posts featured image', 'bizflow'), 'description' => __('Featured image on blog homepage and archive pages', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'archive_thumb', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'default_thumb', array('default' => trailingslashit(IP_THEME_URL) . 'assets/image/default-thumb.jpg', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_image')); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, IP_THEME . 'default_thumb', array( 'label' => __('Default thumbnail', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'default_thumb', 'context' => IP_THEME, 'active_callback' => 'ip_condition_should_show_default_thumb' ) ) ); $wp_customize->add_setting(IP_THEME . 'archive_cat_link', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'archive_cat_link', array( 'label' => __('Categories on archive page', 'bizflow'), 'description' => __('Category links on blog homepage and archive pages', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'archive_cat_link', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'archive_read_more', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'archive_read_more', array( 'label' => __('Read more link on archive page', 'bizflow'), 'description' => __('Read more links on blog homepage and archive pages', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'archive_read_more', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'single_cat_link', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'single_cat_link', array( 'label' => __('Categories on single post', 'bizflow'), 'description' => __('Category links on single post page', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'single_cat_link', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'single_tag_link', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'single_tag_link', array( 'label' => __('Tags on single post', 'bizflow'), 'description' => __('Tag links on single post page', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'single_tag_link', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'single_date', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'single_date', array( 'label' => __('Date on single post', 'bizflow'), 'description' => __('Show publishing date on single post page', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'single_date', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'single_author', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'single_author', array( 'label' => __('Author on single post', 'bizflow'), 'description' => __('Show author name on single post page', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'single_author', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); $wp_customize->add_setting(IP_THEME . 'prev_next_nav', array('default' => 'show', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'ip_theme_sanitize_setting_radio_select')); $wp_customize->add_control( IP_THEME . 'prev_next_nav', array( 'label' => __('Previous and Next posts link', 'bizflow'), 'description' => __('Previous and Next posts link at bottom of single content', 'bizflow'), 'section' => IP_THEME . 'post_section', 'settings' => IP_THEME . 'prev_next_nav', 'type' => 'radio', 'choices' => array( 'show' => __('Show', 'bizflow'), 'hide' => __('Hide', 'bizflow') ) ) ); } add_action('customize_register', 'ip_register_customization_post_options'); } if (!function_exists('ip_register_customization_font_options')) { /** * Customizer options to manage font appearence * * @param object $wp_customize instance of WP_Customize_Manager * @return void */ function ip_register_customization_font_options($wp_customize) { $wp_customize->add_section(IP_THEME . 'font_section', array( 'title' => __('Fonts', 'bizflow'), 'description' => __('Font settings', 'bizflow'), 'priority' => 59 )); $wp_customize->add_setting(IP_THEME . 'font_size', array('default' => '14', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_range')); $wp_customize->add_control( new Ip_customize_range_control( $wp_customize, IP_THEME . 'font_size', array( 'label' => __('Font size', 'bizflow'), 'description' => __('Global font size (in px)', 'bizflow'), 'section' => IP_THEME . 'font_section', 'settings' => IP_THEME . 'font_size', 'context' => IP_THEME, 'min' => 8, 'max' => 72, ) ) ); $wp_customize->add_setting(IP_THEME . 'single_title_size', array('default' => '32', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_range')); $wp_customize->add_control( new Ip_customize_range_control( $wp_customize, IP_THEME . 'single_title_size', array( 'label' => __('Single post title size', 'bizflow'), 'description' => __('Single post, page, archive title size (in px)', 'bizflow'), 'section' => IP_THEME . 'font_section', 'settings' => IP_THEME . 'single_title_size', 'context' => IP_THEME, 'min' => 18, 'max' => 72, ) ) ); $wp_customize->add_setting(IP_THEME . 'archive_title_size', array('default' => '18', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_range')); $wp_customize->add_control( new Ip_customize_range_control( $wp_customize, IP_THEME . 'archive_title_size', array( 'label' => __('Archive post title size', 'bizflow'), 'description' => __('Archive item title size (in px)', 'bizflow'), 'section' => IP_THEME . 'font_section', 'settings' => IP_THEME . 'archive_title_size', 'context' => IP_THEME, 'min' => 12, 'max' => 72, ) ) ); $wp_customize->add_setting(IP_THEME . 'navbar_font_size', array('default' => '14', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'ip_theme_sanitize_setting_range')); $wp_customize->add_control( new Ip_customize_range_control( $wp_customize, IP_THEME . 'navbar_font_size', array( 'label' => __('Navigation bar font size', 'bizflow'), 'description' => __('Navigation bar font size for top level menus (in px)', 'bizflow'), 'section' => IP_THEME . 'font_section', 'settings' => IP_THEME . 'navbar_font_size', 'context' => IP_THEME, 'min' => 12, 'max' => 72, ) ) ); } add_action('customize_register', 'ip_register_customization_font_options'); } if (!function_exists('ip_condition_should_show_site_width')) { /** * Callback function to control if site width control should be active * * Not used * * @return boolean */ function ip_condition_should_show_site_width() { $show = true; if (get_option(IP_THEME . 'site_layout', ip_theme_get_default_options()['site_layout']) == 'fullwidth') { $show = false; } return apply_filters('ip_theme_condition_should_show_site_width', $show); } } if (!function_exists('ip_condition_should_show_grid_col')) { /** * Callback function to control is grid column count should be active * * @return boolean */ function ip_condition_should_show_grid_col() { $show = true; if (get_option(IP_THEME . 'archive_type', ip_theme_get_default_options()['archive_type']) == 'list') { $show = false; } return apply_filters('ip_theme_condition_should_show_grid_col', $show); } } if (!function_exists('ip_condition_should_show_default_thumb')) { /** * Callback function to control is default thumbnail should be active * * @return boolean */ function ip_condition_should_show_default_thumb() { $show = true; if (get_option(IP_THEME . 'archive_thumb', ip_theme_get_default_options()['archive_thumb']) == 'hide') { $show = false; } return apply_filters('ip_theme_condition_should_show_default_thumb', $show); } } if (!function_exists('ip_condition_should_show_excerpt_length')) { /** * Callback function to control is archive word count should be active * * @return boolean */ function ip_condition_should_show_excerpt_length() { $show = true; if (get_option(IP_THEME . 'archive_content_display', ip_theme_get_default_options()['archive_content_display']) == 'full') { $show = false; } return apply_filters('ip_theme_condition_should_show_excerpt_length', $show); } } if (!function_exists('ip_theme_custom_css_output')) { /** * Custom css generated using customizer options * * Uses scss to generate css output * * @return void */ function ip_theme_custom_css_output() { if (class_exists('scssc')) return; //Initialize php scss include_once IP_THEME_PATH . 'scss/ip-scss.php'; include_once IP_THEME_PATH . 'scss/custom-scss.php'; $scss = new scssc(); //We want compressed (minified) output $scss->setFormatter('scss_formatter_compressed'); $custom_css_values = ip_theme_get_custom_css_values(); //Set scss variables $scss->setVariables($custom_css_values); //Get the genearted css content $custom_css = apply_filters('ip_theme_custom_css_output', $scss->compile($custom_scss)); //Add as inline css after main style i.e. style.css wp_add_inline_style( IP_THEME . 'main_style', $custom_css); } add_action('wp_enqueue_scripts', 'ip_theme_custom_css_output'); } if (!function_exists('ip_theme_additional_header_css')) { /** * Some additional CSS * * Output directly to
* * @return void */ function ip_theme_additional_header_css() { $css = ''; //Header background image if (version_compare(get_bloginfo('version'), '4.3', '>=')) { if ($header_bg_img = get_option(IP_THEME . 'header_bg_img')) { $css .= '.header-container,.header-container.container-boxed{background-image:url(' . esc_url(wp_get_attachment_image_url($header_bg_img, 'full')) . ');}'; } } else { if ($header_bg_img = get_option(IP_THEME . 'header_bg_img')) { $css .= '.header-container,.header-container.container-boxed{background-image:url(' . esc_url($header_bg_img) . ');}'; } } //Hide footer on smaller screen devices if( get_option( IP_THEME . 'mobile_hide_footer', ip_theme_get_default_options()['mobile_hide_footer'] ) == 'hide'){ $css .= '.footer-container{ display: none;} @media only screen and (min-width: 767px){ .footer-container{ display: block;} }'; } echo apply_filters('ip_theme_additional_header_css', sprintf( '', $css )); } add_action('wp_head', 'ip_theme_additional_header_css', 9); } if (!function_exists('ip_theme_js_config')) { /** * Make necessary customizer settings available to frontend JS as global variables * * @return void */ function ip_theme_js_config() { $jsVals = array(); //If main navigation bar should be fixed on scroll $jsVals['fixedNavbar'] = get_option(IP_THEME . 'fixed_navbar', ip_theme_get_default_options()['fixed_navbar']); //If back to top button should be shown $jsVals['backToTop'] = get_option(IP_THEME . 'back_to_top_show', ip_theme_get_default_options()['back_to_top_show']); wp_localize_script(IP_THEME . 'frontend', 'ipTheme', $jsVals); } add_action('wp_enqueue_scripts', 'ip_theme_js_config'); } if (!function_exists('ip_theme_sanitize_setting_radio_select')) { /** * Satitization callback function for customize control type radio * * @param string $input selected value * @param array $setting default setting * @return string */ function ip_theme_sanitize_setting_radio_select($input, $setting) { $input = sanitize_key($input); $choices = $setting->manager->get_control($setting->id)->choices; return (array_key_exists($input, $choices)) ? $input : $setting->default; } } if(!function_exists('ip_theme_sanitize_setting_range')){ /** * Satitization callback function for custom control type range * * @param string $input selected value * @param array $setting default setting * @return integer */ function ip_theme_sanitize_setting_range($input, $setting){ $input = absint( $input ); $min = absint( $setting->manager->get_control($setting->id)->min ); $max = absint( $setting->manager->get_control($setting->id)->max ); return ( $input >= $min && $input <= $max ) ? $input : $setting->default; } } if (!function_exists('ip_theme_sanitize_setting_cropped_image')) { /** * Satitization callback function for control custom logo * * Since wordpress version 4.3 WP_Customize_Cropped_Image_Control is available which returns attachment id as int * * For backward compatibility WP_Customize_Image_Control is used which returns URL * * @param string $input selected value * @param array $setting default setting * @return string or integer */ function ip_theme_sanitize_setting_cropped_image($input, $setting) { if (version_compare(get_bloginfo('version'), '4.3', '>=')) { return absint($input); } else { return esc_url_raw($input); } } } if(!function_exists('ip_theme_sanitize_setting_image')){ /** * Satitization callback function for WP_Customize_Image_Control * * @param string $input selected value * @param array $setting default setting * @return string */ function ip_theme_sanitize_setting_image($input, $setting){ return esc_url_raw($input); } }