Advertisement
alexgieg

Relevanssi populate stopwords alternative

May 25th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. function relevanssi_populate_stopwords() {
  2.     global $wpdb, $stopword_table;
  3.  
  4.     $stopwords_file = 'stopwords';
  5.     if ( defined('WPLANG') ) {
  6.         $tmp_filename = $stopwords_file . '.' . WPLANG;
  7.         if ( file_exists( $tmp_filename ) ) {
  8.             $stopwords_file = $tmp_filename;
  9.         } else {
  10.             if ( strpos( WPLANG, '_' ) > 0 ) {
  11.                 $tmp_filename = $stopwords_file . '.' . substr( WPLANG, 0, strpos( WPLANG, '_' ) );
  12.                 if ( file_exists( $tmp_filename ) ) {
  13.                     $stopwords_file = $tmp_filename;
  14.                 }
  15.             }
  16.         }
  17.     }
  18.     include($stopwords_file);
  19.  
  20.     if (is_array($stopwords) && count($stopwords) > 0) {
  21.         foreach ($stopwords as $word) {
  22.             $q = $wpdb->prepare("INSERT IGNORE INTO $stopword_table (stopword) VALUES (%s)", trim($word));
  23.             $wpdb->query($q);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement