manager->get_control( $primebulletin_setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $primebulletin_input, $choices ) ? $primebulletin_input : $primebulletin_setting->default ); } endif; if ( ! function_exists( 'primebulletin_sanitize_repeater' ) ) : /** * Sanitise Repeater Field */ function primebulletin_sanitize_repeater($input){ $input_decoded = json_decode( $input, true ); if(!empty($input_decoded)) { foreach ($input_decoded as $boxes => $box ){ foreach ($box as $key => $value){ if( $key == 'section_ed' || $key == 'ed_tab' || $key == 'ed_arrows_carousel' || $key == 'ed_dots_carousel' || $key == 'ed_autoplay_carousel' || $key == 'ed_flip_column' || $key == 'ed_ribbon_bg' ){ $input_decoded[$boxes][$key] = primebulletin_sanitize_repeater_ed( $value ); }elseif( $key == 'home_section_type' ){ $input_decoded[$boxes][$key] = primebulletin_sanitize_home_sections( $value ); }elseif( $key == 'ribbon_bg_color_schema' ){ $input_decoded[$boxes][$key] = primebulletin_sanitize_ribbon_bg( $value ); }elseif( $key == 'category_color' ){ $input_decoded[$boxes][$key] = sanitize_hex_color( $value ); }elseif( $key == 'tiles_post_per_page' ){ $input_decoded[$boxes][$key] = absint( $value ); }elseif( $key == 'advertise_image' || $key == 'advertise_link' ){ $input_decoded[$boxes][$key] = esc_url_raw( $value ); }elseif($key == 'section_category' || $key == 'section_post_slide_cat' || $key == 'section_category_1' || $key == 'section_category_2' || $key == 'section_category_3' || $key == 'section_category_4' || $key == 'category' ){ $input_decoded[$boxes][$key] = primebulletin_sanitize_category( $value ); }else{ $input_decoded[$boxes][$key] = sanitize_text_field( $value ); } } } return json_encode($input_decoded); } return $input; } endif; /** Sanitize Enable Disable Checkbox **/ function primebulletin_sanitize_repeater_ed( $input ) { $valid_keys = array('yes','no'); if ( in_array( $input , $valid_keys ) ) { return $input; } return ''; } function primebulletin_sanitize_home_sections( $input ) { $home_sections = array( 'main-banner' => esc_html__('Slider & Vertical Slider','primebulletin'), 'banner-blocks-1' => esc_html__('Slider & Tab Block','primebulletin'), 'latest-posts-blocks' => esc_html__('Latest Posts Block','primebulletin'), 'slider-blocks' => esc_html__('Slider Block','primebulletin'), 'tiles-blocks' => esc_html__('Tiles Block','primebulletin'), 'advertise-blocks' => esc_html__('Advertise Block','primebulletin'), 'home-widget-area' => esc_html__('Widgets Area Block','primebulletin'), ); if ( array_key_exists( $input , $home_sections ) ) { return $input; } return ''; } /** Sanitize Category **/ function primebulletin_sanitize_category( $input ) { $primebulletin_post_category_list = primebulletin_post_category_list(); if ( array_key_exists( $input , $primebulletin_post_category_list ) ) { return $input; } return ''; } function primebulletin_sanitize_ribbon_bg( $input ) { $ribbon_bg = array( '1' => array( 'title' => esc_html__( 'Blue', 'primebulletin' ), 'color' => '#3061ff', ), '2' => array( 'title' => esc_html__( 'Orange', 'primebulletin' ), 'color' => '#fa9000', ), '3' => array( 'title' => esc_html__( 'Royal Blue', 'primebulletin' ), 'color' => '#00167a', ), '4' => array( 'title' => esc_html__( 'Pink', 'primebulletin' ), 'color' => '#ff2d55', ), ); if ( array_key_exists( $input , $ribbon_bg ) ) { return $input; } return ''; }