Site Kit by Google - Version 1.13.1

Version Description

Download this release

Release Info

Developer flixos90
Plugin Icon 128x128 Site Kit by Google
Version 1.13.1
Comparing to
See all releases

Code changes from version 1.13.0 to 1.13.1

google-site-kit.php CHANGED
@@ -11,7 +11,7 @@
11
  * Plugin Name: Site Kit by Google
12
  * Plugin URI: https://sitekit.withgoogle.com
13
  * Description: Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
14
- * Version: 1.13.0
15
  * Author: Google
16
  * Author URI: https://opensource.google.com
17
  * License: Apache License 2.0
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
24
  }
25
 
26
  // Define most essential constants.
27
- define( 'GOOGLESITEKIT_VERSION', '1.13.0' );
28
  define( 'GOOGLESITEKIT_PLUGIN_MAIN_FILE', __FILE__ );
29
  define( 'GOOGLESITEKIT_PHP_MINIMUM', '5.6.0' );
30
 
11
  * Plugin Name: Site Kit by Google
12
  * Plugin URI: https://sitekit.withgoogle.com
13
  * Description: Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
14
+ * Version: 1.13.1
15
  * Author: Google
16
  * Author URI: https://opensource.google.com
17
  * License: Apache License 2.0
24
  }
25
 
26
  // Define most essential constants.
27
+ define( 'GOOGLESITEKIT_VERSION', '1.13.1' );
28
  define( 'GOOGLESITEKIT_PLUGIN_MAIN_FILE', __FILE__ );
29
  define( 'GOOGLESITEKIT_PHP_MINIMUM', '5.6.0' );
30
 
includes/Modules/Analytics.php CHANGED
@@ -971,41 +971,9 @@ final class Analytics extends Module
971
  }
972
 
973
  // Order by.
974
- $orderby = $data['orderby'];
975
- if ( ! empty( $orderby ) && is_array( $orderby ) ) {
976
- // When just object is passed we need to convert it to an array of objects.
977
- if ( ! wp_is_numeric_array( $orderby[0] ) ) {
978
- $orderby = array( $orderby );
979
- }
980
-
981
- $orderby = array_filter(
982
- array_map(
983
- function ( $order_def ) {
984
- $order_def = array_merge(
985
- array(
986
- 'fieldName' => '',
987
- 'sortOrder' => 'DESCENDING',
988
- ),
989
- (array) $order_def
990
- );
991
-
992
- if ( empty( $order_def['fieldName'] ) ) {
993
- return null;
994
- }
995
-
996
- $order_by = new Google_Service_AnalyticsReporting_OrderBy();
997
- $order_by->setFieldName( $order_def['fieldName'] );
998
- $order_by->setSortOrder( $order_def['sortOrder'] );
999
-
1000
- return $order_by;
1001
- },
1002
- $orderby
1003
- )
1004
- );
1005
-
1006
- if ( ! empty( $orderby ) ) {
1007
- $request->setOrderBys( $orderby );
1008
- }
1009
  }
1010
 
1011
  // Batch reports requests.
@@ -1069,7 +1037,7 @@ final class Analytics extends Module
1069
  $this->has_access_to_property( $property_id )
1070
  );
1071
  };
1072
- case 'GET:tracking-disabled':
1073
  return function() {
1074
  $option = $this->get_settings()->get();
1075
 
@@ -1094,6 +1062,49 @@ final class Analytics extends Module
1094
  throw new Invalid_Datapoint_Exception();
1095
  }
1096
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1097
  /**
1098
  * Parses a response for the given datapoint.
1099
  *
@@ -1437,7 +1448,7 @@ final class Analytics extends Module
1437
  );
1438
  }
1439
  }
1440
-
1441
  // No property matched the account ID.
1442
  return array(
1443
  'permission' => false,
971
  }
972
 
973
  // Order by.
974
+ $orderby = $this->parse_reporting_orderby( $data['orderby'] );
975
+ if ( ! empty( $orderby ) ) {
976
+ $request->setOrderBys( $orderby );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
977
  }
978
 
979
  // Batch reports requests.
1037
  $this->has_access_to_property( $property_id )
1038
  );
1039
  };
1040
+ case 'GET:tracking-disabled':
1041
  return function() {
1042
  $option = $this->get_settings()->get();
1043
 
1062
  throw new Invalid_Datapoint_Exception();
1063
  }
1064
 
1065
+ /**
1066
+ * Parses the orderby value of the data request into an array of reporting orderby object instances.
1067
+ *
1068
+ * @since 1.13.1
1069
+ *
1070
+ * @param array|null $orderby Data request orderby value.
1071
+ * @return Google_Service_AnalyticsReporting_OrderBy[] An array of reporting orderby objects.
1072
+ */
1073
+ protected function parse_reporting_orderby( $orderby ) {
1074
+ if ( empty( $orderby ) || ! is_array( $orderby ) ) {
1075
+ return array();
1076
+ }
1077
+
1078
+ $results = array_map(
1079
+ function ( $order_def ) {
1080
+ $order_def = array_merge(
1081
+ array(
1082
+ 'fieldName' => '',
1083
+ 'sortOrder' => '',
1084
+ ),
1085
+ (array) $order_def
1086
+ );
1087
+
1088
+ if ( empty( $order_def['fieldName'] ) || empty( $order_def['sortOrder'] ) ) {
1089
+ return null;
1090
+ }
1091
+
1092
+ $order_by = new Google_Service_AnalyticsReporting_OrderBy();
1093
+ $order_by->setFieldName( $order_def['fieldName'] );
1094
+ $order_by->setSortOrder( $order_def['sortOrder'] );
1095
+
1096
+ return $order_by;
1097
+ },
1098
+ // When just object is passed we need to convert it to an array of objects.
1099
+ wp_is_numeric_array( $orderby ) ? $orderby : array( $orderby )
1100
+ );
1101
+
1102
+ $results = array_filter( $results );
1103
+ $results = array_values( $results );
1104
+
1105
+ return $results;
1106
+ }
1107
+
1108
  /**
1109
  * Parses a response for the given datapoint.
1110
  *
1448
  );
1449
  }
1450
  }
1451
+
1452
  // No property matched the account ID.
1453
  return array(
1454
  'permission' => false,
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: google
4
  Requires at least: 4.7
5
  Tested up to: 5.4
6
  Requires PHP: 5.6
7
- Stable tag: 1.13.0
8
  License: Apache License 2.0
9
  License URI: https://www.apache.org/licenses/LICENSE-2.0
10
  Tags: google, search-console, analytics, adsense, pagespeed-insights, optimize, tag-manager, site-kit
4
  Requires at least: 4.7
5
  Tested up to: 5.4
6
  Requires PHP: 5.6
7
+ Stable tag: 1.13.1
8
  License: Apache License 2.0
9
  License URI: https://www.apache.org/licenses/LICENSE-2.0
10
  Tags: google, search-console, analytics, adsense, pagespeed-insights, optimize, tag-manager, site-kit