Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $path = dirname(dirname(dirname(dirname(__FILE__))));
- require_once($path.'/wp-config.php');
- function autocompleter()
- {
- $results = (get_option('autocompleter_results')!= false)?get_option('autocompleter_results'):1;
- $wpdb =& $GLOBALS['wpdb'];
- $search = $wpdb->escape($_GET['q']);
- if(strlen($search)){
- switch($results){
- case 7: //Go GeoTheme
- $words1 = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
- if($_SESSION['multi_city']){
- $multi_city_id = mysql_real_escape_string ($_SESSION['multi_city']);
- $words2 = $wpdb->get_results("SELECT DISTINCT post_title as name FROM $wpdb->posts join $wpdb->postmeta on $wpdb->postmeta.post_id=$wpdb->posts.ID where $wpdb->posts.post_status='publish' and $wpdb->posts.post_type in ('place','event') AND ($wpdb->posts.ID in (select $wpdb->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='post_city_id' and ($wpdb->postmeta.meta_value in ($multi_city_id) )))and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
- }else{
- $words2 = $wpdb->get_results("SELECT post_title as name FROM $wpdb->posts where post_status='publish' and post_type in ('place','event') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
- }
- $words = array_merge((array)$words1 ,(array)$words2 );
- break;
- }
- foreach ($words as $word){
- if($results > 3)
- echo $word->name."|".get_permalink($word->ID)."\n";
- else
- echo $word->name."\n";
- }
- }
- }
- if($_GET['q']){
- autocompleter();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement