Changeset 8965
- Timestamp:
- 09/24/2008 05:24:33 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r8791 r8965 8 8 9 9 /** 10 * Get current theme name.11 * 12 * The theme name that the administrator has currently set the front end theme10 * Retrieve name of the current stylesheet. 11 * 12 * The theme name that the administrator has currently set the front end theme 13 13 * as. 14 14 * 15 * @since 1.5.0 16 * @uses apply_filters() Calls 'stylesheet' filter 17 * 18 * @return string 15 * For all extensive purposes, the template name and the stylesheet name are 16 * going to be the same for most cases. 17 * 18 * @since 1.5.0 19 * @uses apply_filters() Calls 'stylesheet' filter on stylesheet name. 20 * 21 * @return string Stylesheet name. 19 22 */ 20 23 function get_stylesheet() { … … 23 26 24 27 /** 25 * get_stylesheet_directory() - {@internal Missing Short Description}} 26 * 27 * {@internal Missing Long Description}} 28 * 29 * @since 1.5.0 30 * 31 * @return unknown 28 * Retrieve stylesheet directory path for current theme. 29 * 30 * @since 1.5.0 31 * @uses apply_filters() Calls 'stylesheet_directory' filter on stylesheet directory and theme name. 32 * 33 * @return string Path to current theme directory. 32 34 */ 33 35 function get_stylesheet_directory() { … … 38 40 39 41 /** 40 * get_stylesheet_directory_uri() - {@internal Missing Short Description}} 41 * 42 * {@internal Missing Long Description}} 43 * 44 * @since 1.5.0 45 * 46 * @return unknown 42 * Retrieve stylesheet directory URI. 43 * 44 * @since 1.5.0 45 * 46 * @return string 47 47 */ 48 48 function get_stylesheet_directory_uri() { … … 53 53 54 54 /** 55 * get_stylesheet_uri() - {@internal Missing Short Description}} 56 * 57 * {@internal Missing Long Description}} 58 * 59 * @since 1.5.0 60 * 61 * @return unknown 55 * Retrieve URI of current theme stylesheet. 56 * 57 * The stylesheet file name is 'style.css' which is appended to {@link 58 * get_stylesheet_directory_uri() stylesheet directory URI} path. 59 * 60 * @since 1.5.0 61 * @uses apply_filters() Calls 'stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI. 62 * 63 * @return string 62 64 */ 63 65 function get_stylesheet_uri() { … … 68 70 69 71 /** 70 * get_locale_stylesheet_uri() - {@internal Missing Short Description}}72 * Retrieve localized stylesheet URI. 71 73 * 72 74 * {@internal Missing Long Description}} 73 75 * 74 76 * @since 2.1.0 75 * 76 * @return unknown 77 * @uses apply_filters() Calls 'locale_stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI. 78 * 79 * @return string 77 80 */ 78 81 function get_locale_stylesheet_uri() { … … 91 94 92 95 /** 93 * get_template() - {@internal Missing Short Description}} 94 * 95 * {@internal Missing Long Description}} 96 * 97 * @since 1.5.0 98 * 99 * @return unknown 96 * Retrieve name of the current theme. 97 * 98 * @since 1.5.0 99 * @uses apply_filters() Calls 'template' filter on template option. 100 * 101 * @return string Template name. 100 102 */ 101 103 function get_template() { … … 104 106 105 107 /** 106 * get_template_directory() - {@internal Missing Short Description}} 107 * 108 * {@internal Missing Long Description}} 109 * 110 * @since 1.5.0 111 * 112 * @return unknown 108 * Retrieve current theme directory. 109 * 110 * @since 1.5.0 111 * @uses apply_filters() Calls 'template_directory' filter on template directory path and template name. 112 * 113 * @return string Template directory path. 113 114 */ 114 115 function get_template_directory() { … … 119 120 120 121 /** 121 * get_template_directory_uri() - {@internal Missing Short Description}} 122 * 123 * {@internal Missing Long Description}} 124 * 125 * @since 1.5.0 126 * 127 * @return unknown 122 * Retrieve theme directory URI. 123 * 124 * @since 1.5.0 125 * @uses apply_filters() Calls 'template_directory_uri' filter on template directory URI path and template name. 126 * 127 * @return string Template directory URI. 128 128 */ 129 129 function get_template_directory_uri() { … … 134 134 135 135 /** 136 * get_theme_data() - {@internal Missing Short Description}}136 * Retrieve theme data from parsed theme file. 137 137 * 138 138 * {@internal Missing Long Description}} … … 140 140 * @since 1.5.0 141 141 * 142 * @param unknown_type $theme_file143 * @return unknown142 * @param string $theme_file Theme file path. 143 * @return array Theme data. 144 144 */ 145 145 function get_theme_data( $theme_file ) { … … 208 208 209 209 /** 210 * get_themes() - {@internal Missing Short Description}}210 * Retrieve list of themes with theme data in theme directory. 211 211 * 212 212 * {@internal Missing Long Description}} … … 214 214 * @since 1.5.0 215 215 * 216 * @return unknown216 * @return array Theme list with theme data. 217 217 */ 218 218 function get_themes() { … … 401 401 402 402 /** 403 * get_theme() - {@internal Missing Short Description}} 404 * 405 * {@internal Missing Long Description}} 406 * 407 * @since 1.5.0 408 * 409 * @param unknown_type $theme 410 * @return unknown 403 * Retrieve theme data. 404 * 405 * @since 1.5.0 406 * 407 * @param string $theme Theme name. 408 * @return array|null Null, if theme name does not exist. Theme data, if exists. 411 409 */ 412 410 function get_theme($theme) { … … 416 414 return $themes[$theme]; 417 415 418 return NULL; 419 } 420 421 /** 422 * get_current_theme() - {@internal Missing Short Description}} 423 * 424 * {@internal Missing Long Description}} 425 * 426 * @since 1.5.0 427 * 428 * @return unknown 416 return null; 417 } 418 419 /** 420 * Retrieve current theme display name. 421 * 422 * If the 'current_theme' option has already been set, then it will be returned 423 * instead. If it is not set, then each theme will be iterated over until both 424 * the current stylesheet and current template name. 425 * 426 * @since 1.5.0 427 * 428 * @return string 429 429 */ 430 430 function get_current_theme() { … … 454 454 455 455 /** 456 * get_theme_root() - {@internal Missing Short Description}} 457 * 458 * {@internal Missing Long Description}} 459 * 460 * @since 1.5.0 461 * 462 * @return unknown 456 * Retrieve path to themes directory. 457 * 458 * Does not have trailing slash. 459 * 460 * @since 1.5.0 461 * @uses apply_filters() Calls 'theme_root' filter on path. 462 * 463 * @return string Theme path. 463 464 */ 464 465 function get_theme_root() { … … 467 468 468 469 /** 469 * get_theme_root_uri() - {@internal Missing Short Description}}470 * 471 * {@internal Missing Long Description}}472 * 473 * @since 1.5.0 474 * 475 * @return unknown470 * Retrieve URI for themes directory. 471 * 472 * Does not have trailing slash. 473 * 474 * @since 1.5.0 475 * 476 * @return string Themes URI. 476 477 */ 477 478 function get_theme_root_uri() { … … 480 481 481 482 /** 482 * get_query_template() - {@internal Missing Short Description}} 483 * 484 * {@internal Missing Long Description}} 485 * 486 * @since 1.5.0 487 * 488 * @param unknown_type $type 489 * @return unknown 483 * Retrieve path to file without the use of extension. 484 * 485 * Used to quickly retrieve the path of file without including the file 486 * extension. It will also check the parent template, if the file exists, with 487 * the use of {@link locate_template()}. Allows for more generic file location 488 * without the use of the other get_*_template() functions. 489 * 490 * Can be used with include() or require() to retrieve path. 491 * <code> 492 * if( '' != get_query_template( '404' ) ) 493 * include( get_query_template( '404' ) ); 494 * </code> 495 * or the same can be accomplished with 496 * <code> 497 * if( '' != get_404_template() ) 498 * include( get_404_template() ); 499 * </code> 500 * 501 * @since 1.5.0 502 * 503 * @param string $type Filename without extension. 504 * @return string Full path to file. 490 505 */ 491 506 function get_query_template($type) { … … 495 510 496 511 /** 497 * get_404_template() - {@internal Missing Short Description}} 498 * 499 * {@internal Missing Long Description}} 500 * 501 * @since 1.5.0 502 * 503 * @return unknown 512 * Retrieve path of 404 template in current or parent template. 513 * 514 * @since 1.5.0 515 * 516 * @return string 504 517 */ 505 518 function get_404_template() { … … 508 521 509 522 /** 510 * get_archive_template() - {@internal Missing Short Description}} 511 * 512 * {@internal Missing Long Description}} 513 * 514 * @since 1.5.0 515 * 516 * @return unknown 523 * Retrieve path of archive template in current or parent template. 524 * 525 * @since 1.5.0 526 * 527 * @return string 517 528 */ 518 529 function get_archive_template() { … … 521 532 522 533 /** 523 * get_author_template() - {@internal Missing Short Description}} 524 * 525 * {@internal Missing Long Description}} 526 * 527 * @since 1.5.0 528 * 529 * @return unknown 534 * Retrieve path of author template in current or parent template. 535 * 536 * @since 1.5.0 537 * 538 * @return string 530 539 */ 531 540 function get_author_template() { … … 534 543 535 544 /** 536 * get_category_template() - {@internal Missing Short Description}} 537 * 538 * {@internal Missing Long Description}} 539 * 540 * @since 1.5.0 541 * 542 * @return unknown 545 * Retrieve path of category template in current or parent template. 546 * 547 * Works by retrieving the current category ID, for example 'category-1.php' and 548 * will fallback to category.php template, if the ID category file doesn't 549 * exist. 550 * 551 * @since 1.5.0 552 * @uses apply_filters() Calls 'category_template' on file path of category template. 553 * 554 * @return string 543 555 */ 544 556 function get_category_template() { 545 $template = locate_template(array("category-" . absint( get_query_var('cat') ) . '.php',"category.php"));557 $template = locate_template(array("category-" . absint( get_query_var('cat') ) . '.php', 'category.php')); 546 558 return apply_filters('category_template', $template); 547 559 } 548 560 549 561 /** 550 * get_tag_template() - {@internal Missing Short Description}} 551 * 552 * {@internal Missing Long Description}} 562 * Retrieve path of tag template in current or parent template. 563 * 564 * Works by retrieving the current tag ID, for example 'tag-1.php' and will 565 * fallback to tag.php template, if the ID tag file doesn't exist. 553 566 * 554 567 * @since 2.3.0 555 * 556 * @return unknown 568 * @uses apply_filters() Calls 'tag_template' on file path of tag template. 569 * 570 * @return string 557 571 */ 558 572 function get_tag_template() { 559 $template = locate_template(array("tag-" . absint( get_query_var('tag') ) . '.php', "tag.php"));573 $template = locate_template(array("tag-" . absint( get_query_var('tag') ) . '.php', 'tag.php')); 560 574 return apply_filters('tag_template', $template); 561 575 } 562 576 563 /**564 * get_date_template() - {@internal Missing Short Description}}565 *566 * {@internal Missing Long Description}}567 *568 * @since 1.5.0569 *570 * @return unknown571 */572 577 function get_taxonomy_template() { 573 578 $taxonomy = get_query_var('taxonomy'); … … 579 584 if ( $taxonomy ) 580 585 $templates[] = "taxonomy-$taxonomy.php"; 581 586 582 587 $templates[] = "taxonomy.php"; 583 588 … … 586 591 } 587 592 593 /** 594 * Retrieve path of date template in current or parent template. 595 * 596 * @since 1.5.0 597 * 598 * @return string 599 */ 588 600 function get_date_template() { 589 601 return get_query_template('date'); … … 591 603 592 604 /** 593 * get_home_template() - {@internal Missing Short Description}} 594 * 595 * {@internal Missing Long Description}} 596 * 597 * @since 1.5.0 598 * 599 * @return unknown 605 * Retrieve path of home template in current or parent template. 606 * 607 * Attempts to locate 'home.php' first before falling back to 'index.php'. 608 * 609 * @since 1.5.0 610 * @uses apply_filters() Calls 'home_template' on file path of home template. 611 * 612 * @return string 600 613 */ 601 614 function get_home_template() { 602 $template = locate_template(array('home.php', 'index.php'));615 $template = locate_template(array('home.php', 'index.php')); 603 616 return apply_filters('home_template', $template); 604 617 } 605 618 606 619 /** 607 * get_page_template() - {@internal Missing Short Description}} 608 * 609 * {@internal Missing Long Description}} 610 * 611 * @since 1.5.0 612 * 613 * @return unknown 620 * Retrieve path of page template in current or parent template. 621 * 622 * First attempt is to look for the file in the '_wp_page_template' page meta 623 * data. The second attempt, if the first has a file and is not empty, is to 624 * look for 'page.php'. 625 * 626 * @since 1.5.0 627 * 628 * @return string 614 629 */ 615 630 function get_page_template() { … … 625 640 if ( !empty($template) && !validate_file($template) ) 626 641 $templates[] = $template; 627 642 628 643 $templates[] = "page.php"; 629 644 … … 632 647 633 648 /** 634 * get_paged_template() - {@internal Missing Short Description}} 635 * 636 * {@internal Missing Long Description}} 637 * 638 * @since 1.5.0 639 * 640 * @return unknown 649 * Retrieve path of paged template in current or parent template. 650 * 651 * @since 1.5.0 652 * 653 * @return string 641 654 */ 642 655 function get_paged_template() { … … 645 658 646 659 /** 647 * get_search_template() - {@internal Missing Short Description}} 648 * 649 * {@internal Missing Long Description}} 650 * 651 * @since 1.5.0 652 * 653 * @return unknown 660 * Retrieve path of search template in current or parent template. 661 * 662 * @since 1.5.0 663 * 664 * @return string 654 665 */ 655 666 function get_search_template() { … … 658 669 659 670 /** 660 * get_single_template() - {@internal Missing Short Description}} 661 * 662 * {@internal Missing Long Description}} 671 * Retrieve path of single template in current or parent template. 663 672 * 664 673 * @since 1.5.0 … … 671 680 672 681 /** 673 * get_attachment_template() - {@internal Missing Short Description}} 674 * 675 * {@internal Missing Long Description}} 682 * Retrieve path of attachment template in current or parent template. 683 * 684 * The attachment path first checks if the first part of the mime type exists. 685 * The second check is for the second part of the mime type. The last check is 686 * for both types separated by an underscore. If neither are found then the file 687 * 'attachment.php' is checked and returned. 688 * 689 * Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and 690 * finally 'text_plain.php'. 676 691 * 677 692 * @since 2.0.0 678 693 * 679 * @return unknown694 * @return string 680 695 */ 681 696 function get_attachment_template() { … … 693 708 694 709 /** 695 * get_comments_popup_template() - {@internal Missing Short Description}} 696 * 697 * {@internal Missing Long Description}} 698 * 699 * @since 1.5.0 700 * 701 * @return unknown 710 * Retrieve path of comment popup template in current or parent template. 711 * 712 * Checks for comment popup template in current template, if it exists or in the 713 * parent template. If it doesn't exist, then it retrieves the comment-popup.php 714 * file from the default theme. The default theme must then exist for it to 715 * work. 716 * 717 * @since 1.5.0 718 * @uses apply_filters() Calls 'comments_popup_template' filter on path. 719 * 720 * @return string 702 721 */ 703 722 function get_comments_popup_template() { … … 710 729 711 730 /** 712 * Ret urns the name of the highest priority template file that exists731 * Retrieve the name of the highest priority template file that exists. 713 732 * 714 733 * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which 715 734 * inherit from a parent theme can just overload one file. 716 * @since 2.7 717 * 718 * @param array $template_names Array of template files to search for in priority order 735 * 736 * @since 2.7.0 737 * 738 * @param array $template_names Array of template files to search for in priority order. 719 739 * @param bool $load If true the template file will be loaded if it is found. 720 740 * @return string The template filename if one is located. … … 723 743 if (!is_array($template_names)) 724 744 return ''; 725 745 726 746 $located = ''; 727 747 foreach($template_names as $template_name) { … … 734 754 } 735 755 } 736 756 737 757 if ($load && '' != $located) 738 758 load_template($located); 739 759 740 760 return $located; 741 761 } 742 762 743 763 /** 744 * load_template() - {@internal Missing Short Description}} 745 * 746 * {@internal Missing Long Description}} 747 * 748 * @since 1.5.0 749 * 750 * @param unknown_type $_template_file 764 * Require once the template file with WordPress environment. 765 * 766 * The globals are set up for the template file to ensure that the WordPress 767 * environment is available from within the function. The query variables are 768 * also available. 769 * 770 * @since 1.5.0 771 * 772 * @param string $_template_file Path to template file. 751 773 */ 752 774 function load_template($_template_file) { … … 760 782 761 783 /** 762 * locale_stylesheet() - {@internal Missing Short Description}} 763 * 764 * {@internal Missing Long Description}} 784 * Display localized stylesheet link element. 765 785 * 766 786 * @since 2.1.0 … … 774 794 775 795 /** 776 * switch_theme() -{@internal Missing Short Description}}796 * {@internal Missing Short Description}} 777 797 * 778 798 * {@internal Missing Long Description}} … … 839 859 840 860 /** 841 * validate_current_theme() - {@internal Missing Short Description}} 842 * 843 * {@internal Missing Long Description}} 844 * 845 * @since 1.5.0 846 * 847 * @return unknown 861 * Checks that current theme files 'index.php' and 'style.css' exists. 862 * 863 * Does not check the 'default' theme. The 'default' theme should always exist 864 * or should have another theme renamed to that template name and directory 865 * path. Will switch theme to default if current theme does not validate. 866 * 867 * @since 1.5.0 868 * 869 * @return bool 848 870 */ 849 871 function validate_current_theme() { … … 866 888 867 889 /** 868 * get_theme_mod() - {@internal Missing Short Description}} 869 * 870 * {@internal Missing Long Description}} 890 * Retrieve theme modification value for the current theme. 891 * 892 * If the modification name does not exist, then the $default will be passed 893 * through {@link http://php.net/sprintf sprintf()} PHP function with the first 894 * string the template directory URI and the second string the stylesheet 895 * directory URI. 871 896 * 872 897 * @since 2.1.0 873 * 874 * @param unknown_type $name 875 * @param unknown_type $default 876 * @return unknown 898 * @uses apply_filters() Calls 'theme_mod_$name' filter on the value. 899 * 900 * @param string $name Theme modification name. 901 * @param bool|string $default 902 * @return string 877 903 */ 878 904 function get_theme_mod($name, $default = false) { … … 888 914 889 915 /** 890 * set_theme_mod() - {@internal Missing Short Description}} 891 * 892 * {@internal Missing Long Description}} 916 * Update theme modification value for the current theme. 893 917 * 894 918 * @since 2.1.0 895 919 * 896 * @param unknown_type $name897 * @param unknown_type $value920 * @param string $name Theme modification name. 921 * @param string $value theme modification value. 898 922 */ 899 923 function set_theme_mod($name, $value) { … … 909 933 910 934 /** 911 * remove_theme_mod() - {@internal Missing Short Description}} 912 * 913 * {@internal Missing Long Description}} 935 * Remove theme modification name from current theme list. 936 * 937 * If removing the name also removes all elements, then the entire option will 938 * be removed. 914 939 * 915 940 * @since 2.1.0 916 941 * 917 * @param unknown_type $name918 * @return unknown942 * @param string $name Theme modification name. 943 * @return null 919 944 */ 920 945 function remove_theme_mod( $name ) { … … 936 961 937 962 /** 938 * remove_theme_mods() - {@internal Missing Short Description}} 939 * 940 * {@internal Missing Long Description}} 963 * Remove theme modifications option for current theme. 941 964 * 942 965 * @since 2.1.0 … … 949 972 950 973 /** 951 * get_header_textcolor() - {@internal Missing Short Description}} 952 * 953 * {@internal Missing Long Description}} 974 * Retrieve text color for custom header. 954 975 * 955 976 * @since 2.1.0 956 * 957 * @return unknown 977 * @uses HEADER_TEXTCOLOR 978 * 979 * @return string 958 980 */ 959 981 function get_header_textcolor() { … … 962 984 963 985 /** 964 * header_textcolor() - {@internal Missing Short Description}} 965 * 966 * {@internal Missing Long Description}} 986 * Display text color for custom header. 967 987 * 968 988 * @since 2.1.0 969 *970 989 */ 971 990 function header_textcolor() { … … 974 993 975 994 /** 976 * get_header_image() - {@internal Missing Short Description}} 977 * 978 * {@internal Missing Long Description}} 995 * Retrieve header image for custom header. 979 996 * 980 997 * @since 2.1.0 981 * 982 * @return unknown 998 * @uses HEADER_IMAGE 999 * 1000 * @return string 983 1001 */ 984 1002 function get_header_image() { … … 987 1005 988 1006 /** 989 * header_image() - {@internal Missing Short Description}} 990 * 991 * {@internal Missing Long Description}} 1007 * Display header image path. 992 1008 * 993 1009 * @since 2.1.0 … … 998 1014 999 1015 /** 1000 * add_custom_image_header() - {@internal Missing Short Description}} 1001 * 1002 * {@internal Missing Long Description}} 1016 * Add callbacks for image header display. 1017 * 1018 * The parameter $header_callback callback will be required to display the 1019 * content for the 'wp_head' action. The parameter $admin_header_callback 1020 * callback will be added to Custom_Image_Header class and that will be added 1021 * to the 'admin_menu' action. 1003 1022 * 1004 1023 * @since 2.1.0 1005 * 1006 * @param unknown_type $header_callback 1007 * @param unknown_type $admin_header_callback 1024 * @uses Custom_Image_Header Sets up for $admin_header_callback for administration panel display. 1025 * 1026 * @param callback $header_callback Call on 'wp_head' action. 1027 * @param callback $admin_header_callback Call on administration panels. 1008 1028 */ 1009 1029 function add_custom_image_header($header_callback, $admin_header_callback) {
Note: See TracChangeset
for help on using the changeset viewer.