Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/packages/my-jetpack/changelog/try-fix_WP-CLI_fatal
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Prevent PHP fatal when using WP-CLI.
47 changes: 28 additions & 19 deletions projects/packages/my-jetpack/src/class-rest-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct() {
'permission_callback' => __CLASS__ . '::view_products_permissions_callback',
'args' => array(
'products' => array(
'description' => __( 'Comma seperated list of product slugs that should be retrieved.', 'jetpack-my-jetpack' ),
'description' => __( 'Comma-separated list of product slugs that should be retrieved.', 'jetpack-my-jetpack' ),
'type' => 'string',
'required' => false,
'validate_callback' => __CLASS__ . '::check_products_string',
Expand Down Expand Up @@ -113,24 +113,7 @@ public function __construct() {
),
),
),
'schema' => array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'Products interstitials',
'type' => 'object',
'properties' => array(
'products' => array(
'type' => 'object',
'description' => __( 'Key-value pairs of product slugs and their interstitial states.', 'jetpack-my-jetpack' ),
'properties' => array_fill_keys(
Products::get_products_slugs(),
array(
'description' => __( 'Interstitial state for the product. True means that the user has seen the interstitial for the product.', 'jetpack-my-jetpack' ),
'type' => 'boolean',
)
),
),
),
),
'schema' => array( self::class, 'get_interstitials_schema' ),
)
);

Expand Down Expand Up @@ -176,6 +159,32 @@ public function get_products_schema() {
);
}

/**
* Get the schema for the interstitials endpoint
*
* @return array
*/
public static function get_interstitials_schema() {
return array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'Products interstitials',
'type' => 'object',
'properties' => array(
'products' => array(
'type' => 'object',
'description' => __( 'Key-value pairs of product slugs and their interstitial states.', 'jetpack-my-jetpack' ),
'properties' => array_fill_keys(
Products::get_products_slugs(),
array(
'description' => __( 'Interstitial state for the product. True means that the user has seen the interstitial for the product.', 'jetpack-my-jetpack' ),
'type' => 'boolean',
)
),
),
),
);
}

/**
* Check user capability to access the endpoint.
*
Expand Down
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/try-fix_WP-CLI_fatal
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

My Jetpack: Prevent PHP error when using WP-CLI.
Loading