homepage * :: display home keywords in admin page **/ /** * default values for the plugin settings **/ define('PK_MAX_SEARCH_TERMS','10'); define('PK_AUTO_ADD','1'); define('PK_AUTO_LINK','0'); define('PK_SHOW_COUNT','0'); define('PK_BEFORE_KEYWORD','
  • '); define('PK_AFTER_KEYWORD','
  • '); define('PK_BEFORE_LIST',''); define('PK_LIST_HEADER','

    Incoming search terms:

    '); define('PK_AUTO_CLEANUP','90'); define('PK_AUTO_TAG','0'); define('PK_PROMOTE_OLD_POST','0'); define('PK_BADWORDS','http:,cache:,site:,utm_source,sex,porn,gamble,xxx,nude,squirt,gay,abortion,attack,bomb,casino,cocaine,die,death,erection,gambling,heroin,marijuana,masturbation,pedophile,penis,poker,pussy,terrorist'); define('PK_ACTIVATED','Thank you for registering the plugin. It has been activated.'); define('PK_WATERMARK',''); /** * plugin action & filter **/ register_activation_hook(__file__,'pk_stt2_admin_activation'); register_deactivation_hook(__file__,'pk_stt2_admin_deactivation'); add_action('admin_menu','pk_stt2_admin_menu_hook'); add_action('admin_notices', 'pk_stt2_admin_notices'); add_action('wp_head', 'pk_stt2_function_wp_head_hook'); add_action('pk_stt2_admin_event_hook', 'pk_stt2_admin_scheduled_event'); add_action('pk_stt2_promote_old_post_event_hook', 'pk_stt2_promote_old_post_scheduled_event'); add_filter('the_content','pk_stt2_admin_content_filter'); /** * == ADMIN SECTION == * wordpress admin setting **/ function pk_stt2_more_reccurences() { return array( 'stt2debugevent' => array('interval' => 120, 'display' => '5 minutes event') ); } add_filter('cron_schedules', 'pk_stt2_more_reccurences'); /** * install the plugin and save the initial values * */ function pk_stt2_admin_activation(){ pk_stt2_db_create_table(); add_option('pk_stt2_enabled', '1'); $plugin_settings = array( 'max' => PK_MAX_SEARCH_TERMS, 'auto_add' => PK_AUTO_ADD, 'auto_link' => PK_AUTO_LINK, 'show_count' => PK_SHOW_COUNT, 'before_keyword' => PK_BEFORE_KEYWORD, 'after_keyword' => PK_AFTER_KEYWORD, 'before_list' => PK_BEFORE_LIST, 'after_list' => PK_AFTER_LIST,'list_header' => PK_LIST_HEADER ); add_option ( 'pk_stt2_settings', $plugin_settings ); add_option ( 'onlist_status', 0 ); add_option ( 'pk_stt2_auto_tag', PK_AUTO_TAG ); add_option ( 'pk_stt2_promote_old_post', PK_PROMOTE_OLD_POST ); $auto_cleanup = intval( get_option ( 'pk_stt2_auto_cleanup' ) ); $auto_cleanup = ( 0 == $auto_cleanup ) ? PK_AUTO_CLEANUP : $auto_cleanup; add_option ( 'pk_stt2_auto_cleanup', $auto_cleanup ); add_option ( 'pk_stt2_badwords', PK_BADWORDS ); if (!wp_next_scheduled('pk_stt2_admin_event_hook')) { wp_schedule_event( time(), 'daily', 'pk_stt2_admin_event_hook' ); } if (!wp_next_scheduled('pk_stt2_promote_old_post_event_hook')) { wp_schedule_event( time(), 'twicedaily', 'pk_stt2_promote_old_post_event_hook' ); } pk_stt2_flush_rewrite_rules(); } /** * uninstall the plugin **/ function pk_stt2_admin_deactivation(){ remove_filter('the_content','pk_stt2_admin_content_filter'); wp_clear_scheduled_hook('pk_stt2_admin_event_hook'); wp_clear_scheduled_hook('pk_stt2_promote_old_post_event_hook'); remove_action('pk_stt2_admin_event_hook', 'pk_stt2_admin_scheduled_event'); remove_action('pk_stt2_promote_old_post_event_hook', 'pk_stt2_promote_old_post_scheduled_event'); } /** * scheduled event to delete unpopular searchterms **/ function pk_stt2_admin_scheduled_event(){ $days = get_option('pk_stt2_auto_cleanup'); if ( 0 < $days ) { $result = pk_stt2_db_cleanup( $days ); update_option('pk_stt2_last_clean_up',date('F j, Y, g:i A').'; '.$result.' search term(s) deleted.'); } } /** * scheduled event to promote old post **/ function pk_stt2_promote_old_post_scheduled_event(){ $promote = get_option('pk_stt2_promote_old_post'); if ( 1 == $promote ) { pk_stt2_promote_old_post(); } } /* * display admin notice to upgrade the database when previous format of database exist */ function pk_stt2_admin_notices() { if ( get_option('onlist_status') < 2 ){ echo "

    " . sprintf(__('SEO SearchTerms Tagging 2 plugin need your attention.'), "options-general.php?page=".basename(plugin_basename(__FILE__))). "

    "; } } /** * framework to handle the admin form * */ function pk_stt2_create_admin_menu(){ pk_stt2_admin_print_title(); if ( trim($_GET['onlist']) == 1 ) echo '

    '.PK_ACTIVATED.'

    '; if ( pk_stt2_onlist() ) { pk_stt2_admin_print_header(); /* intercept form submit */ if (isset($_POST['submit'])){ pk_stt2_admin_update_options(); } elseif ( isset($_POST['upgrade_db_charset']) ){ pk_stt2_db_convert_to_utf8(); if ( 'utf8' == get_option('pk_stt2_db_charset') ){ ?>

    SEO SearchTerms Tagging 2 database was successfully upgraded to support international characters.

    Failed to upgrade SEO SearchTerms Tagging 2 database!


    SEO SearchTerms Tagging 2

    If you think this plugin useful, please consider making a donation or write a review about it or at least give it a good rating on WordPress.org.

    Settings | Widgets | Help | More Stats: 50, 100, 200, 300, 400, 500

    Please enter the search terms you want to delete, separate them with a comma.

    "; foreach($searchterms as $term){ $permalink = ( 0 == $term->post_id ) ? 'http://www.google.com/search?q='.str_replace(' ','+',$term->meta_value) : get_permalink($term->post_id); $toReturn .= "
  • $term->meta_value"; $toReturn .= " ($term->meta_count)
  • "; } $toReturn = trim($toReturn,', '); $toReturn .= ""; $toReturn = htmlspecialchars_decode($toReturn); return $toReturn; } else { return false; } } /** * print the admin form * */ function pk_stt2_admin_print_admin_page(){ $options = get_option('pk_stt2_settings'); $auto_cleanup = intval( get_option ( 'pk_stt2_auto_cleanup' ) ); $auto_cleanup = ( 0 == $auto_cleanup ) ? PK_AUTO_CLEANUP : $auto_cleanup; $promote_old_post = get_option('pk_stt2_promote_old_post'); $badwords = get_option('pk_stt2_badwords'); if ( empty($badwords) ){ $badwords = PK_BADWORDS; update_option ( 'pk_stt2_badwords', $badwords ); }; $dbcharset = get_option('pk_stt2_db_charset'); if (empty($dbcharset)){ $baseurl = "options-general.php?page=".basename(plugin_basename(__FILE__)); echo '

    If you need international character support, or you have a non English website, please click here to upgrade your database.

    '; } ?>

    What's New in Version 1.5?

    1. Change blog search permalink, now using - instead of + (e.g: domain.com/search/search-terms/).
    2. New option to upgrade database to support international characters (default for new installation).
    3. New option to promote/republish post that has not received traffic after 30 days in publishing (most likely not indexed yet).
    4. Auto cleaned up database is mandatory now, with the default setting to delete unused search terms after 90 days.
    5. Now record all the keywords, not only the one that comes to single post or page.

    General Settings ( Widgets has it own settings )

    value="1" name="enabled"/>
    Before:   After:
    Before:   After:
    /> Yes, link to post content   /> Yes, link to search page   /> No
    /> Yes   /> No
    /> Yes   /> No
    /> Yes   /> No
    days ( default is 90 days )
    /> Yes   /> No

    Auto Clean Up Unused Search Terms:

    • Last database cleaned up:
    • Next scheduled database clean up on .

    Once a day, we perform database clean up by removing search terms that are never used again within days. It is necessary to prevent an excessive use of server resources, especially if you use shared web hosting.

    If your blog has more than a thousand visitors per day, we recommend to reduce the auto clean up setting. You are free to determine when a search term is considered not useful, 7, 15, or 30 days maybe?

    Promote Post With No Search Engine Traffic

    • Number of posts with no search engine traffic:
    • Last promoted blog post:
    • Next scheduled promotion on .

    To ensure that the promoted post get indexed, use free services such as TwitterFeed to publish your blog feed into social network sites such as Twitter, Facebook, Ping.fm etc.

    As an alternative, you can also use a premium plugin like Indexing Tool to make sure that your articles are indexed.

    Delete Search Terms:

    Enter the search terms you want to delete, separate them with a comma ( e.g.: keyword1,keyword2 ):



       OR

    Please Donate to Support Us:

    Popular Search Terms:

    Recent Search Terms:

    Popular Home Keywords:

    Options saved.

    Failed to save options.

    posts WHERE post_type = 'post' AND post_status = 'publish' AND ID NOT IN ( SELECT post_id FROM ".$wpdb->prefix."stt2_meta ) ORDER BY post_date DESC LIMIT ".$count.";"; $results = $wpdb->get_results( $sql ); if ( $results ) return $results; } /** * promote single blog post with no search engine traffic * @params: $old_post_ID, $new_time, $gmt_time * @return: 1 if succes **/ function pk_stt2_db_promote_single_post_wo_traffic( $old_post_ID ){ global $wpdb; $new_time = date('Y-m-d H:i:s'); $gmt_time = get_gmt_from_date($new_time); $sql = "UPDATE $wpdb->posts SET post_date = '$new_time', post_date_gmt = '$gmt_time', post_modified = '$new_time', post_modified_gmt = '$gmt_time' WHERE ID = '$old_post_ID';"; $return = $wpdb->query($sql); return $return; } /** * get the number of posts with no traffic yet **/ function pk_stt2_db_get_number_of_posts_wo_traffic(){ global $wpdb; $sql = "SELECT count(`ID`) FROM $wpdb->posts WHERE `post_status` = 'publish' AND `post_type` = 'post' AND ID NOT IN ( SELECT post_id FROM ".$wpdb->prefix."stt2_meta GROUP BY post_id );"; $post_count = $wpdb->get_var($wpdb->prepare( $sql )); return $post_count; } /** * get single post ID of posts with no traffic yet **/ function pk_stt2_db_get_id_post_wo_traffic(){ global $wpdb; $sql = "SELECT `ID` FROM $wpdb->posts WHERE `post_status` = 'publish' AND `post_type` = 'post' AND ID NOT IN ( SELECT post_id FROM ".$wpdb->prefix."stt2_meta GROUP BY post_id ) LIMIT 1;"; $post_count = $wpdb->get_var($wpdb->prepare( $sql )); return $post_count; } /** * get the number of posts **/ function pk_stt2_db_get_number_of_posts(){ global $wpdb; $sql = "SELECT count(`ID`) FROM $wpdb->posts WHERE `post_status` = 'publish' AND `post_type` = 'post';"; $post_count = $wpdb->get_var($wpdb->prepare( $sql )); return $post_count; } /** * get 10 popular search terms for the posts, will be used as tags * @param $id: post id * @return: comma separated text of popular search terms **/ function pk_stt2_db_get_popular_tags( $id ){ global $wpdb; $sql = "SELECT meta_value FROM ".$wpdb->prefix."stt2_meta WHERE ( post_id = ".$id." AND meta_count > 25 AND meta_value NOT LIKE '%http%' ) ORDER BY meta_count DESC LIMIT 5;"; $a_results = $wpdb->get_results( $sql ); if ( $a_results ){ foreach ( $a_results as $value ){ $result .= $value->meta_value.','; } $result = trim($result,','); } return $result; } /** * get popular search terms * @param $count: max number of search terms **/ function pk_stt2_db_get_popular_terms( $count ){ global $wpdb; $result = $wpdb->get_results( "SELECT DISTINCT `meta_value`,`meta_count`,`post_id` FROM `".$wpdb->prefix."stt2_meta` ORDER BY `meta_count` DESC LIMIT ".$count.";" ); return $result; } /** * get home keywords * @param $count: max number of search terms **/ function pk_stt2_db_get_home_keywords( $count ){ global $wpdb; $result = $wpdb->get_results( "SELECT DISTINCT `meta_value`,`meta_count`,`post_id` FROM `".$wpdb->prefix."stt2_meta` WHERE `post_id` = 0 ORDER BY `meta_count` DESC LIMIT ".$count.";" ); return $result; } /** * get list of search terms * @param $max: max number of search terms **/ function pk_stt2_db_get_search_terms( $max ){ global $wpdb, $post; $result = $wpdb->get_results( "SELECT `meta_value`,`meta_count` FROM `".$wpdb->prefix."stt2_meta` WHERE `post_id` = $post->ID ORDER BY `meta_count` DESC LIMIT ".$max.";" ); return $result; } /** * get recent search terms * @param $count: max number of search terms **/ function pk_stt2_db_get_recent_terms( $count ){ global $wpdb; $result = $wpdb->get_results( "SELECT DISTINCT `meta_value`,`meta_count`,`post_id` FROM `".$wpdb->prefix."stt2_meta` ORDER BY `last_modified` DESC LIMIT ".$count.";" ); return $result; } /** * get random search terms * @param $count: max number of search terms **/ function pk_stt2_db_get_random_terms( $count ){ global $wpdb; $result = $wpdb->get_results( "SELECT DISTINCT `meta_value` FROM `".$wpdb->prefix."stt2_meta` ORDER BY RAND() LIMIT ".$count.";" ); return $result; } /** * get the number of searchterms **/ function pk_stt2_db_get_number_of_searchterms(){ global $wpdb; $result = $wpdb->get_var("SELECT COUNT(`meta_value`) FROM ".$wpdb->prefix."stt2_meta;"); return $result; } /** * delete searchterms from the database * @param $searchterms: comma separated search terms or 'delete_all_terms' * @output: number of rows effected by the delete query **/ function pk_stt2_db_delete_searchterms( $searchterms ){ global $wpdb; if ( 'delete_all_terms' !== $searchterms ) { $arr_searchterms = explode(',',$searchterms); foreach ($arr_searchterms as $value) { $success += $wpdb->query( "DELETE FROM ".$wpdb->prefix."stt2_meta WHERE LOWER(meta_value) LIKE '%". strtolower(trim($value)) ."%'; "); } } else { $success = $wpdb->query( "DELETE FROM ".$wpdb->prefix."stt2_meta" ); } $opt = $wpdb->query('OPTIMIZE TABLE '.$wpdb->prefix.'stt2_meta;'); return $success; } /** * clean the database in daily basis **/ function pk_stt2_db_cleanup( $days ){ global $wpdb; $result = $wpdb->query('DELETE FROM '.$wpdb->prefix.'stt2_meta WHERE (meta_count < 10) AND (date(last_modified) < date(now()-interval '.$days.' day));'); $opt = $wpdb->query('OPTIMIZE TABLE '.$wpdb->prefix.'stt2_meta;'); return $result; } /** * create stt2 database; UTF-8 version * */ function pk_stt2_db_create_table() { global $wpdb; $table_name = $wpdb->prefix.'stt2_meta'; if($wpdb->get_var("SHOW TABLES LIKE '$table_name';") != $table_name) { $sql = "CREATE TABLE `".$wpdb->prefix."stt2_meta` ( `post_id` INT( 20 ) NOT NULL , `meta_value` VARCHAR ( 255 ) NOT NULL, `meta_count` INT( 20 ) NOT NULL DEFAULT '1', `last_modified` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY ( `post_id` , `meta_value` ) ) CHARACTER SET utf8 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT COLLATE utf8_general_ci;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); add_option('pk_stt2_db_charset','utf8'); } } /** * update old db charset into utf8 **/ function pk_stt2_db_convert_to_utf8(){ global $wpdb; if ( 'utf8' !== get_option('pk_stt2_db_charset') ){ $sql = "ALTER TABLE ".$wpdb->prefix."stt2_meta CONVERT TO CHARACTER SET utf8;"; $result = $wpdb->query($sql); update_option('pk_stt2_db_charset', 'utf8'); } } /** * save search terms into database **/ function pk_stt2_db_save_searchterms( $meta_value) { if ( strlen($meta_value) > 3 ){ if ( is_single() || is_page() ) { global $post; $ID = $post->ID; } else { $ID = 0; } global $wpdb; $success = $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->prefix."stt2_meta ( `post_id`,`meta_value`,`meta_count` ) VALUES ( %s, %s, 1 ) ON DUPLICATE KEY UPDATE `meta_count` = `meta_count` + 1", $ID, $meta_value ) ); } return $success; } /** * get popular search terms in category * @author: pile ( http://pile.web.id ) **/ function pk_stt2_db_get_popular_searchterms_in_category( $count ){ global $wpdb; $cat_ID = get_query_var('cat'); $sql = " SELECT wps.post_id, wps.meta_value, wps.meta_count FROM ".$wpdb->prefix."terms INNER JOIN ".$wpdb->prefix."term_taxonomy ON ".$wpdb->prefix."terms.term_id = ".$wpdb->prefix."term_taxonomy.term_id INNER JOIN ".$wpdb->prefix."term_relationships wpr ON wpr.term_taxonomy_id = ".$wpdb->prefix."term_taxonomy.term_taxonomy_id INNER JOIN ".$wpdb->prefix."posts p ON p.ID = wpr.object_id INNER JOIN ".$wpdb->prefix."stt2_meta wps ON wps.post_id = p.ID WHERE taxonomy = 'category' AND p.post_type = 'post' AND p.post_status = 'publish' AND ( ".$wpdb->prefix."terms.term_id = '".$cat_ID."' ) ORDER BY `wps`.`meta_count` DESC LIMIT ".$count.";"; $results = $wpdb->get_results($sql); return $results; } /** * == MAIN SECTION == * all main functions of searchterms tagging 2 plugin **/ /** * get popular search terms on coresponding category * @param $count: number of search terms to be displayed **/ function stt_popular_terms_in_category( $count=10 ){ if (is_category()) { $options = get_option('pk_stt2_settings'); $searchterms = pk_stt2_db_get_popular_searchterms_in_category( $count ); if(!empty($searchterms)) { $result = pk_stt2_function_prepare_searchterms($searchterms,$options,true); return $result; } else { return false; } } } /** * save popular search terms as tags in monthly basis **/ function pk_stt2_function_save_tags(){ if ( '1' == get_option('pk_stt2_auto_tag') && !empty($post->ID) ) { $day_diff = ceil(( strtotime(date('F j, Y')) - strtotime( get_post_meta( $id,'stt2_update_tags',true ) ) + 1) / (60*60*24) ) ; if ( 30 < $day_diff ){ global $post; $tags = pk_stt2_db_get_popular_tags( $post->ID ); wp_set_post_tags( $post->ID, $tags, true ); update_post_meta( $post->ID,'stt2_update_tags', date('F j, Y') ); } } } /** * hooked to wp-head() * */ function pk_stt2_function_wp_head_hook() { if( 1 == intval(get_option('pk_stt2_enabled')) ){ $referer = pk_stt2_function_get_referer(); if (!$referer) return false; $delimiter = pk_stt2_function_get_delimiter($referer); if( $delimiter ){ $term = pk_stt2_function_get_terms($delimiter); if (!pk_stt2_is_contain_bad_words( $term )) { pk_stt2_db_save_searchterms( $term ); } } pk_stt2_function_save_tags(); } } /** * display the search terms below post content * */ function stt_terms_list(){ $options = get_option('pk_stt2_settings'); $searchterms = pk_stt2_db_get_search_terms( $options['max'] ); if(!empty( $searchterms )) { $result = pk_stt2_function_prepare_searchterms( $searchterms, $options ); return $result; } else { return false; } } /** * strip the slash from each search terms * */ function pk_stt2_function_stripslashes_options($options){ foreach($options as $i=>$row){ $row = stripslashes($row); $options[$i]=$row; } return $options; } /** * common function to print the search terms * */ function pk_stt2_function_prepare_searchterms( $searchterms, $options, $popular=false ){ global $post; $options = pk_stt2_function_stripslashes_options($options); $toReturn .= ( $popular == false ) ? $options['list_header'].$options['before_list'] : $options['before_list']; foreach($searchterms as $term){ if ( 0 == $options['auto_link'] ){ $toReturn .= $options['before_keyword'].$term->meta_value; } else { if( !$popular ){ if ( 1 == $options['auto_link'] ){ $permalink = get_permalink( $post->ID ); } elseif ( 2 == $options['auto_link']){ $permalink = get_bloginfo( 'url' ).'/search/'.user_trailingslashit(pk_stt2_function_sanitize_search_link($term->meta_value)); } } else { $permalink = ( 0 == $term->post_id ) ? get_bloginfo('url') : get_permalink($term->post_id); } $toReturn .= $options['before_keyword']."meta_value\">$term->meta_value"; } $toReturn .= ( $options['show_count'] == true ) ? " ($term->meta_count)".$options['after_keyword'] : $options['after_keyword']; } $toReturn = trim($toReturn, ', '); $toReturn .= $options['after_list']; $toReturn = htmlspecialchars_decode($toReturn); $toReturn .= PK_WATERMARK; return $toReturn; } /** * display popular search terms manually * @param $count: number of search terms to be displayed * */ function stt_popular_terms( $count=10 ){ $options = get_option('pk_stt2_settings'); $searchterms = pk_stt2_db_get_popular_terms($count); if(!empty($searchterms)) { $result = pk_stt2_function_prepare_searchterms($searchterms,$options,true); return $result; } else { return false; } } /** * display recent search terms manually * @param $count: number of search terms to be displayed * */ function stt_recent_terms( $count=10 ){ $options = get_option('pk_stt2_settings'); $searchterms = pk_stt2_db_get_recent_terms( $count ); if(!empty($searchterms)) { $result = pk_stt2_function_prepare_searchterms($searchterms,$options,true); return $result; } else { return false; } } /** * display random search terms manually * @param $count: number of search terms to be displayed * */ function stt_random_terms( $count=10 ){ $options = get_option('pk_stt2_settings'); $searchterms = pk_stt2_db_get_random_terms( $count ); if(!empty($searchterms)) { $result = pk_stt2_function_prepare_searchterms($searchterms,$options,true); return $result; } else { return false; } } /** * get search delimiter for each search engine * base on the original searchterms tagging plugin * */ function pk_stt2_function_get_delimiter($ref) { $search_engines = array('google.com' => 'q', 'go.google.com' => 'q', 'images.google.com' => 'q', 'video.google.com' => 'q', 'news.google.com' => 'q', 'blogsearch.google.com' => 'q', 'maps.google.com' => 'q', 'local.google.com' => 'q', 'search.yahoo.com' => 'p', 'search.msn.com' => 'q', 'bing.com' => 'q', 'msxml.excite.com' => 'qkw', 'search.lycos.com' => 'query', 'alltheweb.com' => 'q', 'search.aol.com' => 'query', 'search.iwon.com' => 'searchfor', 'ask.com' => 'q', 'ask.co.uk' => 'ask', 'search.cometsystems.com' => 'qry', 'hotbot.com' => 'query', 'overture.com' => 'Keywords', 'metacrawler.com' => 'qkw', 'search.netscape.com' => 'query', 'looksmart.com' => 'key', 'dpxml.webcrawler.com' => 'qkw', 'search.earthlink.net' => 'q', 'search.viewpoint.com' => 'k', 'mamma.com' => 'query'); $delim = false; if (isset($search_engines[$ref])) { $delim = $search_engines[$ref]; } else { if (strpos('ref:'.$ref,'google')) $delim = "q"; elseif (strpos('ref:'.$ref,'search.atomz.')) $delim = "sp-q"; elseif (strpos('ref:'.$ref,'search.msn.')) $delim = "q"; elseif (strpos('ref:'.$ref,'search.yahoo.')) $delim = "p"; elseif (preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $ref)) $delim = "bellsouth"; } return $delim; } /** * retrieve the search terms from search engine query * */ function pk_stt2_function_get_terms($d) { $terms = null; $query_array = array(); $query_terms = null; $query = explode($d.'=', $_SERVER['HTTP_REFERER']); $query = explode('&', $query[1]); $query = urldecode($query[0]); $query = str_replace("'", '', $query); $query = str_replace('"', '', $query); $query_array = preg_split('/[\s,\+\.]+/',$query); $query_terms = implode(' ', $query_array); $terms = htmlspecialchars(urldecode(trim($query_terms))); return $terms; } /** * get the referer * */ function pk_stt2_function_get_referer() { if (!isset($_SERVER['HTTP_REFERER']) || ($_SERVER['HTTP_REFERER'] == '')) return false; $referer_info = parse_url($_SERVER['HTTP_REFERER']); $referer = $referer_info['host']; if(substr($referer, 0, 4) == 'www.') $referer = substr($referer, 4); return $referer; } /** * sanitize link to search page * @param $title: search engine terms * @output: search terms in form of web safe url slug **/ function pk_stt2_function_sanitize_search_link($title) { $title = strip_tags($title); // Preserve escaped octets. $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); // Remove percent signs that are not part of an octet. $title = str_replace('%', '', $title); // Restore octets. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); $title = remove_accents($title); if (seems_utf8($title)) { if (function_exists('mb_strtolower')) { $title = mb_strtolower($title, 'UTF-8'); } $title = utf8_uri_encode($title); } $title = strtolower($title); $title = preg_replace('/&.+?;/', '', $title); // kill entities $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); $title = preg_replace('/\s+/', '-', $title); $title = preg_replace('|-+|', '-', $title); $title = trim($title, '-'); return $title; } /** * check whether the search term contain forbidden word **/ function pk_stt2_is_contain_bad_words( $term ){ $option = get_option('pk_stt2_badwords'); $option = ( empty($option) ) ? PK_BADWORDS : $option; $badwords = explode( ',',$option ); $term = str_ireplace( $badwords,'***',$term ); if( false === strpos( $term, '***' ) ) return false; else return true; } /** * == PLUGIN REGISTRATION SECTION == **/ /** * check onlist status */ function pk_stt2_onlist(){ $form_1 = 'stt2_reg_form_1'; $form_2 = 'stt2_reg_form_2'; $pk_stt2_list = get_option('onlist_status'); if ( trim($_GET['onlist']) == 1 || $_GET['no'] == 1 ) { $pk_stt2_list = 2; update_option('onlist_status', $pk_stt2_list); } if ( ((trim($_GET['activate']) != '' && trim($_GET['from']) != '') || trim($_GET['activate_again']) != '') && $pk_stt2_list != 2 ) { update_option('pk_stt2_name', $_GET['name']); update_option('pk_stt2_email', $_GET['from']); $pk_stt2_list = 1; update_option('onlist_status', $pk_stt2_list); } if ( $pk_stt2_list == 0 ) { pk_stt2_register_1($form_1); } else if ( $pk_stt2_list == 1 ) { $name = get_option('pk_stt2_name'); $email = get_option('pk_stt2_email'); pk_stt2_register_2($form_2,$name,$email); } else if ( $pk_stt2_list == 2 ) { return true; } } /** * Plugin registration form */ function pk_stt2_registration_form($form_name, $submit_btn_txt='Register', $name, $email, $hide=0, $activate_again='') { $wp_url = get_bloginfo('wpurl'); $wp_url = (strpos($wp_url,'http://') === false) ? get_bloginfo('siteurl') : $wp_url; $thankyou_url = $wp_url.'/wp-admin/options-general.php?page='.$_GET['page']; $onlist_url = $wp_url.'/wp-admin/options-general.php?page='.$_GET['page'].'&onlist=1'; $nothankyou_url = $wp_url.'/wp-admin/options-general.php?page='.$_GET['page'].'&no=1'; if ( $hide == 1 ) $align_tbl = 'left'; else $align_tbl = 'center'; ?> onsubmit="return pk_stt2_validate_form_0()">
    Name:
    Email:
     
     
     

    '.$msg.'

    '; } ?>

    Almost Done....

    Step 1:

    A confirmation email has been sent to your email "". You must click on the confirmation link inside the email to register the plugin.
     
    The confirmation email will look like this:
     

    Step 2:

    Click on the button below to Verify and Activate the plugin.
     
     

     

    Troubleshooting

    1. I can't found the confirmation email in my inbox.
    Please check your spam or bulk folder.
     
    2. It's not there in the junk folder either.
    In a rare case, it took times to arrive. Please wait for 6 hours at most. If after 6 hours and still no confirmation email, please register again using the form below:
     
     
    3. Still no confirmation email and I have already registered twice.
    Using the form above, try to register again using DIFFERENT EMAIL ADDRESS.
     
    4. I receive an error like this:


    This error means that you have already subscribed but have not yet clicked on the link inside confirmation email. In order to avoid any spam complain we don't send repeated confirmation emails.
     
    5. If you still got problems, please contact us about it and we will get to you ASAP.

     

    user_firstname; $email = $current_user->user_email; ?>

    Please register the plugin...

    Registration is Free and only has to be done once. If you've register before or don't want to register, please click "No Thank You!" button.
     
    In addition, you'll receive complimentary subscription to our Email Newsletter which will give you many tips and tricks to attract lots of visitors to your blog. Of course, you can unsubscribe any time you want.
     
     
    Disclaimer: Your contact information will be handled with the strictest confidence and will never be sold or shared with third parties.

     

    Recent Search Terms:

    Manual Usage Instructions:

    1. To display incoming search terms to the article:

      <?php if(function_exists('stt_terms_list')) echo stt_terms_list() ;?>

    2. To display most popular search terms for all articles:

      <?php if(function_exists('stt_popular_terms')) echo stt_popular_terms(10) ;?>

      If your theme supports widgets, it is better to use the "Popular Search Terms" widget.

    3. To display most recent search terms:

      <?php if(function_exists('stt_recent_terms')) echo stt_recent_terms(10) ;?>

      If your theme supports widgets, it is better to use the "Recent Search Terms" widget.

    4. To display most popular search terms in category archive:

      <?php if(function_exists('stt_popular_terms_in_category')) echo stt_popular_terms_in_category(10) ;?>

      If your theme supports widgets, it is better to use the "Popular Terms in Category" widget.

    5. To display random search terms:

      <?php if(function_exists('stt_random_terms')) echo stt_random_terms(10) ;?>

      If your theme supports widgets, it is better to use the "Random Search Terms" widget.

    * Replace '10' with the number of search terms to display.

    Frequently Asked Questions:

    1. Do I still need to edit the template and add the plugin code manually if I choose to add the search terms list automatically after post content?

      No, the list of search terms will automatically be added right after the post content.

    2. Where do I need to add the plugin code manually?

      You can put the plugin code into the current template that you use in file index.php or single.php and page.php. The most common place is under the post content or below the comment form.

    3. I prefer to display the search terms in the form of paragraphs, separated by commas, not in the form of a list like the plugin default format. How can I get results like that?

      * Go to 'WordPress Admin > Settings > SEO searchTerms 2' menu,
      * Empty columns 'Text and code After and Before the list',
      * Empty columns 'Text and code before each keyword',
      * And type `','` (a comma followed by a space) in the 'Text and code after each keyword',
      * Save.

    4. I can't see any changes on the single post page. How do I know that this plugin works well?

      This plugin will not display the list of search terms until there were visitors who come from search engines into the blog posts. Until then, no search terms will be displayed.

      So please wait until the plugin logs any visitors coming from search engines. Alternatively, you can search your own blog post from search engines to do a test.

    5. It seems the plugin won't work with my theme, what is wrong?

      Like many others SEO plugins, this plugin requires your theme to call wp_head() hook on the HTML header. Put <?php wp_head(); ?> code between your <head>...</head> tag, usually on header.php file. Open the header file of WordPress Default Theme if you need any references.

    Database Upgrade for International Characters Support

    Please NOTE that this upgrade is only required for web sites that use international characters/non English.

    The possibility for the occurrence of error is very small, but it is highly recommended to create database backup before upgrading. Detailed information on how to backing up your Wordpress database can be found here.

    ID).'" target="_blank">'.$post->post_title.''; } else { echo 'None'; } } /** * == END OF PROMOTE POST SECTION == **/ /** * == PHP 4 SECTION == **/ /** * PHP 4 equivalent of PHP 5 str_ireplace function **/ if( !function_exists('str_ireplace') ){ function str_ireplace($search,$replace,$subject){ $token = chr(1); $haystack = strtolower($subject); $needle = strtolower($search); while (($pos=strpos($haystack,$needle))!==FALSE){ $subject = substr_replace($subject,$token,$pos,strlen($search)); $haystack = substr_replace($haystack,$token,$pos,strlen($search)); } $subject = str_replace($token,$replace,$subject); return $subject; } } /** * PHP 4 equivalent of PHP 5 htmlspecialchars_decode function **/ if ( !function_exists('htmlspecialchars_decode') ){ function htmlspecialchars_decode($text){ return strtr($text,array_flip(get_html_translation_table(HTML_SPECIALCHARS))); } } /** * == END OF PHP 4 SECTION == **/ /** * == SEARCH QUERY SECTION == **/ add_action('generate_rewrite_rules', 'pk_stt2_add_rewrite_rules'); function pk_stt2_add_rewrite_rules( $wp_rewrite ){ $new_rules = array('^search/(.+)\$' => 'index.php?s=' .$wp_rewrite->preg_index(1)); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } // add_action('init', 'pk_stt2_flush_rewrite_rules'); function pk_stt2_flush_rewrite_rules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); } add_action('parse_request', 'pk_stt2_filter_search_query'); function pk_stt2_filter_search_query(){ global $wp; if (!empty($wp->query_vars['s'])){ $wp->set_query_var('s', str_replace('-',' ',$wp->query_vars['s'])); } } /** * == END OF SEARCH QUERY SECTION == **/ /** * add widgets **/ include_once ( 'widget.php' ); ?>