Skip to content

Commit

Permalink
Make endpoints provide minimum the Jetpack version.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymitr committed Oct 25, 2024
1 parent 9ba813f commit 9633b2c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions projects/plugins/jetpack/class.json-api-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ abstract class WPCOM_JSON_API_Endpoint {
*
* @var string
*/
public $rest_route = null;
public $rest_route;

/**
* Jetpack Version in which REST support was introduced.
*
* @var string
*/
public $rest_min_jp_version;

/**
* Accepted query parameters
Expand Down Expand Up @@ -350,12 +357,14 @@ public function __construct( $args ) {
$this->method = $args['method'];
$this->path = $args['path'];
$this->path_labels = $args['path_labels'];
$this->rest_route = $args['rest_route'];
$this->min_version = $args['min_version'];
$this->max_version = $args['max_version'];
$this->deprecated = $args['deprecated'];
$this->new_version = $args['new_version'];

$this->rest_route = $args['rest_route'];
$this->rest_min_jp_version = $args['rest_min_jp_version'];

// Ensure max version is not less than min version.
if ( version_compare( $this->min_version, $this->max_version, '>' ) ) {
$this->max_version = $this->min_version;
Expand Down Expand Up @@ -2761,6 +2770,15 @@ public function build_rest_route() {
return $version_prefix . $this->rest_route;
}

/**
* Get Jetpack Version where support for the endpoint was introduced.
*
* @return string
*/
public function get_rest_min_jp_version() {
return $this->rest_min_jp_version;
}

/**
* Return endpoint response
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'method' => 'GET',
'path' => '/sites/%s/plugins',
'rest_route' => '/plugins',
'rest_min_jp_version' => '14.0-a.7',
'stat' => 'plugins',
'min_version' => '1',
'max_version' => '1.1',
Expand Down

0 comments on commit 9633b2c

Please sign in to comment.