Changeset 14078
- Timestamp:
- 09/25/2024 04:48:38 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-blueprint.php
r14075 r14078 195 195 if ( $helper_zip && $install_prh ) { 196 196 $steps[] = (object)[ 197 198 199 200 201 202 203 204 205 197 'step' => 'installPlugin', 198 'pluginZipFile' => [ 199 'resource' => 'url', 200 'url' => $helper_zip, 201 ], 202 'options' => (object)[ 203 'activate' => (bool)$activate_plugin 204 ] 205 ]; 206 206 } 207 207 … … 224 224 // Now the plugin itself 225 225 $steps[] = (object)[ 226 'step' => 'installPlugin', 227 'pluginZipFile' => (object)[ 228 'resource' => 'url', 229 'url' => $zip_url, 230 ], 231 'options' => (object)[ 232 'activate' => (bool)$activate_plugin 233 ] 234 ]; 226 'step' => 'installPlugin', 227 'pluginZipFile' => (object)[ 228 'resource' => 'url', 229 'url' => $zip_url, 230 ], 231 'options' => (object)[ 232 'activate' => (bool)$activate_plugin 233 ] 234 ]; 235 236 /* 237 * Maybe rename the plugin to exist in the expected folder. 238 * 239 * Temporary workaround for https://github.com/WordPress/wordpress-playground/issues/1802 240 */ 241 if ( ! str_starts_with( 'https://downloads.wordpress.org/', $zip_url ) ) { 242 $steps[] = (object)[ 243 'step' => 'runPHP', 244 'code' => '<?php 245 include "/wordpress/wp-load.php"; 246 $expected_slug = ' . var_export( $plugin->post_name, true ) . '; 247 $expected_plugins = ' . var_export( array_merge( [ 'plugin-check', 'playground-review-helper' ], $dependencies ), true ) . '; 248 $installed_plugins = array_diff( 249 array_map( "basename", glob( WP_PLUGIN_DIR . "/*", GLOB_ONLYDIR ) ), 250 $expected_plugins 251 ); 252 if ( 1 === count( $installed_plugins) ) { 253 $plugin_dir = reset( $installed_plugins ); 254 if ( $plugin_dir !== $expected_slug ) { 255 if ( rename( WP_PLUGIN_DIR . "/" . $plugin_dir, WP_PLUGIN_DIR . "/" . $expected_slug ) ) { 256 $active_plugins = get_option( "active_plugins" ); 257 foreach ( $active_plugins as &$active_plugin ) { 258 if ( 0 === strpos( $active_plugin, $plugin_dir ) ) { 259 $active_plugin = $expected_slug . substr( $active_plugin, strlen( $plugin_dir ) ); 260 } 261 } 262 update_option( "active_plugins", $active_plugins ); 263 } 264 } 265 } 266 ' 267 ]; 268 } 235 269 236 270 // Finally log in 237 271 $steps[] = (object)[ 238 239 240 241 272 'step' => 'login', 273 'username' => 'admin', 274 'password' => 'password', 275 ]; 242 276 243 277 $zip_blueprint->steps = $steps;
Note: See TracChangeset
for help on using the changeset viewer.