WordPress.org

Make WordPress Core

Ticket #38673: patch-38673-6.diff

File patch-38673-6.diff, 5.5 KB (added by Mte90, 2 years ago)

changed the approach for the new function name

  • src/wp-admin/includes/class-wp-automatic-updater.php

    From b8f3e8d59a89bf7371921dc06a4893d99b5366d7 Mon Sep 17 00:00:00 2001
    From: Maxime Culea <culea.maxime@gmail.com>
    Date: Sun, 23 Apr 2017 10:43:07 +0200
    Subject: [PATCH 1/2] #38673 : Change method usage name from
     "wp_disallow_file_mods" to "wp_is_file_mod_allowed"
    
    ---
     src/wp-admin/includes/class-wp-automatic-updater.php | 2 +-
     src/wp-admin/includes/dashboard.php                  | 2 +-
     src/wp-admin/includes/translation-install.php        | 4 ++--
     src/wp-includes/capabilities.php                     | 4 ++--
     src/wp-includes/load.php                             | 2 +-
     5 files changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php
    index 3922a0b..9321f2c 100644
    a b class WP_Automatic_Updater { 
    3131         */
    3232        public function is_disabled() {
    3333                // Background updates are disabled if you don't want file changes.
    34                 if ( wp_disallow_file_mods( 'automatic_updater' ) )
     34                if ( ! wp_is_file_mod_allowed( 'automatic_updater' ) )
    3535                        return true;
    3636
    3737                if ( wp_installing() )
  • src/wp-admin/includes/dashboard.php

    diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php
    index b763d43..35bfa49 100644
    a b function wp_dashboard_primary() { 
    11521152                )
    11531153        );
    11541154
    1155         if ( ( ! wp_disallow_file_mods( 'dashboard_widget' ) ) && ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) {
     1155        if ( ( wp_is_file_mod_allowed( 'dashboard_widget' ) ) && ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) {
    11561156                $feeds['plugins'] = array(
    11571157                        'link'         => '',
    11581158                        'url'          => array(
  • src/wp-admin/includes/translation-install.php

    diff --git a/src/wp-admin/includes/translation-install.php b/src/wp-admin/includes/translation-install.php
    index e65ec27..5fd9816 100644
    a b function wp_download_language_pack( $download ) { 
    202202                return $download;
    203203        }
    204204
    205         if ( wp_disallow_file_mods( 'download_language_pack' ) ) {
     205        if ( ! wp_is_file_mod_allowed( 'download_language_pack' ) ) {
    206206                return false;
    207207        }
    208208
    function wp_download_language_pack( $download ) { 
    245245 * @return bool Returns true on success, false on failure.
    246246 */
    247247function wp_can_install_language_pack() {
    248         if ( wp_disallow_file_mods( 'can_install_language_pack' ) ) {
     248        if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
    249249                return false;
    250250        }
    251251
  • src/wp-includes/capabilities.php

    diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php
    index abd8725..c903ff0 100644
    a b function map_meta_cap( $cap, $user_id ) { 
    362362                // Disallow the file editors.
    363363                if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
    364364                        $caps[] = 'do_not_allow';
    365                 elseif ( wp_disallow_file_mods( 'capability_edit_themes' ) )
     365                elseif ( ! wp_is_file_mod_allowed( 'capability_edit_themes' ) )
    366366                        $caps[] = 'do_not_allow';
    367367                elseif ( is_multisite() && ! is_super_admin( $user_id ) )
    368368                        $caps[] = 'do_not_allow';
    function map_meta_cap( $cap, $user_id ) { 
    380380        case 'update_core':
    381381                // Disallow anything that creates, deletes, or updates core, plugin, or theme files.
    382382                // Files in uploads are excepted.
    383                 if ( wp_disallow_file_mods( 'capability_update_core' ) ) {
     383                if ( ! wp_is_file_mod_allowed( 'capability_update_core' ) ) {
    384384                        $caps[] = 'do_not_allow';
    385385                } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
    386386                        $caps[] = 'do_not_allow';
  • src/wp-includes/load.php

    diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php
    index a8f730e..50d87bb 100644
    a b function is_wp_error( $thing ) { 
    10811081 * @param string $context The usage context.
    10821082 * @return bool True if file modification is disallowed, false otherwise.
    10831083 */
    1084 function wp_disallow_file_mods( $context ) {
     1084function wp_is_file_mod_allowed( $context ) {
    10851085        /**
    10861086         * Filters whether file modifications are disallowed.
    10871087         *
  • src/wp-includes/load.php

    --
    2.9.0
    
    
    From 32e32e307b9c08266358abb61bc618409450c977 Mon Sep 17 00:00:00 2001
    From: Maxime Culea <culea.maxime@gmail.com>
    Date: Sun, 23 Apr 2017 10:43:44 +0200
    Subject: [PATCH 2/2] #38673 : Some documentation and refactoring.
    
    ---
     src/wp-includes/load.php | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php
    index 50d87bb..b593f88 100644
    a b function wp_is_file_mod_allowed( $context ) { 
    10871087         *
    10881088         * @since 4.8.0
    10891089         *
    1090          * @param bool   $disllow_file_mods Whether file modifications are disallowed.
    1091          * @param string $context           The usage context.
     1090         * @param bool   $disallow_file_mods Whether file modifications are disallowed.
     1091         * @param string $context            The usage context.
    10921092         */
    1093         return apply_filters( 'disallow_file_mods' , defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS, $context );
     1093        return apply_filters( 'disallow_file_mods', defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS, $context );
    10941094}