예제 #1
0
function relevanssi_add_stopword($term)
{
    global $wpdb;
    if ('' == $term) {
        return;
    }
    // do not add empty $term to stopwords - added by renaissancehack
    $n = 0;
    $s = 0;
    $terms = explode(',', $term);
    if (count($terms) > 1) {
        foreach ($terms as $term) {
            $n++;
            $term = trim($term);
            $success = relevanssi_add_single_stopword($term);
            if ($success) {
                $s++;
            }
        }
        printf(__("<div id='message' class='updated fade'><p>Successfully added %d/%d terms to stopwords!</p></div>", "relevanssi"), $s, $n);
    } else {
        // add to stopwords
        $success = relevanssi_add_single_stopword($term);
        if ($success) {
            printf(__("<div id='message' class='updated fade'><p>Term '%s' added to stopwords!</p></div>", "relevanssi"), $term);
        } else {
            printf(__("<div id='message' class='updated fade'><p>Couldn't add term '%s' to stopwords!</p></div>", "relevanssi"), $term);
        }
    }
}
예제 #2
0
 public function add_stopword($args = array())
 {
     if (!isset($args[0])) {
         return $this->help();
     }
     $term = $args[0];
     if (relevanssi_add_single_stopword($term)) {
         WP_CLI::success('Added term ' . $term . ' to the list of stopwords and removed it from the index.');
     } else {
         WP_CLI::error('Could not add the term ' . $term . ' to the list of stopwords.');
     }
 }