Update WP and plugins

This commit is contained in:
Oliver Davies 2019-04-16 20:56:22 +01:00
parent 10a4713229
commit 1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions

View file

@ -35,7 +35,7 @@ class WP_Scripts extends WP_Dependencies {
public $content_url;
/**
* Default version string for stylesheets.
* Default version string for scripts.
*
* @since 2.6.0
* @var string
@ -145,7 +145,7 @@ class WP_Scripts extends WP_Dependencies {
*
* @param WP_Scripts $this WP_Scripts instance (passed by reference).
*/
do_action_ref_array( 'wp_default_scripts', array(&$this) );
do_action_ref_array( 'wp_default_scripts', array( &$this ) );
}
/**
@ -196,13 +196,15 @@ class WP_Scripts extends WP_Dependencies {
* @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' ) )
if ( ! $output = $this->get_data( $handle, 'data' ) ) {
return;
}
if ( !$echo )
if ( ! $echo ) {
return $output;
}
echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5.
echo "/* <![CDATA[ */\n";
echo "$output\n";
echo "/* ]]> */\n";
@ -219,23 +221,25 @@ class WP_Scripts extends WP_Dependencies {
*
* @see WP_Dependencies::do_item()
*
* @param string $handle The script's registered handle.
* @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) )
if ( ! parent::do_item( $handle ) ) {
return false;
}
if ( 0 === $group && $this->groups[$handle] > 0 ) {
if ( 0 === $group && $this->groups[ $handle ] > 0 ) {
$this->in_footer[] = $handle;
return false;
}
if ( false === $group && in_array($handle, $this->in_footer, true) )
if ( false === $group && in_array( $handle, $this->in_footer, true ) ) {
$this->in_footer = array_diff( $this->in_footer, (array) $handle );
}
$obj = $this->registered[$handle];
$obj = $this->registered[ $handle ];
if ( null === $obj->ver ) {
$ver = '';
@ -243,20 +247,21 @@ class WP_Scripts extends WP_Dependencies {
$ver = $obj->ver ? $obj->ver : $this->default_version;
}
if ( isset($this->args[$handle]) )
$ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
if ( isset( $this->args[ $handle ] ) ) {
$ver = $ver ? $ver . '&amp;' . $this->args[ $handle ] : $this->args[ $handle ];
}
$src = $obj->src;
$src = $obj->src;
$cond_before = $cond_after = '';
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
if ( $conditional ) {
$cond_before = "<!--[if {$conditional}]>\n";
$cond_after = "<![endif]-->\n";
$cond_after = "<![endif]-->\n";
}
$before_handle = $this->print_inline_script( $handle, 'before', false );
$after_handle = $this->print_inline_script( $handle, 'after', false );
$after_handle = $this->print_inline_script( $handle, 'after', false );
if ( $before_handle ) {
$before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );
@ -290,8 +295,8 @@ class WP_Scripts extends WP_Dependencies {
_print_scripts();
$this->reset();
} elseif ( $this->in_default_dir( $srce ) && ! $conditional ) {
$this->print_code .= $this->print_extra_script( $handle, false );
$this->concat .= "$handle,";
$this->print_code .= $this->print_extra_script( $handle, false );
$this->concat .= "$handle,";
$this->concat_version .= "$handle$ver";
return true;
} else {
@ -334,14 +339,16 @@ class WP_Scripts extends WP_Dependencies {
$src = $this->base_url . $src;
}
if ( ! empty( $ver ) )
if ( ! empty( $ver ) ) {
$src = add_query_arg( 'ver', $ver, $src );
}
/** This filter is documented in wp-includes/class.wp-scripts.php */
$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
if ( ! $src )
if ( ! $src ) {
return true;
}
$tag = "{$translations}{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}";
@ -399,7 +406,7 @@ class WP_Scripts extends WP_Dependencies {
* @param string $handle Name of the script to add the inline script to. Must be lowercase.
* @param string $position Optional. Whether to add the inline script before the handle
* or after. Default 'after'.
* @param bool $echo Optional. Whether to echo the script instead of just returning it.
* @param bool $echo Optional. Whether to echo the script instead of just returning it.
* Default true.
* @return string|false Script on success, false otherwise.
*/
@ -424,36 +431,40 @@ class WP_Scripts extends WP_Dependencies {
*
* @since 2.1.0
*
* @param string $handle
* @param string $object_name
* @param array $l10n
* @return bool
* @param string $handle Name of the script to attach data to.
* @param string $object_name Name of the variable that will contain the data.
* @param array $l10n Array of data to localize.
* @return bool True on success, false on failure.
*/
public function localize( $handle, $object_name, $l10n ) {
if ( $handle === 'jquery' )
if ( $handle === 'jquery' ) {
$handle = 'jquery-core';
}
if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present
if ( is_array( $l10n ) && isset( $l10n['l10n_print_after'] ) ) { // back compat, preserve the code in 'l10n_print_after' if present.
$after = $l10n['l10n_print_after'];
unset($l10n['l10n_print_after']);
unset( $l10n['l10n_print_after'] );
}
foreach ( (array) $l10n as $key => $value ) {
if ( !is_scalar($value) )
if ( ! is_scalar( $value ) ) {
continue;
}
$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
$l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
}
$script = "var $object_name = " . wp_json_encode( $l10n ) . ';';
if ( !empty($after) )
if ( ! empty( $after ) ) {
$script .= "\n$after;";
}
$data = $this->get_data( $handle, 'data' );
if ( !empty( $data ) )
if ( ! empty( $data ) ) {
$script = "$data\n$script";
}
return $this->add_data( $handle, 'data', $script );
}
@ -471,13 +482,15 @@ class WP_Scripts extends WP_Dependencies {
* @return bool Not already in the group or a lower group
*/
public function set_group( $handle, $recursion, $group = false ) {
if ( isset( $this->registered[$handle]->args ) && $this->registered[$handle]->args === 1 )
if ( isset( $this->registered[ $handle ]->args ) && $this->registered[ $handle ]->args === 1 ) {
$grp = 1;
else
} else {
$grp = (int) $this->get_data( $handle, 'group' );
}
if ( false !== $group && $grp > $group )
if ( false !== $group && $grp > $group ) {
$grp = $group;
}
return parent::set_group( $handle, $recursion, $grp );
}
@ -486,14 +499,14 @@ class WP_Scripts extends WP_Dependencies {
* Sets a translation textdomain.
*
* @since 5.0.0
* @since 5.1.0 The `$domain` parameter was made optional.
*
* @param string $handle Name of the script to register a translation domain to.
* @param string $domain The textdomain.
* @param string $domain Optional. Text domain. Default 'default'.
* @param string $path Optional. The full file path to the directory containing translation files.
*
* @return bool True if the textdomain was registered, false if not.
* @return bool True if the text domain was registered, false if not.
*/
public function set_translations( $handle, $domain, $path = null ) {
public function set_translations( $handle, $domain = 'default', $path = null ) {
if ( ! isset( $this->registered[ $handle ] ) ) {
return false;
}
@ -504,6 +517,7 @@ class WP_Scripts extends WP_Dependencies {
if ( ! in_array( 'wp-i18n', $obj->deps, true ) ) {
$obj->deps[] = 'wp-i18n';
}
return $obj->set_translations( $domain, $path );
}
@ -567,7 +581,7 @@ JS;
*
* @since 2.3.0
*
* @param array $to_do An array of script dependencies.
* @param string[] $to_do An array of script dependency handles.
*/
$this->to_do = apply_filters( 'print_scripts_array', $this->to_do );
}
@ -584,7 +598,7 @@ JS;
* @return array Handles of items that have been processed.
*/
public function do_head_items() {
$this->do_items(false, 0);
$this->do_items( false, 0 );
return $this->done;
}
@ -598,7 +612,7 @@ JS;
* @return array Handles of items that have been processed.
*/
public function do_footer_items() {
$this->do_items(false, 1);
$this->do_items( false, 1 );
return $this->done;
}
@ -633,12 +647,12 @@ JS;
* @since 2.8.0
*/
public function reset() {
$this->do_concat = false;
$this->print_code = '';
$this->concat = '';
$this->do_concat = false;
$this->print_code = '';
$this->concat = '';
$this->concat_version = '';
$this->print_html = '';
$this->ext_version = '';
$this->ext_handles = '';
$this->print_html = '';
$this->ext_version = '';
$this->ext_handles = '';
}
}