Changeset 62195 for branches/7.0/src/wp-includes/connectors.php
- Timestamp:
- 04/01/2026 04:41:40 PM (5 months ago)
- Location:
- branches/7.0
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/connectors.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/7.0
-
branches/7.0/src/wp-includes/connectors.php
r62194 r62195 59 59 * Optional. Plugin data for install/activate UI. 60 60 * 61 * @type string $slug The WordPress.org plugin slug. 61 * @type string $file The plugin's main file path relative to the plugins 62 * directory (e.g. 'akismet/akismet.php' or 'hello.php'). 62 63 * } 63 64 * } … … 75 76 * }, 76 77 * plugin?: array{ 77 * slug: non-empty-string78 * file: non-empty-string 78 79 * } 79 80 * } … … 119 120 * Optional. Plugin data for install/activate UI. 120 121 * 121 * @type string $slug The WordPress.org plugin slug. 122 * @type string $file The plugin's main file path relative to the plugins 123 * directory (e.g. 'akismet/akismet.php' or 'hello.php'). 122 124 * } 123 125 * } … … 136 138 * }, 137 139 * plugin?: array{ 138 * slug: non-empty-string140 * file: non-empty-string 139 141 * } 140 142 * }> … … 257 259 'type' => 'ai_provider', 258 260 'plugin' => array( 259 ' slug' => 'ai-provider-for-anthropic',261 'file' => 'ai-provider-for-anthropic/plugin.php', 260 262 ), 261 263 'authentication' => array( … … 269 271 'type' => 'ai_provider', 270 272 'plugin' => array( 271 ' slug' => 'ai-provider-for-google',273 'file' => 'ai-provider-for-google/plugin.php', 272 274 ), 273 275 'authentication' => array( … … 281 283 'type' => 'ai_provider', 282 284 'plugin' => array( 283 ' slug' => 'ai-provider-for-openai',285 'file' => 'ai-provider-for-openai/plugin.php', 284 286 ), 285 287 'authentication' => array( … … 637 639 $registry = AiClient::defaultRegistry(); 638 640 639 // Build a slug-to-file map for plugin installation status. 640 if ( ! function_exists( 'get_plugins' ) ) { 641 if ( ! function_exists( 'is_plugin_active' ) ) { 641 642 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 642 }643 $plugin_files_by_slug = array();644 foreach ( array_keys( get_plugins() ) as $plugin_file ) {645 $slug = str_contains( $plugin_file, '/' ) ? dirname( $plugin_file ) : str_replace( '.php', '', $plugin_file );646 $plugin_files_by_slug[ $slug ] = $plugin_file;647 643 } 648 644 … … 677 673 ); 678 674 679 if ( ! empty( $connector_data['plugin']['slug'] ) ) { 680 $plugin_slug = $connector_data['plugin']['slug']; 681 $plugin_file = $plugin_files_by_slug[ $plugin_slug ] ?? null; 682 683 $is_installed = null !== $plugin_file; 684 $is_activated = $is_installed && is_plugin_active( $plugin_file ); 675 if ( ! empty( $connector_data['plugin']['file'] ) ) { 676 $file = $connector_data['plugin']['file']; 677 $is_installed = file_exists( wp_normalize_path( WP_PLUGIN_DIR . '/' . $file ) ); 678 $is_activated = $is_installed && is_plugin_active( $file ); 685 679 686 680 $connector_out['plugin'] = array( 687 'slug' => $plugin_slug, 688 'pluginFile' => $is_installed 689 ? ( str_ends_with( $plugin_file, '.php' ) ? substr( $plugin_file, 0, -4 ) : $plugin_file ) 690 : null, 681 'file' => $file, 682 'isInstalled' => $is_installed, 691 683 'isActivated' => $is_activated, 692 684 );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)