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

Also, make them and related files part of WordPress.

See #35964.
Built from https://develop.svn.wordpress.org/trunk@36744


git-svn-id: http://core.svn.wordpress.org/trunk@36711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-02-27 20:34:29 +00:00
parent 1f4b40b9c3
commit 820c9e2fca
7 changed files with 147 additions and 82 deletions

View File

@ -1,14 +1,19 @@
<?php
/**
* BackPress Scripts enqueue
* Dependencies API: WP_Dependencies base class
*
* Classes were refactored from the WP_Scripts and WordPress script enqueue API.
* @since 2.6.0
*
* @since BackPress r74
* @package WordPress
* @subpackage Dependencies
*/
/**
* Core base class extended to register items.
*
* @package BackPress
* @package WordPress
* @since 2.6.0
* @uses _WP_Dependency
* @since r74
*/
class WP_Dependencies {
/**
@ -77,7 +82,7 @@ class WP_Dependencies {
public $group = 0;
/**
* Process the items and dependencies.
* Processes the items and dependencies.
*
* Processes the items passed to it or the queue, and their dependencies.
*
@ -116,7 +121,7 @@ class WP_Dependencies {
}
/**
* Process a dependency.
* Processes a dependency.
*
* @access public
* @since 2.6.0
@ -129,7 +134,7 @@ class WP_Dependencies {
}
/**
* Determine dependencies.
* Determines dependencies.
*
* Recursively builds an array of items to process taking
* dependencies into account. Does NOT catch infinite loops.
@ -139,9 +144,9 @@ class WP_Dependencies {
* @since 2.6.0 Moved from `WP_Scripts`.
* @since 2.8.0 Added the `$group` parameter.
*
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself.
* @param mixed $group Group level: (int) level, (false) no groups.
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself.
* @param int|false $group Group level: (int) level, (false) no groups.
* @return bool True on success, false on failure.
*/
public function all_deps( $handles, $recursion = false, $group = false ) {

View File

@ -1,20 +1,19 @@
<?php
/**
* BackPress Scripts enqueue.
* Dependencies API: WP_Scripts class
*
* These classes were refactored from the WordPress WP_Scripts and WordPress
* script enqueue API.
* @since 2.6.0
*
* @package BackPress
* @since r16
* @package WordPress
* @subpackage Dependencies
*/
/**
* BackPress Scripts enqueue class.
* Core class used to register scripts.
*
* @package BackPress
* @package WordPress
* @uses WP_Dependencies
* @since r16
* @since 2.1.0
*/
class WP_Scripts extends WP_Dependencies {
/**
@ -29,6 +28,7 @@ class WP_Scripts extends WP_Dependencies {
public $base_url;
/**
* URL of the content directory.
*
* @since 2.8.0
* @access public
@ -37,6 +37,7 @@ class WP_Scripts extends WP_Dependencies {
public $content_url;
/**
* Default version string for stylesheets.
*
* @since 2.6.0
* @access public
@ -45,6 +46,7 @@ class WP_Scripts extends WP_Dependencies {
public $default_version;
/**
* Holds handles of scripts which are enqueued in footer.
*
* @since 2.8.0
* @access public
@ -53,6 +55,7 @@ class WP_Scripts extends WP_Dependencies {
public $in_footer = array();
/**
* Holds a list of script handles which will be concatenated.
*
* @since 2.8.0
* @access public
@ -61,14 +64,17 @@ class WP_Scripts extends WP_Dependencies {
public $concat = '';
/**
* Holds a string which contains script handles and their version.
*
* @since 2.8.0
* @deprecated 3.4.0
* @access public
* @var string
*/
public $concat_version = '';
/**
* Whether to perform concatenation.
*
* @since 2.8.0
* @access public
@ -77,6 +83,8 @@ class WP_Scripts extends WP_Dependencies {
public $do_concat = false;
/**
* Holds HTML markup of scripts and additional data if concatenation
* is enabled.
*
* @since 2.8.0
* @access public
@ -93,6 +101,7 @@ class WP_Scripts extends WP_Dependencies {
public $print_html_before = '';
/**
* Holds inline code if concatenation is enabled.
*
* @since 2.8.0
* @access public
@ -101,6 +110,10 @@ class WP_Scripts extends WP_Dependencies {
public $print_code = '';
/**
* Holds a list of script handles which are not in the default directory
* if concatenation is enabled.
*
* Unused in core.
*
* @since 2.8.0
* @access public
@ -109,6 +122,10 @@ class WP_Scripts extends WP_Dependencies {
public $ext_handles = '';
/**
* Holds a string which contains handles and versions of scripts which
* are not in the default directory if concatenation is enabled.
*
* Unused in core.
*
* @since 2.8.0
* @access public
@ -117,6 +134,7 @@ class WP_Scripts extends WP_Dependencies {
public $ext_version = '';
/**
* List of default directories.
*
* @since 2.8.0
* @access public
@ -172,6 +190,7 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Prints extra scripts of a registered script.
*
* @since 2.1.0
* @since 2.8.0 Added the `$echo` parameter.
@ -180,9 +199,10 @@ class WP_Scripts extends WP_Dependencies {
*
* @see print_extra_script()
*
* @param string $handle
* @param bool $echo
* @return bool|string|void
* @param string $handle The script's registered handle.
* @param bool $echo Optional. Whether to echo the extra script instead of just returning it.
* Default true.
* @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise.
*/
public function print_scripts_l10n( $handle, $echo = true ) {
_deprecated_function( __FUNCTION__, '3.3', 'print_extra_script()' );
@ -190,13 +210,15 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Prints extra scripts of a registered script.
*
* @since 3.3.0
* @access public
*
* @param string $handle
* @param bool $echo
* @return bool|string|void
* @param string $handle The script's registered handle.
* @param bool $echo Optional. Whether to echo the extra script instead of just returning it.
* Default true.
* @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise.
*/
public function print_extra_script( $handle, $echo = true ) {
if ( !$output = $this->get_data( $handle, 'data' ) )
@ -215,14 +237,17 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Processes a script dependency.
*
* @since 2.6.0
* @since 2.8.0 Added the `$group` parameter.
* @access public
*
* @param string $handle Name of the item. Should be unique.
* @param int|bool $group
* @return bool True on success, false if not set.
* @see WP_Dependencies::do_item()
*
* @param string $handle The script's registered handle.
* @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false.
* @return bool True on success, false on failure.
*/
public function do_item( $handle, $group = false ) {
if ( !parent::do_item($handle) )
@ -406,7 +431,7 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Localizes a script, only if the script has already been added
* Localizes a script, only if the script has already been added.
*
* @since 2.1.0
* @access public
@ -446,13 +471,16 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Sets handle group.
*
* @since 2.8.0
* @access public
*
* @param string $handle Name of the item. Should be unique.
* @param bool $recursion Internal flag that calling function was called recursively.
* @param mixed $group Group level.
* @see WP_Dependencies::set_group()
*
* @param string $handle Name of the item. Should be unique.
* @param bool $recursion Internal flag that calling function was called recursively.
* @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false.
* @return bool Not already in the group or a lower group
*/
public function set_group( $handle, $recursion, $group = false ) {
@ -468,13 +496,16 @@ class WP_Scripts extends WP_Dependencies {
}
/**
*
* Determines script dependencies.
*
* @since 2.1.0
* @access public
*
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself.
* @param mixed $group Group level: (int) level, (false) no groups.
* @see WP_Dependencies::all_deps()
*
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself.
* @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false.
* @return bool True on success, false on failure.
*/
public function all_deps( $handles, $recursion = false, $group = false ) {
@ -493,11 +524,14 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Processes items and dependencies for the head group.
*
* @since 2.8.0
* @access public
*
* @return array
* @see WP_Dependencies::do_items()
*
* @return array Handles of items that have been processed.
*/
public function do_head_items() {
$this->do_items(false, 0);
@ -505,11 +539,14 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Processes items and dependencies for the footer group.
*
* @since 2.8.0
* @access public
*
* @return array
* @see WP_Dependencies::do_items()
*
* @return array Handles of items that have been processed.
*/
public function do_footer_items() {
$this->do_items(false, 1);
@ -517,12 +554,13 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Whether a handle's source is in a default directory.
*
* @since 2.8.0
* @access public
*
* @param string $src
* @return bool
* @param string $src The source of the enqueued script.
* @return bool True if found, false if not.
*/
public function in_default_dir( $src ) {
if ( ! $this->default_dirs ) {
@ -542,6 +580,7 @@ class WP_Scripts extends WP_Dependencies {
}
/**
* Resets class properties.
*
* @since 2.8.0
* @access public

View File

@ -1,20 +1,19 @@
<?php
/**
* BackPress Styles enqueue.
* Dependencies API: WP_Styles class
*
* These classes were refactored from the WordPress WP_Scripts and WordPress
* script enqueue API.
* @since 2.6.0
*
* @package BackPress
* @since r74
* @package WordPress
* @subpackage Dependencies
*/
/**
* BackPress Styles enqueue class.
* Core class used to register styles.
*
* @package BackPress
* @package WordPress
* @uses WP_Dependencies
* @since r74
* @since 2.6.0
*/
class WP_Styles extends WP_Dependencies {
/**
@ -29,6 +28,7 @@ class WP_Styles extends WP_Dependencies {
public $base_url;
/**
* URL of the content directory.
*
* @since 2.8.0
* @access public
@ -37,6 +37,7 @@ class WP_Styles extends WP_Dependencies {
public $content_url;
/**
* Default version string for stylesheets.
*
* @since 2.6.0
* @access public
@ -45,6 +46,7 @@ class WP_Styles extends WP_Dependencies {
public $default_version;
/**
* The current text direction.
*
* @since 2.6.0
* @access public
@ -53,6 +55,7 @@ class WP_Styles extends WP_Dependencies {
public $text_direction = 'ltr';
/**
* Holds a list of style handles which will be concatenated.
*
* @since 2.8.0
* @access public
@ -61,14 +64,17 @@ class WP_Styles extends WP_Dependencies {
public $concat = '';
/**
* Holds a string which contains style handles and their version.
*
* @since 2.8.0
* @deprecated 3.4.0
* @access public
* @var string
*/
public $concat_version = '';
/**
* Whether to perform concatenation.
*
* @since 2.8.0
* @access public
@ -77,6 +83,8 @@ class WP_Styles extends WP_Dependencies {
public $do_concat = false;
/**
* Holds HTML markup of styles and additional data if concatenation
* is enabled.
*
* @since 2.8.0
* @access public
@ -85,6 +93,7 @@ class WP_Styles extends WP_Dependencies {
public $print_html = '';
/**
* Holds inline styles if concatenation is enabled.
*
* @since 3.3.0
* @access public
@ -93,6 +102,7 @@ class WP_Styles extends WP_Dependencies {
public $print_code = '';
/**
* List of default directories.
*
* @since 2.8.0
* @access public
@ -118,12 +128,15 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Processes a style dependency.
*
* @since 2.6.0
* @access public
*
* @param string $handle
* @return bool
* @see WP_Dependencies::do_item()
*
* @param string $handle The style's registered handle.
* @return bool True on success, false on failure.
*/
public function do_item( $handle ) {
if ( !parent::do_item($handle) )
@ -230,12 +243,14 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Adds extra CSS styles to a registered stylesheet.
*
* @since 3.3.0
* @access public
*
* @param string $handle
* @param string $code
* @param string $handle The style's registered handle.
* @param string $code String containing the CSS styles to be added.
* @return bool True on success, false on failure.
*/
public function add_inline_style( $handle, $code ) {
if ( ! $code ) {
@ -253,13 +268,15 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Prints extra CSS styles of a registered stylesheet.
*
* @since 3.3.0
* @access public
*
* @param string $handle
* @param bool $echo
* @return bool
* @param string $handle The style's registered handle.
* @param bool $echo Optional. Whether to echo the inline style instead of just returning it.
* Default true.
* @return string|bool False if no data exists, inline styles if `$echo` is true, true otherwise.
*/
public function print_inline_style( $handle, $echo = true ) {
$output = $this->get_data( $handle, 'after' );
@ -280,18 +297,21 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Determines style dependencies.
*
* @since 2.6.0
* @access public
*
* @param mixed $handles
* @param bool $recursion
* @param mixed $group
* @return bool
* @see WP_Dependencies::all_deps()
*
* @param mixed $handles Item handle and argument (string) or item handles and arguments (array of strings).
* @param bool $recursion Internal flag that function is calling itself.
* @param int|false $group Group level: (int) level, (false) no groups.
* @return bool True on success, false on failure.
*/
public function all_deps( $handles, $recursion = false, $group = false ) {
$r = parent::all_deps( $handles, $recursion );
if ( !$recursion ) {
if ( ! $recursion ) {
/**
* Filter the array of enqueued styles before processing for output.
*
@ -305,14 +325,15 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Generates an enqueued style's fully-qualified URL.
*
* @since 2.6.0
* @access public
*
* @param string $src
* @param string $ver
* @param string $handle
* @return string
* @param string $src The source of the enqueued style.
* @param string $ver The version of the enqueued style.
* @param string $handle The style's registered handle.
* @return string Style's fully-qualified URL.
*/
public function _css_href( $src, $ver, $handle ) {
if ( !is_bool($src) && !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
@ -335,12 +356,13 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Whether a handle's source is in a default directory.
*
* @since 2.8.0
* @access public
*
* @param string $src
* @return bool
* @param string $src The source of the enqueued style.
* @return bool True if found, false if not.
*/
public function in_default_dir( $src ) {
if ( ! $this->default_dirs )
@ -354,13 +376,16 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Processes items and dependencies for the footer group.
*
* HTML 5 allows styles in the body, grab late enqueued items and output them in the footer.
*
* @since 3.3.0
* @access public
*
* @return array
* @see WP_Dependencies::do_items()
*
* @return array Handles of items that have been processed.
*/
public function do_footer_items() {
$this->do_items(false, 1);
@ -368,6 +393,7 @@ class WP_Styles extends WP_Dependencies {
}
/**
* Resets class properties.
*
* @since 3.3.0
* @access public

View File

@ -1,11 +1,11 @@
<?php
/**
* BackPress Scripts Procedural API
* Dependencies API: Scripts functions
*
* @since 2.6.0
*
* @package WordPress
* @subpackage BackPress
* @subpackage Dependencies
*/
/**

View File

@ -1,11 +1,11 @@
<?php
/**
* BackPress Styles Procedural API
* Dependencies API: Styles functions
*
* @since 2.6.0
*
* @package WordPress
* @subpackage BackPress
* @subpackage Dependencies
*/
/**

View File

@ -2,11 +2,6 @@
/**
* WordPress scripts and styles default loader.
*
* Most of the functionality that existed here was moved to
* {@link http://backpress.automattic.com/ BackPress}. WordPress themes and
* plugins will only be concerned about the filters and actions set in this
* file.
*
* Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
* define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
* define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
@ -21,19 +16,19 @@
* @package WordPress
*/
/** BackPress: WordPress Dependencies Class */
/** WordPress Dependencies Class */
require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
/** BackPress: WordPress Scripts Class */
/** WordPress Scripts Class */
require( ABSPATH . WPINC . '/class.wp-scripts.php' );
/** BackPress: WordPress Scripts Functions */
/** WordPress Scripts Functions */
require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
/** BackPress: WordPress Styles Class */
/** WordPress Styles Class */
require( ABSPATH . WPINC . '/class.wp-styles.php' );
/** BackPress: WordPress Styles Functions */
/** WordPress Styles Functions */
require( ABSPATH . WPINC . '/functions.wp-styles.php' );
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-beta1-36743';
$wp_version = '4.5-beta1-36744';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.