Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the newspack_managed_plugins filter #2605

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

philipjohn
Copy link
Contributor

@philipjohn philipjohn commented Aug 15, 2023

All Submissions:

Changes proposed in this Pull Request:

Adds a filter to allow for the modification of the managed plugins array. For example, some hosts may pre-install plugins in a way that Newspack isn't able to detect and so plugins that are active may not be recognised as such by Newspack, preventing users from using the features. This is the case on VIP where Jetpack is always active but doesn't appear in the normal plugins list.

Here's how the filter could be used on VIP to ensure wizards move past the Jetpack requirement:

/**
 * Make sure Newspack sees Jetpack as active.
 *
 * On VIP, Jetpack is always active but Newspack uses the core get_plugins()
 * function to determine if Jetpack is active, which won't show Jetpack. This
 * hook marks Jetpack as active on VIP.
 *
 * @param array $plugins Array of plugins.
 *
 * @return array Modified array of plugins.
 */
function mytheme_newspack_managed_plugins( $plugins ) {
	// Jetpack is always active on VIP.
	if ( defined( 'VIP_GO_ENV' ) && VIP_GO_ENV ) {
		$plugins['jetpack']['Status'] = 'active';
	}
	return $plugins;
}
add_filter( 'newspack_managed_plugins', 'mytheme_newspack_managed_plugins' );

How to test the changes in this Pull Request:

Testing on VIP would be best if possible. Otherwise, filter the get_plugins() function to explicitly remove Jetpack even when active.

  1. Try to access a wizard (e.g. Engagement) and observe you are asked to install/activate Jetpack
  2. Apply this patch
  3. Add a filter to the theme's functions.php, such as the example above.
  4. Refresh the wizard screen and observe that it no longer asks you to activate Jetpack

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@philipjohn philipjohn requested a review from a team as a code owner August 15, 2023 14:52
@adekbadek adekbadek merged commit 81ba5f2 into Automattic:master Oct 16, 2023
matticbot pushed a commit that referenced this pull request Oct 16, 2023
# [2.9.0-alpha.1](v2.8.3...v2.9.0-alpha.1) (2023-10-16)

### Features

* add Perfmatters to managed plugins ([#2684](#2684)) ([eb657d8](eb657d8))
* **design-wizard:** allow bulk update of featured image, post template ([#2670](#2670)) ([37a4656](37a4656))
* newspack_managed_plugins filter ([#2605](#2605)) ([81ba5f2](81ba5f2))
* **reader-registration:** custom checkbox state for lists ([#2682](#2682)) ([b8ce865](b8ce865))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.9.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Oct 17, 2023
# [2.10.0-alpha.1](v2.9.0...v2.10.0-alpha.1) (2023-10-17)

### Features

* add Perfmatters to managed plugins ([#2684](#2684)) ([eb657d8](eb657d8))
* **design-wizard:** allow bulk update of featured image, post template ([#2670](#2670)) ([37a4656](37a4656))
* newspack_managed_plugins filter ([#2605](#2605)) ([81ba5f2](81ba5f2))
* **reader-registration:** custom checkbox state for lists ([#2682](#2682)) ([b8ce865](b8ce865))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.10.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Oct 31, 2023
# [2.10.0](v2.9.1...v2.10.0) (2023-10-31)

### Features

* add Perfmatters to managed plugins ([#2684](#2684)) ([eb657d8](eb657d8))
* **data-events:** activecampaign connector ([#2663](#2663)) ([377a51f](377a51f))
* **design-wizard:** allow bulk update of featured image, post template ([#2670](#2670)) ([37a4656](37a4656))
* newspack_managed_plugins filter ([#2605](#2605)) ([81ba5f2](81ba5f2))
* **ras:** custom newsletter list selection on registration ([#2706](#2706)) ([57b2871](57b2871))
* **ras:** overlay management for content gate refresh ([#2708](#2708)) ([6767740](6767740))
* **reader-registration:** custom checkbox state for lists ([#2682](#2682)) ([b8ce865](b8ce865))
* remove order-received text ([#2707](#2707)) ([a386524](a386524))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

4 participants