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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Test bootstrap only: ignore a wpcomsh module policy in the wpcomsh test run.


3 changes: 3 additions & 0 deletions projects/plugins/jetpack/tests/php/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ function _manually_load_muplugin() {
require_once JETPACK_WPCOMSH_INSTALL_DIR . '/wpcomsh.php';
\Automattic\Jetpack\Jetpack_Mu_Wpcom::init();

// Module-state tests assume self-hosted defaults, which this policy overrides.
remove_filter( 'jetpack_feature_policy', 'wpcomsh_force_activity_log_module' );

defined( 'WPCOMSH_PREMIUM_THEMES_PATH' ) || define( 'WPCOMSH_PREMIUM_THEMES_PATH', sys_get_temp_dir() . '/premium' );
if ( ! is_dir( WPCOMSH_PREMIUM_THEMES_PATH ) ) {
mkdir( WPCOMSH_PREMIUM_THEMES_PATH, 0777 );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Activity Log: Keep the Activity Log on for all sites, including newly transferred and reset ones.
29 changes: 29 additions & 0 deletions projects/plugins/wpcomsh/feature-plugins/activity-log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Keep the Jetpack Activity Log on for every Atomic site.
*
* @package wpcomsh
*/

/**
* Force the Activity Log module on through Jetpack's feature policy.
*
* @param array $policy Map of feature slug to policy.
* @param string|null $jetpack_version Jetpack version to check, defaulting to the running one.
* @return array
*/
function wpcomsh_force_activity_log_module( $policy, $jetpack_version = null ) {
if ( null === $jetpack_version && defined( 'JETPACK__VERSION' ) ) {
$jetpack_version = JETPACK__VERSION;
}

// Older builds have no module, and forcing an unknown slug triggers _doing_it_wrong().
if ( ! $jetpack_version || version_compare( $jetpack_version, '16.3-a.3', '<' ) ) {
return $policy;
}

$policy['activity-log'] = array( 'activation' => 'forced-on' );

return $policy;
}
add_filter( 'jetpack_feature_policy', 'wpcomsh_force_activity_log_module' );
50 changes: 50 additions & 0 deletions projects/plugins/wpcomsh/tests/ActivityLogTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Activity Log feature plugin test file.
*
* @package wpcomsh
*/

use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Class ActivityLogTest.
*
* @covers ::wpcomsh_force_activity_log_module
*/
#[CoversFunction( 'wpcomsh_force_activity_log_module' )]
class ActivityLogTest extends WP_UnitTestCase {
use \Automattic\Jetpack\PHPUnit\WP_UnitTestCase_Fix;

/**
* Tests that the module is forced on only for Jetpack builds that ship it.
*
* @dataProvider version_provider
*
* @param string $jetpack_version Jetpack version.
* @param bool $forced Whether the module should be forced on.
*/
#[DataProvider( 'version_provider' )]
public function test_forces_module_on_only_when_jetpack_ships_it( $jetpack_version, $forced ) {
$existing = array( 'stats' => array( 'activation' => 'forced-on' ) );
$expected = $forced
? array_merge( $existing, array( 'activity-log' => array( 'activation' => 'forced-on' ) ) )
: $existing;

$this->assertSame( $expected, wpcomsh_force_activity_log_module( $existing, $jetpack_version ) );
}

/**
* Data provider for test_forces_module_on_only_when_jetpack_ships_it.
*
* @return array
*/
public static function version_provider() {
return array(
'before the module' => array( '16.2', false ),
'prerelease build' => array( '16.3-beta', true ),
'release' => array( '16.3', true ),
);
}
}
3 changes: 2 additions & 1 deletion projects/plugins/wpcomsh/woa.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ function wpcomsh_woa_post_process_store_woocommerce_connection_details( $args, $

/**
* Ensures that specific Jetpack modules are activated after a transfer.
* Addresses the issue where certain modules like blocks, account-protection, blaze, and wpcom-reader
* Addresses the issue where certain modules like blocks, account-protection, activity-log, blaze, and wpcom-reader
* may be disabled during the transfer process.
*
* @param array $args Arguments.
Expand All @@ -460,6 +460,7 @@ function wpcomsh_woa_post_process_activate_jetpack_modules( $args, $assoc_args )

$modules_to_activate = array(
'account-protection',
'activity-log',
'blaze',
'blocks',
'wpcom-reader',
Expand Down
1 change: 1 addition & 0 deletions projects/plugins/wpcomsh/wpcomsh.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function () {
require_once __DIR__ . '/endpoints/rest-api.php';

// Load feature plugins.
require_once __DIR__ . '/feature-plugins/activity-log.php';
require_once __DIR__ . '/feature-plugins/activitypub.php';
require_once __DIR__ . '/feature-plugins/additional-css.php';
require_once __DIR__ . '/feature-plugins/ai-launchpad.php';
Expand Down
Loading