You appear to be a bot. Output may be restricted
Description
Processes a script dependency.
Usage
$bool = WP_Scripts::do_item( $handle, $group );
Parameters
- $handle
- ( string ) required – The script's registered handle.
- $group
- ( int|false ) optional – Optional. Group level: level (int), no groups (false). Default false.
Returns
bool True on success, false on failure.
Source
File name: wordpress/wp-includes/class.wp-scripts.php
Lines:
1 to 100 of 149
public function do_item( $handle, $group = false ) { if ( ! parent::do_item( $handle ) ) { return false; } if ( 0 === $group && $this->groups[ $handle ] > 0 ) { $this->in_footer[] = $handle; return false; } if ( false === $group && in_array( $handle, $this->in_footer, true ) ) { $this->in_footer = array_diff( $this->in_footer, (array) $handle ); } $obj = $this->registered[ $handle ]; if ( null === $obj->ver ) { $ver = ''; } else { $ver = $obj->ver ? $obj->ver : $this->default_version; } if ( isset( $this->args[ $handle ] ) ) { $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; } $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"; } $before_handle = $this->WP_Scripts::print_inline_script( $handle, 'before', false ); $after_handle = $this->WP_Scripts::print_inline_script( $handle, 'after', false ); if ( $before_handle ) { $before_handle = sprintf( "<script%s id='%s-js-before'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $before_handle ); } if ( $after_handle ) { $after_handle = sprintf( "<script%s id='%s-js-after'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $after_handle ); } if ( $before_handle || $after_handle ) { $inline_script_tag = $cond_before . $before_handle . $after_handle . $cond_after; } else { $inline_script_tag = ''; } $translations = $this->WP_Scripts::print_translations( $handle, false ); if ( $translations ) { $translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $translations ); } if ( $this->do_concat ) { /** * Filters the script loader source. * * @since 2.2.0 * * @param string $src Script loader source path. * @param string $handle Script handle. */ $srce = apply_filters( 'script_loader_src', $src, $handle ); if ( $this->WP_Scripts::in_default_dir( $srce ) && ( $before_handle || $after_handle || $translations ) ) { $this->do_concat = false; // Have to print the so-far concatenated scripts right away to maintain the right order. _print_scripts(); $this->WP_Scripts::reset(); } elseif ( $this->WP_Scripts::in_default_dir( $srce ) && ! $conditional ) { $this->print_code .= $this->WP_Scripts::print_extra_script( $handle, false ); $this->concat .= "$handle,"; $this->concat_version .= "$handle$ver"; return true; } else { $this->ext_handles .= "$handle,"; $this->ext_version .= "$handle$ver"; } } $has_conditional_data = $conditional && $this->get_data( $handle, 'data' ); if ( $has_conditional_data ) { echo $cond_before; } $this->WP_Scripts::print_extra_script( $handle ); if ( $has_conditional_data ) { echo $cond_after; } // A single item may alias a set of items, by having dependencies, but no source. if ( ! $src ) {