Ticket #45888: 44458.diff
File 44458.diff, 6.7 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/plugin.php
diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 412c5330e4..f46b718225 100644
a b 31 31 * Network: Optional. Specify "Network: true" to require that a plugin is activated 32 32 * across all sites in an installation. This will prevent a plugin from being 33 33 * activated on a single site when Multisite is enabled. 34 * Allow Pausing: Optional. Specify "Allow Pausing: false" to disable extension pausing. 34 35 * * / # Remove the space to close comment 35 36 * 36 37 * Some users have issues with opening large files and manipulating the contents … … 46 47 * reading. 47 48 * 48 49 * @since 1.5.0 50 * @since 5.1.0 Added 'AllowPausing' header. 49 51 * 50 52 * @param string $plugin_file Absolute path to the main plugin file. 51 53 * @param bool $markup Optional. If the returned data should have HTML markup applied. … … 54 56 * @return array { 55 57 * Plugin data. Values will be empty if not supplied by the plugin. 56 58 * 57 * @type string $Name Name of the plugin. Should be unique. 58 * @type string $Title Title of the plugin and link to the plugin's site (if set). 59 * @type string $Description Plugin description. 60 * @type string $Author Author's name. 61 * @type string $AuthorURI Author's website address (if set). 62 * @type string $Version Plugin version. 63 * @type string $TextDomain Plugin textdomain. 64 * @type string $DomainPath Plugins relative directory path to .mo files. 65 * @type bool $Network Whether the plugin can only be activated network-wide. 59 * @type string $Name Name of the plugin. Should be unique. 60 * @type string $Title Title of the plugin and link to the plugin's site (if set). 61 * @type string $Description Plugin description. 62 * @type string $Author Author's name. 63 * @type string $AuthorURI Author's website address (if set). 64 * @type string $Version Plugin version. 65 * @type string $TextDomain Plugin textdomain. 66 * @type string $DomainPath Plugins relative directory path to .mo files. 67 * @type bool $Network Whether the plugin can only be activated network-wide. 68 * @type bool $AllowPausing Extension pausing support. 66 69 * } 67 70 */ 68 71 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { 69 72 70 73 $default_headers = array( 71 'Name' => 'Plugin Name', 72 'PluginURI' => 'Plugin URI', 73 'Version' => 'Version', 74 'Description' => 'Description', 75 'Author' => 'Author', 76 'AuthorURI' => 'Author URI', 77 'TextDomain' => 'Text Domain', 78 'DomainPath' => 'Domain Path', 79 'Network' => 'Network', 74 'Name' => 'Plugin Name', 75 'PluginURI' => 'Plugin URI', 76 'Version' => 'Version', 77 'Description' => 'Description', 78 'Author' => 'Author', 79 'AuthorURI' => 'Author URI', 80 'TextDomain' => 'Text Domain', 81 'DomainPath' => 'Domain Path', 82 'Network' => 'Network', 83 'AllowPausing' => 'Allow Pausing', 80 84 // Site Wide Only is deprecated in favor of Network. 81 '_sitewide' => 'Site Wide Only',85 '_sitewide' => 'Site Wide Only', 82 86 ); 83 87 84 88 $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); … … function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { 90 94 $plugin_data['Network'] = $plugin_data['_sitewide']; 91 95 } 92 96 $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); 97 $plugin_data['AllowPausing'] = 'false' !== strtolower( $plugin_data['AllowPausing'] ); 93 98 unset( $plugin_data['_sitewide'] ); 94 99 95 100 // If no text domain is defined fall back to the plugin slug. -
src/wp-includes/error-protection.php
diff --git a/src/wp-includes/error-protection.php b/src/wp-includes/error-protection.php index f12bd2409f..af4e1aac6d 100644
a b function wp_record_extension_error( $error ) { 67 67 if ( 0 === strpos( $error_file, $wp_plugin_dir ) ) { 68 68 $callback = 'wp_paused_plugins'; 69 69 $path = str_replace( $wp_plugin_dir . '/', '', $error_file ); 70 71 if ( ! function_exists( 'get_plugin_data' ) ) { 72 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 73 } 74 75 $plugin_data = get_plugin_data( $wp_plugin_dir . '/' . $path, false, false ); 76 77 if ( ! $plugin_data['AllowPausing'] ) { 78 return false; 79 } 80 70 81 } else { 71 82 foreach ( $wp_theme_directories as $theme_directory ) { 72 83 $theme_directory = wp_normalize_path( $theme_directory ); -
tests/phpunit/tests/admin/includesPlugin.php
diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index 0526801417..bfeb96bd81 100644
a b function test_get_plugin_data() { 8 8 $data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' ); 9 9 10 10 $default_headers = array( 11 'Name' => 'Hello Dolly', 12 'Title' => '<a href="http://wordpress.org/#">Hello Dolly</a>', 13 'PluginURI' => 'http://wordpress.org/#', 14 'Description' => 'This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page. <cite>By <a href="http://ma.tt/">Matt Mullenweg</a>.</cite>', 15 'Author' => '<a href="http://ma.tt/">Matt Mullenweg</a>', 16 'AuthorURI' => 'http://ma.tt/', 17 'Version' => '1.5.1', 18 'TextDomain' => 'hello-dolly', 19 'DomainPath' => '', 11 'Name' => 'Hello Dolly', 12 'Title' => '<a href="http://wordpress.org/#">Hello Dolly</a>', 13 'PluginURI' => 'http://wordpress.org/#', 14 'Description' => 'This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page. <cite>By <a href="http://ma.tt/">Matt Mullenweg</a>.</cite>', 15 'Author' => '<a href="http://ma.tt/">Matt Mullenweg</a>', 16 'AuthorURI' => 'http://ma.tt/', 17 'Version' => '1.5.1', 18 'TextDomain' => 'hello-dolly', 19 'DomainPath' => '', 20 'AllowPausing' => true, 20 21 ); 21 22 22 23 $this->assertTrue( is_array( $data ) ); 23 24 24 25 foreach ( $default_headers as $name => $value ) { 25 $this->assertTrue( isset( $data[ $name ] ) );26 $this->assertEquals( $value, $data[ $name ] );26 $this->assertTrue( isset( $data[ $name ] ), 'Header ' . $name ); 27 $this->assertEquals( $value, $data[ $name ], 'Header ' . $name ); 27 28 } 28 29 } 29 30