Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -96,17 +96,18 @@ class WP_Dependencies {
|
|||
$this->all_deps( $handles );
|
||||
|
||||
foreach ( $this->to_do as $key => $handle ) {
|
||||
if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) {
|
||||
if ( ! in_array( $handle, $this->done, true ) && isset( $this->registered[ $handle ] ) ) {
|
||||
/*
|
||||
* Attempt to process the item. If successful,
|
||||
* add the handle to the done array.
|
||||
*
|
||||
* Unset the item from the to_do array.
|
||||
*/
|
||||
if ( $this->do_item( $handle, $group ) )
|
||||
if ( $this->do_item( $handle, $group ) ) {
|
||||
$this->done[] = $handle;
|
||||
}
|
||||
|
||||
unset( $this->to_do[$key] );
|
||||
unset( $this->to_do[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ class WP_Dependencies {
|
|||
* @return bool True on success, false if not set.
|
||||
*/
|
||||
public function do_item( $handle ) {
|
||||
return isset($this->registered[$handle]);
|
||||
return isset( $this->registered[ $handle ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,43 +142,50 @@ class WP_Dependencies {
|
|||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function all_deps( $handles, $recursion = false, $group = false ) {
|
||||
if ( !$handles = (array) $handles )
|
||||
if ( ! $handles = (array) $handles ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $handles as $handle ) {
|
||||
$handle_parts = explode('?', $handle);
|
||||
$handle = $handle_parts[0];
|
||||
$queued = in_array($handle, $this->to_do, true);
|
||||
$handle_parts = explode( '?', $handle );
|
||||
$handle = $handle_parts[0];
|
||||
$queued = in_array( $handle, $this->to_do, true );
|
||||
|
||||
if ( in_array($handle, $this->done, true) ) // Already done
|
||||
if ( in_array( $handle, $this->done, true ) ) { // Already done
|
||||
continue;
|
||||
}
|
||||
|
||||
$moved = $this->set_group( $handle, $recursion, $group );
|
||||
$new_group = $this->groups[ $handle ];
|
||||
|
||||
if ( $queued && !$moved ) // already queued and in the right group
|
||||
if ( $queued && ! $moved ) { // already queued and in the right group
|
||||
continue;
|
||||
|
||||
$keep_going = true;
|
||||
if ( !isset($this->registered[$handle]) )
|
||||
$keep_going = false; // Item doesn't exist.
|
||||
elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) )
|
||||
$keep_going = false; // Item requires dependencies that don't exist.
|
||||
elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $new_group ) )
|
||||
$keep_going = false; // Item requires dependencies that don't exist.
|
||||
|
||||
if ( ! $keep_going ) { // Either item or its dependencies don't exist.
|
||||
if ( $recursion )
|
||||
return false; // Abort this branch.
|
||||
else
|
||||
continue; // We're at the top level. Move on to the next one.
|
||||
}
|
||||
|
||||
if ( $queued ) // Already grabbed it and its dependencies.
|
||||
continue;
|
||||
$keep_going = true;
|
||||
if ( ! isset( $this->registered[ $handle ] ) ) {
|
||||
$keep_going = false; // Item doesn't exist.
|
||||
} elseif ( $this->registered[ $handle ]->deps && array_diff( $this->registered[ $handle ]->deps, array_keys( $this->registered ) ) ) {
|
||||
$keep_going = false; // Item requires dependencies that don't exist.
|
||||
} elseif ( $this->registered[ $handle ]->deps && ! $this->all_deps( $this->registered[ $handle ]->deps, true, $new_group ) ) {
|
||||
$keep_going = false; // Item requires dependencies that don't exist.
|
||||
}
|
||||
|
||||
if ( isset($handle_parts[1]) )
|
||||
$this->args[$handle] = $handle_parts[1];
|
||||
if ( ! $keep_going ) { // Either item or its dependencies don't exist.
|
||||
if ( $recursion ) {
|
||||
return false; // Abort this branch.
|
||||
} else {
|
||||
continue; // We're at the top level. Move on to the next one.
|
||||
}
|
||||
}
|
||||
|
||||
if ( $queued ) { // Already grabbed it and its dependencies.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $handle_parts[1] ) ) {
|
||||
$this->args[ $handle ] = $handle_parts[1];
|
||||
}
|
||||
|
||||
$this->to_do[] = $handle;
|
||||
}
|
||||
|
@ -194,8 +202,9 @@ class WP_Dependencies {
|
|||
* @since 2.6.0 Moved from `WP_Scripts`.
|
||||
*
|
||||
* @param string $handle Name of the item. Should be unique.
|
||||
* @param string $src Full URL of the item, or path of the item relative to the WordPress root directory.
|
||||
* @param array $deps Optional. An array of registered item handles this item depends on. Default empty array.
|
||||
* @param string|bool $src Full URL of the item, or path of the item relative to the WordPress root directory.
|
||||
* If source is set to false, item is an alias of other items it depends on.
|
||||
* @param string[] $deps Optional. An array of registered item handles this item depends on. Default empty array.
|
||||
* @param string|bool|null $ver Optional. String specifying item version number, if it has one, which is added to the URL
|
||||
* as a query string for cache busting purposes. If version is set to false, a version
|
||||
* number is automatically added equal to current installed WordPress version.
|
||||
|
@ -204,9 +213,10 @@ class WP_Dependencies {
|
|||
* @return bool Whether the item has been registered. True on success, false on failure.
|
||||
*/
|
||||
public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
|
||||
if ( isset($this->registered[$handle]) )
|
||||
if ( isset( $this->registered[ $handle ] ) ) {
|
||||
return false;
|
||||
$this->registered[$handle] = new _WP_Dependency( $handle, $src, $deps, $ver, $args );
|
||||
}
|
||||
$this->registered[ $handle ] = new _WP_Dependency( $handle, $src, $deps, $ver, $args );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -223,10 +233,11 @@ class WP_Dependencies {
|
|||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function add_data( $handle, $key, $value ) {
|
||||
if ( !isset( $this->registered[$handle] ) )
|
||||
if ( ! isset( $this->registered[ $handle ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->registered[$handle]->add_data( $key, $value );
|
||||
return $this->registered[ $handle ]->add_data( $key, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,13 +252,15 @@ class WP_Dependencies {
|
|||
* @return mixed Extra item data (string), false otherwise.
|
||||
*/
|
||||
public function get_data( $handle, $key ) {
|
||||
if ( !isset( $this->registered[$handle] ) )
|
||||
if ( ! isset( $this->registered[ $handle ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !isset( $this->registered[$handle]->extra[$key] ) )
|
||||
if ( ! isset( $this->registered[ $handle ]->extra[ $key ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->registered[$handle]->extra[$key];
|
||||
return $this->registered[ $handle ]->extra[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,8 +273,9 @@ class WP_Dependencies {
|
|||
* @return void
|
||||
*/
|
||||
public function remove( $handles ) {
|
||||
foreach ( (array) $handles as $handle )
|
||||
unset($this->registered[$handle]);
|
||||
foreach ( (array) $handles as $handle ) {
|
||||
unset( $this->registered[ $handle ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -279,11 +293,12 @@ class WP_Dependencies {
|
|||
*/
|
||||
public function enqueue( $handles ) {
|
||||
foreach ( (array) $handles as $handle ) {
|
||||
$handle = explode('?', $handle);
|
||||
if ( !in_array($handle[0], $this->queue) && isset($this->registered[$handle[0]]) ) {
|
||||
$handle = explode( '?', $handle );
|
||||
if ( ! in_array( $handle[0], $this->queue ) && isset( $this->registered[ $handle[0] ] ) ) {
|
||||
$this->queue[] = $handle[0];
|
||||
if ( isset($handle[1]) )
|
||||
$this->args[$handle[0]] = $handle[1];
|
||||
if ( isset( $handle[1] ) ) {
|
||||
$this->args[ $handle[0] ] = $handle[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,11 +316,11 @@ class WP_Dependencies {
|
|||
*/
|
||||
public function dequeue( $handles ) {
|
||||
foreach ( (array) $handles as $handle ) {
|
||||
$handle = explode('?', $handle);
|
||||
$key = array_search($handle[0], $this->queue);
|
||||
$handle = explode( '?', $handle );
|
||||
$key = array_search( $handle[0], $this->queue );
|
||||
if ( false !== $key ) {
|
||||
unset($this->queue[$key]);
|
||||
unset($this->args[$handle[0]]);
|
||||
unset( $this->queue[ $key ] );
|
||||
unset( $this->args[ $handle[0] ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,8 +330,8 @@ class WP_Dependencies {
|
|||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param array $queue An array of queued _WP_Dependency handle objects.
|
||||
* @param string $handle Name of the item. Should be unique.
|
||||
* @param string[] $queue An array of queued _WP_Dependency handles.
|
||||
* @param string $handle Name of the item. Should be unique.
|
||||
* @return bool Whether the handle is found after recursively searching the dependency tree.
|
||||
*/
|
||||
protected function recurse_deps( $queue, $handle ) {
|
||||
|
@ -347,24 +362,25 @@ class WP_Dependencies {
|
|||
*/
|
||||
public function query( $handle, $list = 'registered' ) {
|
||||
switch ( $list ) {
|
||||
case 'registered' :
|
||||
case 'registered':
|
||||
case 'scripts': // back compat
|
||||
if ( isset( $this->registered[ $handle ] ) )
|
||||
if ( isset( $this->registered[ $handle ] ) ) {
|
||||
return $this->registered[ $handle ];
|
||||
}
|
||||
return false;
|
||||
|
||||
case 'enqueued' :
|
||||
case 'queue' :
|
||||
case 'enqueued':
|
||||
case 'queue':
|
||||
if ( in_array( $handle, $this->queue ) ) {
|
||||
return true;
|
||||
}
|
||||
return $this->recurse_deps( $this->queue, $handle );
|
||||
|
||||
case 'to_do' :
|
||||
case 'to_do':
|
||||
case 'to_print': // back compat
|
||||
return in_array( $handle, $this->to_do );
|
||||
|
||||
case 'done' :
|
||||
case 'done':
|
||||
case 'printed': // back compat
|
||||
return in_array( $handle, $this->done );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue