Skip to content

Commit 02a6150

Browse files
enhacements
1 parent 7ac8cf5 commit 02a6150

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

‎lib/compat/wordpress-7.0/class-wp-connector-registry.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ final class WP_Connector_Registry {
9898
* Optional. Plugin data for install/activate UI.
9999
*
100100
* @type string $file The plugin's main file path relative to the plugins
101-
* directory (e.g. 'akismet/akismet.php').
101+
* directory (e.g. 'akismet/akismet.php' or 'hello.php').
102102
* }
103103
* }
104104
* @return array|null The registered connector data on success, null on failure.
@@ -231,8 +231,8 @@ public function register( string $id, array $args ): ?array {
231231
}
232232
}
233233

234-
if ( ! empty( $args['plugin'] ) && is_array( $args['plugin'] ) ) {
235-
$connector['plugin'] = $args['plugin'];
234+
if ( ! empty( $args['plugin'] ) && is_array( $args['plugin'] ) && ! empty( $args['plugin']['file'] ) ) {
235+
$connector['plugin'] = array( 'file' => $args['plugin']['file'] );
236236
}
237237

238238
$this->registered_connectors[ $id ] = $connector;

‎lib/experimental/connectors/default-connectors.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ function _gutenberg_get_connector_script_module_data( array $data ): array {
529529
$is_activated = $is_installed && is_plugin_active( $file );
530530

531531
$connector_out['plugin'] = array(
532-
'file' => str_ends_with( $file, '.php' ) ? substr( $file, 0, -4 ) : $file,
532+
'file' => $file,
533533
'isInstalled' => $is_installed,
534534
'isActivated' => $is_activated,
535535
);

‎routes/connectors-home/default-connectors.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ function ApiKeyConnector( {
104104
authentication?.method === 'api_key' ? authentication : undefined;
105105
const settingName = auth?.settingName ?? '';
106106
const helpUrl = auth?.credentialsUrl ?? undefined;
107-
const pluginSlug = plugin?.file?.includes( '/' )
108-
? plugin.file.split( '/' )[ 0 ]
109-
: plugin?.file;
107+
const pluginFile = plugin?.file?.replace( /\.php$/, '' );
108+
const pluginSlug = pluginFile?.includes( '/' )
109+
? pluginFile.split( '/' )[ 0 ]
110+
: pluginFile;
110111

111112
let helpLabel: string | undefined;
112113
try {

‎routes/connectors-home/use-connector-plugin.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ export function useConnectorPlugin( {
5454
const [ pluginStatusOverride, setPluginStatusOverride ] =
5555
useState< PluginStatus | null >( null );
5656

57-
const pluginSlug = pluginFileFromServer?.includes( '/' )
58-
? pluginFileFromServer.split( '/' )[ 0 ]
59-
: pluginFileFromServer;
57+
const pluginBasename = pluginFileFromServer?.replace( /\.php$/, '' );
58+
const pluginSlug = pluginBasename?.includes( '/' )
59+
? pluginBasename.split( '/' )[ 0 ]
60+
: pluginBasename;
6061

6162
const {
6263
derivedPluginStatus,
@@ -94,12 +95,12 @@ export function useConnectorPlugin( {
9495
const plugin = store.getEntityRecord(
9596
'root',
9697
'plugin',
97-
pluginFileFromServer
98+
pluginBasename
9899
) as { plugin: string; status: string } | undefined;
99100

100101
const hasFinished = store.hasFinishedResolution(
101102
'getEntityRecord',
102-
[ 'root', 'plugin', pluginFileFromServer ]
103+
[ 'root', 'plugin', pluginBasename ]
103104
);
104105

105106
if ( ! hasFinished ) {
@@ -139,7 +140,7 @@ export function useConnectorPlugin( {
139140
canInstallPlugins: canCreate,
140141
};
141142
},
142-
[ pluginFileFromServer, settingName, isInstalled, isActivated ]
143+
[ pluginBasename, settingName, isInstalled, isActivated ]
143144
);
144145

145146
const pluginStatus = pluginStatusOverride ?? derivedPluginStatus;
@@ -202,7 +203,7 @@ export function useConnectorPlugin( {
202203
'root',
203204
'plugin',
204205
{
205-
plugin: pluginFileFromServer,
206+
plugin: pluginBasename,
206207
status: 'active',
207208
},
208209
{ throwOnError: true }

0 commit comments

Comments
 (0)