| 1 |
<?php |
| 2 |
/** |
| 3 |
* Get search stats for use in the wp-admin dashboard. |
| 4 |
* |
| 5 |
* @package automattic/jetpack-search |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Automattic\Jetpack\Search; |
| 9 |
|
| 10 |
use Automattic\Jetpack\Connection\Client; |
| 11 |
use Jetpack_Options; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit( 0 ); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Search stats (e.g. post count, post type breakdown) |
| 19 |
*/ |
| 20 |
class Stats { |
| 21 |
/** |
| 22 |
* Get stats from the WordPress.com API for the current blog ID. |
| 23 |
*/ |
| 24 |
public function get_stats_from_wpcom() { |
| 25 |
$blog_id = Jetpack_Options::get_option( 'id' ); |
| 26 |
|
| 27 |
if ( ! is_numeric( $blog_id ) ) { |
| 28 |
return null; |
| 29 |
} |
| 30 |
|
| 31 |
$response = Client::wpcom_json_api_request_as_blog( |
| 32 |
'/sites/' . (int) $blog_id . '/jetpack-search/stats', |
| 33 |
'2', |
| 34 |
array(), |
| 35 |
null, |
| 36 |
'wpcom' |
| 37 |
); |
| 38 |
|
| 39 |
return $response; |
| 40 |
} |
| 41 |
} |
| 42 |
|