← All changes
|
_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-top-posts.php
+8
-4
13.6.2
→
16.3-a.7
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 | } |