PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | json-endpoints/class.wpcom-json-api-get-post-counts-v1-1-endpoint.php +8 -3 12.5.2 → 16.3-a.7 View file →
@@ -1,6 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit( 0 );
5 +}
6 +
3 7 new WPCOM_JSON_API_GET_Post_Counts_V1_1_Endpoint(
4 8 array(
5 9 'description' => 'Get number of posts in the post type groups by post status',
6 10 'group' => 'sites',
@@ -32,8 +36,10 @@
32 36 );
33 37
34 38 /**
35 39 * GET Post Counts v1_1 endpoint class.
40 + *
41 + * @phan-constructor-used-for-side-effects
36 42 */
37 43 class WPCOM_JSON_API_GET_Post_Counts_V1_1_Endpoint extends WPCOM_JSON_API_Endpoint {
38 44
39 45 /**
@@ -38,9 +44,9 @@
38 44
39 45 /**
40 46 * Whitelist array.
41 47 *
42 - * @var allowlist
48 + * @var string[]
43 49 */
44 50 private $allowlist = array( 'publish' );
45 51
46 52 /**
@@ -136,9 +142,8 @@
136 142 return $blog_id;
137 143 }
138 144
139 145 // @todo see if we can use a strict comparison here.
140 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
141 146 if ( ! in_array( $post_type, array( 'post', 'revision', 'page', 'any' ), true ) && defined( 'IS_WPCOM' ) && IS_WPCOM ) {
142 147 $this->load_theme_functions();
143 148 }
144 149
@@ -153,9 +158,9 @@
153 158 array_push( $this->allowlist, 'draft', 'future', 'pending', 'private', 'trash' );
154 159 }
155 160
156 161 $return = array(
157 - 'counts' => (array) array(
162 + 'counts' => array(
158 163 'all' => (object) $this->retrieveCounts( $post_type ),
159 164 'mine' => (object) $this->retrieveCounts( $post_type, $mine_ID ), // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
160 165 ),
161 166 );