ajax_get_term_keyword_usage

Retrieves the keyword for the keyword doubles of the termpages.

Description

ajax_get_term_keyword_usage(); 

Usage

  1. if ( !function_exists( 'ajax_get_term_keyword_usage' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/admin/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ajax_get_term_keyword_usage(); 
  7.  

Defined (1)

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

/admin/ajax.php  
  1. function ajax_get_term_keyword_usage() { 
  2. $post_id = filter_input( INPUT_POST, 'post_id' ); 
  3. $keyword = filter_input( INPUT_POST, 'keyword' ); 
  4. $taxonomy_name = filter_input( INPUT_POST, 'taxonomy' ); 
  5.  
  6. $taxonomy = get_taxonomy( $taxonomy_name ); 
  7.  
  8. if ( ! $taxonomy ) { 
  9. wp_die( 0 ); 
  10.  
  11. if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) { 
  12. wp_die( -1 ); 
  13.  
  14. $usage = WPSEO_Taxonomy_Meta::get_keyword_usage( $keyword, $post_id, $taxonomy_name ); 
  15.  
  16. // Normalize the result so it it the same as the post keyword usage AJAX request. 
  17. $usage = $usage[ $keyword ]; 
  18.  
  19. wp_die( 
  20. wp_json_encode( $usage ) 
  21. );