Make WordPress Core

Ticket #51190: 51190.diff

File 51190.diff, 2.8 KB (added by imath, 5 years ago)
  • src/wp-admin/includes/template.php

    diff --git src/wp-admin/includes/template.php src/wp-admin/includes/template.php
    index ad87a89521..f1b024d9f5 100644
    function do_settings_sections( $page ) { 
    16971697        }
    16981698}
    16991699
     1700/**
     1701 * Check whether a particular settings section has settings fields.
     1702 *
     1703 * @global array $wp_settings_fields Storage array of settings fields and their pages/sections.
     1704 *
     1705 * @since 5.6.0
     1706 *
     1707 * @param string $page Slug title of the admin page whose settings fields you want to check.
     1708 * @param string $section Slug title of the settings section whose fields you want to check.
     1709 * @return bool True if the settings section has settings fields. False otherwise.
     1710 */
     1711function has_settings_fields( $page, $section ) {
     1712        global $wp_settings_fields;
     1713
     1714        return isset( $wp_settings_fields[ $page ][ $section ] ) && $wp_settings_fields[ $page ][ $section ];
     1715}
     1716
    17001717/**
    17011718 * Print out the settings fields for a particular settings section.
    17021719 *
  • src/wp-admin/options-media.php

    diff --git src/wp-admin/options-media.php src/wp-admin/options-media.php
    index 6236b20f6d..425a8bbea5 100644
    if ( ! current_user_can( 'manage_options' ) ) { 
    1313        wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
    1414}
    1515
    16 $title       = __( 'Media Settings' );
    17 $parent_file = 'options-general.php';
     16$title                = __( 'Media Settings' );
     17$parent_file          = 'options-general.php';
     18$can_edit_uploads_dir = false;
    1819
    1920$media_options_help = '<p>' . __( 'You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.' ) . '</p>';
    2021
    if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : 
    107108<h2 class="title"><?php _e( 'Uploading Files' ); ?></h2>
    108109<table class="form-table" role="presentation">
    109110        <?php
     111        $can_edit_uploads_dir = get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) !== 'wp-content/uploads' && get_option( 'upload_path' ) );
    110112        /*
    111113         * If upload_url_path is not the default (empty),
    112114         * or upload_path is not the default ('wp-content/uploads' or empty),
    113115         * they can be edited, otherwise they're locked.
    114116         */
    115         if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) :
     117        if ( $can_edit_uploads_dir ) :
    116118                ?>
    117119<tr>
    118120<th scope="row"><label for="upload_path"><?php _e( 'Store uploads in this folder' ); ?></label></th>
    if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : 
    132134<p class="description"><?php _e( 'Configuring this is optional. By default, it should be blank.' ); ?></p>
    133135</td>
    134136</tr>
     137<?php endif; ?>
     138
     139<?php if ( $can_edit_uploads_dir || has_settings_fields( 'media', 'uploads' ) ) : ?>
    135140<tr>
    136141<td colspan="2" class="td-full">
    137142<?php else : ?>