← All changes
|
json-endpoints/class.wpcom-json-api-get-post-counts-v1-1-endpoint.php
+8
-3
12.2.3
→
16.3-a.5
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 | ); |