Changeset 20590
- Timestamp:
- 04/25/2012 05:40:43 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-theme.php
r20589 r20590 471 471 * @since 3.4.0 472 472 * 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) 474 474 * @param string $data Data to store 475 475 * @return bool Return value from wp_cache_add() … … 487 487 * @since 3.4.0 488 488 * 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) 490 490 * @return mixed Retrieved data 491 491 */ … … 501 501 */ 502 502 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 ) 504 504 wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' ); 505 505 $this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null; … … 857 857 * The main screenshot is called screenshot.png. gif and jpg extensions are also allowed. 858 858 * 859 * Screenshots for a theme must be in the stylesheet directory. (In the case of achild860 * theme , a parent theme'sscreenshots 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.) 861 861 * 862 862 * @since 3.4.0 … … 886 886 887 887 $this->cache_add( 'screenshot', 0 ); 888 $this->cache_add( 'screenshot_count', 0 );889 888 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. Subsequent896 * screenshots can be screenshot-2.png, screenshot-3.png, etc. The count must897 * be consecutive for screenshots to be counted, and all screenshots beyond the898 * initial one must be image/png files.899 *900 * @see WP_Theme::get_screenshot()901 * @since 3.4.0902 * @access public903 *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.0933 * @access public934 *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;948 889 } 949 890
Note: See TracChangeset
for help on using the changeset viewer.