Make WordPress Core

Changeset 36744


Ignore:
Timestamp:
02/27/2016 08:33:57 PM (9 years ago)
Author:
ocean90
Message:

Docs: Improve inline docs for WP_Dependencies, WP_Styles, and WP_Scripts.

Also, make them and related files part of WordPress.

See #35964.

Location:
trunk/src/wp-includes
Files:
6 edited

Legend:

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

    r36732 r36744  
    11<?php
    22/**
    3  * BackPress Scripts enqueue
     3 * Dependencies API: WP_Dependencies base class
    44 *
    5  * Classes were refactored from the WP_Scripts and WordPress script enqueue API.
     5 * @since 2.6.0
    66 *
    7  * @since BackPress r74
     7 * @package WordPress
     8 * @subpackage Dependencies
     9 */
     10
     11/**
     12 * Core base class extended to register items.
    813 *
    9  * @package BackPress
     14 * @package WordPress
     15 * @since 2.6.0
    1016 * @uses _WP_Dependency
    11  * @since r74
    1217 */
    1318class WP_Dependencies {
     
    7883
    7984    /**
    80      * Process the items and dependencies.
     85     * Processes the items and dependencies.
    8186     *
    8287     * Processes the items passed to it or the queue, and their dependencies.
     
    117122
    118123    /**
    119      * Process a dependency.
     124     * Processes a dependency.
    120125     *
    121126     * @access public
     
    130135
    131136    /**
    132      * Determine dependencies.
     137     * Determines dependencies.
    133138     *
    134139     * Recursively builds an array of items to process taking
     
    140145     * @since 2.8.0 Added the `$group` parameter.
    141146     *
    142      * @param mixed $handles   Item handle and argument (string) or item handles and arguments (array of strings).
    143      * @param bool  $recursion Internal flag that function is calling itself.
    144      * @param mixed $group     Group level: (int) level, (false) no groups.
     147     * @param mixed     $handles   Item handle and argument (string) or item handles and arguments (array of strings).
     148     * @param bool      $recursion Internal flag that function is calling itself.
     149     * @param int|false $group     Group level: (int) level, (false) no groups.
    145150     * @return bool True on success, false on failure.
    146151     */
  • trunk/src/wp-includes/class.wp-scripts.php

    r36730 r36744  
    11<?php
    22/**
    3  * BackPress Scripts enqueue.
     3 * Dependencies API: WP_Scripts class
    44 *
    5  * These classes were refactored from the WordPress WP_Scripts and WordPress
    6  * script enqueue API.
     5 * @since 2.6.0
    76 *
    8  * @package BackPress
    9  * @since r16
     7 * @package WordPress
     8 * @subpackage Dependencies
    109 */
    1110
    1211/**
    13  * BackPress Scripts enqueue class.
     12 * Core class used to register scripts.
    1413 *
    15  * @package BackPress
     14 * @package WordPress
    1615 * @uses WP_Dependencies
    17  * @since r16
     16 * @since 2.1.0
    1817 */
    1918class WP_Scripts extends WP_Dependencies {
     
    3029
    3130    /**
     31     * URL of the content directory.
    3232     *
    3333     * @since 2.8.0
     
    3838
    3939    /**
     40     * Default version string for stylesheets.
    4041     *
    4142     * @since 2.6.0
     
    4647
    4748    /**
     49     * Holds handles of scripts which are enqueued in footer.
    4850     *
    4951     * @since 2.8.0
     
    5456
    5557    /**
     58     * Holds a list of script handles which will be concatenated.
    5659     *
    5760     * @since 2.8.0
     
    6265
    6366    /**
    64      *
    65      * @since 2.8.0
     67     * Holds a string which contains script handles and their version.
     68     *
     69     * @since 2.8.0
     70     * @deprecated 3.4.0
    6671     * @access public
    6772     * @var string
     
    7075
    7176    /**
     77     * Whether to perform concatenation.
    7278     *
    7379     * @since 2.8.0
     
    7884
    7985    /**
     86     * Holds HTML markup of scripts and additional data if concatenation
     87     * is enabled.
    8088     *
    8189     * @since 2.8.0
     
    94102
    95103    /**
     104     * Holds inline code if concatenation is enabled.
    96105     *
    97106     * @since 2.8.0
     
    102111
    103112    /**
     113     * Holds a list of script handles which are not in the default directory
     114     * if concatenation is enabled.
     115     *
     116     * Unused in core.
    104117     *
    105118     * @since 2.8.0
     
    110123
    111124    /**
     125     * Holds a string which contains handles and versions of scripts which
     126     * are not in the default directory if concatenation is enabled.
     127     *
     128     * Unused in core.
    112129     *
    113130     * @since 2.8.0
     
    118135
    119136    /**
     137     * List of default directories.
    120138     *
    121139     * @since 2.8.0
     
    173191
    174192    /**
     193     * Prints extra scripts of a registered script.
    175194     *
    176195     * @since 2.1.0
     
    181200     * @see print_extra_script()
    182201     *
    183      * @param string $handle
    184      * @param bool   $echo
    185      * @return bool|string|void
     202     * @param string $handle The script's registered handle.
     203     * @param bool   $echo   Optional. Whether to echo the extra script instead of just returning it.
     204     *                       Default true.
     205     * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise.
    186206     */
    187207    public function print_scripts_l10n( $handle, $echo = true ) {
     
    191211
    192212    /**
     213     * Prints extra scripts of a registered script.
    193214     *
    194215     * @since 3.3.0
    195216     * @access public
    196217     *
    197      * @param string $handle
    198      * @param bool   $echo
    199      * @return bool|string|void
     218     * @param string $handle The script's registered handle.
     219     * @param bool   $echo   Optional. Whether to echo the extra script instead of just returning it.
     220     *                       Default true.
     221     * @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise.
    200222     */
    201223    public function print_extra_script( $handle, $echo = true ) {
     
    216238
    217239    /**
     240     * Processes a script dependency.
    218241     *
    219242     * @since 2.6.0
     
    221244     * @access public
    222245     *
    223      * @param string   $handle Name of the item. Should be unique.
    224      * @param int|bool $group
    225      * @return bool True on success, false if not set.
     246     * @see WP_Dependencies::do_item()
     247     *
     248     * @param string $handle    The script's registered handle.
     249     * @param int|false $group  Optional. Group level: (int) level, (false) no groups. Default false.
     250     * @return bool True on success, false on failure.
    226251     */
    227252    public function do_item( $handle, $group = false ) {
     
    407432
    408433    /**
    409      * Localizes a script, only if the script has already been added
     434     * Localizes a script, only if the script has already been added.
    410435     *
    411436     * @since 2.1.0
     
    447472
    448473    /**
    449      *
    450      * @since 2.8.0
    451      * @access public
    452      *
    453      * @param string $handle    Name of the item. Should be unique.
    454      * @param bool   $recursion Internal flag that calling function was called recursively.
    455      * @param mixed  $group     Group level.
     474     * Sets handle group.
     475     *
     476     * @since 2.8.0
     477     * @access public
     478     *
     479     * @see WP_Dependencies::set_group()
     480     *
     481     * @param string    $handle    Name of the item. Should be unique.
     482     * @param bool      $recursion Internal flag that calling function was called recursively.
     483     * @param int|false $group     Optional. Group level: (int) level, (false) no groups. Default false.
    456484     * @return bool Not already in the group or a lower group
    457485     */
     
    469497
    470498    /**
    471      *
     499     * Determines script dependencies.
     500     *
    472501     * @since 2.1.0
    473502     * @access public
    474503     *
    475      * @param mixed $handles   Item handle and argument (string) or item handles and arguments (array of strings).
    476      * @param bool  $recursion Internal flag that function is calling itself.
    477      * @param mixed $group     Group level: (int) level, (false) no groups.
     504     * @see WP_Dependencies::all_deps()
     505     *
     506     * @param mixed     $handles   Item handle and argument (string) or item handles and arguments (array of strings).
     507     * @param bool      $recursion Internal flag that function is calling itself.
     508     * @param int|false $group     Optional. Group level: (int) level, (false) no groups. Default false.
    478509     * @return bool True on success, false on failure.
    479510     */
     
    494525
    495526    /**
    496      *
    497      * @since 2.8.0
    498      * @access public
    499      *
    500      * @return array
     527     * Processes items and dependencies for the head group.
     528     *
     529     * @since 2.8.0
     530     * @access public
     531     *
     532     * @see WP_Dependencies::do_items()
     533     *
     534     * @return array Handles of items that have been processed.
    501535     */
    502536    public function do_head_items() {
     
    506540
    507541    /**
    508      *
    509      * @since 2.8.0
    510      * @access public
    511      *
    512      * @return array
     542     * Processes items and dependencies for the footer group.
     543     *
     544     * @since 2.8.0
     545     * @access public
     546     *
     547     * @see WP_Dependencies::do_items()
     548     *
     549     * @return array Handles of items that have been processed.
    513550     */
    514551    public function do_footer_items() {
     
    518555
    519556    /**
    520      *
    521      * @since 2.8.0
    522      * @access public
    523      *
    524      * @param string $src
    525      * @return bool
     557     * Whether a handle's source is in a default directory.
     558     *
     559     * @since 2.8.0
     560     * @access public
     561     *
     562     * @param string $src The source of the enqueued script.
     563     * @return bool True if found, false if not.
    526564     */
    527565    public function in_default_dir( $src ) {
     
    543581
    544582    /**
     583     * Resets class properties.
    545584     *
    546585     * @since 2.8.0
  • trunk/src/wp-includes/class.wp-styles.php

    r36733 r36744  
    11<?php
    22/**
    3  * BackPress Styles enqueue.
     3 * Dependencies API: WP_Styles class
    44 *
    5  * These classes were refactored from the WordPress WP_Scripts and WordPress
    6  * script enqueue API.
     5 * @since 2.6.0
    76 *
    8  * @package BackPress
    9  * @since r74
     7 * @package WordPress
     8 * @subpackage Dependencies
    109 */
    1110
    1211/**
    13  * BackPress Styles enqueue class.
     12 * Core class used to register styles.
    1413 *
    15  * @package BackPress
     14 * @package WordPress
    1615 * @uses WP_Dependencies
    17  * @since r74
     16 * @since 2.6.0
    1817 */
    1918class WP_Styles extends WP_Dependencies {
     
    3029
    3130    /**
     31     * URL of the content directory.
    3232     *
    3333     * @since 2.8.0
     
    3838
    3939    /**
     40     * Default version string for stylesheets.
    4041     *
    4142     * @since 2.6.0
     
    4647
    4748    /**
     49     * The current text direction.
    4850     *
    4951     * @since 2.6.0
     
    5456
    5557    /**
     58     * Holds a list of style handles which will be concatenated.
    5659     *
    5760     * @since 2.8.0
     
    6265
    6366    /**
    64      *
    65      * @since 2.8.0
     67     * Holds a string which contains style handles and their version.
     68     *
     69     * @since 2.8.0
     70     * @deprecated 3.4.0
    6671     * @access public
    6772     * @var string
     
    7075
    7176    /**
     77     * Whether to perform concatenation.
    7278     *
    7379     * @since 2.8.0
     
    7884
    7985    /**
     86     * Holds HTML markup of styles and additional data if concatenation
     87     * is enabled.
    8088     *
    8189     * @since 2.8.0
     
    8694
    8795    /**
     96     * Holds inline styles if concatenation is enabled.
    8897     *
    8998     * @since 3.3.0
     
    94103
    95104    /**
     105     * List of default directories.
    96106     *
    97107     * @since 2.8.0
     
    119129
    120130    /**
    121      *
    122      * @since 2.6.0
    123      * @access public
    124      *
    125      * @param string $handle
    126      * @return bool
     131     * Processes a style dependency.
     132     *
     133     * @since 2.6.0
     134     * @access public
     135     *
     136     * @see WP_Dependencies::do_item()
     137     *
     138     * @param string $handle The style's registered handle.
     139     * @return bool True on success, false on failure.
    127140     */
    128141    public function do_item( $handle ) {
     
    231244
    232245    /**
     246     * Adds extra CSS styles to a registered stylesheet.
    233247     *
    234248     * @since 3.3.0
    235249     * @access public
    236250     *
    237      * @param string $handle
    238      * @param string $code
     251     * @param string $handle The style's registered handle.
     252     * @param string $code   String containing the CSS styles to be added.
     253     * @return bool True on success, false on failure.
    239254     */
    240255    public function add_inline_style( $handle, $code ) {
     
    254269
    255270    /**
     271     * Prints extra CSS styles of a registered stylesheet.
    256272     *
    257273     * @since 3.3.0
    258274     * @access public
    259275     *
    260      * @param string $handle
    261      * @param bool $echo
    262      * @return bool
     276     * @param string $handle The style's registered handle.
     277     * @param bool   $echo   Optional. Whether to echo the inline style instead of just returning it.
     278     *                       Default true.
     279     * @return string|bool False if no data exists, inline styles if `$echo` is true, true otherwise.
    263280     */
    264281    public function print_inline_style( $handle, $echo = true ) {
     
    281298
    282299    /**
    283      *
    284      * @since 2.6.0
    285      * @access public
    286      *
    287      * @param mixed $handles
    288      * @param bool $recursion
    289      * @param mixed $group
    290      * @return bool
     300     * Determines style dependencies.
     301     *
     302     * @since 2.6.0
     303     * @access public
     304     *
     305     * @see WP_Dependencies::all_deps()
     306     *
     307     * @param mixed     $handles   Item handle and argument (string) or item handles and arguments (array of strings).
     308     * @param bool      $recursion Internal flag that function is calling itself.
     309     * @param int|false $group     Group level: (int) level, (false) no groups.
     310     * @return bool True on success, false on failure.
    291311     */
    292312    public function all_deps( $handles, $recursion = false, $group = false ) {
    293313        $r = parent::all_deps( $handles, $recursion );
    294         if ( !$recursion ) {
     314        if ( ! $recursion ) {
    295315            /**
    296316             * Filter the array of enqueued styles before processing for output.
     
    306326
    307327    /**
    308      *
    309      * @since 2.6.0
    310      * @access public
    311      *
    312      * @param string $src
    313      * @param string $ver
    314      * @param string $handle
    315      * @return string
     328     * Generates an enqueued style's fully-qualified URL.
     329     *
     330     * @since 2.6.0
     331     * @access public
     332     *
     333     * @param string $src The source of the enqueued style.
     334     * @param string $ver The version of the enqueued style.
     335     * @param string $handle The style's registered handle.
     336     * @return string Style's fully-qualified URL.
    316337     */
    317338    public function _css_href( $src, $ver, $handle ) {
     
    336357
    337358    /**
    338      *
    339      * @since 2.8.0
    340      * @access public
    341      *
    342      * @param string $src
    343      * @return bool
     359     * Whether a handle's source is in a default directory.
     360     *
     361     * @since 2.8.0
     362     * @access public
     363     *
     364     * @param string $src The source of the enqueued style.
     365     * @return bool True if found, false if not.
    344366     */
    345367    public function in_default_dir( $src ) {
     
    355377
    356378    /**
     379     * Processes items and dependencies for the footer group.
    357380     *
    358381     * HTML 5 allows styles in the body, grab late enqueued items and output them in the footer.
     
    361384     * @access public
    362385     *
    363      * @return array
     386     * @see WP_Dependencies::do_items()
     387     *
     388     * @return array Handles of items that have been processed.
    364389     */
    365390    public function do_footer_items() {
     
    369394
    370395    /**
     396     * Resets class properties.
    371397     *
    372398     * @since 3.3.0
  • trunk/src/wp-includes/functions.wp-scripts.php

    r36729 r36744  
    11<?php
    22/**
    3  * BackPress Scripts Procedural API
     3 * Dependencies API: Scripts functions
    44 *
    55 * @since 2.6.0
    66 *
    77 * @package WordPress
    8  * @subpackage BackPress
     8 * @subpackage Dependencies
    99 */
    1010
  • trunk/src/wp-includes/functions.wp-styles.php

    r36649 r36744  
    11<?php
    22/**
    3  * BackPress Styles Procedural API
     3 * Dependencies API: Styles functions
    44 *
    55 * @since 2.6.0
    66 *
    77 * @package WordPress
    8  * @subpackage BackPress
     8 * @subpackage Dependencies
    99 */
    1010
  • trunk/src/wp-includes/script-loader.php

    r36733 r36744  
    22/**
    33 * WordPress scripts and styles default loader.
    4  *
    5  * Most of the functionality that existed here was moved to
    6  * {@link http://backpress.automattic.com/ BackPress}. WordPress themes and
    7  * plugins will only be concerned about the filters and actions set in this
    8  * file.
    94 *
    105 * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
     
    2217 */
    2318
    24 /** BackPress: WordPress Dependencies Class */
     19/** WordPress Dependencies Class */
    2520require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
    2621
    27 /** BackPress: WordPress Scripts Class */
     22/** WordPress Scripts Class */
    2823require( ABSPATH . WPINC . '/class.wp-scripts.php' );
    2924
    30 /** BackPress: WordPress Scripts Functions */
     25/** WordPress Scripts Functions */
    3126require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
    3227
    33 /** BackPress: WordPress Styles Class */
     28/** WordPress Styles Class */
    3429require( ABSPATH . WPINC . '/class.wp-styles.php' );
    3530
    36 /** BackPress: WordPress Styles Functions */
     31/** WordPress Styles Functions */
    3732require( ABSPATH . WPINC . '/functions.wp-styles.php' );
    3833
Note: See TracChangeset for help on using the changeset viewer.