wpseo_remove_stopwords_sample_permalink

Removes stopword from the sample permalink that is generated in an AJAX request.

Description

(array) wpseo_remove_stopwords_sample_permalink( (array) $permalink, (int) $post_id, (string) $title, (string) $name ); 

Returns (array)

Parameters (4)

0. $permalink (array)
The permalink generated for this post by WordPress.
1. $post_id (int)
The ID of the post.
2. $title (string)
The title for the post that the user used.
3. $name (string)
The name for the post that the user used.

Usage

  1. if ( !function_exists( 'wpseo_remove_stopwords_sample_permalink' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/admin/ajax.php'; 
  3.  
  4. // The permalink generated for this post by WordPress. 
  5. $permalink = array(); 
  6.  
  7. // The ID of the post. 
  8. $post_id = -1; 
  9.  
  10. // The title for the post that the user used. 
  11. $title = ''; 
  12.  
  13. // The name for the post that the user used. 
  14. $name = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wpseo_remove_stopwords_sample_permalink($permalink, $post_id, $title, $name); 
  18.  

Defined (1)

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

/admin/ajax.php  
  1. function wpseo_remove_stopwords_sample_permalink( $permalink, $post_id, $title, $name ) { 
  2. WPSEO_Options::get_instance(); 
  3. $options = WPSEO_Options::get_options( array( 'wpseo_permalinks' ) ); 
  4. if ( $options['cleanslugs'] !== true ) { 
  5. return $permalink; 
  6.  
  7. /** 
  8. * If the name is empty and the title is not, WordPress will generate a slug. In that case we want to remove stop 
  9. * words from the slug. 
  10. */ 
  11. if ( empty( $name ) && ! empty( $title ) ) { 
  12. $stop_words = new WPSEO_Admin_Stop_Words(); 
  13.  
  14. // The second element is the slug. 
  15. $permalink[1] = $stop_words->remove_in( $permalink[1] ); 
  16.  
  17. return $permalink;