WordPress.org

Make WordPress Core

Ticket #45888: 44458.diff

File 44458.diff, 6.7 KB (added by TimothyBlynJacobs, 3 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  
    3131 *     Network: Optional. Specify "Network: true" to require that a plugin is activated
    3232 *          across all sites in an installation. This will prevent a plugin from being
    3333 *          activated on a single site when Multisite is enabled.
     34 *     Allow Pausing: Optional. Specify "Allow Pausing: false" to disable extension pausing.
    3435 *      * / # Remove the space to close comment
    3536 *
    3637 * Some users have issues with opening large files and manipulating the contents
     
    4647 * reading.
    4748 *
    4849 * @since 1.5.0
     50 * @since 5.1.0 Added 'AllowPausing' header.
    4951 *
    5052 * @param string $plugin_file Absolute path to the main plugin file.
    5153 * @param bool   $markup      Optional. If the returned data should have HTML markup applied.
     
    5456 * @return array {
    5557 *     Plugin data. Values will be empty if not supplied by the plugin.
    5658 *
    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.
    6669 * }
    6770 */
    6871function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
    6972
    7073        $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',
    8084                // Site Wide Only is deprecated in favor of Network.
    81                 '_sitewide'   => 'Site Wide Only',
     85                '_sitewide'    => 'Site Wide Only',
    8286        );
    8387
    8488        $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
    function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { 
    9094                $plugin_data['Network'] = $plugin_data['_sitewide'];
    9195        }
    9296        $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
     97        $plugin_data['AllowPausing'] = 'false' !== strtolower( $plugin_data['AllowPausing'] );
    9398        unset( $plugin_data['_sitewide'] );
    9499
    95100        // 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 ) { 
    6767        if ( 0 === strpos( $error_file, $wp_plugin_dir ) ) {
    6868                $callback = 'wp_paused_plugins';
    6969                $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
    7081        } else {
    7182                foreach ( $wp_theme_directories as $theme_directory ) {
    7283                        $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() { 
    88                $data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' );
    99
    1010                $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,
    2021                );
    2122
    2223                $this->assertTrue( is_array( $data ) );
    2324
    2425                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 );
    2728                }
    2829        }
    2930