WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/01/2013 05:23:05 PM (5 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/theme.php.

Props ShinichiN.
Fixes #25588.

File:
1 edited

Legend:

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

    r26352 r26501  
    142142 *
    143143 * @since 1.5.0
    144  * @uses apply_filters() Calls 'stylesheet' filter on stylesheet name.
    145144 *
    146145 * @return string Stylesheet name.
    147146 */
    148147function get_stylesheet() {
    149     return apply_filters('stylesheet', get_option('stylesheet'));
     148    /**
     149     * Filter the name of current stylesheet.
     150     *
     151     * @since 1.5.0
     152     *
     153     * @param string $stylesheet Name of the current stylesheet.
     154     */
     155    return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );
    150156}
    151157
     
    154160 *
    155161 * @since 1.5.0
    156  * @uses apply_filters() Calls 'stylesheet_directory' filter on stylesheet directory and theme name.
    157162 *
    158163 * @return string Path to current theme directory.
     
    163168    $stylesheet_dir = "$theme_root/$stylesheet";
    164169
     170    /**
     171     * Filter the stylesheet directory path for current theme.
     172     *
     173     * @since 1.5.0
     174     *
     175     * @param string $stylesheet_dir Absolute path to the current them.
     176     * @param string $stylesheet     Directory name of the current theme.
     177     * @param string $theme_root     Absolute path to themes directory.
     178     */
    165179    return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
    166180}
     
    178192    $stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
    179193
     194    /**
     195     * Filter the stylesheet directory URI.
     196     *
     197     * @since 1.5.0
     198     *
     199     * @param string $stylesheet_dir_uri Stylesheet directory URI.
     200     * @param string $stylesheet         Name of the activated theme's directory.
     201     * @param string $theme_root_uri     Themes root URI.
     202     */
    180203    return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
    181204}
     
    188211 *
    189212 * @since 1.5.0
    190  * @uses apply_filters() Calls 'stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.
    191213 *
    192214 * @return string
     
    195217    $stylesheet_dir_uri = get_stylesheet_directory_uri();
    196218    $stylesheet_uri = $stylesheet_dir_uri . '/style.css';
    197     return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
     219    /**
     220     * Filter the URI of the current theme stylesheet.
     221     *
     222     * @since 1.5.0
     223     *
     224     * @param string $stylesheet_uri     Stylesheet URI for the current theme/child theme.
     225     * @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme.
     226     */
     227    return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
    198228}
    199229
     
    213243 *
    214244 * @since 2.1.0
    215  * @uses apply_filters() Calls 'locale_stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.
    216245 *
    217246 * @return string
     
    228257    else
    229258        $stylesheet_uri = '';
    230     return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
     259    /**
     260     * Filter the localized stylesheet URI.
     261     *
     262     * @since 2.1.0
     263     *
     264     * @param string $stylesheet_uri     Localized stylesheet URI.
     265     * @param string $stylesheet_dir_uri Stylesheet directory URI.
     266     */
     267    return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
    231268}
    232269
     
    240277 */
    241278function get_template() {
    242     return apply_filters('template', get_option('template'));
     279    /**
     280     * Filter the name of the current theme.
     281     *
     282     * @since 1.5.0
     283     *
     284     * @param string $template Current theme's directory name.
     285     */
     286    return apply_filters( 'template', get_option( 'template' ) );
    243287}
    244288
     
    247291 *
    248292 * @since 1.5.0
    249  * @uses apply_filters() Calls 'template_directory' filter on template directory path and template name.
    250293 *
    251294 * @return string Template directory path.
     
    256299    $template_dir = "$theme_root/$template";
    257300
     301    /**
     302     * Filter the current theme directory path.
     303     *
     304     * @since 1.5.0
     305     *
     306     * @param string $template_dir The URI of the current theme directory.
     307     * @param string $template     Directory name of the current theme.
     308     * @param string $theme_root   Absolute path to the themes directory.
     309     */
    258310    return apply_filters( 'template_directory', $template_dir, $template, $theme_root );
    259311}
     
    263315 *
    264316 * @since 1.5.0
    265  * @uses apply_filters() Calls 'template_directory_uri' filter on template directory URI path and template name.
    266317 *
    267318 * @return string Template directory URI.
     
    272323    $template_dir_uri = "$theme_root_uri/$template";
    273324
     325    /**
     326     * Filter the current theme directory URI.
     327     *
     328     * @since 1.5.0
     329     *
     330     * @param string $template_dir_uri The URI of the current theme directory.
     331     * @param string $template         Directory name of the current theme.
     332     * @param string $theme_root_uri   The themes root URI.
     333     */
    274334    return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
    275335}
     
    351411    }
    352412
     413    /**
     414     * Filter whether to get the cache of the registered theme directories.
     415     *
     416     * @since 3.4.0
     417     *
     418     * @param bool   $cache_expiration Whether to get the cache of the theme directories. Default false.
     419     * @param string $cache_directory  Directory to be searched for the cache.
     420     */
    353421    if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) {
    354422        $cached_roots = get_site_transient( 'theme_roots' );
     
    442510 *
    443511 * @since 1.5.0
    444  * @uses apply_filters() Calls 'theme_root' filter on path.
    445512 *
    446513 * @param string $stylesheet_or_template The stylesheet or template name of the theme
     
    459526    }
    460527
     528    /**
     529     * Filter the absolute path to the themes directory.
     530     *
     531     * @since 1.5.0
     532     *
     533     * @param string $theme_root Absolute path to themes directory.
     534     */
    461535    return apply_filters( 'theme_root', $theme_root );
    462536}
     
    499573    }
    500574
    501     return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template );
     575    /**
     576     * Filter the URI for themes directory.
     577     *
     578     * @since 1.5.0
     579     *
     580     * @param string $theme_root_uri         The URI for themes directory.
     581     * @param string $siteurl                WordPress web address which is set in General Options.
     582     * @param string $stylesheet_or_template Stylesheet or template name of the theme.
     583     */
     584    return apply_filters( 'theme_root_uri', $theme_root_uri, get_option( 'siteurl' ), $stylesheet_or_template );
    502585}
    503586
     
    666749 *
    667750 * @since 2.5.0
    668  * @uses do_action() Calls 'switch_theme' action, passing the new theme.
    669751 *
    670752 * @param string $stylesheet Stylesheet name
     
    707789
    708790    update_option( 'theme_switched', $old_theme->get_stylesheet() );
     791    /**
     792     * Fires after the theme is switched.
     793     *
     794     * @since 1.5.0
     795     *
     796     * @param string   $new_name  Name of the new theme.
     797     * @param WP_Theme $new_theme WP_Theme instance of the new theme.
     798     */
    709799    do_action( 'switch_theme', $new_name, $new_theme );
    710800}
     
    724814 */
    725815function validate_current_theme() {
    726     // Don't validate during an install/upgrade.
    727     if ( defined('WP_INSTALLING') || !apply_filters( 'validate_current_theme', true ) )
     816    /**
     817     * Filter whether to validate the current theme.
     818     *
     819     * @since 2.7.0
     820     *
     821     * @param bool true Validation flag to check the current theme.
     822     */
     823    if ( defined('WP_INSTALLING') || ! apply_filters( 'validate_current_theme', true ) )
    728824        return true;
    729825
     
    777873 *
    778874 * @since 2.1.0
    779  * @uses apply_filters() Calls 'theme_mod_$name' filter on the value.
    780875 *
    781876 * @param string $name Theme modification name.
     
    786881    $mods = get_theme_mods();
    787882
    788     if ( isset( $mods[ $name ] ) )
    789         return apply_filters( "theme_mod_$name", $mods[ $name ] );
     883    if ( isset( $mods[$name] ) ) {
     884        /**
     885         * Filter the theme modification, or 'theme_mod', value.
     886         *
     887         * The dynamic portion of the hook name, $name, refers to
     888         * the key name of the modification array. For example,
     889         * 'header_textcolor', 'header_image', and so on depending
     890         * on the theme options.
     891         *
     892         * @since 2.2.0
     893         *
     894         * @param string $current_mod The value of the current theme modification.
     895         */
     896        return apply_filters( "theme_mod_{$name}", $mods[$name] );
     897    }
    790898
    791899    if ( is_string( $default ) )
    792900        $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
    793901
    794     return apply_filters( "theme_mod_$name", $default );
     902    /** This filter is documented in wp-includes/theme.php */
     903    return apply_filters( "theme_mod_{$name}", $default );
    795904}
    796905
     
    15941703    }
    15951704
    1596     return apply_filters('current_theme_supports-' . $feature, true, $args, $_wp_theme_features[$feature]);
     1705    /**
     1706     * Filter whether the current theme supports a specific feature.
     1707     *
     1708     * The dynamic portion of the hook name, $feature, refers to
     1709     * the specific theme feature. Possible values include 'post-formats',
     1710     * 'post-thumbnails', 'custom-background', 'custom-header', 'menus',
     1711     * 'automatic-feed-links', and 'html5'.
     1712     *
     1713     * @since 3.4.0
     1714     *
     1715     * @param bool   true     Whether the current theme supports the given feature. Default true.
     1716     * @param array  $args    Array of arguments for the feature.
     1717     * @param string $feature The theme feature.
     1718     */
     1719    return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature] );
    15971720}
    15981721
     
    16421765        $old_theme = wp_get_theme( $stylesheet );
    16431766
    1644         if ( $old_theme->exists() )
    1645             do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme );
    1646         else
     1767        if ( $old_theme->exists() ) {
     1768            /**
     1769             * Fires on the first WP load after a theme switch if the old theme still exists.
     1770             *
     1771             * This action fires multiple times and the parameters differs
     1772             * according to the context, if the old theme exists or not.
     1773             * If the old theme is missing, the parameter will be the slug
     1774             * of the old theme.
     1775             *
     1776             * @since 3.3.0
     1777             *
     1778             * @param string   $old_name  Old theme name.
     1779             * @param WP_Theme $old_theme WP_Theme instance of the old theme.
     1780             */
     1781            do_action( 'after_switch_theme', $old_theme->get( 'Name' ), $old_theme );
     1782        } else {
     1783            /** This action is documented in wp-includes/theme.php */
    16471784            do_action( 'after_switch_theme', $stylesheet );
     1785        }
    16481786
    16491787        update_option( 'theme_switched', false );
Note: See TracChangeset for help on using the changeset viewer.