WPSEO_Admin_Stop_Words

Manages stop words and filtering stop words from slugs.

Defined (1)

The class is defined in the following location(s).

/admin/class-stop-words.php  
  1. class WPSEO_Admin_Stop_Words { 
  2. /** 
  3. * Removes stop words in a slug 
  4. * @param string $original_slug The slug to remove stop words in. 
  5. * @return string 
  6. */ 
  7. public function remove_in( $original_slug ) { 
  8. // Turn it to an array and strip stop words by comparing against an array of stopwords. 
  9. $new_slug_parts = array_diff( explode( '-', $original_slug ), $this->list_stop_words() ); 
  10.  
  11. // Don't change the slug if there are less than 3 words left. 
  12. if ( count( $new_slug_parts ) < 3 ) { 
  13. return $original_slug; 
  14.  
  15. // Turn the sanitized array into a string. 
  16. $new_slug = join( '-', $new_slug_parts ); 
  17.  
  18. return $new_slug; 
  19.  
  20. /** 
  21. * Returns a translated, filtered list of stop words 
  22. * @return array An array of stop words. 
  23. */ 
  24. public function list_stop_words() { 
  25. /** translators: this should be an array of stop words for your language, separated by comma's. */ 
  26. $stopwords = explode( ', ', __( "a, about, above, after, again, against, all, am, an, and, any, are, as, at, be, because, been, before, being, below, between, both, but, by, could, did, do, does, doing, down, during, each, few, for, from, further, had, has, have, having, he, he'd, he'll, he's, her, here, here's, hers, herself, him, himself, his, how, how's, i, i'd, i'll, i'm, i've, if, in, into, is, it, it's, its, itself, let's, me, more, most, my, myself, nor, of, on, once, only, or, other, ought, our, ours, ourselves, out, over, own, same, she, she'd, she'll, she's, should, so, some, such, than, that, that's, the, their, theirs, them, themselves, then, there, there's, these, they, they'd, they'll, they're, they've, this, those, through, to, too, under, until, up, very, was, we, we'd, we'll, we're, we've, were, what, what's, when, when's, where, where's, which, while, who, who's, whom, why, why's, with, would, you, you'd, you'll, you're, you've, your, yours, yourself, yourselves", 'wordpress-seo' ) ); 
  27.  
  28. /** 
  29. * Allows filtering of the stop words list 
  30. * Especially useful for users on a language in which WPSEO is not available yet 
  31. * and/or users who want to turn off stop word filtering 
  32. * @api array $stopwords Array of all lowercase stop words to check and/or remove from slug 
  33. */ 
  34. $stopwords = apply_filters( 'wpseo_stopwords', $stopwords ); 
  35.  
  36. return $stopwords;