Jetpack_RelatedPosts_Raw

The Jetpack by WordPress.com Jetpack RelatedPosts Raw class.

Defined (1)

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

/modules/related-posts/jetpack-related-posts.php  
  1. class Jetpack_RelatedPosts_Raw extends Jetpack_RelatedPosts { 
  2. protected $_query_name; 
  3.  
  4. /** 
  5. * Allows callers of this class to tag each query with a unique name for tracking purposes. 
  6. * @param string $name 
  7. * @return Jetpack_RelatedPosts_Raw 
  8. */ 
  9. public function set_query_name( $name ) { 
  10. $this->_query_name = (string) $name; 
  11. return $this; 
  12.  
  13. /** 
  14. * The raw related posts class can be used by other plugins or themes 
  15. * to get related content. This class wraps the existing RelatedPosts 
  16. * logic thus we never want to add anything to the DOM or do anything 
  17. * for event hooks. We will also not present any settings for this 
  18. * class and keep it enabled as calls to this class is done 
  19. * programmatically. 
  20. */ 
  21. public function action_admin_init() {} 
  22. public function action_frontend_init() {} 
  23. public function get_options() { 
  24. return array( 
  25. 'enabled' => true,  
  26. ); 
  27.  
  28. /** 
  29. * Workhorse method to return array of related posts ids matched by ElasticSearch. 
  30. * @param int $post_id 
  31. * @param int $size 
  32. * @param array $filters 
  33. * @uses wp_remote_post, is_wp_error, wp_remote_retrieve_body 
  34. * @return array 
  35. */ 
  36. protected function _get_related_posts( $post_id, $size, array $filters ) { 
  37. $hits = $this->_filter_non_public_posts( 
  38. $this->_get_related_post_ids( 
  39. $post_id,  
  40. $size,  
  41. $filters 
  42. ); 
  43.  
  44. /** This filter is already documented in modules/related-posts/related-posts.php */ 
  45. $hits = apply_filters( 'jetpack_relatedposts_filter_hits', $hits, $post_id ); 
  46.  
  47. return $hits;