Changeset 20586
- Timestamp:
- 04/25/2012 04:37:49 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/class-wp-theme.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-theme.php
r20481 r20586 291 291 * @return string Theme name, ready for display (translated) 292 292 */ 293 function __toString() {293 public function __toString() { 294 294 return (string) $this->display('Name'); 295 295 } … … 318 318 return $this->get('Version'); 319 319 case 'parent_theme' : 320 return $this->parent ? $this->parent->get('Name') : '';320 return $this->parent() ? $this->parent()->get('Name') : ''; 321 321 case 'template_dir' : 322 322 return $this->get_template_directory(); … … 370 370 371 371 /** 372 * Method to implement ArrayAccess for keys formerly returned by get_themes() 372 * Method to implement ArrayAccess for keys formerly returned by get_themes(). 373 * 374 * Author, Author Name, Author URI, and Description did not previously return 375 * translated data. We are doing so now as it is safe to do. However, as 376 * Name and Title could have been used as the key for get_themes(), both remain 377 * untranslated for back compatibility. This means that ['Name'] is not ideal, 378 * and care should be taken to use $theme->display('Name') to get a properly 379 * translated header. 373 380 */ 374 381 public function offsetGet( $offset ) { 375 382 switch ( $offset ) { 376 383 case 'Name' : 377 case 'Version' :378 case 'Status' :379 return $this->get( $offset );380 384 case 'Title' : 385 // See note above about using translated data. get() is not ideal. 386 // It is only for backwards compatibility. Use display(). 381 387 return $this->get('Name'); 382 // Author, Author Name, Author URI, and Description did not383 // previously return translated data. We are doing so now.384 // Title and Name could have been used as the key for get_themes(),385 // so both to remain untranslated for back compatibility.386 388 case 'Author' : 387 389 return $this->display( 'Author'); … … 392 394 case 'Description' : 393 395 return $this->display( 'Description'); 396 case 'Version' : 397 case 'Status' : 398 return $this->get( $offset ); 394 399 case 'Template' : 395 400 return $this->get_template(); … … 419 424 return $this->get_theme_root_uri(); 420 425 case 'Parent Theme' : 421 return $this->parent ? $this->parent->get('Name') : '';426 return $this->parent() ? $this->parent()->get('Name') : ''; 422 427 default : 423 428 return null; … … 441 446 * 442 447 * A theme with errors exists. A theme with the error of 'theme_not_found', 443 * meaning that the theme directory was not found, does not exist.448 * meaning that the theme's directory was not found, does not exist. 444 449 * 445 450 * @since 3.4.0 … … 449 454 */ 450 455 public function exists() { 451 return ! ( is_wp_error( $this->errors ) && in_array( 'theme_not_found', $this->errors->get_error_codes() ) );456 return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) ); 452 457 } 453 458 … … 510 515 511 516 /** 512 * Gets a theme header. 513 * 514 * The header is sanitized. 515 * 516 * @access public 517 * @since 3.4.0 518 * 519 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status. 517 * Get a raw, unformatted theme header. 518 * 519 * The header is sanitized, but is not translated, and is not marked up for display. 520 * To get a theme header for display, use the display() method. 521 * 522 * Use the get_template() method, not the 'Template' header, for finding the template. 523 * The 'Template' header is only good for what was written in the style.css, while 524 * get_template() takes into account where WordPress actually located the theme and 525 * whether it is actually valid. 526 * 527 * @access public 528 * @since 3.4.0 529 * 530 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. 520 531 * @return string String on success, false on failure. 521 532 */ … … 546 557 547 558 /** 548 * Gets a theme header ready for display (marked up, translated).549 * 550 * @access public 551 * @since 3.4.0 552 * 553 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status .559 * Gets a theme header, formatted and translated for display. 560 * 561 * @access public 562 * @since 3.4.0 563 * 564 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. 554 565 * @param bool $markup Optional. Whether to mark up the header. Defaults to true. 555 566 * @param bool $translate Optional. Whether to translate the header. Defaults to true. … … 574 585 * Sanitize a theme header. 575 586 * 576 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status .587 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. 577 588 * @param string $value Value to sanitize. 578 589 */ … … 626 637 * @since 3.4.0 627 638 * 628 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status .639 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. 629 640 * @param string $value Value to mark up. 630 641 * @param string $translate Whether the header has been translated. … … 673 684 * @since 3.4.0 674 685 * 675 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status .686 * @param string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. 676 687 * @param string $value Value to translate. 677 688 * @return string Translated value. … … 764 775 */ 765 776 public function get_stylesheet_directory() { 766 if ( $this->errors && in_array( 'theme_root_missing', $this->errors->get_error_codes() ) )777 if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) 767 778 return ''; 768 779 … … 782 793 */ 783 794 public function get_template_directory() { 784 if ( $this->parent )785 $theme_root = $this->parent ->theme_root;795 if ( $this->parent() ) 796 $theme_root = $this->parent()->theme_root; 786 797 else 787 798 $theme_root = $this->theme_root; … … 817 828 */ 818 829 public function get_template_directory_uri() { 819 if ( $this->parent )820 $theme_root_uri = $this->parent ->get_theme_root_uri();830 if ( $this->parent() ) 831 $theme_root_uri = $this->parent()->get_theme_root_uri(); 821 832 else 822 833 $theme_root_uri = $this->get_theme_root_uri(); … … 865 876 * 866 877 * Screenshots for a theme must be in the stylesheet directory. (In the case of a child 867 * theme, a parent theme's screenshots are inherited.)878 * theme, a parent theme's screenshots are not inherited.) 868 879 * 869 880 * @since 3.4.0 … … 1031 1042 * 1032 1043 * @param string $path Absolute path to search. 1033 * @param array|string $extensions Array of extensions to find, or string of a single extension1044 * @param mixed Array of extensions to find, string of a single extension, or null for all extensions. 1034 1045 * @param int $depth How deep to search for files. Optional, defaults to a flat scan (0 depth). -1 depth is infinite. 1035 1046 * @param string $relative_path The basename of the absolute path. Used to control the returned path
Note: See TracChangeset
for help on using the changeset viewer.