WordPress.org

Make WordPress Core

Ticket #38673: patch-38673.diff

File patch-38673.diff, 4.0 KB (added by MaximeCulea, 3 years ago)
  • src/wp-admin/includes/class-wp-automatic-updater.php

    diff --git c/src/wp-admin/includes/class-wp-automatic-updater.php w/src/wp-admin/includes/class-wp-automatic-updater.php
    index ea2d70c..3922a0b 100644
    c w class WP_Automatic_Updater { 
    3131         */
    3232        public function is_disabled() {
    3333                // Background updates are disabled if you don't want file changes.
    34                 if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
     34                if ( wp_disallow_file_mods( 'automatic_updater' ) )
    3535                        return true;
    3636
    3737                if ( wp_installing() )
  • src/wp-admin/includes/dashboard.php

    diff --git c/src/wp-admin/includes/dashboard.php w/src/wp-admin/includes/dashboard.php
    index aab5976..906b410 100644
    c w function wp_dashboard_primary() { 
    11491149                )
    11501150        );
    11511151
    1152         if ( ( ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS ) && ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) {
     1152        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' ) ) ) {
    11531153                $feeds['plugins'] = array(
    11541154                        'link'         => '',
    11551155                        'url'          => array(
  • src/wp-admin/includes/translation-install.php

    diff --git c/src/wp-admin/includes/translation-install.php w/src/wp-admin/includes/translation-install.php
    index ee8254d..c9e942e 100644
    c w function wp_download_language_pack( $download ) { 
    181181                return $download;
    182182        }
    183183
    184         if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
     184        if ( wp_disallow_file_mods( 'download_language_pack' ) ) {
    185185                return false;
    186186        }
    187187
    function wp_download_language_pack( $download ) { 
    224224 * @return bool Returns true on success, false on failure.
    225225 */
    226226function wp_can_install_language_pack() {
    227         if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
     227        if ( wp_disallow_file_mods( 'can_install_language_pack' ) ) {
    228228                return false;
    229229        }
    230230
  • src/wp-includes/capabilities.php

    diff --git c/src/wp-includes/capabilities.php w/src/wp-includes/capabilities.php
    index fe87bc8..92e6311 100644
    c w function map_meta_cap( $cap, $user_id ) { 
    336336                // Disallow the file editors.
    337337                if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT )
    338338                        $caps[] = 'do_not_allow';
    339                 elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS )
     339                elseif ( wp_disallow_file_mods( 'capability_edit_themes' ) )
    340340                        $caps[] = 'do_not_allow';
    341341                elseif ( is_multisite() && ! is_super_admin( $user_id ) )
    342342                        $caps[] = 'do_not_allow';
    function map_meta_cap( $cap, $user_id ) { 
    354354        case 'update_core':
    355355                // Disallow anything that creates, deletes, or updates core, plugin, or theme files.
    356356                // Files in uploads are excepted.
    357                 if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
     357                if ( wp_disallow_file_mods( 'capability_update_core' ) ) {
    358358                        $caps[] = 'do_not_allow';
    359359                } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
    360360                        $caps[] = 'do_not_allow';
  • src/wp-includes/load.php

    diff --git c/src/wp-includes/load.php w/src/wp-includes/load.php
    index 42e2b71..5eff9c9 100644
    c w function wp_doing_ajax() { 
    10641064function is_wp_error( $thing ) {
    10651065        return ( $thing instanceof WP_Error );
    10661066}
     1067
     1068/**
     1069 * Determines whether file modifications are disallowed.
     1070 *
     1071 * @since 4.7.0
     1072 *
     1073 * @param string $context : where it has been called from
     1074 * @return bool : True if file modification is disallowed, False otherwise.
     1075 */
     1076function wp_disallow_file_mods( $context ) {
     1077        return apply_filters( "disallow_file_mods_{$context}" , defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS );
     1078}
     1079 No newline at end of file