WordPress database error: [Disk got full writing 'information_schema.(temporary)' (Errcode: 28 "No space left on device")] SHOW FULL COLUMNS FROM `wp_options`
WordPress database error: [Disk got full writing 'information_schema.(temporary)' (Errcode: 28 "No space left on device")] SHOW FULL COLUMNS FROM `wp_options`
/*
Template Name: BOTY TV API (Year)
*/
if (!current_user_can( 'edit_posts' ))
exit();
// Load the Google API PHP Client Library.
require_once __DIR__ . '/../real-time-pop/gc/vendor/autoload.php';
if (!get_transient( 'tv_stats' )) :
$analytics = initializeAnalytics();
$response = getReport($analytics);
$array_of_tv = printResults($response);
set_transient( 'tv_stats', $array_of_tv, 60*60 );
else :
$array_of_tv = get_transient( 'tv_stats' );
endif;
//var_dump($array_of_tv);
$tv_list = array();
foreach ($array_of_tv as $movie) :
$m = explode("/", $movie[0]);
$tv_list[$m[2]] = $movie[1];
endforeach;
/**
* Initializes an Analytics Reporting API V4 service object.
*
* @return An authorized Analytics Reporting API V4 service object.
*/
function initializeAnalytics()
{
// Use the developers console and download your service account
// credentials in JSON format. Place them in this directory or
// change the key file location if necessary.
$KEY_FILE_LOCATION = __DIR__ . '/../real-time-pop/service-account-credentials.json';
// Create and configure a new client object.
$client = new Google_Client();
$client->setApplicationName("Hello Analytics Reporting");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$analytics = new Google_Service_AnalyticsReporting($client);
return $analytics;
}
/**
* Queries the Analytics Reporting API V4.
*
* @param service An authorized Analytics Reporting API V4 service object.
* @return The Analytics Reporting API V4 response.
*/
function getReport($analytics) {
// Replace with your view ID, for example XXXX.
$VIEW_ID = "118849341";
// Create the DateRange object.
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("yesterday");
$dateRange->setEndDate("today");
// Create the Metrics object.
$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("ga:sessions");
$sessions->setAlias("sessions");
$pageviews = new Google_Service_AnalyticsReporting_Metric();
$pageviews->setExpression("ga:pageviews");
$pageviews->setAlias("pageviews");
//Create the Dimensions object.
$pagePath = new Google_Service_AnalyticsReporting_Dimension();
$pagePath->setName("ga:pagePath");
$ordering = new Google_Service_AnalyticsReporting_OrderBy();
$ordering->setFieldName("ga:pageviews");
$ordering->setOrderType("VALUE");
$ordering->setSortOrder("DESCENDING");
// Create the ReportRequest object.
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($VIEW_ID);
$request->setDateRanges($dateRange);
$request->setDimensions(array($pagePath));
$request->setMetrics(array($sessions, $pageviews));
$request->setOrderBys($ordering);
$request->setPageSize(1000);
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );
//var_dump($body);
return $analytics->reports->batchGet( $body );
}
/**
* Parses and prints the Analytics Reporting API V4 response.
* @param An Analytics Reporting API V4 response.
*/
function printResults($reports) {
$pages = $reports->reports[0]->data->rows;
$arr = [];
foreach ($pages as $page) :
$slug = $page->dimensions[0];
$count = $page->metrics[0]->values[1];
if (strpos($slug, '/tv-serial/') !== false ) { //found at start
$arr[] = array($slug, $count);
}
endforeach;
return $arr;
}
// End Google Anlytics
$paged = 1;
if (isset($_GET['p'])) :
$paged = $_GET['p'];
endif;
$args = array(
'post_type' => 'tv',
'posts_per_page' => 300,
'paged' => $paged,
'post_status' => 'any',
);
$q = new WP_Query( $args );
?>