WordPress.org

Make WordPress Core

Changeset 38355


Ignore:
Timestamp:
08/25/2016 07:08:38 PM (3 years ago)
Author:
wonderboymusic
Message:

Site Icon: There is no good reason for class-wp-site-icon.php to drop a global instance of itself whenever the file is loaded. The lone use of the global instance of WP_Site_Icon is in an AJAX action that provides virtually no way to override - the file is loaded immediately before the global is used.

Let us remove the $wp_site_icon global. I will fall on the sword if this comes back to bite us (waiting with bated breath).

See #37699.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r38199 r38355  
    31633163 *
    31643164 * @since 4.3.0
    3165  *
    3166  * @global WP_Site_Icon $wp_site_icon
    31673165 */
    31683166function wp_ajax_crop_image() {
     
    31853183        case 'site-icon':
    31863184            require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php';
    3187             global $wp_site_icon;
     3185            $wp_site_icon = new WP_Site_Icon();
    31883186
    31893187            // Skip creating a new attachment if the attachment is a Site Icon.
  • trunk/src/wp-admin/includes/class-wp-site-icon.php

    r37488 r38355  
    241241    }
    242242}
    243 
    244 /**
    245  * @global WP_Site_Icon $wp_site_icon
    246  */
    247 $GLOBALS['wp_site_icon'] = new WP_Site_Icon;
  • trunk/tests/phpunit/tests/general/template.php

    r37866 r38355  
    11<?php
    2 
    32/**
    43 * A set of unit tests for functions in wp-includes/general-template.php
    54 *
    65 * @group template
     6 * @group site_icon
    77 */
     8
     9require_once( ABSPATH . 'wp-admin/includes/class-wp-site-icon.php' );
     10
    811class Tests_General_Template extends WP_UnitTestCase {
    9 
    10     public $wp_site_icon;
     12    protected $wp_site_icon;
    1113    public $site_icon_id;
    1214    public $site_icon_url;
     
    1820        parent::setUp();
    1921
    20         require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php';
    21         $this->wp_site_icon = $GLOBALS['wp_site_icon'];
     22        $this->wp_site_icon = new WP_Site_Icon();
    2223    }
    2324
  • trunk/tests/phpunit/tests/image/site_icon.php

    r35309 r38355  
    11<?php
    2 
    32/**
    43 * Tests for the WP_Site_Icon class.
     
    65 * @group site_icon
    76 */
     7
     8require_once( ABSPATH . 'wp-admin/includes/class-wp-site-icon.php' );
     9
    810class Tests_WP_Site_Icon extends WP_UnitTestCase {
    9     public $wp_site_icon;
     11    protected $wp_site_icon;
     12
    1013    public $attachment_id = 0;
    1114
     
    1316        parent::setUp();
    1417
    15         require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php';
    16         $this->wp_site_icon = $GLOBALS['wp_site_icon'];
     18        $this->wp_site_icon = new WP_Site_Icon();
    1719    }
    1820
    1921    function tearDown() {
    20         $this->site_icon = null;
     22        $this->_remove_custom_logo();
    2123        $this->remove_added_uploads();
    2224        parent::tearDown();
     25    }
     26
     27    function _remove_custom_logo() {
     28        remove_theme_mod( 'custom_logo' );
    2329    }
    2430
Note: See TracChangeset for help on using the changeset viewer.