|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Module Name: Related Posts |
|
4
|
|
|
* Module Description: Display similar content. |
|
5
|
|
|
* Jumpstart Description: Keep visitors engaged on your blog by highlighting relevant and new content at the bottom of each published post. |
|
6
|
|
|
* First Introduced: 2.9 |
|
7
|
|
|
* Sort Order: 29 |
|
8
|
|
|
* Recommendation Order: 9 |
|
9
|
|
|
* Requires Connection: Yes |
|
10
|
|
|
* Auto Activate: No |
|
11
|
|
|
* Module Tags: Recommended |
|
12
|
|
|
* Feature: Recommended, Jumpstart, Traffic |
|
13
|
|
|
* Additional Search Queries: related, related posts |
|
14
|
|
|
*/ |
|
15
|
|
|
class Jetpack_RelatedPosts_Module { |
|
16
|
|
|
/** |
|
17
|
|
|
* Class variables |
|
18
|
|
|
*/ |
|
19
|
|
|
private static $__instance = null; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Singleton implementation |
|
23
|
|
|
* |
|
24
|
|
|
* @return object |
|
25
|
|
|
*/ |
|
26
|
|
|
public static function instance() { |
|
27
|
|
|
if ( ! is_a( self::$__instance, 'Jetpack_RelatedPosts_Module' ) ) |
|
28
|
|
|
self::$__instance = new Jetpack_RelatedPosts_Module(); |
|
29
|
|
|
|
|
30
|
|
|
return self::$__instance; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Register actions and filters |
|
35
|
|
|
* |
|
36
|
|
|
* @uses add_action, add_filter |
|
37
|
|
|
* @return null |
|
|
|
|
|
|
38
|
|
|
*/ |
|
39
|
|
|
private function __construct() { |
|
40
|
|
|
add_action( 'jetpack_module_loaded_related-posts', array( $this, 'action_on_load' ) ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* This action triggers if the module is in an active state, load related posts and options. |
|
45
|
|
|
* |
|
46
|
|
|
* @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack::module_configuration_load, Jetpack_Sync::sync_posts |
|
47
|
|
|
* @return null |
|
48
|
|
|
*/ |
|
49
|
|
|
public function action_on_load() { |
|
50
|
|
|
require_once 'related-posts/jetpack-related-posts.php'; |
|
51
|
|
|
Jetpack_RelatedPosts::init(); |
|
52
|
|
|
|
|
53
|
|
|
if ( is_admin() ) { |
|
54
|
|
|
// Enable "Configure" button on module card |
|
55
|
|
|
Jetpack::enable_module_configurable( __FILE__ ); |
|
56
|
|
|
Jetpack::module_configuration_load( __FILE__, array( $this, 'module_configuration_load' ) ); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Redirect configure button to Settings > Reading |
|
62
|
|
|
* |
|
63
|
|
|
* @uses wp_safe_redirect, admin_url |
|
64
|
|
|
* @return null |
|
65
|
|
|
*/ |
|
66
|
|
|
public function module_configuration_load() { |
|
67
|
|
|
wp_safe_redirect( admin_url( 'options-reading.php#jetpack_relatedposts' ) ); |
|
68
|
|
|
exit; |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
// Do it. |
|
74
|
|
|
Jetpack_RelatedPosts_Module::instance(); |
|
75
|
|
|
|
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.