Make WordPress Core

Ticket #23040: class-wp-theme.php.patch

File class-wp-theme.php.patch, 3.1 KB (added by wpsmith, 10 years ago)

Deprecating methods

  • class-wp-theme.php

     
    299299
    300300        /**
    301301         * __isset() magic method for properties formerly returned by current_theme_info()
     302     * Use appropriate method to obtain WP_Theme properties.
    302303         */
    303304        public function __isset( $offset ) {
     305       
     306        _doing_it_wrong( __METHOD__, sprintf( __( 'Please use the appropriate, public WP_Theme method: %s.' ), $this->_deprecated( $offset ) ), '3.7' );
    304307                static $properties = array(
    305308                        'name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet',
    306309                        'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri',
     
    308311
    309312                return in_array( $offset, $properties );
    310313        }
     314   
     315    /**
     316         * Generate appropriate WP_Theme method for _doing_it_wrong notice.
     317         */
     318    private function _deprecated( $offset ) {
     319        $properties = array(
     320                        'name'           => "wp_get_theme()->get('Name')",
     321            'title'          => "wp_get_theme()->get('Name')",
     322            'version'        => "wp_get_theme()->get('Version')",
     323            'parent_theme'   => "wp_get_theme()->parent() ? wp_get_theme()->->parent() : wp_get_theme()->get('Name')",
     324            'template_dir'   => "wp_get_theme()->get_template_directory()",
     325            'stylesheet_dir' => "wp_get_theme()->get_stylesheet_directory()",
     326            'template'       => "wp_get_theme()->get_template()",
     327            'stylesheet'     => "wp_get_theme()->get_stylesheet()",
     328                        'screenshot'     => "wp_get_theme()->get_screenshot()",
     329            'description'    => "wp_get_theme()->display('description')",
     330            'author'         => "wp_get_theme()->display('author')",
     331            'tags'           => "wp_get_theme()->get('Tags')",
     332            'theme_root'     => "wp_get_theme()->get_theme_root()",
     333            'theme_root_uri' => "wp_get_theme()->get_theme_root_uri()",
     334            'default'        => "wp_get_theme()->offsetGet( $offset )",
     335                );
     336        return isset( $properties[ $offset ] ) ? $properties[ $offset ] : $properties['default'];
     337    }
    311338
    312339        /**
    313340         * __get() magic method for properties formerly returned by current_theme_info()
     341     * Use appropriate method to obtain WP_Theme properties.
    314342         */
    315343        public function __get( $offset ) {
     344        _doing_it_wrong( __METHOD__, sprintf( __( 'Please use the appropriate, public WP_Theme method: %s.' ), $this->_deprecated( $offset ) ), '3.7' );
     345       
    316346                switch ( $offset ) {
    317347                        case 'name' :
    318348                        case 'title' :
     
    362392         * Method to implement ArrayAccess for keys formerly returned by get_themes()
    363393         */
    364394        public function offsetExists( $offset ) {
     395        _deprecated_function( __METHOD__, sprintf( __( 'Please use the appropriate, public WP_Theme method: %s.' ), $this->_deprecated( $offset ) ), '3.7' );
    365396                static $keys = array(
    366397                        'Name', 'Version', 'Status', 'Title', 'Author', 'Author Name', 'Author URI', 'Description',
    367398                        'Template', 'Stylesheet', 'Template Files', 'Stylesheet Files', 'Template Dir', 'Stylesheet Dir',