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 '
' ;
echo sprintf( '', esc_attr( $tab ) ) ;
$this->notice( $tab, $tab . '_panel' );
$callback = $tab . '_panel';
$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 );
$excludes = $post->prop( '_is_excludes' );
$settings = $post->prop( '_is_settings' );
?>
' ;
if ( class_exists( 'WooCommerce' ) ) {
$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 ) ) {
$ind_status = false;
$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 );
if ( $checked ) {
$ind_status = true;
}
echo '
' ;
echo ' ' . esc_html__( "Search in WooCommerce products SKU.", 'ivory-search' ) . '
' ;
$checked = ( isset( $includes['woo']['variation'] ) && $includes['woo']['variation'] ? 1 : 0 );
if ( !$ind_status && $checked ) {
$ind_status = true;
}
echo '
' ;
echo ' ' . esc_html__( "Search in WooCommerce products variation.", 'ivory-search' ) . ' ' ;
echo IS_Admin::pro_link( 'pro_plus' ) . '
' ;
if ( $ind_status ) {
echo '
' ;
}
} else {
_e( 'WooCommerce product post type is not included in search.', 'ivory-search' );
}
} else {
_e( 'Activate WooCommerce plugin to use this option.', '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 '
ID, $checked, false ) . '/>' ;
echo ' ' . ucfirst( esc_html( $author->display_name ) ) . '
' ;
}
}
} else {
echo '
' . esc_html__( "Search has been already limited by excluding specific authors posts in the Excludes section.", 'ivory-search' ) . ' ' ;
}
if ( '' !== $author_disable ) {
echo '
' ;
}
$checked = ( isset( $includes['search_author'] ) && $includes['search_author'] ? 1 : 0 );
echo '
' ;
echo ' ' . esc_html__( "Search in author Display name and display the posts created by that author.", 'ivory-search' ) . '
' ;
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 '
' ;
echo ' ' . ucwords( str_replace( '-', ' ', esc_html( $post_status ) ) ) . '
' ;
}
}
if ( isset( $includes['post_status'] ) && !empty($includes['post_status']) ) {
echo '
' ;
}
} else {
echo '
' . esc_html__( "Search has been already limited by excluding specific posts statuses from search in the Excludes section.", 'ivory-search' ) . ' ' ;
}
?>
' ;
$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 ' ' . esc_html( __( 'The search operator to compare comments count.', 'ivory-search' ) ) . ' ' ;
echo ' ' . esc_html( __( 'The amount of comments your posts has to have.', 'ivory-search' ) ) . ' ' ;
if ( '' !== $comment_count_disable ) {
echo '
' ;
}
$checked = ( isset( $includes['search_comment'] ) && $includes['search_comment'] ? 1 : 0 );
if ( !$ind_status && $checked ) {
$ind_status = true;
}
echo '
' ;
echo ' ' . esc_html__( "Search in approved comments content.", 'ivory-search' ) . '
' ;
if ( $ind_status ) {
echo '' ;
}
?>
' ;
$range = array( 'after', 'before' );
$ind_status = false;
foreach ( $range as $value ) {
echo '
' . ucfirst( $value ) . '
' ;
echo '
' ;
$checked = ( isset( $includes['date_query'][$value]['day'] ) ? $includes['date_query'][$value]['day'] : 'day' );
if ( 'day' !== $checked ) {
$ind_status = true;
}
echo '' . esc_html( __( 'Day', 'ivory-search' ) ) . ' ' ;
for ( $d = 1 ; $d <= 31 ; $d++ ) {
echo '' . $d . ' ' ;
}
echo ' ' ;
echo '
' ;
$checked = ( isset( $includes['date_query'][$value]['month'] ) ? $includes['date_query'][$value]['month'] : 'month' );
if ( !$ind_status && 'month' !== $checked ) {
$ind_status = true;
}
echo '' . esc_html( __( 'Month', 'ivory-search' ) ) . ' ' ;
for ( $m = 1 ; $m <= 12 ; $m++ ) {
echo '' . date( 'F', mktime(
0,
0,
0,
$m,
1
) ) . ' ' ;
}
echo ' ' ;
echo '
' ;
$checked = ( isset( $includes['date_query'][$value]['year'] ) ? $includes['date_query'][$value]['year'] : 'year' );
if ( !$ind_status && 'year' !== $checked ) {
$ind_status = true;
}
echo '' . esc_html( __( 'Year', 'ivory-search' ) ) . ' ' ;
for ( $y = date( "Y" ) ; $y >= 1995 ; $y-- ) {
echo '' . $y . ' ' ;
}
echo ' ' ;
}
if ( $ind_status ) {
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 '' ;
foreach ( $file_types as $key => $file_type ) {
$checked = ( isset( $includes['post_file_type'] ) && in_array( $file_type, $includes['post_file_type'] ) ? $file_type : 0 );
echo '' . esc_html( $key ) . ' ' ;
}
echo ' ' ;
echo IS_Admin::pro_link( 'pro_plus' ) ;
echo '' . esc_html__( "Press CTRL key & Left Mouse button to select multiple terms or deselect them.", 'ivory-search' ) . ' ' ;
}
} else {
echo '' . esc_html__( "Search has been already limited by excluding specific File type in the Excludes section.", 'ivory-search' ) . ' ' ;
}
} 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' );
?>
' ;
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 '
ID, $checked, false ) . '/>' ;
echo ' ' . ucfirst( esc_html( $author->display_name ) ) . '
' ;
}
if ( isset( $excludes['author'] ) && !empty($excludes['author']) ) {
echo '
' ;
}
}
} else {
echo '
' . esc_html__( "Search has been already limited to posts created by specific authors in the Includes section.", 'ivory-search' ) . ' ' ;
}
?>
' ;
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 '
' ;
echo ' ' . ucwords( str_replace( '-', ' ', esc_html( $post_status ) ) ) . '
' ;
}
if ( '' !== $post_status_disable ) {
echo '
' ;
}
}
} else {
echo '
' . esc_html__( "Search has been already limited to posts statuses set in the Includes section.", 'ivory-search' ) . ' ' ;
}
$checked = ( isset( $excludes['ignore_sticky_posts'] ) && $excludes['ignore_sticky_posts'] ? 1 : 0 );
if ( isset( $excludes['post_status'] ) && !empty($excludes['post_status']) || $checked ) {
echo '
' ;
}
echo '
' ;
echo ' ' . esc_html__( "Exclude sticky posts from search.", 'ivory-search' ) . '
' ;
?>
' ;
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 '' ;
foreach ( $file_types as $key => $file_type ) {
$checked = ( isset( $excludes['post_file_type'] ) && in_array( $file_type, $excludes['post_file_type'] ) ? $file_type : 0 );
echo '' . esc_html( $key ) . ' ' ;
}
echo ' ' ;
echo IS_Admin::pro_link( 'pro_plus' ) ;
echo '' . esc_html__( "Press CTRL key & Left Mouse button to select multiple terms or deselect them.", 'ivory-search' ) . ' ' ;
}
} else {
echo '' . esc_html__( "Search has been already limited to specific File type set in the Includes section.", 'ivory-search' ) . ' ' ;
}
} 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 );
?>