Server IP : 104.21.14.48 / Your IP : 18.191.122.146 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/mu-plugins/vendor/wptool/wp-admin-dash/src/adminDash/services/ |
Upload File : |
<?php namespace Wptool\adminDash\services; use Wptool\adminDash\exceptions\SiteTrafficRequestFailedException; use Wptool\adminDash\utils\Configuration; use WPaaS\Plugin; class SiteTrafficDataService { private $api_url; public function __construct() { $this->api_url = Configuration::get( 'public_api_url' ); } /** * This function returns site traffic data from rum API * * @return array * @throws SiteTrafficRequestFailedException */ public function get_site_traffic_data( $from_date, $to_date ) { if ( ! $GLOBALS['wpaas_feature_flag']->get_feature_flag_value( 'traffic_data_admin', false ) ) { return null; } $account_uid = defined( 'GD_ACCOUNT_UID' ) ? GD_ACCOUNT_UID : null; $response = wp_remote_get( $this->api_url . '/siteTraffic/' . $account_uid . '?' . http_build_query( array( 'from' => $from_date, 'to' => $to_date, ) ), array( 'headers' => Plugin::sign_http_request( wp_json_encode( array() ) ) ) ); if ( is_wp_error( $response ) ) { throw new SiteTrafficRequestFailedException( $response->get_error_message() ); } if ( 200 !== wp_remote_retrieve_response_code( $response ) ) { return null; } return json_decode( wp_remote_retrieve_body( $response ) )->siteTrafficData; } }