Skip to content
Draft
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
4 changes: 0 additions & 4 deletions src/wp-includes/class-wp-connector-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ public function register( string $id, array $args ): ?array {
}
}

if ( ! isset( $connector['plugin']['is_active'] ) ) {
$connector['plugin']['is_active'] = '__return_true';
}

Comment on lines -273 to -276
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.

Remove Defaults to __return_true. from line no 118

$this->registered_connectors[ $id ] = $connector;
return $connector;
}
Expand Down
9 changes: 7 additions & 2 deletions src/wp-includes/connectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,13 @@ function _wp_connectors_get_connector_script_module_data( array $data ): array {
);

if ( ! empty( $connector_data['plugin']['file'] ) ) {
$file = $connector_data['plugin']['file'];
$is_activated = (bool) call_user_func( $connector_data['plugin']['is_active'] );
$file = $connector_data['plugin']['file'];
if ( ! isset( $connector_data['plugin']['is_active'] ) ) {
// Assume plugin has registered own connector and is therefore active.
$is_activated = true;
} else {
$is_activated = (bool) call_user_func( $connector_data['plugin']['is_active'] );
}
$is_installed = $is_activated || file_exists( wp_normalize_path( WP_PLUGIN_DIR . '/' . $file ) );

$connector_out['plugin'] = array(
Expand Down
7 changes: 3 additions & 4 deletions tests/phpunit/tests/connectors/wpConnectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,14 @@ public function test_register_rejects_non_callable_plugin_is_active() {
/**
* @ticket 65020
*/
public function test_register_defaults_plugin_is_active_to_return_true() {
public function test_register_omits_plugin_is_active_when_not_provided() {
$args = self::$default_args;
$args['plugin'] = array( 'file' => 'my-plugin/my-plugin.php' );

$result = $this->registry->register( 'default-callback', $args );

$this->assertIsArray( $result );
$this->assertArrayHasKey( 'is_active', $result['plugin'] );
$this->assertSame( '__return_true', $result['plugin']['is_active'] );
$this->assertArrayNotHasKey( 'is_active', $result['plugin'] );
}

/**
Expand All @@ -358,7 +357,7 @@ public function test_register_defaults_plugin_when_not_provided() {

$this->assertArrayHasKey( 'plugin', $result );
$this->assertArrayNotHasKey( 'file', $result['plugin'] );
$this->assertSame( '__return_true', $result['plugin']['is_active'] );
$this->assertArrayNotHasKey( 'is_active', $result['plugin'] );
}

/**
Expand Down
Loading