canonical-urls
4 months ago
carousel
1 day ago
comment-likes
8 months ago
comments
2 months ago
custom-post-types
1 month ago
external-media
8 months ago
google-fonts
1 month ago
gravatar
6 years ago
infinite-scroll
1 month ago
likes
1 day ago
markdown
2 months ago
memberships
1 day ago
photon-cdn
1 day ago
plugin-search
2 months ago
post-by-email
8 months ago
related-posts
1 week ago
scan
4 months ago
seo-tools
1 month ago
sharedaddy
1 month ago
shortcodes
1 week ago
shortlinks
4 weeks ago
simple-payments
8 months ago
site-icon
8 months ago
sitemaps
2 months ago
stats
7 months ago
subscriptions
1 week ago
theme-tools
1 month ago
tiled-gallery
1 month ago
verification-tools
2 months ago
videopress
1 day ago
widget-visibility
2 months ago
widgets
1 month ago
woocommerce-analytics
3 months ago
wordads
1 month ago
wpcom-tos
7 months ago
account-protection.php
3 months ago
blaze.php
8 months ago
blocks.php
8 months ago
canonical-urls.php
5 months ago
carousel.php
8 months ago
comment-likes.php
8 months ago
comments.php
4 months ago
contact-form.php
8 months ago
copy-post.php
2 months ago
custom-content-types.php
3 months ago
google-fonts.php
3 months ago
gravatar-hovercards.php
2 months ago
infinite-scroll.php
8 months ago
json-api.php
8 months ago
latex.php
2 months ago
likes.php
2 months ago
markdown.php
8 months ago
module-extras.php
8 months ago
module-headings.php
1 week ago
module-info.php
5 months ago
monitor.php
1 month ago
notes.php
1 day ago
photon-cdn.php
8 months ago
photon.php
8 months ago
plugin-search.php
1 month ago
podcast.php
1 week ago
post-by-email.php
3 months ago
post-list.php
8 months ago
protect.php
3 months ago
publicize.php
8 months ago
related-posts.php
2 months ago
search.php
8 months ago
seo-tools.php
1 month ago
sharedaddy.php
5 months ago
shortcodes.php
8 months ago
shortlinks.php
2 months ago
simple-payments.php
8 months ago
sitemaps.php
8 months ago
sso.php
1 month ago
stats.php
1 week ago
subscriptions.php
1 week ago
theme-tools.php
8 months ago
tiled-gallery.php
8 months ago
vaultpress.php
8 months ago
verification-tools.php
3 months ago
videopress.php
8 months ago
waf.php
8 months ago
widget-visibility.php
8 months ago
widgets.php
8 months ago
woocommerce-analytics.php
8 months ago
wordads.php
8 months ago
wpcom-reader.php
5 months ago
wpgroho.js
1 year ago
related-posts.php
82 lines
| 1 | <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Module Name: Related Posts |
| 4 | * Module Description: Automatically display related articles to keep visitors reading longer. |
| 5 | * First Introduced: 2.9 |
| 6 | * Sort Order: 29 |
| 7 | * Recommendation Order: 9 |
| 8 | * Requires Connection: Yes |
| 9 | * Auto Activate: No |
| 10 | * Module Tags: Recommended |
| 11 | * Feature: Engagement |
| 12 | * // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInComment |
| 13 | * Additional Search Queries: related, jetpack related posts, related posts for wordpress, related posts, popular posts, popular, related content, related post, contextual, context, contextual related posts, related articles, similar posts, easy related posts, related page, simple related posts, free related posts, related thumbnails, similar, engagement, yet another related posts plugin, creator |
| 14 | * |
| 15 | * @package automattic/jetpack |
| 16 | */ |
| 17 | |
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | exit( 0 ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Class Jetpack_RelatedPosts_Module |
| 24 | * |
| 25 | * @phan-constructor-used-for-side-effects |
| 26 | */ |
| 27 | class Jetpack_RelatedPosts_Module { |
| 28 | /** |
| 29 | * Class variables |
| 30 | * |
| 31 | * @var Jetpack_RelatedPosts_Module |
| 32 | */ |
| 33 | private static $instance = null; |
| 34 | |
| 35 | /** |
| 36 | * Singleton implementation |
| 37 | * |
| 38 | * @return object |
| 39 | */ |
| 40 | public static function instance() { |
| 41 | if ( ! is_a( self::$instance, 'Jetpack_RelatedPosts_Module' ) ) { |
| 42 | self::$instance = new Jetpack_RelatedPosts_Module(); |
| 43 | } |
| 44 | |
| 45 | return self::$instance; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Register actions and filters |
| 50 | * |
| 51 | * @uses add_action, add_filter |
| 52 | */ |
| 53 | private function __construct() { |
| 54 | add_action( 'jetpack_module_loaded_related-posts', array( $this, 'action_on_load' ) ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * This action triggers if the module is in an active state, load related posts and options. |
| 59 | * |
| 60 | * @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack_Sync::sync_posts |
| 61 | */ |
| 62 | public function action_on_load() { |
| 63 | require_once __DIR__ . '/related-posts/jetpack-related-posts.php'; |
| 64 | Jetpack_RelatedPosts::init(); |
| 65 | |
| 66 | if ( is_admin() ) { |
| 67 | Jetpack::enable_module_configurable( __FILE__ ); |
| 68 | } |
| 69 | |
| 70 | // Load Customizer controls. |
| 71 | if ( class_exists( WP_Customize_Manager::class ) && class_exists( WP_Customize_Control::class ) ) { |
| 72 | require_once __DIR__ . '/related-posts/class.related-posts-customize.php'; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // Do it. |
| 78 | Jetpack_RelatedPosts_Module::instance(); |
| 79 | |
| 80 | require_once __DIR__ . '/related-posts/abilities/class-related-posts-abilities.php'; |
| 81 | \Automattic\Jetpack\Plugin\Abilities\Related_Posts_Abilities::init(); |
| 82 |