PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 3.2.5
Jetpack – WP Security, Backup, Speed, & Growth v3.2.5
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / related-posts.php

related-posts.php in Jetpack – WP Security, Backup, Speed, & Growth 3.2.5, at modules/related-posts.php

86 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Module Name: Related Posts
4 * Module Description: Display links to your related content under posts and pages.
5 * First Introduced: 2.9
6 * Sort Order: 29
7 * Requires Connection: Yes
8 * Auto Activate: No
9 */
10 class Jetpack_RelatedPosts_Module {
11 /**
12 * Class variables
13 */
14 private static $__instance = null;
15
16 /**
17 * Singleton implementation
18 *
19 * @return object
20 */
21 public static function instance() {
22 if ( ! is_a( self::$__instance, 'Jetpack_RelatedPosts_Module' ) )
23 self::$__instance = new Jetpack_RelatedPosts_Module();
24
25 return self::$__instance;
26 }
27
28 /**
29 * Register actions and filters
30 *
31 * @uses add_action, add_filter
32 * @return null
33 */
34 private function __construct() {
35 add_action( 'jetpack_module_loaded_related-posts', array( $this, 'action_on_load' ) );
36 add_action( 'jetpack_activate_module_related-posts', array( $this, 'action_on_activate' ) );
37 }
38
39 /**
40 * This action triggers when module is activated.
41 *
42 * @uses Jetpack::init, Jetpack_Sync::reindex_needed, Jetpack_Sync::reindex_trigger
43 * @return null
44 */
45 public function action_on_activate() {
46 if ( Jetpack::init()->sync->reindex_needed() ) {
47 Jetpack::init()->sync->reindex_trigger();
48 }
49 }
50
51 /**
52 * This action triggers if the module is in an active state, load related posts and options.
53 *
54 * @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack::module_configuration_load, Jetpack_Sync::sync_posts
55 * @return null
56 */
57 public function action_on_load() {
58 require_once 'related-posts/jetpack-related-posts.php';
59 Jetpack_RelatedPosts::init();
60
61 if ( is_admin() ) {
62 // Enable "Configure" button on module card
63 Jetpack::enable_module_configurable( __FILE__ );
64 Jetpack::module_configuration_load( __FILE__, array( $this, 'module_configuration_load' ) );
65
66 // Sync new posts
67 Jetpack_Sync::sync_posts( __FILE__ );
68 }
69 }
70
71 /**
72 * Redirect configure button to Settings > Reading
73 *
74 * @uses wp_safe_redirect, admin_url
75 * @return null
76 */
77 public function module_configuration_load() {
78 wp_safe_redirect( admin_url( 'options-reading.php#jetpack_relatedposts' ) );
79 exit;
80 }
81
82 }
83
84 // Do it.
85 Jetpack_RelatedPosts_Module::instance();
86