search_form = $search_form; $this->index_conflicts = $this->get_index_conflicts(); } function is_name( $string ) { return preg_match( '/^[A-Za-z][-A-Za-z0-9_:.]*$/', $string ); } public function add_panel( $id, $title, $callback, $description ) { if ( $this->is_name( $id ) ) { $this->panels[$id] = array( 'title' => $title, 'callback' => $callback, 'description' => $description, ); } } public function display() { if ( empty( $this->panels ) ) { return; } echo ''; echo sprintf( '
', esc_attr( $tab ) ); $this->notice( $tab, $tab . '_panel' ); $callback = $tab . '_panel'; if ( method_exists( $this, $callback ) ) { $this->{$callback}( $this->search_form ); } else { _e( 'The requested section does not exist.', 'add-search-to-menu' ); } echo '
'; } public function notice( $id, $panel ) { echo '
'; } /** * Gets all public meta keys of post types * * @global Object $wpdb WPDB object * @return Array array of meta keys */ function is_meta_keys() { global $wpdb; $is_fields = $wpdb->get_results( apply_filters( 'is_meta_keys_query', "select DISTINCT meta_key from {$wpdb->postmeta} pt LEFT JOIN {$wpdb->posts} p ON (pt.post_id = p.ID) where meta_key NOT LIKE '\\_%' ORDER BY meta_key ASC" ) ); $meta_keys = array(); if ( is_array( $is_fields ) && !empty( $is_fields ) ) { foreach ( $is_fields as $field ) { if ( isset( $field->meta_key ) ) { $meta_keys[] = $field->meta_key; } } } /** * Filter results of SQL query for meta keys */ return apply_filters( 'is_meta_keys', $meta_keys ); } public function inc_exc_url( $section ) { $includes_url = ''; $sec_name = __( "Search", 'add-search-to-menu' ); if ( 'excludes' === $section ) { $sec_name = __( "Exclude", 'add-search-to-menu' ); } if ( isset( $_REQUEST['post'] ) ) { $includes_url = '' . esc_html( $sec_name ) . ''; } else { if ( isset( $_REQUEST['page'] ) && 'ivory-search-new' === $_REQUEST['page'] ) { $includes_url = '' . esc_html( $sec_name ) . ''; } } return $includes_url; } public function includes_panel( $post ) { $id = '_is_includes'; $includes = $post->prop( $id ); $excludes = $post->prop( '_is_excludes' ); $settings = $post->prop( '_is_settings' ); $default_search = ( NULL == $post->id() ? true : false ); ?>

true, ), 'objects' ); $post_types2 = array(); if ( $default_search ) { $post_types2 = get_post_types( array( 'public' => true, 'exclude_from_search' => false, ) ); } else { if ( isset( $includes['post_type'] ) && !empty( $includes['post_type'] ) && is_array( $includes['post_type'] ) ) { $post_types2 = array_values( $includes['post_type'] ); } } if ( !empty( $post_types ) ) { ?>
labels->name ); ?>
$post_type ) { $checked = ( $default_search && in_array( $key, $post_types2 ) || isset( $includes['post_type'][esc_attr( $key )] ) ? esc_attr( $key ) : 0 ); ?>

$post_type, 'posts_per_page' => $posts_per_page, 'orderby' => 'title', 'order' => 'ASC', ) ); if ( !empty( $posts ) ) { $tchecked = 'all'; if ( isset( $includes['post__in'] ) ) { foreach ( $posts as $post1 ) { if ( in_array( $post1->ID, $includes['post__in'] ) ) { array_push( $selected_pt, $post_type ); $tchecked = 'selected'; } } if ( 'all' === $tchecked ) { echo '' . sprintf( __( 'The %s are not searchable as the search form is configured to only search specific posts of another post type.', 'add-search-to-menu' ), strtolower( esc_html( $post_types[$post_type]->labels->name ) ) ) . ''; } } echo '

'; echo '

'; } echo '
'; if ( !empty( $posts ) ) { echo '
'; $col_title = '' . esc_html( $post_types[$post_type]->labels->name ) . ''; $temp = ''; foreach ( $posts as $post2 ) { $checked = ( isset( $includes['post__in'] ) && in_array( $post2->ID, $includes['post__in'] ) ? $post2->ID : 0 ); $post_title = ( isset( $post2->post_title ) && '' !== $post2->post_title ? esc_html( $post2->post_title ) : $post2->post_name ); $temp .= ''; } if ( 'selected' === $tchecked ) { $col_title = '' . $col_title . ''; } echo $col_title . '
'; echo ''; if ( count( $posts ) >= 100 && !defined( 'DISABLE_IS_LOAD_ALL' ) && !isset( $includes['post__in'] ) ) { echo '
' . __( 'Load All', 'add-search-to-menu' ) . '
'; } echo '

'; echo '
'; } else { echo '' . sprintf( __( 'No %s created.', 'add-search-to-menu' ), $post_types[$post_type]->labels->name ) . ''; } echo '
'; $tax_objs = get_object_taxonomies( $post_type, 'objects' ); if ( !empty( $tax_objs ) ) { $terms_exist = false; $html = '
'; $selected_tax = false; foreach ( $tax_objs as $key => $tax_obj ) { $terms = get_terms( array( 'taxonomy' => $key, 'lang' => '', 'number' => 1000, ) ); if ( !empty( $terms ) && !empty( $tax_obj->labels->name ) ) { $terms_exist = true; $html .= '
'; $col_title = ucwords( str_replace( '-', ' ', str_replace( '_', ' ', esc_html( $tax_obj->labels->name ) ) ) ); if ( isset( $includes['tax_query'][$key] ) ) { $col_title = '' . $col_title . ''; $selected_tax = true; } $html .= $col_title . '
'; $html .= '
'; } } if ( $terms_exist ) { $html .= '

'; $html .= '
'; $checked = ( $selected_tax ? 'selected' : 'all' ); echo '

'; echo '

'; echo $html; } } if ( 'product' == $post_type && !IS_Help::is_woocommerce_inactive() ) { $woo_sku_disable = ( is_fs()->is_plan_or_trial( 'pro_plus' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $checked = ( isset( $includes['woo']['sku'] ) && $includes['woo']['sku'] ? 1 : 0 ); echo '
'; if ( '' !== $woo_sku_disable ) { echo '
'; } echo '

'; $checked = ( isset( $includes['woo']['variation'] ) && $includes['woo']['variation'] ? 1 : 0 ); echo '

'; echo IS_Admin::pro_link( 'pro_plus' ); if ( '' !== $woo_sku_disable ) { echo '

'; } echo '

'; echo '

'; echo $this->get_conflicts_info( 'woo', 'sku' ); echo $this->get_conflicts_info( 'woo', 'variation' ); echo '

'; } if ( 'attachment' == $post_type && empty( $selected_pt ) ) { global $wp_version; if ( 4.9 <= $wp_version ) { if ( !isset( $excludes['post_file_type'] ) ) { echo '
'; $file_types = get_allowed_mime_types(); if ( !empty( $file_types ) ) { $file_type_disable = ( is_fs()->is_plan_or_trial( 'pro_plus' ) && $this->is_premium_plugin ? '' : ' disabled ' ); if ( '' !== $file_type_disable ) { echo '
'; } ksort( $file_types ); $html = '
'; $html .= ''; $html .= ''; echo IS_Admin::pro_link( 'pro_plus' ); $html .= '

'; if ( isset( $includes['post_file_type'] ) ) { $html .= __( 'Selected File Types :', 'add-search-to-menu' ); foreach ( $includes['post_file_type'] as $post_file_type ) { $html .= '
' . $post_file_type . ''; } } $html .= '
'; $checked = ( isset( $includes['post_file_type'] ) && !empty( $includes['post_file_type'] ) ? 'selected' : 'all' ); echo '

'; echo '

'; echo $html; echo ''; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '
'; if ( '' !== $file_type_disable ) { echo '
'; } } } else { echo '
' . sprintf( esc_html__( "This search form is configured in the %s section to not search specific MIME types.", 'add-search-to-menu' ), $this->inc_exc_url( 'excludes' ) ) . ''; } } else { echo '
' . __( 'You are using WordPress version less than 4.9 which does not support searching by MIME type.', 'add-search-to-menu' ) . ''; } } ?>

'; echo $this->get_conflicts_info( 'search_title' ); $checked = ( $default_search || isset( $includes['search_content'] ) && $includes['search_content'] ? 1 : 0 ); echo '

'; echo $this->get_conflicts_info( 'search_content' ); $checked = ( $default_search || isset( $includes['search_excerpt'] ) && $includes['search_excerpt'] ? 1 : 0 ); echo '

'; echo $this->get_conflicts_info( 'search_excerpt' ); $checked = ( isset( $includes['search_tax_title'] ) && $includes['search_tax_title'] ? 1 : 0 ); echo '

'; echo $this->get_conflicts_info( 'search_tax_title' ); $checked = ( isset( $includes['search_tax_desp'] ) && $includes['search_tax_desp'] ? 1 : 0 ); echo '

'; echo $this->get_conflicts_info( 'search_tax_desp' ); if ( isset( $includes['tax_query'] ) ) { $tax_rel_disable = ''; if ( isset( $includes['tax_post_type'] ) ) { $temp = array(); foreach ( $includes['tax_query'] as $key => $value ) { if ( isset( $includes['tax_post_type'][$key] ) && (empty( $temp ) || !in_array( $includes['tax_post_type'][$key], $temp )) ) { array_push( $temp, $includes['tax_post_type'][$key] ); } if ( count( $temp ) > 1 ) { $tax_rel_disable = 'disabled'; $includes['tax_rel'] = "OR"; break; } } } echo '

'; if ( 'disabled' == $tax_rel_disable ) { echo '
'; $content = __( 'Note: The below option is disabled and set to OR as you have configured the search form to search multiple taxonomies.', 'add-search-to-menu' ); IS_Help::help_info( $content ); } $checked = ( isset( $includes['tax_rel'] ) && "AND" == $includes['tax_rel'] ? "AND" : "OR" ); echo '

'; echo '

'; } ?>

is_meta_keys(); if ( !empty( $meta_keys ) ) { $html = '
'; $selected_meta = false; $html .= ''; $html .= ''; $html .= '
'; $html .= '
'; $checked = ( $selected_meta ? 'selected' : 'all' ); echo ''; echo $html; echo '

'; echo $this->get_conflicts_info( 'custom_field' ); echo '

'; } ?>

'; $post_statuses = get_post_stati(); $post_status_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); if ( !empty( $post_statuses ) ) { if ( '' !== $post_status_disable ) { echo IS_Admin::pro_link(); } echo '
'; echo '
'; if ( $default_search || !isset( $includes['post_status'] ) || empty( $includes['post_status'] ) ) { $includes = array( 'post_status' => array( 'publish' => 'publish', 'inherit' => 'inherit', ), ); } echo ''; foreach ( $includes['post_status'] as $post_status2 ) { echo ' ' . str_replace( '-', ' ', esc_html( $post_status2 ) ) . ''; } echo ''; echo '
'; echo '
'; foreach ( $post_statuses as $key => $post_status ) { $checked = ( isset( $includes['post_status'][esc_attr( $key )] ) ? $includes['post_status'][esc_attr( $key )] : 0 ); $temp = ( 'publish' === $post_status || 'inherit' === $post_status ? '' : $post_status_disable ); echo ''; } echo '
'; } ?>

'; $author_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); if ( !isset( $excludes['author'] ) ) { $authors = get_users( array( 'fields' => array('ID', 'display_name'), 'role__not_in' => 'subscriber', 'orderby' => 'post_count', 'order' => 'DESC', ) ); if ( !empty( $authors ) ) { if ( '' !== $author_disable ) { echo '
' . IS_Admin::pro_link(); } echo '
'; echo '
'; if ( !isset( $includes['author'] ) || empty( $includes['author'] ) ) { echo '' . __( 'Searches all author posts', 'add-search-to-menu' ) . ''; } else { echo ''; foreach ( $includes['author'] as $author2 ) { $display_name = get_userdata( $author2 ); if ( $display_name ) { echo ' ' . esc_html( $display_name->display_name ) . ''; } } echo ''; } echo '
'; echo '
'; foreach ( $authors as $author ) { $post_count = count_user_posts( $author->ID ); // Move on if user has not published a post (yet). if ( !$post_count ) { continue; } $checked = ( isset( $includes['author'][esc_attr( $author->ID )] ) ? $includes['author'][esc_attr( $author->ID )] : 0 ); echo ''; } echo '
'; } } else { echo '
' . sprintf( esc_html__( "This search form is configured in the %s section to not search for specific author posts.", 'add-search-to-menu' ), $this->inc_exc_url( 'excludes' ) ) . ''; } if ( '' !== $author_disable ) { echo '
'; } $checked = ( isset( $includes['search_author'] ) && $includes['search_author'] ? 1 : 0 ); echo '

'; echo $this->get_conflicts_info( 'search_author' ); ?>

'; $comment_count_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); if ( '' !== $comment_count_disable ) { echo '
' . IS_Admin::pro_link(); } echo ''; echo ''; if ( '' !== $comment_count_disable ) { echo '
'; } $checked = ( isset( $includes['search_comment'] ) && $includes['search_comment'] ? 1 : 0 ); echo '

'; echo $this->get_conflicts_info( 'search_comment' ); ?>

'; echo '

'; echo '

'; ?>

'; $range = array('after', 'before'); foreach ( $range as $value ) { $col_title = ( 'after' == $value ? __( 'From', 'add-search-to-menu' ) : __( 'To', 'add-search-to-menu' ) ); echo '
' . esc_html( $col_title ) . '
'; $checked = ( isset( $includes['date_query'][$value]['date'] ) ? $includes['date_query'][$value]['date'] : '' ); echo ''; echo '
'; } ?>
prop( $id ); $enable_customize = ( isset( $settings['enable_customize'] ) ? $settings['enable_customize'] : false ); $is_ajax = $post->prop( '_is_ajax' ); ?>

name() && !isset( $is_ajax['enable_ajax'] ) ) { ?>

name() && !isset( $is_ajax['enable_ajax'] ) ) { ?>
' . __( "Search Form Customizer", "add-search-to-menu" ) . ''; } ?>
prop( $id ); $includes = $post->prop( '_is_includes' ); // If not have any settings saved then set default value for fields. if ( empty( $settings ) ) { $show_description = true; $show_details_box = true; $show_more_result = true; $show_more_func = false; $show_price = true; $show_matching_categories = true; $show_image = true; $search_results = 'both'; } else { $show_description = ( isset( $settings['show_description'] ) && $settings['show_description'] ? 1 : 0 ); $show_details_box = ( isset( $settings['show_details_box'] ) ? $settings['show_details_box'] : false ); $show_more_result = ( isset( $settings['show_more_result'] ) && $settings['show_more_result'] ? 1 : 0 ); $show_more_func = ( isset( $settings['show_more_func'] ) && $settings['show_more_func'] ? 1 : 0 ); $show_price = ( isset( $settings['show_price'] ) && $settings['show_price'] ? 1 : 0 ); $show_matching_categories = ( isset( $settings['show_matching_categories'] ) && $settings['show_matching_categories'] ? 1 : 0 ); $show_image = ( isset( $settings['show_image'] ) ? 1 : 0 ); $search_results = ( isset( $settings['search_results'] ) ? $settings['search_results'] : 'both' ); } $enable_ajax = ( isset( $settings['enable_ajax'] ) ? $settings['enable_ajax'] : false ); $description_source = ( isset( $settings['description_source'] ) ? $settings['description_source'] : 'excerpt' ); $description_length = ( isset( $settings['description_length'] ) ? $settings['description_length'] : 20 ); $hide_price_out_of_stock = ( isset( $settings['hide_price_out_of_stock'] ) && $settings['hide_price_out_of_stock'] ? 1 : 0 ); $show_sale_badge = ( isset( $settings['show_sale_badge'] ) && $settings['show_sale_badge'] ? 1 : 0 ); $show_categories = ( isset( $settings['show_categories'] ) && $settings['show_categories'] ? 1 : 0 ); $show_tags = ( isset( $settings['show_tags'] ) && $settings['show_tags'] ? 1 : 0 ); $show_sku = ( isset( $settings['show_sku'] ) && $settings['show_sku'] ? 1 : 0 ); $show_matching_tags = ( isset( $settings['show_matching_tags'] ) && $settings['show_matching_tags'] ? 1 : 0 ); $show_stock_status = ( isset( $settings['show_stock_status'] ) && $settings['show_stock_status'] ? 1 : 0 ); $show_featured_icon = ( isset( $settings['show_featured_icon'] ) && $settings['show_featured_icon'] ? 1 : 0 ); $nothing_found_text = ( isset( $settings['nothing_found_text'] ) ? $settings['nothing_found_text'] : __( 'Nothing found', 'add-search-to-menu' ) ); $min_no_for_search = ( isset( $settings['min_no_for_search'] ) ? $settings['min_no_for_search'] : 1 ); $view_all_results = ( isset( $settings['view_all_results'] ) ? $settings['view_all_results'] : false ); $view_all_text = ( isset( $settings['view_all_text'] ) ? $settings['view_all_text'] : __( 'View All', 'add-search-to-menu' ) ); // Result Layout. $result_box_max_height = ( isset( $settings['result_box_max_height'] ) ? $settings['result_box_max_height'] : 400 ); $more_result_text = ( isset( $settings['more_result_text'] ) ? $settings['more_result_text'] : __( 'More Results..', 'add-search-to-menu' ) ); $show_author = ( isset( $settings['show_author'] ) && $settings['show_author'] ? 1 : 0 ); $show_date = ( isset( $settings['show_date'] ) && $settings['show_date'] ? 1 : 0 ); // Details Box. $product_list = ( isset( $settings['product_list'] ) ? $settings['product_list'] : 'all' ); $order_by = ( isset( $settings['order_by'] ) ? $settings['order_by'] : 'date' ); $order = ( isset( $settings['order'] ) ? $settings['order'] : 'desc' ); $field_class = ( $enable_ajax ? '' : 'is-field-disabled' ); ?>






' . sprintf( esc_html__( "Please first configure this search form in the %s section to search WooCommerce product post type.", 'add-search-to-menu' ), $this->inc_exc_url( 'includes' ) ) . '
'; } else { ?>


prop( $id ); $includes = $post->prop( '_is_includes' ); $default_search = ( NULL == $post->id() ? true : false ); ?>

true, 'exclude_from_search' => false, ) ); $post_types2 = get_post_types( '', 'objects' ); if ( isset( $includes['post_type'] ) && !empty( $includes['post_type'] ) && is_array( $includes['post_type'] ) ) { $post_types = array_values( $includes['post_type'] ); } foreach ( $post_types as $key => $post_type ) { if ( !isset( $post_types2[$post_type] ) ) { continue; } $accord_title = $post_types2[$post_type]->labels->name; if ( 'product' == $post_type && !IS_Help::is_woocommerce_inactive() ) { $accord_title .= ' ' . __( '( WooCommerce )', 'add-search-to-menu' ) . ''; } else { if ( 'attachment' == $post_type ) { $accord_title .= ' ' . __( '( Images, Videos, Audios, Docs, PDFs, Files & Attachments )', 'add-search-to-menu' ) . ''; } } ?>

'; if ( 'attachment' != $post_type || !isset( $includes['post_file_type'] ) ) { $posts_found = false; $posts_per_page = ( defined( 'DISABLE_IS_LOAD_ALL' ) || isset( $excludes['post__not_in'] ) ? -1 : 100 ); $posts = get_posts( array( 'post_type' => $post_type, 'posts_per_page' => $posts_per_page, 'orderby' => 'title', 'order' => 'ASC', ) ); $html = '
'; $selected_pt = array(); $selected_pt2 = array(); if ( !empty( $posts ) ) { $posts_found = true; $html .= '
'; $col_title = '' . $post_types2[$post_type]->labels->name . ''; $temp = ''; foreach ( $posts as $post2 ) { $checked = ( isset( $includes['post__in'] ) && in_array( $post2->ID, $includes['post__in'] ) ? $post2->ID : 0 ); if ( $checked ) { array_push( $selected_pt2, $post_type ); } $checked = ( isset( $excludes['post__not_in'] ) && in_array( $post2->ID, $excludes['post__not_in'] ) ? $post2->ID : 0 ); if ( $checked ) { array_push( $selected_pt, $post_type ); } $post_title = ( isset( $post2->post_title ) && '' !== $post2->post_title ? esc_html( $post2->post_title ) : $post2->post_name ); $temp .= ''; } if ( !empty( $selected_pt ) && in_array( $post_type, $selected_pt ) ) { $col_title = '' . $col_title . ''; } $html .= $col_title . '
'; $html .= ''; if ( count( $posts ) >= 100 && !defined( 'DISABLE_IS_LOAD_ALL' ) && !isset( $excludes['post__not_in'] ) ) { $html .= '
' . __( 'Load All', 'add-search-to-menu' ) . '
'; } $html .= '
'; } if ( !$posts_found ) { $html .= '
' . sprintf( __( 'No %s created.', 'add-search-to-menu' ), $post_types2[$post_type]->labels->name ) . ''; } else { $html .= '

'; } $html .= '
'; $checked = 'all'; if ( !empty( $selected_pt ) && in_array( $post_type, $selected_pt ) ) { $checked = 'selected'; } if ( empty( $selected_pt2 ) ) { if ( isset( $includes['post__in'] ) ) { echo '' . sprintf( esc_html__( "The search form is configured in the %s section to only search specific posts of another post type.", 'add-search-to-menu' ), $this->inc_exc_url( 'includes' ) ) . ''; echo '
'; continue; } echo '

'; echo '

'; echo $html; } else { echo '' . sprintf( esc_html__( 'The search form is configured in the %1$s section to only search specific %2$s.', 'add-search-to-menu' ), $this->inc_exc_url( 'includes' ), strtolower( $post_types2[$post_type]->labels->name ) ) . '
'; } } $tax_objs = get_object_taxonomies( $post_type, 'objects' ); if ( !empty( $tax_objs ) ) { $terms_exist = false; $html = '
'; $selected_tax = false; foreach ( $tax_objs as $key => $tax_obj ) { $terms = get_terms( array( 'taxonomy' => $key, 'lang' => '', 'number' => 1000, ) ); if ( !empty( $terms ) && !empty( $tax_obj->labels->name ) ) { $terms_exist = true; $html .= '
'; $col_title = ucwords( str_replace( '-', ' ', str_replace( '_', ' ', esc_html( $tax_obj->labels->name ) ) ) ); if ( isset( $excludes['tax_query'][$key] ) ) { $col_title = '' . $col_title . ''; $selected_tax = true; } $html .= $col_title . '
'; } } if ( $terms_exist ) { $html .= '

'; $html .= '
'; $checked = ( $selected_tax ? 'selected' : 'all' ); echo '

'; echo '

'; echo $html; } } if ( 'product' == $post_type && !IS_Help::is_woocommerce_inactive() ) { echo '
'; $outofstock_disable = ( is_fs()->is_plan_or_trial( 'pro_plus' ) && $this->is_premium_plugin ? '' : ' disabled ' ); if ( '' !== $outofstock_disable ) { echo '
'; } $checked = ( isset( $excludes['woo']['outofstock'] ) && $excludes['woo']['outofstock'] ? 1 : 0 ); echo '

'; echo IS_Admin::pro_link( 'pro_plus' ); if ( '' !== $outofstock_disable ) { echo '
'; } } if ( 'attachment' == $post_type ) { global $wp_version; if ( 4.9 <= $wp_version ) { if ( !isset( $includes['post_file_type'] ) ) { echo '
'; $file_types = get_allowed_mime_types(); if ( !empty( $file_types ) ) { $file_type_disable = ( is_fs()->is_plan_or_trial( 'pro_plus' ) && $this->is_premium_plugin ? '' : ' disabled ' ); if ( '' !== $file_type_disable ) { echo '
'; } ksort( $file_types ); $html = '
'; $html .= ''; $html .= ''; echo IS_Admin::pro_link( 'pro_plus' ); $html .= '

'; if ( isset( $excludes['post_file_type'] ) ) { $html .= __( 'Excluded File Types :', 'add-search-to-menu' ); foreach ( $excludes['post_file_type'] as $post_file_type ) { $html .= '
' . $post_file_type . ''; } } $html .= '
'; $checked = ( isset( $excludes['post_file_type'] ) && !empty( $excludes['post_file_type'] ) ? 'selected' : 'all' ); echo '

'; echo '

'; echo $html; echo ''; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '

'; echo '
'; if ( '' !== $file_type_disable ) { echo '
'; } } } else { echo '
' . sprintf( esc_html__( "This search form is configured in the %s section to search specific attachments.", 'add-search-to-menu' ), $this->inc_exc_url( 'includes' ) ) . '
'; } } else { echo '' . __( 'You are using WordPress version less than 4.9 which does not support searching by MIME type.', 'add-search-to-menu' ) . ''; } } ?>

is_meta_keys(); if ( !empty( $meta_keys ) ) { $html = '
'; $selected_meta = false; $custom_field_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $html .= ''; $html .= ''; $html .= IS_Admin::pro_link(); $html .= ''; $html .= '
'; $checked = ( $selected_meta ? 'selected' : 'all' ); echo ''; echo $html; } ?>

'; if ( !isset( $includes['author'] ) ) { $author_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $args = array( 'fields' => array('ID', 'display_name'), 'orderby' => 'post_count', 'role__not_in' => 'subscriber', 'order' => 'DESC', ); if ( version_compare( $GLOBALS['wp_version'], '5.9', '<' ) ) { $args['who'] = 'authors'; } else { $args['capability'] = ['edit_posts']; } $authors = get_users( $args ); if ( !empty( $authors ) ) { if ( '' !== $author_disable ) { echo IS_Admin::pro_link(); } echo '
'; echo '
'; if ( !isset( $excludes['author'] ) || empty( $excludes['author'] ) ) { echo '' . __( 'Search all author posts', 'add-search-to-menu' ) . ''; } else { echo ''; foreach ( $excludes['author'] as $author2 ) { $display_name = get_userdata( $author2 ); if ( $display_name ) { echo ' ' . esc_html( $display_name->display_name ) . ''; } } echo ''; } echo '
'; echo '
'; foreach ( $authors as $author ) { $post_count = count_user_posts( $author->ID ); // Move on if user has not published a post (yet). if ( !$post_count ) { continue; } $checked = ( isset( $excludes['author'][esc_attr( $author->ID )] ) ? $excludes['author'][esc_attr( $author->ID )] : 0 ); echo ''; } echo '
'; } } else { echo '
' . sprintf( esc_html__( "This search form is configured in the %s section to search posts created by specific authors.", 'add-search-to-menu' ), $this->inc_exc_url( 'includes' ) ) . '
'; } ?>

'; $checked = ( isset( $excludes['ignore_sticky_posts'] ) && $excludes['ignore_sticky_posts'] ? 1 : 0 ); echo ''; ?>
prop( $id ); ?>

'; echo ''; ?>

'; $orderby_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); echo ''; echo IS_Admin::pro_link(); ?>

'; $color = ( isset( $settings['highlight_color'] ) ? $settings['highlight_color'] : '#FFFFB9' ); echo '

'; echo '
' . esc_html__( "Select text highlight color", 'add-search-to-menu' ) . '
'; ?>

'; $checked = ( isset( $settings['term_rel'] ) && "OR" === $settings['term_rel'] ? "OR" : "AND" ); echo '

'; echo '

'; ?>

'; $checked = ( isset( $settings['fuzzy_match'] ) ? $settings['fuzzy_match'] : '2' ); echo '

'; echo '

'; echo '

'; echo $this->get_conflicts_info( 'fuzzy_match' ); ?>

' . __( 'For Example: If you search "doing" then it also searches base word of "doing" that is "do" in the specified post types.', 'add-search-to-menu' ) . '

'; $content .= '

' . __( 'Not recommended to use when Fuzzy Matching option is set to Whole.', 'add-search-to-menu' ) . '

'; IS_Help::help_info( $content ); echo '
'; $stem_disable = ( is_fs()->is_plan_or_trial( 'pro_plus' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $checked = ( isset( $settings['keyword_stem'] ) && $settings['keyword_stem'] ? 1 : 0 ); echo '

'; echo IS_Admin::pro_link( 'pro_plus' ); ?>

'; $checked = ( isset( $settings['search_engine'] ) && "index" === $settings['search_engine'] ? "index" : "wp" ); echo '

'; echo '

'; ?>

index_conflicts ) ) { foreach ( $this->index_conflicts as $option => $conflicts ) { echo $this->get_conflicts_info( $option ); } } ?>

