function do_item($handle) { if (!parent::do_item($handle)) { return false; } $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]; } if ($this->do_concat) { if ($this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt'])) { $this->concat .= "{$handle},"; $this->concat_version .= "{$handle}{$ver}"; $this->print_code .= $this->print_inline_style($handle, false); return true; } } if (isset($obj->args)) { $media = esc_attr($obj->args); } else { $media = 'all'; } $href = $this->_css_href($obj->src, $ver, $handle); $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; $title = isset($obj->extra['title']) ? "title='" . esc_attr($obj->extra['title']) . "'" : ''; $tag = apply_filters('style_loader_tag', "<link rel='{$rel}' id='{$handle}-css' {$title} href='{$href}' type='text/css' media='{$media}' />\n", $handle); if ('rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl']) { if (is_bool($obj->extra['rtl']) || 'replace' === $obj->extra['rtl']) { $suffix = isset($obj->extra['suffix']) ? $obj->extra['suffix'] : ''; $rtl_href = str_replace("{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href($obj->src, $ver, "{$handle}-rtl")); } else { $rtl_href = $this->_css_href($obj->extra['rtl'], $ver, "{$handle}-rtl"); } $rtl_tag = apply_filters('style_loader_tag', "<link rel='{$rel}' id='{$handle}-rtl-css' {$title} href='{$rtl_href}' type='text/css' media='{$media}' />\n", $handle); if ($obj->extra['rtl'] === 'replace') { $tag = $rtl_tag; } else { $tag .= $rtl_tag; } } if (isset($obj->extra['conditional']) && $obj->extra['conditional']) { $tag = "<!--[if {$obj->extra['conditional']}]>\n" . $tag . "<![endif]-->\n"; } if ($this->do_concat) { $this->print_html .= $tag; if ($inline_style = $this->print_inline_style($handle, false)) { $this->print_html .= sprintf("<style type='text/css'>\n%s\n</style>\n", $inline_style); } } else { echo $tag; $this->print_inline_style($handle); } return true; }
function do_item($handle) { if (!parent::do_item($handle)) { return false; } if (null === $this->registered[$handle]->ver) { $ver = ''; } else { $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; } if (isset($this->args[$handle])) { $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; } if ($this->do_concat) { if ($this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt'])) { $this->concat .= "{$handle},"; $this->concat_version .= "{$handle}{$ver}"; return true; } } if (isset($this->registered[$handle]->args)) { $media = esc_attr($this->registered[$handle]->args); } else { $media = 'all'; } $href = $this->_css_href($this->registered[$handle]->src, $ver, $handle); $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr($this->registered[$handle]->extra['title']) . "'" : ''; $end_cond = $tag = ''; if (isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional']) { $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n"; $end_cond = "<![endif]-->\n"; } $tag .= apply_filters('style_loader_tag', "<link rel='{$rel}' id='{$handle}-css' {$title} href='{$href}' type='text/css' media='{$media}' />\n", $handle); if ('rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl']) { if (is_bool($this->registered[$handle]->extra['rtl'])) { $suffix = isset($this->registered[$handle]->extra['suffix']) ? $this->registered[$handle]->extra['suffix'] : ''; $rtl_href = str_replace("{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href($this->registered[$handle]->src, $ver, "{$handle}-rtl")); } else { $rtl_href = $this->_css_href($this->registered[$handle]->extra['rtl'], $ver, "{$handle}-rtl"); } $tag .= apply_filters('style_loader_tag', "<link rel='{$rel}' id='{$handle}-rtl-css' {$title} href='{$rtl_href}' type='text/css' media='{$media}' />\n", $handle); } $tag .= $end_cond; if ($this->do_concat) { $this->print_html .= $tag; } else { echo $tag; } // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules // echo "<style type='text/css'>\n"; // echo "/* <![CDATA[ */\n"; // echo "/* ]]> */\n"; // echo "</style>\n"; return true; }
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 ); if ( null === $this->registered[$handle]->ver ) $ver = ''; else $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; if ( isset($this->args[$handle]) ) $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; $src = $this->registered[$handle]->src; if ( $this->do_concat ) { $srce = apply_filters( 'script_loader_src', $src, $handle ); if ( $this->in_default_dir($srce) ) { $this->print_code .= $this->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"; } } $this->print_extra_script( $handle ); if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { $src = $this->base_url . $src; } if ( !empty($ver) ) $src = add_query_arg('ver', $ver, $src); $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); if ( $this->do_concat ) $this->print_html .= "<script type='text/javascript' src='$src'></script>\n"; else echo "<script type='text/javascript' src='$src'></script>\n"; return true; }
function do_item($handle) { if (!parent::do_item($handle)) { return false; } $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; if (isset($this->args[$handle])) { $ver .= '&' . $this->args[$handle]; } $src = $this->registered[$handle]->src; if (!preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src)) { $src = $this->base_url . $src; } $src = add_query_arg('ver', $ver, $src); $src = clean_url(apply_filters('script_loader_src', $src, $handle)); $this->print_scripts_l10n($handle); echo "<script type='text/javascript' src='{$src}'></script>\n"; return true; }
function do_item($handle) { if (!parent::do_item($handle)) { return false; } $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; if (isset($this->args[$handle])) { $ver .= '&' . $this->args[$handle]; } if (isset($this->registered[$handle]->args)) { $media = attribute_escape($this->registered[$handle]->args); } else { $media = 'all'; } $href = $this->_css_href($this->registered[$handle]->src, $ver, $handle); $end_cond = ''; if (isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional']) { echo "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n"; $end_cond = "<![endif]-->\n"; } echo apply_filters('style_loader_tag', "<link rel='stylesheet' href='{$href}' type='text/css' media='{$media}' />\n", $handle); if ('rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl']) { if (is_bool($this->registered[$handle]->extra['rtl'])) { $rtl_href = str_replace('.css', '-rtl.css', $href); } else { $rtl_href = $this->_css_href($this->registered[$handle]->extra['rtl'], $ver, "{$handle}-rtl"); } echo apply_filters('style_loader_tag', "<link rel='stylesheet' href='{$rtl_href}' type='text/css' media='{$media}' />\n", $handle); } echo $end_cond; // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules // echo "<style type='text/css'>\n"; // echo "/* <![CDATA[ */\n"; // echo "/* ]]> */\n"; // echo "</style>\n"; return true; }
/** * @param string $handle * @return bool */ public function do_item($handle) { if (!parent::do_item($handle)) { return false; } $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]; } if ($this->do_concat) { if ($this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt'])) { $this->concat .= "{$handle},"; $this->concat_version .= "{$handle}{$ver}"; $this->print_code .= $this->print_inline_style($handle, false); return true; } } if (isset($obj->args)) { $media = esc_attr($obj->args); } else { $media = 'all'; } $href = $this->_css_href($obj->src, $ver, $handle); if (empty($href)) { // Turns out there is nothing to print. return true; } $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; $title = isset($obj->extra['title']) ? "title='" . esc_attr($obj->extra['title']) . "'" : ''; /** * Filter the HTML link tag of an enqueued style. * * @since 2.6.0 * * @param string The link tag for the enqueued style. * @param string $handle The style's registered handle. */ $tag = apply_filters('style_loader_tag', "<link rel='{$rel}' id='{$handle}-css' {$title} href='{$href}' type='text/css' media='{$media}' />\n", $handle); if ('rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl']) { if (is_bool($obj->extra['rtl']) || 'replace' === $obj->extra['rtl']) { $suffix = isset($obj->extra['suffix']) ? $obj->extra['suffix'] : ''; $rtl_href = str_replace("{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href($obj->src, $ver, "{$handle}-rtl")); } else { $rtl_href = $this->_css_href($obj->extra['rtl'], $ver, "{$handle}-rtl"); } /** This filter is documented in wp-includes/class.wp-styles.php */ $rtl_tag = apply_filters('style_loader_tag', "<link rel='{$rel}' id='{$handle}-rtl-css' {$title} href='{$rtl_href}' type='text/css' media='{$media}' />\n", $handle); if ($obj->extra['rtl'] === 'replace') { $tag = $rtl_tag; } else { $tag .= $rtl_tag; } } $conditional_pre = $conditional_post = ''; if (isset($obj->extra['conditional']) && $obj->extra['conditional']) { $conditional_pre = "<!--[if {$obj->extra['conditional']}]>\n"; $conditional_post = "<![endif]-->\n"; } if ($this->do_concat) { $this->print_html .= $conditional_pre; $this->print_html .= $tag; if ($inline_style = $this->print_inline_style($handle, false)) { $this->print_html .= sprintf("<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr($handle), $inline_style); } $this->print_html .= $conditional_post; } else { echo $conditional_pre; echo $tag; $this->print_inline_style($handle); echo $conditional_post; } return true; }
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"; } if ($this->do_concat) { /** * Filter 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->in_default_dir($srce) && !$conditional) { $this->print_code .= $this->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->print_extra_script($handle); if ($has_conditional_data) { echo $cond_after; } if (!preg_match('|^(https?:)?//|', $src) && !($this->content_url && 0 === strpos($src, $this->content_url))) { $src = $this->base_url . $src; } 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) { return true; } $tag = "{$cond_before}<script type='text/javascript' src='{$src}'></script>\n{$cond_after}"; /** * Filter the HTML script tag of an enqueued script. * * @since 4.1.0 * * @param string $tag The `<script>` tag for the enqueued script. * @param string $handle The script's registered handle. * @param string $src The script's source URL. */ $tag = apply_filters('script_loader_tag', $tag, $handle, $src); if ($this->do_concat) { $this->print_html .= $tag; } else { echo $tag; } return true; }
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); } if (null === $this->registered[$handle]->ver) { $ver = ''; } else { $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; } if (isset($this->args[$handle])) { $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; } $src = $this->registered[$handle]->src; if ($this->do_concat) { /** * Filter 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->in_default_dir($srce)) { $this->print_code .= $this->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}"; } } $this->print_extra_script($handle); if (!preg_match('|^(https?:)?//|', $src) && !($this->content_url && 0 === strpos($src, $this->content_url))) { $src = $this->base_url . $src; } 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) { return true; } if ($this->do_concat) { $this->print_html .= "<script type='text/javascript' src='{$src}'></script>\n"; } else { echo "<script type='text/javascript' src='{$src}'></script>\n"; } return true; }
/** * @param string $handle * @return bool */ public function do_item($handle) { if (!parent::do_item($handle)) { return false; } $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]; } /* if ( $this->do_concat ) { if ( $this->in_default_dir( $obj->src ) && !isset( $obj->extra['conditional'] ) && !isset( $obj->extra['alt'] ) ) { $this->concat .= "$handle,"; $this->concat_version .= "$handle$ver"; $this->print_code .= $this->print_inline_document( $handle, false ); return true; } } */ $href = $this->_html_href($obj->src, $ver, $handle); if (empty($href)) { // Turns out there is nothing to print. return true; } $rel = 'import'; $title = isset($obj->extra['title']) ? "title='" . esc_attr($obj->extra['title']) . "'" : ''; /** * Filter the HTML link tag of an enqueued document. * * @param string $html The link tag for the enqueued document. * @param string $handle The document's registered handle. * @param string $href The document's source URL. */ $tag = apply_filters('document_loader_tag', "<link rel='{$rel}' id='{$handle}-document' {$title} href='{$href}' />\n", $handle, $href); $conditional_pre = $conditional_post = ''; if (isset($obj->extra['conditional']) && $obj->extra['conditional']) { $conditional_pre = "<!--[if {$obj->extra['conditional']}]>\n"; $conditional_post = "<![endif]-->\n"; } /* if ( $this->do_concat ) { $this->print_html .= $conditional_pre; $this->print_html .= $tag; if ( $inline_style = $this->print_inline_style( $handle, false ) ) { $this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style ); } $this->print_html .= $conditional_post; } else { */ echo $conditional_pre; echo $tag; echo $conditional_post; // } return true; }