Make WordPress Core

Changeset 20590


Ignore:
Timestamp:
04/25/2012 05:40:43 PM (13 years ago)
Author:
nacin
Message:

Remove support from WP_Theme for multiple screenshots until we bring it to the UI. fixes #20546.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-theme.php

    r20589 r20590  
    471471     * @since 3.4.0
    472472     *
    473      * @param string $key Type of data to store (theme, screenshot, screenshot_count, files, headers)
     473     * @param string $key Type of data to store (theme, screenshot, headers, page_templates)
    474474     * @param string $data Data to store
    475475     * @return bool Return value from wp_cache_add()
     
    487487     * @since 3.4.0
    488488     *
    489      * @param string $key Type of data to retrieve (theme, screenshot, screenshot_count, files, headers)
     489     * @param string $key Type of data to retrieve (theme, screenshot, headers, page_templates)
    490490     * @return mixed Retrieved data
    491491     */
     
    501501     */
    502502    public function cache_delete() {
    503         foreach ( array( 'theme', 'screenshot', 'screenshot_count', 'headers', 'page_templates' ) as $key )
     503        foreach ( array( 'theme', 'screenshot', 'headers', 'page_templates' ) as $key )
    504504            wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
    505505        $this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null;
     
    857857     * The main screenshot is called screenshot.png. gif and jpg extensions are also allowed.
    858858     *
    859      * Screenshots for a theme must be in the stylesheet directory. (In the case of a child
    860      * theme, a parent theme's screenshots are not inherited.)
     859     * Screenshots for a theme must be in the stylesheet directory. (In the case of child
     860     * themes, parent theme screenshots are not inherited.)
    861861     *
    862862     * @since 3.4.0
     
    886886
    887887        $this->cache_add( 'screenshot', 0 );
    888         $this->cache_add( 'screenshot_count', 0 );
    889888        return false;
    890     }
    891 
    892     /**
    893      * Returns the number of screenshots for a theme.
    894      *
    895      * The first screenshot may be called screenshot.png, .gif, or .jpg. Subsequent
    896      * screenshots can be screenshot-2.png, screenshot-3.png, etc. The count must
    897      * be consecutive for screenshots to be counted, and all screenshots beyond the
    898      * initial one must be image/png files.
    899      *
    900      * @see WP_Theme::get_screenshot()
    901      * @since 3.4.0
    902      * @access public
    903      *
    904      * @return int Number of screenshots. Can be 0.
    905      */
    906     public function get_screenshot_count() {
    907         $screenshot_count = $this->cache_get( 'screenshot_count' );
    908         if ( is_numeric( $screenshot_count ) )
    909             return $screenshot_count;
    910 
    911         // This will set the screenshot cache.
    912         // If there is no screenshot, the screenshot_count cache will also be set.
    913         if ( ! $screenshot = $this->get_screenshot( 'relative' ) )
    914             return 0;
    915 
    916         $prefix = $this->get_stylesheet() . '/screenshot-';
    917         $files = self::scandir( $this->get_stylesheet_directory(), $this->get_stylesheet(), 'png' );
    918 
    919         $screenshot_count = 1;
    920         while ( in_array( $prefix . ( $screenshot_count + 1 ) . '.png', $files['png'] ) )
    921             $screenshot_count++;
    922 
    923         $this->cache_add( 'screenshot_count', $screenshot_count );
    924         return $screenshot_count;
    925     }
    926 
    927     /**
    928      * Returns an array of screenshot filenames.
    929      *
    930      * @see WP_Theme::get_screenshot()
    931      * @see WP_Theme::get_screenshot_count()
    932      * @since 3.4.0
    933      * @access public
    934      *
    935      * @param string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI.
    936      * @return array Screenshots. Empty array if no screenshors are found.
    937      */
    938     public function get_screenshots( $uri = 'uri' ) {
    939         if ( ! $count = $this->get_screenshot_count() )
    940             return array();
    941 
    942         $pre = 'relative' == $uri ? '' : $this->get_stylesheet_directory_uri() . '/';
    943 
    944         $screenshots = array( $pre . $this->get_screenshot( 'relative' ) );
    945         for ( $i = 2; $i <= $count; $i++ )
    946             $screenshots[] = $pre . 'screenshot-' . $i . '.png';
    947         return $screenshots;
    948889    }
    949890
Note: See TracChangeset for help on using the changeset viewer.