<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[25597] trunk/src/wp-includes/functions.wp-scripts.php: Improve inline documentation for wp-includes/functions.wp-scripts.php.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/25597">25597</a></dd>
<dt>Author</dt> <dd>DrewAPicture</dd>
<dt>Date</dt> <dd>2013-09-24 02:57:56 +0000 (Tue, 24 Sep 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Improve inline documentation for wp-includes/functions.wp-scripts.php.

Props kpdesign.
Fixes <a href="http://core.trac.wordpress.org/ticket/25402">#25402</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesfunctionswpscriptsphp">trunk/src/wp-includes/functions.wp-scripts.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesfunctionswpscriptsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/functions.wp-scripts.php (25596 => 25597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/functions.wp-scripts.php   2013-09-24 02:54:00 UTC (rev 25596)
+++ trunk/src/wp-includes/functions.wp-scripts.php      2013-09-24 02:57:56 UTC (rev 25597)
</span><span class="lines">@@ -1,22 +1,28 @@
</span><span class="cx"> <?php
</span><span class="cx"> /**
</span><del>- * BackPress script procedural API.
</del><ins>+ * BackPress Scripts Procedural API
</ins><span class="cx">  *
</span><del>- * @package BackPress
- * @since r16
</del><ins>+ * @since 2.6.0
+ *
+ * @package WordPress
+ * @subpackage BackPress
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Prints script tags in document head.
</del><ins>+ * Print scripts in document head that are in the $handles queue.
</ins><span class="cx">  *
</span><del>- * Called by admin-header.php and by wp_head hook. Since it is called by wp_head
- * on every page load, the function does not instantiate the WP_Scripts object
- * unless script names are explicitly passed. Does make use of already
- * instantiated $wp_scripts if present. Use provided wp_print_scripts hook to
- * register/enqueue new scripts.
</del><ins>+ * Called by admin-header.php and wp_head hook. Since it is called by wp_head on every page load,
+ * the function does not instantiate the WP_Scripts object unless script names are explicitly passed.
+ * Makes use of already-instantiated $wp_scripts global if present. Use provided wp_print_scripts
+ * hook to register/enqueue new scripts.
</ins><span class="cx">  *
</span><del>- * @since r16
- * @see WP_Dependencies::print_scripts()
</del><ins>+ * @see WP_Scripts::do_items()
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
+ *
+ * @since 2.6.0
+ *
+ * @param array|bool $handles Optional. Scripts to be printed. Default 'false'.
+ * @return array On success, a processed array of WP_Dependencies items; otherwise, an empty array.
</ins><span class="cx">  */
</span><span class="cx"> function wp_print_scripts( $handles = false ) {
</span><span class="cx">  do_action( 'wp_print_scripts' );
</span><span class="lines">@@ -39,15 +45,25 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Register new Javascript file.
</del><ins>+ * Register a new script.
</ins><span class="cx">  *
</span><del>- * @since r16
- * @param string $handle Script name
- * @param string $src Script url
- * @param array $deps (optional) Array of script names on which this script depends
- * @param string|bool $ver (optional) Script version (used for cache busting), set to null to disable
- * @param bool $in_footer (optional) Whether to enqueue the script before </head> or before </body>
- * @return null
</del><ins>+ * Registers a script to be linked later using the wp_enqueue_script() function.
+ *
+ * @see WP_Dependencies::add(), WP_Dependencies::add_data()
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
+ *
+ * @since 2.6.0
+ *
+ * @param string      $handle    Name of the script. Should be unique.
+ * @param string      $src       Path to the script from the WordPress root directory. Example: '/js/myscript.js'.
+ * @param array       $deps      Optional. An array of registered script handles this script depends on. Set to false if there
+ *                               are no dependencies. Default empty array.
+ * @param string|bool $ver       Optional. String specifying script version number, if it has one, which is concatenated
+ *                               to end of path as a query string. If no version is specified or set to false, a version
+ *                               number is automatically added equal to current installed WordPress version.
+ *                               If set to null, no version is added. Default 'false'. Accepts 'false', 'null', or 'string'.
+ * @param bool        $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
+ *                               Default 'false'. Accepts 'false' or 'true'.
</ins><span class="cx">  */
</span><span class="cx"> function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
</span><span class="cx">  global $wp_scripts;
</span><span class="lines">@@ -64,24 +80,30 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Wrapper for $wp_scripts->localize().
</del><ins>+ * Localize a script.
</ins><span class="cx">  *
</span><del>- * Used to localize a script.
</del><span class="cx">  * Works only if the script has already been added.
</span><del>- * Accepts an associative array $l10n and creates JS object:
</del><ins>+ *
+ * Accepts an associative array $l10n and creates a JavaScript object:
+ * <code>
</ins><span class="cx">  * "$object_name" = {
</span><del>- *   key: value,
- *   key: value,
- *   ...
</del><ins>+ *       key: value,
+ *       key: value,
+ *       ...
</ins><span class="cx">  * }
</span><del>- * See http://core.trac.wordpress.org/ticket/11520 for more information.
</del><ins>+ * </code>
</ins><span class="cx">  *
</span><del>- * @since r16
</del><ins>+ * @see WP_Dependencies::localize()
+ * @link http://core.trac.wordpress.org/ticket/11520
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
</ins><span class="cx">  *
</span><del>- * @param string $handle The script handle that was registered or used in script-loader
- * @param string $object_name Name for the created JS object. This is passed directly so it should be qualified JS variable /[a-zA-Z0-9_]+/
- * @param array $l10n Associative PHP array containing the translated strings. HTML entities will be converted and the array will be JSON encoded.
- * @return bool Whether the localization was added successfully.
</del><ins>+ * @since 2.6.0
+ *
+ * @param string $handle      Script handle the data will be attached to.
+ * @param string $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable.
+ *                            Example: '/[a-zA-Z0-9_]+/'.
+ * @param array $l10n         The data itself. The data can be either a single or multi-dimensional array.
+ * @return bool True if the script was successfully localized, false otherwise.
</ins><span class="cx">  */
</span><span class="cx"> function wp_localize_script( $handle, $object_name, $l10n ) {
</span><span class="cx">  global $wp_scripts;
</span><span class="lines">@@ -99,8 +121,15 @@
</span><span class="cx"> /**
</span><span class="cx">  * Remove a registered script.
</span><span class="cx">  *
</span><del>- * @since r16
- * @see WP_Scripts::remove() For parameter information.
</del><ins>+ * Note: there are intentional safeguards in place to prevent critical admin scripts,
+ * such as jQuery core, from being unregistered.
+ *
+ * @see WP_Dependencies::remove()
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
+ *
+ * @since 2.6.0
+ *
+ * @param string $handle Name of the script to be removed.
</ins><span class="cx">  */
</span><span class="cx"> function wp_deregister_script( $handle ) {
</span><span class="cx">  global $wp_scripts;
</span><span class="lines">@@ -111,8 +140,10 @@
</span><span class="cx">          $wp_scripts = new WP_Scripts();
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       // Do not allow accidental or negligent deregistering of critical scripts in the admin.
-       // Show minimal remorse if the correct hook is used.
</del><ins>+        /**
+        * Do not allow accidental or negligent de-registering of critical scripts in the admin.
+        * Show minimal remorse if the correct hook is used.
+        */
</ins><span class="cx">   $current_filter = current_filter();
</span><span class="cx">  if ( ( is_admin() && 'admin_enqueue_scripts' !== $current_filter ) ||
</span><span class="cx">          ( 'wp-login.php' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter )
</span><span class="lines">@@ -123,8 +154,7 @@
</span><span class="cx">                  'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse',
</span><span class="cx">                  'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable',
</span><span class="cx">                  'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs',
</span><del>-                       'jquery-ui-tooltip', 'jquery-ui-widget',
-                       'underscore', 'backbone',
</del><ins>+                        'jquery-ui-tooltip', 'jquery-ui-widget', 'underscore', 'backbone',
</ins><span class="cx">           );
</span><span class="cx"> 
</span><span class="cx">          if ( in_array( $handle, $no ) ) {
</span><span class="lines">@@ -139,12 +169,23 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Enqueues script.
</del><ins>+ * Enqueue a script.
</ins><span class="cx">  *
</span><del>- * Registers the script if src provided (does NOT overwrite) and enqueues.
</del><ins>+ * Registers the script if $src provided (does NOT overwrite), and enqueues it.
</ins><span class="cx">  *
</span><del>- * @since r16
- * @see wp_register_script() For parameter information.
</del><ins>+ * @see WP_Dependencies::add(), WP_Dependencies::add_data(), WP_Dependencies::enqueue()
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
+ *
+ * @since 2.6.0
+
+ * @param string      $handle    Name of the script.
+ * @param string|bool $src       Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
+ * @param array       $deps      An array of registered handles this script depends on. Default empty array.
+ * @param string|bool $ver       Optional. String specifying the script version number, if it has one. This parameter
+ *                               is used to ensure that the correct version is sent to the client regardless of caching,
+ *                               and so should be included if a version number is available and makes sense for the script.
+ * @param bool        $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
+ *                               Default 'false'. Accepts 'false' or 'true'.
</ins><span class="cx">  */
</span><span class="cx"> function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
</span><span class="cx">  global $wp_scripts;
</span><span class="lines">@@ -165,10 +206,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Remove an enqueued script.
</del><ins>+ * Remove a previously enqueued script.
</ins><span class="cx">  *
</span><ins>+ * @see WP_Dependencies::dequeue()
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
+ *
</ins><span class="cx">  * @since 3.1.0
</span><del>- * @see WP_Scripts::dequeue() For parameter information.
</del><ins>+ *
+ * @param string $handle Name of the script to be removed.
</ins><span class="cx">  */
</span><span class="cx"> function wp_dequeue_script( $handle ) {
</span><span class="cx">  global $wp_scripts;
</span><span class="lines">@@ -183,18 +228,17 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Check whether script has been added to WordPress Scripts.
</del><ins>+ * Check whether a script has been added to the queue.
</ins><span class="cx">  *
</span><del>- * By default, checks if the script has been enqueued. You can also
- * pass 'registered' to $list, to see if the script is registered,
- * and you can check processing statuses with 'to_do' and 'done'.
</del><ins>+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
</ins><span class="cx">  *
</span><span class="cx">  * @since 2.8.0
</span><ins>+ * @since 3.5.0 'enqueued' added as an alias of the 'queue' list.
</ins><span class="cx">  *
</span><span class="cx">  * @param string $handle Name of the script.
</span><del>- * @param string $list Optional. Defaults to 'enqueued'. Values are
- *     'registered', 'enqueued' (or 'queue'), 'to_do', and 'done'.
- * @return bool Whether script is in the list.
</del><ins>+ * @param string $list   Optional. Status of the script to check. Default 'enqueued'.
+ *                       Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.
+ * @return bool Whether the script script is queued.
</ins><span class="cx">  */
</span><span class="cx"> function wp_script_is( $handle, $list = 'enqueued' ) {
</span><span class="cx">  global $wp_scripts;
</span></span></pre>
</div>
</div>

</body>
</html>