Skip to content

Plans In Plugin: Add plans endpoint#8834

Merged
withinboredom merged 3 commits intomasterfrom
add/plans-endpoint
Feb 15, 2018
Merged

Plans In Plugin: Add plans endpoint#8834
withinboredom merged 3 commits intomasterfrom
add/plans-endpoint

Conversation

@withinboredom
Copy link
Copy Markdown
Contributor

@withinboredom withinboredom commented Feb 13, 2018

Changes proposed in this Pull Request:

  • This adds a local endpoint to get the current plans available. Works with D10122-code

Testing instructions:

You will get back an api response that contains a localized list of plans in the correct currency for your location.

Proposed changelog entry for your changes:

  • We added a plans endpoint to Jetpack's REST API to better handle the features of each Jetpack plan internally.

@withinboredom withinboredom added Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Pri] Normal Plans labels Feb 13, 2018
@withinboredom withinboredom added this to the 5.9 milestone Feb 13, 2018
@withinboredom withinboredom self-assigned this Feb 13, 2018
@withinboredom withinboredom requested a review from a team as a code owner February 13, 2018 21:38
Copy link
Copy Markdown
Contributor

@oskosk oskosk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests well, although as dicussed on DM, I got a 404 cached in the transient, so when I had all set up correctly, I still saw that the route didn't exist. Good to merge after that is solved if it needs to be solved.

Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add more details about the filter for the parser to process it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a docblock here?

I'm also not quite sure __return_true is the best option here; it is usually meant to be used when adding filters. Just true may be easier to understand imo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Feature] WP REST API and removed [Status] Needs Review This PR is ready for review. labels Feb 15, 2018
@withinboredom
Copy link
Copy Markdown
Contributor Author

@jeherve Documented the filter and fixed the value being passed. While I was writing it, for some reason my brain confused apply_filter and add_filter lol

@jeherve jeherve added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Feb 15, 2018
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More nitpicking, sorry :|

}

public static function get_plans( $request ) {
$data = get_transient( 'jetpack_plans' );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the lines are now separated from each other, maybe we don't need the extra spaces before the = anymore? What do you think?

*
* @param bool true Whether to cache Jetpack plans locally
*/
$use_cache = apply_filters( 'cache_jetpack_plans', true );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would not better to change the filter to start with jetpack_ instead of cache_? It seems more in line with our other filters.

*/
$use_cache = apply_filters( 'cache_jetpack_plans', true );

if ( $data === false ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to use a Yoda condition here, as per the WP coding standards.

}
$data = Jetpack_Client::wpcom_json_api_request_as_blog( $path, '2', array( 'headers' => array( 'X-Forwarded-For' => $ip ) ), null, 'wpcom' );

if ( $use_cache ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this more specific, just in case someone decides to use the filter incorrectly and uses the false string instead of a boolean for example?

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Feb 15, 2018
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Feb 15, 2018
@withinboredom withinboredom merged commit 99de635 into master Feb 15, 2018
@withinboredom withinboredom deleted the add/plans-endpoint branch February 15, 2018 21:30
mattwiebe added a commit that referenced this pull request Feb 23, 2018
mattwiebe added a commit that referenced this pull request Feb 26, 2018
…ation (#8930)

* forward all possible client IPs for currency l10n

Follows on from #8834
oskosk added a commit that referenced this pull request Feb 27, 2018
oskosk added a commit that referenced this pull request Feb 27, 2018
* update changelog.txt

* Update readme.txt with scaffolding for 5.9 changelog and release draft shortlink

* Add changelog entry for #8243

* Add changelog entry for #8296

* Add changelog entry for #8367

* Add changelog entry for #8686

* Add changelog entry for #8707

* Add changelog entry for #8709 and #8714

* Add changelog entry for #8729

* Add changelog entry for #8777

* Add changelog entry for #8780

* Add changelog entry for #8786

* Add changelog entry for #8787

* Add changelog entry for #8801 #8805 #8832 #8865 and #8804

* Add changelog entry for #8817

* Add changelog entry for #8822

* Add changelog entry for #8823

* Add changelog entry for #8829

* Add changelog entry for #8834

* move some items to major enhancements

* Add changelog entry for #8836

* Add changelog entry for #8839

* Add changelog entry for #8861

* Add changelog entry for #8862

* Add changelog entry for #8863

* Add changelog entry for #8866

* Add changelog entry for #8870

* Add changelog entry for #8874

* Add changelog entry for #8875

* Add changelog entry for #8881

* Add changelog entry for #8890

* Add changelog entry for #8911

* Add changelog entry for #8927

* Add changelog entry for #8931

* Add changelog entry for #8933

* Add changelog entry for #8930

* fix wording

* typo

* minor fixes

* replace partner scripts for Jetpack Start in changelog entry

* Update to-test.md

* Update to-test.md

* minor style fixes to to-test.md

* minor style fixes to to-test.md

* minor fixes on to-test.md

* Add changelog entry for #8868

* Add changelog entry for #8844

* Add changelog entry for #8664

* Add changelog entry for #8935

* Add changelog entry for #8425

* Add changelog entry for #8625
@kraftbj kraftbj removed the [Status] Ready to Merge Go ahead, you can push that green button! label Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] WP REST API Plans [Pri] Normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants