search_form = $search_form; } function is_name( $string ) { return preg_match( '/^[A-Za-z][-A-Za-z0-9_:.]*$/', $string ); } public function add_panel( $id, $title, $callback ) { if ( $this->is_name( $id ) ) { $this->panels[$id] = array( 'title' => $title, 'callback' => $callback, ); } } public function display() { if ( empty($this->panels) ) { return; } echo '' ; foreach ( $this->panels as $id => $panel ) { echo sprintf( '
', esc_attr( $id ) ) ; $this->notice( $id, $panel ); $callback = $panel['callback']; $this->{$callback}( $this->search_form ); 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( $post_types ) { global $wpdb ; $post_types = implode( "', '", $post_types ); $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 '\\_%' AND post_type IN ( '{$post_types}' ) 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 includes_panel( $post ) { $id = '_is_includes'; $includes = $post->prop( $id ); $settings = $post->prop( '_is_settings' ); $excludes = $post->prop( '_is_excludes' ); ?>

' ; $args = array( 'public' => true, ); if ( isset( $settings['exclude_from_search'] ) ) { $args = array( 'public' => true, 'exclude_from_search' => false, ); } $posts = get_post_types( $args ); if ( !empty($posts) ) { $ind_status = false; foreach ( $posts as $key => $post_type ) { $checked = ( isset( $includes['post_type'][esc_attr( $key )] ) ? $includes['post_type'][esc_attr( $key )] : 0 ); if ( !$ind_status && $checked && 'post' !== $key && 'page' !== $key ) { $ind_status = true; } echo '
' ; echo '
' ; } $checked = ( isset( $includes['search_title'] ) && $includes['search_title'] ? 1 : 0 ); if ( !$ind_status && !$checked ) { $ind_status = true; } echo '

' ; $checked = ( isset( $includes['search_content'] ) && $includes['search_content'] ? 1 : 0 ); if ( !$ind_status && !$checked ) { $ind_status = true; } echo '

' ; $checked = ( isset( $includes['search_excerpt'] ) && $includes['search_excerpt'] ? 1 : 0 ); if ( !$ind_status && !$checked ) { $ind_status = true; } echo '

' ; echo '
' ; if ( $ind_status ) { echo '' ; } } else { _e( 'No post types registered on your site.', 'ivory-search' ); } ?>


' . __( 'Terms selected here will restrict the search to posts that have the selected terms.', 'ivory-search' ); $content .= '
' . __( 'Taxonomy terms selected display in BOLD', 'ivory-search' ); IS_Help::help_info( $content ); echo '
' ; $args = array( 'post', 'page' ); if ( isset( $includes['post_type'] ) && !empty($includes['post_type']) && is_array( $includes['post_type'] ) ) { $args = array_values( $includes['post_type'] ); } $tax_objs = get_object_taxonomies( $args, 'objects' ); if ( !empty($tax_objs) ) { foreach ( $tax_objs as $key => $tax_obj ) { $terms = get_terms( array( 'taxonomy' => $key, 'hide_empty' => false, ) ); if ( !empty($terms) ) { echo '
' ; $col_title = ucwords( str_replace( '-', ' ', str_replace( '_', ' ', esc_html( $key ) ) ) ); if ( isset( $includes['tax_query'][$key] ) ) { $col_title = '' . $col_title . ''; } echo $col_title . '
' ; echo '
' ; } } echo '
' ; $ind_status = false; if ( isset( $includes['tax_query'] ) && !empty($includes['tax_query']) ) { $ind_status = true; } $checked = ( isset( $includes['tax_rel'] ) && "OR" == $includes['tax_rel'] ? "OR" : "AND" ); if ( !$ind_status && "AND" !== $checked ) { $ind_status = true; } echo '

' ; echo '

' ; $checked = ( isset( $includes['search_tax_title'] ) && $includes['search_tax_title'] ? 1 : 0 ); if ( !$ind_status && $checked ) { $ind_status = true; } echo '

' ; $checked = ( isset( $includes['search_tax_desp'] ) && $includes['search_tax_desp'] ? 1 : 0 ); if ( !$ind_status && $checked ) { $ind_status = true; } echo '

' ; if ( $ind_status ) { echo '' ; } } else { _e( 'No taxonomies registered for slected post types.', 'ivory-search' ); } ?>

' ; $args = array( 'post', 'page' ); if ( isset( $includes['post_type'] ) && !empty($includes['post_type']) && is_array( $includes['post_type'] ) ) { $args = array_values( $includes['post_type'] ); } $meta_keys = $this->is_meta_keys( $args ); if ( !empty($meta_keys) ) { echo '' ; echo '' ; echo '
' ; } if ( isset( $includes['custom_field'] ) ) { echo '
' . __( 'Selected Custom Fields :', 'ivory-search' ) ; foreach ( $includes['custom_field'] as $custom_field ) { echo '
' . $custom_field . '' ; } echo '' ; } ?>

' ; $args = array( 'post', 'page' ); if ( isset( $includes['post_type'] ) && !empty($includes['post_type']) && is_array( $includes['post_type'] ) ) { $args = array_values( $includes['post_type'] ); } if ( in_array( 'product', $args ) ) { $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 '

' ; echo IS_Admin::pro_link( 'pro_plus' ) . '

' ; if ( $checked ) { echo '' ; } } else { _e( 'WooCommerce product post type is not included in search.', 'ivory-search' ); } ?>

' ; $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' ), 'orderby' => 'post_count', 'order' => 'DESC', 'who' => 'authors', ) ); if ( !empty($authors) ) { if ( '' !== $author_disable ) { echo '
' . IS_Admin::pro_link() ; } 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 '
' ; } } } else { echo '' ; } if ( '' !== $author_disable ) { echo '
' ; } $checked = ( isset( $includes['search_author'] ) && $includes['search_author'] ? 1 : 0 ); echo '

' ; if ( $checked || isset( $includes['author'] ) && !empty($includes['author']) ) { echo '' ; } ?>

' ; if ( !isset( $excludes['post_status'] ) ) { $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() ; } foreach ( $post_statuses as $key => $post_status ) { $checked = ( isset( $includes['post_status'][esc_attr( $key )] ) ? $includes['post_status'][esc_attr( $key )] : 0 ); echo '
' ; } } if ( isset( $includes['post_status'] ) && !empty($includes['post_status']) ) { echo '' ; } } else { echo '' ; } ?>

' ; $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 ); if ( !$ind_status && $checked ) { $ind_status = true; } echo '

' ; if ( $ind_status ) { echo '' ; } ?>

' ; $range = array( 'after', 'before' ); $ind_status = false; foreach ( $range as $value ) { echo '
' . ucfirst( $value ) . '
' ; echo '' ; echo '' ; echo '
' ; } if ( $ind_status ) { echo '' ; } ?>

' ; $checked = ( isset( $includes['has_password'] ) ? $includes['has_password'] : 'null' ); echo '

' ; echo '

' ; echo '

' ; if ( 'null' !== $checked ) { echo '' ; } ?>

' ; if ( isset( $includes['post_type'] ) && in_array( 'attachment', $includes['post_type'] ) ) { if ( !isset( $excludes['post_file_type'] ) ) { $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 ' ); ksort( $file_types ); echo '' ; echo '' ; echo IS_Admin::pro_link( 'pro_plus' ) ; echo '

' ; } } else { echo '' ; } } else { _e( 'Attachment post type is not included in search.', 'ivory-search' ); } if ( isset( $includes['post_file_type'] ) ) { echo '
' . __( 'Selected File Types :', 'ivory-search' ) ; foreach ( $includes['post_file_type'] as $post_file_type ) { echo '
' . $post_file_type . '' ; } echo '' ; } ?>
prop( $id ); $includes = $post->prop( '_is_includes' ); ?>

' . __( 'Select the posts you wish to exclude from the search.', 'ivory-search' ); $content .= '
' . __( 'Selected post types display in BOLD.', 'ivory-search' ); IS_Help::help_info( $content ); echo '
' ; $post_types = array( 'post', 'page' ); 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 $post_type ) { $posts = get_posts( array( 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ) ); if ( !empty($posts) ) { $html = '
'; $col_title = ucwords( $post_type ); $temp = ''; $selected_pt = array(); foreach ( $posts as $post2 ) { $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 .= '
'; echo $html ; if ( !empty($selected_pt) ) { echo '' ; } } } echo '
' ; ?>

' . __( 'Exclude posts from search results that have specific terms', 'ivory-search' ); $content .= '
' . __( 'Selected terms taxonomy title display in BOLD.', 'ivory-search' ); IS_Help::help_info( $content ); echo '
' ; $tax_objs = get_object_taxonomies( $post_types, 'objects' ); if ( !empty($tax_objs) ) { foreach ( $tax_objs as $key => $tax_obj ) { $terms = get_terms( array( 'taxonomy' => $key, 'hide_empty' => false, ) ); if ( !empty($terms) ) { echo '
' ; $col_title = ucwords( str_replace( '-', ' ', str_replace( '_', ' ', esc_html( $key ) ) ) ); if ( isset( $excludes['tax_query'][$key] ) ) { $col_title = '' . $col_title . ''; } echo $col_title . '
' ; } } echo '
' ; if ( isset( $excludes['tax_query'] ) && !empty($excludes['tax_query']) ) { echo '' ; } } else { _e( 'No taxonomies registered for slected post types.', 'ivory-search' ); } ?>

' ; $args = array( 'post', 'page' ); if ( isset( $excludes['post_type'] ) && !empty($excludes['post_type']) && is_array( $excludes['post_type'] ) ) { $args = array_values( $excludes['post_type'] ); } $meta_keys = $this->is_meta_keys( $args ); if ( !empty($meta_keys) ) { $custom_field_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); echo '' ; echo '' ; echo IS_Admin::pro_link() ; echo '

' ; } if ( isset( $excludes['custom_field'] ) ) { echo '
' . __( 'Excluded Custom Fields :', 'ivory-search' ) ; foreach ( $excludes['custom_field'] as $custom_field ) { echo '
' . $custom_field . '' ; } echo '' ; } ?>

' ; $args = array( 'post', 'page' ); if ( isset( $includes['post_type'] ) && !empty($includes['post_type']) && is_array( $includes['post_type'] ) ) { $args = array_values( $includes['post_type'] ); } if ( in_array( 'product', $args ) ) { $outofstock_disable = ( is_fs()->is_plan_or_trial( 'pro_plus' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $checked = ( isset( $excludes['woo']['outofstock'] ) && $excludes['woo']['outofstock'] ? 1 : 0 ); if ( $checked ) { echo '' ; } echo '

' ; echo IS_Admin::pro_link( 'pro_plus' ) ; } else { _e( 'WooCommerce product post type is not included in search.', 'ivory-search' ); } ?>

' ; if ( !isset( $includes['author'] ) ) { $author_disable = ( is_fs()->is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $authors = get_users( array( 'fields' => array( 'ID', 'display_name' ), 'orderby' => 'post_count', 'order' => 'DESC', 'who' => 'authors', ) ); if ( !empty($authors) ) { if ( '' !== $author_disable ) { echo IS_Admin::pro_link() ; } 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 '
' ; } if ( isset( $excludes['author'] ) && !empty($excludes['author']) ) { echo '' ; } } } else { echo '' ; } ?>

' ; if ( !isset( $includes['post_status'] ) ) { $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() ; } foreach ( $post_statuses as $key => $post_status ) { $checked = ( isset( $excludes['post_status'][esc_attr( $key )] ) ? $excludes['post_status'][esc_attr( $key )] : 0 ); echo '
' ; } if ( '' !== $post_status_disable ) { echo '
' ; } } } else { echo '' ; } $checked = ( isset( $excludes['ignore_sticky_posts'] ) && $excludes['ignore_sticky_posts'] ? 1 : 0 ); if ( isset( $excludes['post_status'] ) && !empty($excludes['post_status']) || $checked ) { echo '' ; } echo '

' ; ?>

' ; if ( isset( $includes['post_type'] ) && in_array( 'attachment', $includes['post_type'] ) ) { if ( !isset( $includes['post_file_type'] ) ) { $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 ' ); ksort( $file_types ); echo '' ; echo '' ; echo IS_Admin::pro_link( 'pro_plus' ) ; echo '

