Make WordPress Core

Ticket #7657: 7657.r8786.diff

File 7657.r8786.diff, 13.4 KB (added by jacobsantos, 16 years ago)

Incomplete skeleton patch based off of r8786

  • theme.php

     
    11<?php
    22/**
     3 * Theme, template, and stylesheet functions.
     4 *
    35 * @package WordPress
    4  * @subpackage Themes
    5  * @since 0.0
    6  * Theme/template/stylesheet functions.
     6 * @subpackage Template
    77 */
     8
     9/**
     10 * Get current theme name.
     11 *
     12 * The theme name that the administrator has currently set the frontend theme
     13 * as.
     14 *
     15 * @since 1.5.0
     16 * @uses apply_filters() Calls 'stylesheet' filter
     17 *
     18 * @return string
     19 */
    820function get_stylesheet() {
    921        return apply_filters('stylesheet', get_option('stylesheet'));
    1022}
    1123
     24/**
     25 * get_stylesheet_directory() - {@internal Missing Short Description}}
     26 *
     27 * {@internal Missing Long Description}}
     28 *
     29 * @since 1.5.0
     30 *
     31 * @return unknown
     32 */
    1233function get_stylesheet_directory() {
    1334        $stylesheet = get_stylesheet();
    1435        $stylesheet_dir = get_theme_root() . "/$stylesheet";
    1536        return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
    1637}
    1738
     39/**
     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
     47 */
    1848function get_stylesheet_directory_uri() {
    1949        $stylesheet = get_stylesheet();
    2050        $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
    2151        return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
    2252}
    2353
     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
     62 */
    2463function get_stylesheet_uri() {
    2564        $stylesheet_dir_uri = get_stylesheet_directory_uri();
    2665        $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
    2766        return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
    2867}
    2968
     69/**
     70 * get_locale_stylesheet_uri() - {@internal Missing Short Description}}
     71 *
     72 * {@internal Missing Long Description}}
     73 *
     74 * @since 2.1.0
     75 *
     76 * @return unknown
     77 */
    3078function get_locale_stylesheet_uri() {
    3179        global $wp_locale;
    3280        $stylesheet_dir_uri = get_stylesheet_directory_uri();
     
    4189        return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
    4290}
    4391
     92/**
     93 * get_template() - {@internal Missing Short Description}}
     94 *
     95 * {@internal Missing Long Description}}
     96 *
     97 * @since 1.5.0
     98 *
     99 * @return unknown
     100 */
    44101function get_template() {
    45102        return apply_filters('template', get_option('template'));
    46103}
    47104
     105/**
     106 * get_template_directory() - {@internal Missing Short Description}}
     107 *
     108 * {@internal Missing Long Description}}
     109 *
     110 * @since 1.5.0
     111 *
     112 * @return unknown
     113 */
    48114function get_template_directory() {
    49115        $template = get_template();
    50116        $template_dir = get_theme_root() . "/$template";
    51117        return apply_filters('template_directory', $template_dir, $template);
    52118}
    53119
     120/**
     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
     128 */
    54129function get_template_directory_uri() {
    55130        $template = get_template();
    56131        $template_dir_uri = get_theme_root_uri() . "/$template";
    57132        return apply_filters('template_directory_uri', $template_dir_uri, $template);
    58133}
    59134
     135/**
     136 * get_theme_data() - {@internal Missing Short Description}}
     137 *
     138 * {@internal Missing Long Description}}
     139 *
     140 * @since 1.5.0
     141 *
     142 * @param unknown_type $theme_file
     143 * @return unknown
     144 */
    60145function get_theme_data( $theme_file ) {
    61146        $themes_allowed_tags = array(
    62147                'a' => array(
     
    121206        return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags );
    122207}
    123208
     209/**
     210 * get_themes() - {@internal Missing Short Description}}
     211 *
     212 * {@internal Missing Long Description}}
     213 *
     214 * @since 1.5.0
     215 *
     216 * @return unknown
     217 */
    124218function get_themes() {
    125219        global $wp_themes, $wp_broken_themes;
    126220
     
    305399        return $themes;
    306400}
    307401
     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
     411 */
    308412function get_theme($theme) {
    309413        $themes = get_themes();
    310414
     
    314418        return NULL;
    315419}
    316420
     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
     429 */
    317430function get_current_theme() {
    318431        if ( $theme = get_option('current_theme') )
    319432                return $theme;
     
    339452        return $current_theme;
    340453}
    341454
     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
     463 */
    342464function get_theme_root() {
    343465        return apply_filters('theme_root', WP_CONTENT_DIR . "/themes");
    344466}
    345467
     468/**
     469 * get_theme_root_uri() - {@internal Missing Short Description}}
     470 *
     471 * {@internal Missing Long Description}}
     472 *
     473 * @since 1.5.0
     474 *
     475 * @return unknown
     476 */
    346477function get_theme_root_uri() {
    347478        return apply_filters('theme_root_uri', content_url('themes'), get_option('siteurl'));
    348479}
    349480
     481/**
     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
     490 */
    350491function get_query_template($type) {
    351492        $type = preg_replace( '|[^a-z0-9-]+|', '', $type );
    352493        return apply_filters("{$type}_template", locate_template(array("{$type}.php")));
    353494}
    354495
     496/**
     497 * get_404_template() - {@internal Missing Short Description}}
     498 *
     499 * {@internal Missing Long Description}}
     500 *
     501 * @since 1.5.0
     502 *
     503 * @return unknown
     504 */
    355505function get_404_template() {
    356506        return get_query_template('404');
    357507}
    358508
     509/**
     510 * get_archive_template() - {@internal Missing Short Description}}
     511 *
     512 * {@internal Missing Long Description}}
     513 *
     514 * @since 1.5.0
     515 *
     516 * @return unknown
     517 */
    359518function get_archive_template() {
    360519        return get_query_template('archive');
    361520}
    362521
     522/**
     523 * get_author_template() - {@internal Missing Short Description}}
     524 *
     525 * {@internal Missing Long Description}}
     526 *
     527 * @since 1.5.0
     528 *
     529 * @return unknown
     530 */
    363531function get_author_template() {
    364532        return get_query_template('author');
    365533}
    366534
     535/**
     536 * get_category_template() - {@internal Missing Short Description}}
     537 *
     538 * {@internal Missing Long Description}}
     539 *
     540 * @since 1.5.0
     541 *
     542 * @return unknown
     543 */
    367544function get_category_template() {
    368545        $template =locate_template(array("category-" . absint( get_query_var('cat') ) . '.php',"category.php"));
    369546        return apply_filters('category_template', $template);
    370547}
    371548
     549/**
     550 * get_tag_template() - {@internal Missing Short Description}}
     551 *
     552 * {@internal Missing Long Description}}
     553 *
     554 * @since 2.3.0
     555 *
     556 * @return unknown
     557 */
    372558function get_tag_template() {
    373559        $template = locate_template(array("tag-" . absint( get_query_var('tag') ) . '.php',"tag.php"));
    374560        return apply_filters('tag_template', $template);
    375561}
    376562
     563/**
     564 * get_date_template() - {@internal Missing Short Description}}
     565 *
     566 * {@internal Missing Long Description}}
     567 *
     568 * @since 1.5.0
     569 *
     570 * @return unknown
     571 */
    377572function get_taxonomy_template() {
    378573        $taxonomy = get_query_var('taxonomy');
    379574        $term = get_query_var('term');
     
    394589        return get_query_template('date');
    395590}
    396591
     592/**
     593 * get_home_template() - {@internal Missing Short Description}}
     594 *
     595 * {@internal Missing Long Description}}
     596 *
     597 * @since 1.5.0
     598 *
     599 * @return unknown
     600 */
    397601function get_home_template() {
    398602        $template = locate_template(array('home.php','index.php'));
    399603        return apply_filters('home_template', $template);
    400604}
    401605
     606/**
     607 * get_page_template() - {@internal Missing Short Description}}
     608 *
     609 * {@internal Missing Long Description}}
     610 *
     611 * @since 1.5.0
     612 *
     613 * @return unknown
     614 */
    402615function get_page_template() {
    403616        global $wp_query;
    404617
     
    417630        return apply_filters('page_template', locate_template($templates));
    418631}
    419632
     633/**
     634 * get_paged_template() - {@internal Missing Short Description}}
     635 *
     636 * {@internal Missing Long Description}}
     637 *
     638 * @since 1.5.0
     639 *
     640 * @return unknown
     641 */
    420642function get_paged_template() {
    421643        return get_query_template('paged');
    422644}
    423645
     646/**
     647 * get_search_template() - {@internal Missing Short Description}}
     648 *
     649 * {@internal Missing Long Description}}
     650 *
     651 * @since 1.5.0
     652 *
     653 * @return unknown
     654 */
    424655function get_search_template() {
    425656        return get_query_template('search');
    426657}
    427658
     659/**
     660 * get_single_template() - {@internal Missing Short Description}}
     661 *
     662 * {@internal Missing Long Description}}
     663 *
     664 * @since 1.5.0
     665 *
     666 * @return unknown
     667 */
    428668function get_single_template() {
    429669        return get_query_template('single');
    430670}
    431671
     672/**
     673 * get_attachment_template() - {@internal Missing Short Description}}
     674 *
     675 * {@internal Missing Long Description}}
     676 *
     677 * @since 2.0.0
     678 *
     679 * @return unknown
     680 */
    432681function get_attachment_template() {
    433682        global $posts;
    434683        $type = explode('/', $posts[0]->post_mime_type);
     
    442691                return get_query_template('attachment');
    443692}
    444693
     694/**
     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
     702 */
    445703function get_comments_popup_template() {
    446704        $template = locate_template(array("comments-popup.php"));
    447705        if ('' == $template)
     
    482740        return $located;
    483741}
    484742
     743/**
     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
     751 */
    485752function load_template($_template_file) {
    486753        global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
    487754
     
    491758        require_once($_template_file);
    492759}
    493760
     761/**
     762 * locale_stylesheet() - {@internal Missing Short Description}}
     763 *
     764 * {@internal Missing Long Description}}
     765 *
     766 * @since 2.1.0
     767 */
    494768function locale_stylesheet() {
    495769        $stylesheet = get_locale_stylesheet_uri();
    496770        if ( empty($stylesheet) )
     
    498772        echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
    499773}
    500774
     775/**
     776 * switch_theme() - {@internal Missing Short Description}}
     777 *
     778 * {@internal Missing Long Description}}
     779 *
     780 * @since 2.5.0
     781 *
     782 * @param unknown_type $template
     783 * @param unknown_type $stylesheet
     784 */
    501785function preview_theme() {
    502786        if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
    503787                return;
     
    553837        do_action('switch_theme', $theme);
    554838}
    555839
     840/**
     841 * validate_current_theme() - {@internal Missing Short Description}}
     842 *
     843 * {@internal Missing Long Description}}
     844 *
     845 * @since 1.5.0
     846 *
     847 * @return unknown
     848 */
    556849function validate_current_theme() {
    557850        // Don't validate during an install/upgrade.
    558851        if ( defined('WP_INSTALLING') )
     
    571864        return true;
    572865}
    573866
     867/**
     868 * get_theme_mod() - {@internal Missing Short Description}}
     869 *
     870 * {@internal Missing Long Description}}
     871 *
     872 * @since 2.1.0
     873 *
     874 * @param unknown_type $name
     875 * @param unknown_type $default
     876 * @return unknown
     877 */
    574878function get_theme_mod($name, $default = false) {
    575879        $theme = get_current_theme();
    576880
     
    582886        return apply_filters( "theme_mod_$name", sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()) );
    583887}
    584888
     889/**
     890 * set_theme_mod() - {@internal Missing Short Description}}
     891 *
     892 * {@internal Missing Long Description}}
     893 *
     894 * @since 2.1.0
     895 *
     896 * @param unknown_type $name
     897 * @param unknown_type $value
     898 */
    585899function set_theme_mod($name, $value) {
    586900        $theme = get_current_theme();
    587901
     
    593907        wp_cache_delete("mods_$theme", 'options');
    594908}
    595909
     910/**
     911 * remove_theme_mod() - {@internal Missing Short Description}}
     912 *
     913 * {@internal Missing Long Description}}
     914 *
     915 * @since 2.1.0
     916 *
     917 * @param unknown_type $name
     918 * @return unknown
     919 */
    596920function remove_theme_mod( $name ) {
    597921        $theme = get_current_theme();
    598922
     
    610934        wp_cache_delete("mods_$theme", 'options');
    611935}
    612936
     937/**
     938 * remove_theme_mods() - {@internal Missing Short Description}}
     939 *
     940 * {@internal Missing Long Description}}
     941 *
     942 * @since 2.1.0
     943 */
    613944function remove_theme_mods() {
    614945        $theme = get_current_theme();
    615946
    616947        delete_option("mods_$theme");
    617948}
    618949
     950/**
     951 * get_header_textcolor() - {@internal Missing Short Description}}
     952 *
     953 * {@internal Missing Long Description}}
     954 *
     955 * @since 2.1.0
     956 *
     957 * @return unknown
     958 */
    619959function get_header_textcolor() {
    620960        return get_theme_mod('header_textcolor', HEADER_TEXTCOLOR);
    621961}
    622962
     963/**
     964 * header_textcolor() - {@internal Missing Short Description}}
     965 *
     966 * {@internal Missing Long Description}}
     967 *
     968 * @since 2.1.0
     969 *
     970 */
    623971function header_textcolor() {
    624972        echo get_header_textcolor();
    625973}
    626974
     975/**
     976 * get_header_image() - {@internal Missing Short Description}}
     977 *
     978 * {@internal Missing Long Description}}
     979 *
     980 * @since 2.1.0
     981 *
     982 * @return unknown
     983 */
    627984function get_header_image() {
    628985        return get_theme_mod('header_image', HEADER_IMAGE);
    629986}
    630987
     988/**
     989 * header_image() - {@internal Missing Short Description}}
     990 *
     991 * {@internal Missing Long Description}}
     992 *
     993 * @since 2.1.0
     994 */
    631995function header_image() {
    632996        echo get_header_image();
    633997}
    634998
     999/**
     1000 * add_custom_image_header() - {@internal Missing Short Description}}
     1001 *
     1002 * {@internal Missing Long Description}}
     1003 *
     1004 * @since 2.1.0
     1005 *
     1006 * @param unknown_type $header_callback
     1007 * @param unknown_type $admin_header_callback
     1008 */
    6351009function add_custom_image_header($header_callback, $admin_header_callback) {
    6361010        if ( ! empty($header_callback) )
    6371011                add_action('wp_head', $header_callback);