'; $checked = ( isset( $settings['demo'] ) && $settings['demo'] ? 1 : 0 ); echo '

'; $checked = ( isset( $settings['disable'] ) && $settings['disable'] ? 1 : 0 ); echo '

'; echo '

'; $content = __( 'Select whether to display an error when user perform search without any search word.', 'add-search-to-menu' ); IS_Help::help_info( $content ); $checked = ( isset( $settings['empty_search'] ) && $settings['empty_search'] ? 1 : 0 ); echo '

'; ?>
search_form->group_prop( '_is_settings', 'search_engine' ); $conflict = null; if ( 'index' == $search_engine && !empty( $this->index_conflicts[$option] ) ) { if ( !empty( $post_type ) ) { if ( !empty( $this->index_conflicts[$option][$post_type] ) ) { $conflict = $this->index_conflicts[$option][$post_type]; } } else { if ( is_array( $this->index_conflicts[$option] ) ) { $conflict = implode( '
', $this->index_conflicts[$option] ); } else { $conflict = $this->index_conflicts[$option]; } } if ( $conflict ) { return sprintf( '%s
', wp_kses_post( $conflict ) ); } } } /** * Get index settings conflicts with this search form. * * @since 5.0 * @return array { * string $key The option key * string $notice The html escaped notice to show. * } */ public function get_index_conflicts() { $conflicts = []; $index_opt = IS_Index_Options::getInstance(); if ( IS_Index_Model::is_index_empty() ) { $conflicts['index'] = esc_html__( 'The Index should be created to use this option in the Index ', 'add-search-to-menu' ) . $index_opt->get_index_settings_link(); } $props = $this->search_form->get_properties(); foreach ( $props as $key => $group ) { if ( !empty( $group ) && is_array( $group ) ) { foreach ( $group as $prop => $val ) { $diff = array(); switch ( $prop ) { case 'post_type': $diff = array_diff( $val, $index_opt->get_post_types() ); if ( !empty( $diff ) ) { $conflicts[$prop] = sprintf( esc_html( _n( 'The %s post type is not selected in Index', 'The %s post types are not selected in Index', count( $diff ), 'add-search-to-menu' ) ), implode( ', ', $diff ) ) . $index_opt->get_index_settings_link( 'post_types' ); } break; case 'custom_field': $indexed_meta_fields = $index_opt->get_meta_keys(); $meta_keys = $this->is_meta_keys(); $selected = array_intersect( $meta_keys, $val ); $diff = array_diff( $selected, $indexed_meta_fields ); if ( !empty( $diff ) ) { $conflicts[$prop] = sprintf( esc_html( _n( 'The %s meta field is not selected in Index', 'The %s meta fields are not selected in Index', count( $diff ), 'add-search-to-menu' ) ), implode( ', ', $diff ) ) . $index_opt->get_index_settings_link( 'meta_fields' ); } break; case 'search_title': if ( $val && !$index_opt->index_title ) { $conflicts[$prop] = esc_html__( 'The post title is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'search_content': if ( $val && !$index_opt->index_content ) { $conflicts[$prop] = esc_html__( 'The post content is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'search_excerpt': if ( $val && !$index_opt->index_excerpt ) { $conflicts[$prop] = esc_html__( 'The post excerpt is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'search_tax_title': if ( $val && !$index_opt->index_tax_title ) { $conflicts[$prop] = esc_html__( 'The taxonomy title is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'search_tax_desp': if ( $val && !$index_opt->index_tax_desp ) { $conflicts[$prop] = esc_html__( 'The taxonomy description is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'search_author': if ( $val && !$index_opt->index_author_info ) { $conflicts[$prop] = esc_html__( 'The Author info is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'search_comment': if ( $val && !$index_opt->index_comments ) { $conflicts[$prop] = esc_html__( 'The comments are not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'woo': if ( !empty( $val['sku'] ) && !$index_opt->index_product_sku ) { $conflicts[$prop]['sku'] = esc_html__( 'The product SKU is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } if ( !empty( $val['variation'] ) && !$index_opt->index_product_variation ) { $conflicts[$prop]['variation'] = esc_html__( 'The product variation is not selected in Index', 'add-search-to-menu' ) . $index_opt->get_index_settings_link( 'extra' ); } break; case 'fuzzy_match': if ( 3 == $val && $this->search_form->is_index_search() ) { $link = sprintf( ' %s', 'is-option-link', esc_html__( 'Anywhere Fuzzy Matching', 'add-search-to-menu' ) ); $link1 = sprintf( ' %s', 'is-option-link', esc_html__( 'Inverted Index Search Engine', 'add-search-to-menu' ) ); $conflicts[$prop] = sprintf( '%s %s %s %s', esc_html__( 'It is not recommended to use the', 'add-search-to-menu' ), $link, esc_html__( 'option along with', 'add-search-to-menu' ), $link1 ); } break; } } } } return $conflicts; } }