' ; } } else { echo '' ; } } else { _e( 'Attachment post type is not included in search.', 'ivory-search' ); } if ( isset( $excludes['post_file_type'] ) ) { echo '
' . __( 'Excluded File Types :', 'ivory-search' ) ; foreach ( $excludes['post_file_type'] as $post_file_type ) { echo '
' . $post_file_type . '' ; } echo '' ; } ?>
prop( $id ); ?>

' ; $default_per_page = get_option( 'posts_per_page', 10 ); $checked = ( isset( $settings['posts_per_page'] ) ? $settings['posts_per_page'] : $default_per_page ); for ( $d = 1 ; $d <= 1000 ; $d++ ) { echo '' ; } echo '' ; if ( $checked !== $default_per_page ) { echo '' ; } ?>

is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); echo '' ; echo IS_Admin::pro_link() ; if ( $ind_status ) { echo '' ; } ?>

' ; $color = ( isset( $settings['highlight_color'] ) ? $settings['highlight_color'] : '#FFFFB9' ); if ( !$ind_status && '#FFFFB9' !== $color ) { $ind_status = true; } echo '

' ; echo '' ; if ( $ind_status ) { echo '' ; } ?>

is_plan_or_trial( 'pro' ) && $this->is_premium_plugin ? '' : ' disabled ' ); $checked = ( isset( $settings['term_rel'] ) && "OR" === $settings['term_rel'] ? "OR" : "AND" ); echo '

' . IS_Admin::pro_link() . '

' ; echo '

' ; if ( "AND" !== $checked ) { echo '' ; } ?>

' ; echo '

' ; if ( "2" !== $checked ) { echo '' ; } ?>

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

'; $content .= '

' . __( 'If you want to search whole exact searched term then do not use this options and in this case it is not recommended to use when Fuzzy Matching option is set to Whole.', 'ivory-search' ) . '

'; 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' ) ; echo '
' ; if ( $checked ) { echo '' ; } ?>

' ; if ( $checked ) { echo '' ; } ?>

' ; if ( $checked ) { echo '' ; } ?>

' ; if ( $checked ) { echo '' ; } ?>

' ; if ( $checked ) { echo '' ; } ?>

' ; if ( $checked ) { echo '' ; } ?>