Make WordPress Core

Ticket #44441: 44441.diff

File 44441.diff, 7.1 KB (added by johnregan3, 5 years ago)

Intial patch

  • src/wp-admin/includes/template.php

    diff --git src/wp-admin/includes/template.php src/wp-admin/includes/template.php
    index 4228d931ba..ce719ded24 100644
    function _wp_block_editor_posts_page_notice() {  
    27002700                'after'
    27012701        );
    27022702}
     2703
     2704/**
     2705 * Determine if Image Size settings should be displayed on the Media options page.
     2706 *
     2707 * The image size settings should not be displayed unless they have
     2708 * previously been edited. This value can be filtered.
     2709 *
     2710 * @return bool If the image size settings should be displayed.
     2711 */
     2712function wp_media_options_should_display_image_size_settings() {
     2713
     2714        // Hide the settings by default.
     2715        $should_display = false;
     2716
     2717        /*
     2718         * Image size option names, along with default values.
     2719         * @see wp-admin/includes/schema.php
     2720         */
     2721        $image_sizes = array(
     2722                'large_size_h'     => 1024,
     2723                'large_size_w'     => 1024,
     2724                'medium_size_h'    => 300,
     2725                'medium_size_w'    => 300,
     2726                'thumbnail_size_h' => 150,
     2727                'thumbnail_size_w' => 150,
     2728                'thumbnail_crop'   => 1,
     2729        );
     2730
     2731        foreach ( $image_sizes as $label => $default ) {
     2732                $value = get_option( $label );
     2733                if ( intval( $value ) !== $default ) {
     2734                        $should_display = true;
     2735                        break;
     2736                }
     2737        }
     2738
     2739        /**
     2740         * Filter if the image size settings should be displayed on the Media options page.
     2741         *
     2742         * If the default settings have not been edited, then hide these settings
     2743         * from users. This filter allows developers to modify this value.
     2744         *
     2745         * @param bool $should_display If the settings should be displayed.
     2746         *
     2747         * @return bool If the Media Settings page should display the Image Size settings.
     2748         */
     2749        return apply_filters( 'wp_media_options_should_display_image_size_settings', $should_display );
     2750}
  • src/wp-admin/options-media.php

    diff --git src/wp-admin/options-media.php src/wp-admin/options-media.php
    index 79f4389e88..8ac7a1f9b2 100644
    require_once ABSPATH . 'wp-admin/admin-header.php';  
    5252<form action="options.php" method="post">
    5353<?php settings_fields( 'media' ); ?>
    5454
    55 <h2 class="title"><?php _e( 'Image sizes' ); ?></h2>
    56 <p><?php _e( 'The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.' ); ?></p>
    57 
    58 <table class="form-table" role="presentation">
    59 <tr>
    60 <th scope="row"><?php _e( 'Thumbnail size' ); ?></th>
    61 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Thumbnail size' ); ?></span></legend>
    62 <label for="thumbnail_size_w"><?php _e( 'Width' ); ?></label>
    63 <input name="thumbnail_size_w" type="number" step="1" min="0" id="thumbnail_size_w" value="<?php form_option( 'thumbnail_size_w' ); ?>" class="small-text" />
    64 <br />
    65 <label for="thumbnail_size_h"><?php _e( 'Height' ); ?></label>
    66 <input name="thumbnail_size_h" type="number" step="1" min="0" id="thumbnail_size_h" value="<?php form_option( 'thumbnail_size_h' ); ?>" class="small-text" />
    67 </fieldset>
    68 <input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked( '1', get_option( 'thumbnail_crop' ) ); ?>/>
    69 <label for="thumbnail_crop"><?php _e( 'Crop thumbnail to exact dimensions (normally thumbnails are proportional)' ); ?></label>
    70 </td>
    71 </tr>
    72 
    73 <tr>
    74 <th scope="row"><?php _e( 'Medium size' ); ?></th>
    75 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Medium size' ); ?></span></legend>
    76 <label for="medium_size_w"><?php _e( 'Max Width' ); ?></label>
    77 <input name="medium_size_w" type="number" step="1" min="0" id="medium_size_w" value="<?php form_option( 'medium_size_w' ); ?>" class="small-text" />
    78 <br />
    79 <label for="medium_size_h"><?php _e( 'Max Height' ); ?></label>
    80 <input name="medium_size_h" type="number" step="1" min="0" id="medium_size_h" value="<?php form_option( 'medium_size_h' ); ?>" class="small-text" />
    81 </fieldset></td>
    82 </tr>
    83 
    84 <tr>
    85 <th scope="row"><?php _e( 'Large size' ); ?></th>
    86 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Large size' ); ?></span></legend>
    87 <label for="large_size_w"><?php _e( 'Max Width' ); ?></label>
    88 <input name="large_size_w" type="number" step="1" min="0" id="large_size_w" value="<?php form_option( 'large_size_w' ); ?>" class="small-text" />
    89 <br />
    90 <label for="large_size_h"><?php _e( 'Max Height' ); ?></label>
    91 <input name="large_size_h" type="number" step="1" min="0" id="large_size_h" value="<?php form_option( 'large_size_h' ); ?>" class="small-text" />
    92 </fieldset></td>
    93 </tr>
    94 
    95 <?php do_settings_fields( 'media', 'default' ); ?>
    96 </table>
     55<?php if ( true === wp_media_options_should_display_image_size_settings() ) : ?>
     56        <h2 class="title"><?php _e( 'Image sizes' ); ?></h2>
     57        <p><?php _e( 'The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.' ); ?></p>
     58
     59        <table class="form-table" role="presentation">
     60        <tr>
     61        <th scope="row"><?php _e( 'Thumbnail size' ); ?></th>
     62        <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Thumbnail size' ); ?></span></legend>
     63        <label for="thumbnail_size_w"><?php _e( 'Width' ); ?></label>
     64        <input name="thumbnail_size_w" type="number" step="1" min="0" id="thumbnail_size_w" value="<?php form_option( 'thumbnail_size_w' ); ?>" class="small-text" />
     65        <br />
     66        <label for="thumbnail_size_h"><?php _e( 'Height' ); ?></label>
     67        <input name="thumbnail_size_h" type="number" step="1" min="0" id="thumbnail_size_h" value="<?php form_option( 'thumbnail_size_h' ); ?>" class="small-text" />
     68        </fieldset>
     69        <input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked( '1', get_option( 'thumbnail_crop' ) ); ?>/>
     70        <label for="thumbnail_crop"><?php _e( 'Crop thumbnail to exact dimensions (normally thumbnails are proportional)' ); ?></label>
     71        </td>
     72        </tr>
     73
     74        <tr>
     75        <th scope="row"><?php _e( 'Medium size' ); ?></th>
     76        <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Medium size' ); ?></span></legend>
     77        <label for="medium_size_w"><?php _e( 'Max Width' ); ?></label>
     78        <input name="medium_size_w" type="number" step="1" min="0" id="medium_size_w" value="<?php form_option( 'medium_size_w' ); ?>" class="small-text" />
     79        <br />
     80        <label for="medium_size_h"><?php _e( 'Max Height' ); ?></label>
     81        <input name="medium_size_h" type="number" step="1" min="0" id="medium_size_h" value="<?php form_option( 'medium_size_h' ); ?>" class="small-text" />
     82        </fieldset></td>
     83        </tr>
     84
     85        <tr>
     86        <th scope="row"><?php _e( 'Large size' ); ?></th>
     87        <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Large size' ); ?></span></legend>
     88        <label for="large_size_w"><?php _e( 'Max Width' ); ?></label>
     89        <input name="large_size_w" type="number" step="1" min="0" id="large_size_w" value="<?php form_option( 'large_size_w' ); ?>" class="small-text" />
     90        <br />
     91        <label for="large_size_h"><?php _e( 'Max Height' ); ?></label>
     92        <input name="large_size_h" type="number" step="1" min="0" id="large_size_h" value="<?php form_option( 'large_size_h' ); ?>" class="small-text" />
     93        </fieldset></td>
     94        </tr>
     95        </table>
     96<?php else : ?>
     97        <table class="form-table" role="presentation">
     98                <?php do_settings_fields( 'media', 'default' ); ?>
     99        </table>
     100<?php endif; ?>
    97101
    98102<?php
    99103/**