Mark Ghosh. Configure... Author: Ajay D'Souza Author URI: http://ajaydsouza.com/ */ if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?"); define('ALD_crp_DIR', dirname(__FILE__)); define('CRP_LOCAL_NAME', 'crp'); // Pre-2.6 compatibility if ( ! defined( 'WP_CONTENT_URL' ) ) define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); if ( ! defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // Guess the location $crp_path = WP_PLUGIN_DIR.'/'.plugin_basename(dirname(__FILE__)); $crp_url = WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)); function ald_crp_init() { //* Begin Localization Code */ $crp_localizationName = CRP_LOCAL_NAME; $crp_comments_locale = get_locale(); $crp_comments_mofile = ALD_crp_DIR . "/languages/" . $crp_localizationName . "-". $crp_comments_locale.".mo"; load_textdomain($crp_localizationName, $crp_comments_mofile); //* End Localization Code */ } add_action('init', 'ald_crp_init'); /********************************************************************* * Main Function (Do not edit) * ********************************************************************/ function ald_crp() { global $wpdb, $post, $single; $crp_settings = crp_read_options(); $limit = (stripslashes($crp_settings['limit'])); $exclude_categories = explode(',',$crp_settings['exclude_categories']); // Make sure the post is not from the future $time_difference = get_settings('gmt_offset'); $now = gmdate("Y-m-d H:i:s",(time()+($time_difference*3600))); if($crp_settings['match_content']) { $stuff = addslashes($post->post_title. ' ' . $post->post_content); } else { $stuff = addslashes($post->post_title); } if ((is_int($post->ID))&&($stuff != '')) { $sql = "SELECT DISTINCT ID,post_title,post_date,post_content," . "MATCH(post_title,post_content) AGAINST ('".$stuff."') AS score " . "FROM ".$wpdb->posts." WHERE " . "MATCH (post_title,post_content) AGAINST ('".$stuff."') " . "AND post_date <= '".$now."' " . "AND post_status = 'publish' " . "AND id != ".$post->ID." "; if ($crp_settings['exclude_pages']) $sql .= "AND post_type = 'post' "; $sql .= "ORDER BY score DESC "; $search_counter = 0; $searches = $wpdb->get_results($sql); } else { $searches = false; } $output = '