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( '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' ) ? '' : ' disabled ';
$checked = ( isset( $includes['woo']['sku'] ) && $includes['woo']['sku'] ) ? 1 : 0;
echo '
';
echo ' ' . esc_html__( "Search in WooCommerce products SKU.", 'ivory-search' ) . ' ';
echo IS_Admin::pro_link( 'pro_plus' ) . '
';
} else {
_e( 'WooCommerce product post type is not included in search.', 'ivory-search' );
}
?>
';
if ( ! isset( $excludes['author'] ) ) {
$author_disable = is_fs()->is_plan_or_trial( 'pro' ) ? '' : ' 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( $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 ( ! isset( $excludes['post_status'] ) ) {
$post_statuses = get_post_stati();
$post_status_disable = is_fs()->is_plan_or_trial( 'pro' ) ? '' : ' 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 ) ) ) . '
';
}
}
} 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' ) ? '' : ' disabled ';
if ( '' !== $comment_count_disable ) {
echo '
' . IS_Admin::pro_link();
}
echo '';
$checked = isset( $includes['comment_count']['compare'] ) ? htmlspecialchars_decode( $includes['comment_count']['compare'] ) : '=';
$compare = array( '=', '!=', '>', '>=', '<', '<=' );
foreach ( $compare as $d ) {
echo '' . esc_html( $d ) . ' ';
}
echo ' ' . esc_html( __( 'The search operator to compare comments count.', 'ivory-search' ) ) . ' ';
echo '';
$checked = isset( $includes['comment_count']['value'] ) ? $includes['comment_count']['value'] : 'na';
echo '' . esc_html( __( 'NA', 'ivory-search' ) ) . ' ';
for ( $d = 0; $d <= 999; $d++ ) {
echo '' . $d . ' ';
}
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;
echo '
';
echo ' ' . esc_html__( "Search in approved comments content.", 'ivory-search' ) . '
';
?>
';
$range = array( 'after', 'before' );
foreach ( $range as $value ) {
echo '
' . ucfirst( $value ) . '
';
echo '
';
$checked = isset( $includes['date_query'][$value]['day'] ) ? $includes['date_query'][$value]['day'] : 'day';
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';
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';
echo '' . esc_html( __( 'Year', 'ivory-search' ) ) . ' ';
for ( $y = date("Y"); $y >= 1995; $y-- ) {
echo '' . $y . ' ';
}
echo ' ';
}
?>
';
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' ) ? '' : ' 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 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' ) . ' ';
}
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 . ' ';
}
}
?>
prop( $id );
$includes = $post->prop( '_is_includes' );
?>
';
if ( ! isset( $includes['author'] ) ) {
$author_disable = is_fs()->is_plan_or_trial( 'pro' ) ? '' : ' 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 ) ) . '
';
}
}
} 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' ) ? '' : ' 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;
echo '
';
echo ' ' . esc_html__( "Exclude sticky posts from search.", 'ivory-search' ) . '
';
?>
';
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' ) ? '' : ' 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 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' ) . ' ';
}
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 . ' ';
}
}
?>
prop( $id );
?>