PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 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 All 506 releases
← All changes | _inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-top-posts.php +8 -4 13.8.3 → 16.3-a.5 View file →
@@ -4,8 +4,12 @@
4 4 *
5 5 * @package automattic/jetpack
6 6 */
7 7
8 +if ( ! defined( 'ABSPATH' ) ) {
9 + exit( 0 );
10 +}
11 +
8 12 /**
9 13 * Top Posts & Pages block endpoint.
10 14 */
11 15 class WPCOM_REST_API_V2_Endpoint_Top_Posts extends WP_REST_Controller {
@@ -13,12 +17,8 @@
13 17 * Constructor.
14 18 */
15 19 public function __construct() {
16 20 add_action( 'rest_api_init', array( $this, 'register_routes' ) );
17 -
18 - if ( ! class_exists( 'Jetpack_Top_Posts_Helper' ) ) {
19 - require_once JETPACK__PLUGIN_DIR . '_inc/lib/class-jetpack-top-posts-helper.php';
20 - }
21 21 }
22 22
23 23 /**
24 24 * Register endpoint routes.
@@ -91,8 +91,12 @@
91 91 *
92 92 * @return array Data on top posts.
93 93 */
94 94 public function get_top_posts( $request ) {
95 + if ( ! class_exists( 'Jetpack_Top_Posts_Helper' ) ) {
96 + require_once JETPACK__PLUGIN_DIR . '_inc/lib/class-jetpack-top-posts-helper.php';
97 + }
98 +
95 99 $period = $request->get_param( 'period' );
96 100 return Jetpack_Top_Posts_Helper::get_top_posts( $period );
97 101 }
98 102 }