Skip to content

API: 3rd-party: Add tools for getting module overrides; Add to API#8836

Merged
ebinnion merged 6 commits intomasterfrom
update/filter-modules-ui
Feb 15, 2018
Merged

API: 3rd-party: Add tools for getting module overrides; Add to API#8836
ebinnion merged 6 commits intomasterfrom
update/filter-modules-ui

Conversation

@ebinnion
Copy link
Copy Markdown
Contributor

@ebinnion ebinnion commented Feb 14, 2018

As part of my work on #8800, I need to know which modules are being forced on and which are being forced off. With that information, it should be relatively easy to modify the UI to let a user know that an option can not be modified.

Updating the UI to reflect whether an option can be updated is especially important in the context of a hosting partner forcing modules on/off.

This PR also adds the override key to each module result returned in the API. This will allow us to support module overrides on both WPCOM and in the Jetpack UI.

To test:

  • Review code and ensure testing logic is sound
  • phpunit --filter=Jetpack_Modules_Overrides
  • Optionally functionally test in wp shell
  • Checkout D10224-code on WPCOM, sandbox API and query the following:
    • GET /sites/$site/jetpack/modules
    • GET /sites/$site/jetpack/modules/$module_slug
  • Ensure that both include the override key for modules
  • Add the following to an integration plugin:
    add_filter( 'option_jetpack_active_modules', 'jetpack_test_module_override' );
    function jetpack_test_module_override( $modules ) {
    	$found = array_search( 'sitemaps', $modules );
    	if ( $found ) {
    		unset( $modules[ $found ] );
    	}
    
    	return array_values( array_merge( $modules, array( 'photon', 'lazy-images' ) ) );
    }
    
  • Run GET /sites/$site/jetpack/modules and ensure that the override for photon and lazy-images is active, the override for sitemaps is inactive, and all others have an empty value.

cc @oskosk since you mentioned you looked at this before in #8800.

Changelog entry

  • We updated the modules endpoint in Jetpack's REST API to be aware of modules that have been filtered through option_jetpack_active_modules allowing for better compatibility with custom Jetpack installation where the administrator decides to filter out specific Jetpack modules.

@ebinnion ebinnion added this to the 5.9 milestone Feb 14, 2018
@ebinnion ebinnion self-assigned this Feb 14, 2018
@ebinnion ebinnion requested a review from a team as a code owner February 14, 2018 00:45
@ebinnion ebinnion force-pushed the update/filter-modules-ui branch from e645a6b to fa47b00 Compare February 14, 2018 00:47
@ebinnion ebinnion force-pushed the update/filter-modules-ui branch from ae54490 to d0c2cfb Compare February 14, 2018 22:28
@ebinnion ebinnion changed the title 3rd-party: Add tools for getting module overrides information API: 3rd-party: Add tools for getting module overrides; Add to API Feb 14, 2018
Copy link
Copy Markdown
Contributor

@withinboredom withinboredom left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM! Sorry, forgot to approve yesterday

@oskosk oskosk added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Feb 15, 2018
@ebinnion ebinnion merged commit 196b803 into master Feb 15, 2018
@ebinnion ebinnion deleted the update/filter-modules-ui branch February 15, 2018 20:04
matticbot pushed a commit that referenced this pull request Feb 16, 2018
…se format to add override

Currently, it is possible to override the active modules in Jetpack and force some to be active or inactive. The issue with this is that our UI does not respond to that. So, while a module may be forced on, a user is shown UI that allows them to attempt to disable the module, except, when the page is refreshed, the module is still enabled.

See: #8836
See: #8800

Differential Revision: D10224-code

This commit syncs r170223-wpcom.
dereksmart pushed a commit that referenced this pull request Feb 21, 2018
…se format to add override (#8863)

Currently, it is possible to override the active modules in Jetpack and force some to be active or inactive. The issue with this is that our UI does not respond to that. So, while a module may be forced on, a user is shown UI that allows them to attempt to disable the module, except, when the page is refreshed, the module is still enabled.

See: #8836
See: #8800

Differential Revision: D10224-code

This commit syncs r170223-wpcom.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants