Jetpack_RelatedPosts_Module

Module Name: Related posts Module Description: Increase page views by showing related content to your visitors.

Defined (1)

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

/modules/related-posts.php  
  1. class Jetpack_RelatedPosts_Module { 
  2. /** 
  3. * Class variables 
  4. */ 
  5. private static $__instance = null; 
  6.  
  7. /** 
  8. * Singleton implementation 
  9. * @return object 
  10. */ 
  11. public static function instance() { 
  12. if ( ! is_a( self::$__instance, 'Jetpack_RelatedPosts_Module' ) ) 
  13. self::$__instance = new Jetpack_RelatedPosts_Module(); 
  14.  
  15. return self::$__instance; 
  16.  
  17. /** 
  18. * Register actions and filters 
  19. * @uses add_action, add_filter 
  20. * @return null 
  21. */ 
  22. private function __construct() { 
  23. add_action( 'jetpack_module_loaded_related-posts', array( $this, 'action_on_load' ) ); 
  24. add_action( 'jetpack_activate_module_related-posts', array( $this, 'action_on_activate' ) ); 
  25.  
  26. /** 
  27. * This action triggers when module is activated. 
  28. * @uses Jetpack::init, Jetpack_Sync::reindex_needed, Jetpack_Sync::reindex_trigger 
  29. * @return null 
  30. */ 
  31. public function action_on_activate() { 
  32. if ( Jetpack::init()->sync->reindex_needed() ) { 
  33. Jetpack::init()->sync->reindex_trigger(); 
  34.  
  35. /** 
  36. * This action triggers if the module is in an active state, load related posts and options. 
  37. * @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack::module_configuration_load, Jetpack_Sync::sync_posts 
  38. * @return null 
  39. */ 
  40. public function action_on_load() { 
  41. require_once 'related-posts/jetpack-related-posts.php'; 
  42. Jetpack_RelatedPosts::init(); 
  43.  
  44. if ( is_admin() ) { 
  45. // Enable "Configure" button on module card 
  46. Jetpack::enable_module_configurable( __FILE__ ); 
  47. Jetpack::module_configuration_load( __FILE__, array( $this, 'module_configuration_load' ) ); 
  48.  
  49. // Sync new posts 
  50. Jetpack_Sync::sync_posts( __FILE__ ); 
  51.  
  52. /** 
  53. * Redirect configure button to Settings > Reading 
  54. * @uses wp_safe_redirect, admin_url 
  55. * @return null 
  56. */ 
  57. public function module_configuration_load() { 
  58. wp_safe_redirect( admin_url( 'options-reading.php#jetpack_relatedposts' ) ); 
  59. exit; 
  60.