WordPress.org

Make WordPress Core

Ticket #13078: 13078.1.patch

File 13078.1.patch, 3.4 KB (added by koopersmith, 8 years ago)
  • wp-includes/functions.wp-styles.php

     
    3737 * Register CSS style file.
    3838 *
    3939 * @since r79
     40 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
    4041 * @see WP_Styles::add() For additional information.
    41  * @global object $wp_styles The WP_Styles object for printing styles.
    42  * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
    4342 *
    4443 * @param string $handle Name of the stylesheet.
    4544 * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
     
    5049 * @param string $media The media for which this stylesheet has been defined.
    5150 */
    5251function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
     52        _wp_register_style( $handle, $src, $deps, $ver, $media, false);
     53}
     54
     55
     56/**
     57 * Register or enqueue a CSS style file.
     58 * This function should not be called directly, use wp_register_style() or wp_enqueue_style() instead.
     59 *
     60 * @since 3.0
     61 * @access private
     62 * @global object $wp_styles The WP_Styles object for printing styles.
     63 * @see wp_register_style(), wp_enqueue_style(), WP_Styles::add(), WP_Styles::enqueue()
     64 *
     65 * @param string $handle Name of the stylesheet.
     66 * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
     67 * @param array $deps Array of handles of any stylesheet that this stylesheet depends on.
     68 *  (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
     69 * @param string|bool $ver String specifying the stylesheet version number. Set to NULL to disable.
     70 *  Used to ensure that the correct version is sent to the client regardless of caching.
     71 * @param string $media The media for which this stylesheet has been defined.
     72 * @param boolean $enqueue If the stylesheet will be enqueued.
     73 *
     74 **/
     75function _wp_register_style( $handle, $src, $deps, $ver, $media, $enqueue ) {
    5376        global $wp_styles;
    5477        if ( !is_a($wp_styles, 'WP_Styles') )
    5578                $wp_styles = new WP_Styles();
    5679
    57         $wp_styles->add( $handle, $src, $deps, $ver, $media );
     80        if ( $src ) {
     81                $wp_styles->add( $handle, $src, $deps, $ver, $media );
     82        }
     83        if ( $enqueue ) {
     84                $wp_styles->enqueue( $handle );
     85        }
    5886}
    5987
    6088/**
     
    81109 *
    82110 * @since r79
    83111 * @see WP_Styles::add(), WP_Styles::enqueue()
    84  * @global object $wp_styles The WP_Styles object for printing styles.
    85112 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
    86113 *
    87114 * @param string $handle Name of the stylesheet.
     
    93120 *  if a version number is available and makes sense for the stylesheet.
    94121 * @param string $media The media for which this stylesheet has been defined.
    95122 */
    96 function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = false ) {
    97         global $wp_styles;
    98         if ( !is_a($wp_styles, 'WP_Styles') )
    99                 $wp_styles = new WP_Styles();
    100 
    101         if ( $src ) {
    102                 $_handle = explode('?', $handle);
    103                 $wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
    104         }
    105         $wp_styles->enqueue( $handle );
     123function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
     124        _wp_register_style( $handle, $src, $deps, $ver, $media, true);
    106125}
    107126
    108127/**