'; // The actual fields for data entry echo '
'; echo 'ID,'ShowInSearchlight',true) == "true"){ echo ' checked="checked" '; } echo '/>'; echo ' '; echo '
'; // The actual fields for data entry echo ''; echo 'ID,'NotShowInSearchlight',true) == "true"){ echo ' checked="checked" '; } echo '/>'; echo ' '; echo '
'; echo ''; echo 'Clear options'; echo '
'; } function itsas_onAction_save_post($post_id){ if ( !wp_verify_nonce( $_POST['itsas_showin_searchlight'], plugin_basename(__FILE__) )) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want // to do anything if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) { return $post_id; } // Check permissions if ( 'post' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } /* version 1.4 if ($_POST['chkShowInSearchlight'] == 'itsas_searchlight_showin'){ update_post_meta($post_id,'ShowInSearchlight','true'); }else { delete_post_meta($post_id,'ShowInSearchlight','true'); } */ if ($_POST['chkShowInSearchlight'] == 'itsas_searchlight_showin'){ update_post_meta($post_id,'ShowInSearchlight','true'); delete_post_meta($post_id,'NotShowInSearchlight','true'); }else if ($_POST['chkShowInSearchlight'] == 'itsas_searchlight_notshowin') { update_post_meta($post_id,'NotShowInSearchlight','true'); delete_post_meta($post_id,'ShowInSearchlight','true'); }else{ delete_post_meta($post_id,'ShowInSearchlight','true'); delete_post_meta($post_id,'NotShowInSearchlight','true'); } return $post_id; //return $mydata; } add_action('save_post', 'itsas_onAction_save_post'); function itsas_sqlWhere($search_key){ $sql_where = ""; if ($search_key != ""){ $sql_where = "post_status = 'publish' "; $search_keys = explode(" ",$search_key); $count = count($search_keys); if ($count < 1){ return ""; }else if ($count == 1){ if ($sql_where != "") $sql_where .= " AND "; $sql_where .= " (post_title LIKE '%$search_keys[0]%' "; $sql_where .= " OR post_content LIKE '%$search_keys[0]%')"; }else if ($count > 1){ if ($sql_where != "") $sql_where .= " AND "; $sql_where .= " (post_title LIKE '%$search_keys[0]%' "; $sql_where .= " OR post_content LIKE '%$search_keys[0]%')"; for($i = 1; $i < $count; $i++){ $sql_where .= " AND (post_title LIKE '%$search_keys[$i]%' OR post_content LIKE '%$search_keys[$i]%') "; } } } return $sql_where; } function itsas_result_count($search_key){ global $wpdb; $count = 0; $sql_base = "SELECT COUNT(*) FROM {$wpdb->prefix}posts "; $sql_where = itsas_sqlWhere($search_key); if ($sql_where != ""){ $sql_where = " WHERE " . $sql_where; $sql = $sql_base.$sql_where; //echo $sql; $count = $wpdb->get_var($sql); }else{ $count = 0; } return $count; } function itsas_result($search_key, $post_type, $beginIx = 0,$endIx = 10){ global $wpdb; $sql_base = "SELECT * FROM {$wpdb->prefix}posts "; $sql_where = itsas_sqlWhere($search_key); if ($sql_where != ""){ $sql_where = " WHERE post_type LIKE '$post_type' AND " . $sql_where; $sql = $sql_base.$sql_where." ORDER BY post_date desc LIMIT $beginIx,$endIx"; $results = $wpdb->get_results($sql,ARRAY_A); }else{ $results = null; } return $results; } function itsas_search($search_key){ global $wpdb; $isShowThumbnail = false; if (get_option('itsas_display_thumbnails') === '1' && function_exists('current_theme_supports') && current_theme_supports( 'post-thumbnails' ) ){ $isShowThumbnail = true; } $pageCount = get_option('itsas_displayed_page_count'); $postCount = get_option('itsas_displayed_post_count'); echo ' '; $count = itsas_result_count($search_key); $showInPages = itsas_get_show_in_pages();//print_r($showInPages); $showInPosts = itsas_get_show_in_posts(); $showInPostsWithoutSticky = array(); $stickyPosts = itsas_get_sticky_posts(); $notShowInPages = itsas_get_not_show_in_pages(); $notShowInPosts = itsas_get_not_show_in_posts(); foreach($stickyPosts as $key => $value){ if ($notShowInPosts[$key]){ unset($stickyPosts[$key]); } } if ($count > 0 || count($showInPages) > 0 || count($showInPosts) > 0 || count($stickyPosts) > 0 ){ echo '