manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } function kirhero_sanitize_number( $val ) { return is_numeric( $val ) ? $val : 0; } function kirhero_sanitize_image( $image, $setting ) { /* * Array of valid image file types. * * The array includes image mime types that are included in wp_get_mime_types() */ $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon' ); // Return an array with file extension and mime_type. $file = wp_check_filetype( $image, $mimes ); // If $image has a valid mime_type, return it; otherwise, return the default. return ( $file['ext'] ? $image : $setting->default ); } function kirhero_cac_has_background_image() { if ( '' != get_theme_mod( 'kirhero_admin_general_background_image' ) ) { return true; } else { return false; } } function kirhero_cac_has_slider_background_image() { if ( '' != get_theme_mod( 'kirhero_admin_slider_background_image' ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_slide_title_image() { if ( '' != get_theme_mod( 'kirhero_admin_frontpage_slide_title_image', '' ) && 'image' == get_theme_mod( 'kirhero_admin_frontpage_slide_title_switch', kirhero_get_default_theme_settings( 'frontpage-slide-title-switch' ) ) ) { return true; } else { return false; } } function kirhero_has_header_transparent_hp(){ if ( '' != get_theme_mod( 'kirhero_header_transparent_hp', kirhero_get_default_theme_settings( 'header-transparent-hp' ) ) ) { return true; } else { return false; } } function kirhero_sanitize_color( $color ) { if ( empty( $color ) || is_array( $color ) ) { return ''; } // If string does not start with 'rgba', then treat as hex. // sanitize the hex color and finally convert hex to rgba if ( false === strpos( $color, 'rgba' ) ) { return sanitize_hex_color( $color ); } // echo 'rgba('.$red.','.$green.','.$blue.','.$alpha.')'; // By now we know the string is formatted as an rgba color so we need to further sanitize it. $color = str_replace( ' ', '', $color ); sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')'; } function kirhero_sanitize_checkbox( $checked ) { // Boolean check. return ( ( isset( $checked ) && true == $checked ) ? true : false ); } function kirhero_sanitize_number_blank( $val ) { return is_numeric( $val ) ? $val : ''; } function kirhero_sanitize_multi_choices( $input, $setting ) { // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; $input_keys = $input; foreach ( $input_keys as $key => $value ) { if ( ! array_key_exists( $value, $choices ) ) { unset( $input[ $key ] ); } } // If the input is a valid key, return it; // otherwise, return the default. return ( is_array( $input ) ? $input : $setting->default ); } function kirhero_has_logo() { //usleep(1000); if ( has_custom_logo()) { return true; } else { return false; } } function kirhero_has_blog_entries_both_layout() { if ( 'both-sidebars' == get_theme_mod( 'kirhero_admin_blog_layout', kirhero_get_default_theme_settings( 'blog-both-sidebars-style' ) ) ) { return true; } else { return false; } } function kirhero_has_single_post_blog_entries_both_layout() { if ( 'both-sidebars' == get_theme_mod( 'kirhero_blog_single_layout', kirhero_get_default_theme_settings( 'blog-customizer-single-layout' ) ) ) { return true; } else { return false; } } function kirhero_has_grid_blog_style() { if ( 'grid-entry' == get_theme_mod( 'kirhero_admin_blog_style', kirhero_get_default_theme_settings( 'blog-style' ) ) ) { return true; } else { return false; } } function kirhero_has_equal_heights() { if ( kirhero_has_grid_blog_style()) { return true; } else { return false; } } function kirhero_has_article_display_length() { if ( 'custom-text' == get_theme_mod( 'kirhero_blog_article_display', kirhero_get_default_theme_settings( 'blog-article-display' ) ) ) { return true; } else { return false; } } if ( ! function_exists( 'kirhero_blog_article_elements' ) ) { function kirhero_blog_article_elements() { // Default elements $elements = apply_filters( 'kirhero_blog_article_elements', array( 'featured_image' => esc_html__( 'Featured Image', 'astori' ), 'title' => esc_html__( 'Title', 'astori' ), 'meta' => esc_html__( 'Meta', 'astori' ), 'content' => esc_html__( 'Content', 'astori' ), 'read_more' => esc_html__( 'Read More', 'astori' ), ) ); // Return elements return $elements; } } if ( ! function_exists( 'kirhero_frontpage_elements' ) ) { function kirhero_frontpage_elements() { /* Slide / Title Section + About / Content Section + Subscribe Section + Team Section + Blog Section + Contact Section Features Section + Price Section - Action Section + Testimonials - Widget Section - !? */ // Default elements $elements = apply_filters( 'kirhero_frontpage_elements', array( 'slide_title' => esc_html__( 'Slide / Title Section', 'astori' ), 'about_content' => esc_html__( 'About / Content Section', 'astori' ), 'team' => esc_html__( 'Team Section', 'astori' ), 'blog' => esc_html__( 'Blog Section', 'astori' ), 'contact' => esc_html__( 'Contact Section', 'astori' ), 'features' => esc_html__( 'Features Section ', 'astori' ), 'action' => esc_html__( 'Action Section ', 'astori' ), 'subscribe' => esc_html__( 'Subscribe Section ', 'astori' ), ) ); // Return elements return $elements; } } function kirhero_has_fixed_header() { if ( get_theme_mod( 'kirhero_header_fixed', kirhero_get_default_theme_settings('header-fixed') ) ) { return true; } else { return false; } } if ( ! function_exists( 'kirhero_blog_single_elements' ) ) { function kirhero_blog_single_elements() { /* remove_filter('', 'kirhero_blog_single_elements'); foreach ( array( 'the_content', 'the_title', 'comment_text' ) as $hook ) remove_filter( $hook, 'capital_P_dangit' ); */ // Default elements $elements = apply_filters( 'kirhero_blog_single_elements', array( 'featured_image' => esc_html__( 'Featured Image', 'astori' ), 'title' => esc_html__( 'Title', 'astori' ), 'meta' => esc_html__( 'Meta', 'astori' ), 'content' => esc_html__( 'Content', 'astori' ), 'tags' => esc_html__( 'Tags', 'astori' ), 'next_prev' => esc_html__( 'Next/Prev Links', 'astori' ), 'author_box' => esc_html__( 'Author Box', 'astori' ), 'related_posts' => esc_html__( 'Related Posts', 'astori' ), 'single_comments' => esc_html__( 'Comments', 'astori' ), ) ); // Return elements return $elements; } } if ( ! function_exists( 'kirhero_has_featured_image' ) ) { function kirhero_has_featured_image() { if ( 'page-banner' == get_theme_mod( 'kirhero_blog_page_featured_image_style', kirhero_get_default_theme_settings( 'blog-page-single-featured-style' ) ) ) { return true; } else { return false; } } } if ( ! function_exists( 'kirhero_has_wide_featured_image' ) ) { function kirhero_has_wide_featured_image() { if ( 'page-banner' == get_theme_mod( 'kirhero_blog_page_featured_image_style', kirhero_get_default_theme_settings( 'blog-page-single-featured-style' ) ) && 'wide' == get_theme_mod( 'kirhero_admin_general_layout_style', kirhero_get_default_theme_settings( 'general-layout-style' ) ) ) { return true; } else { return false; } } } if ( ! function_exists( 'kirhero_has_boxed_layout' ) ) { function kirhero_has_boxed_layout() { if ( 'boxed' == get_theme_mod( 'kirhero_admin_general_layout_style', kirhero_get_default_theme_settings( 'general-layout-style' ) ) ) { return true; } else { return false; } } } if ( ! function_exists( 'kirhero_has_wide_layout' ) ) { function kirhero_has_wide_layout() { if ( 'wide' == get_theme_mod( 'kirhero_admin_general_layout_style', kirhero_get_default_theme_settings( 'general-layout-style' ) ) ) { return true; } else { return false; } } } if ( ! function_exists( 'kirhero_has_left_sidebar' ) ) { function kirhero_has_left_sidebar() { if ( 'both-sidebars' == kirhero_layout() ) { return true; } else { return false; } } } if ( ! function_exists( 'kirhero_has_right_sidebar' ) ) { function kirhero_has_right_sidebar() { if ( in_array( kirhero_layout(), array( 'full-screen', 'full-width' ) ) ) { return false; } else { return true; } } } if ( ! function_exists( 'kirhero_has_pages_both_sidebar' ) ) { function kirhero_has_pages_both_sidebar() { if ( 'both-sidebars' == get_theme_mod( 'kirhero_admin_general_pages_layout', kirhero_get_default_theme_settings( 'general-pages-layout' ) ) ) { return true; } else { return false; } } } function customizer_repeater_sanitize($input){ $input_decoded = json_decode($input,true); if(!empty($input_decoded)) { foreach ($input_decoded as $boxk => $box ){ foreach ($box as $key => $value){ $input_decoded[$boxk][$key] = wp_kses_post( force_balance_tags( $value ) ); } } return json_encode($input_decoded); } return $input; } function kirhero_cac_has_frontpage_subscribe_image() { if ( '' != get_theme_mod( 'kirhero_admin_frontpage_subscribe_image', kirhero_get_default_theme_settings('frontpage-subscribe-image') ) && 'image' == get_theme_mod( 'kirhero_admin_frontpage_subscribe_section_switch', kirhero_get_default_theme_settings( 'frontpage-subscribe-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_contact_image() { if ( '' != get_theme_mod( 'kirhero_admin_frontpage_contact_image', kirhero_get_default_theme_settings('frontpage-contact-image') ) && 'image' == get_theme_mod( 'kirhero_admin_frontpage_contact_switch', kirhero_get_default_theme_settings( 'frontpage-contact-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_slide_switch_image() { if ( 'image' == get_theme_mod( 'kirhero_admin_frontpage_slide_title_switch', kirhero_get_default_theme_settings( 'frontpage-slide-title-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_slide_switch_color() { if ( 'color' == get_theme_mod( 'kirhero_admin_frontpage_slide_title_switch', kirhero_get_default_theme_settings( 'frontpage-slide-title-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_subscribe_switch_image() { if ( 'image' == get_theme_mod( 'kirhero_admin_frontpage_subscribe_section_switch', kirhero_get_default_theme_settings( 'frontpage-subscribe-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_subscribe_switch_color() { if ( 'color' == get_theme_mod( 'kirhero_admin_frontpage_subscribe_section_switch', kirhero_get_default_theme_settings( 'frontpage-subscribe-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_contact_switch_image() { if ( 'image' == get_theme_mod( 'kirhero_admin_frontpage_contact_switch', kirhero_get_default_theme_settings( 'frontpage-contact-switch' ) ) ) { return true; } else { return false; } } function kirhero_cac_has_frontpage_contact_switch_color() { if ( 'color' == get_theme_mod( 'kirhero_admin_frontpage_contact_switch', kirhero_get_default_theme_settings( 'frontpage-contact-switch' ) ) ) { return true; } else { return false; } }