本文整理汇总了PHP中wp_default_styles函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_default_styles函数的具体用法?PHP wp_default_styles怎么用?PHP wp_default_styles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_default_styles函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preg_replace
return @file_get_contents($path);
}
require ABSPATH . '/wp-includes/script-loader.php';
require ABSPATH . '/wp-includes/version.php';
$load = preg_replace('/[^a-z0-9,_-]+/i', '', $_GET['load']);
$load = explode(',', $load);
if (empty($load)) {
exit;
}
$compress = isset($_GET['c']) && $_GET['c'];
$force_gzip = $compress && 'gzip' == $_GET['c'];
$rtl = isset($_GET['dir']) && 'rtl' == $_GET['dir'];
$expires_offset = 31536000;
$out = '';
$wp_styles = new WP_Styles();
wp_default_styles($wp_styles);
foreach ($load as $handle) {
if (!array_key_exists($handle, $wp_styles->registered)) {
continue;
}
$style = $wp_styles->registered[$handle];
$path = ABSPATH . $style->src;
$content = get_file($path) . "\n";
if ($rtl && isset($style->extra['rtl']) && $style->extra['rtl']) {
$rtl_path = is_bool($style->extra['rtl']) ? str_replace('.css', '-rtl.css', $path) : ABSPATH . $style->extra['rtl'];
$content .= get_file($rtl_path) . "\n";
}
$out .= str_replace('../images/', 'images/', $content);
}
header('Content-Type: text/css');
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $expires_offset) . ' GMT');
示例2: OutputHead
function OutputHead($bUseEnqueue, $xmlCssData, $xmlScriptData)
{
// ** Standard css
$wp_styles = false;
$standardCss = $xmlCssData->getElementsByTagName("standard");
foreach ($standardCss as $iStdCss) {
if ($bUseEnqueue) {
wp_enqueue_style($iStdCss->attributes->getNamedItem("name")->nodeValue);
} else {
// Get all the default Wordpress styles
// Note: This is done here for efficiency (if no standard wordpress css files are required, this will never be executed)
if (!$wp_styles) {
$wp_styles = new WP_Styles();
wp_default_styles($wp_styles);
}
$stdCssName = $iStdCss->attributes->getNamedItem("name")->nodeValue;
if (!array_key_exists($stdCssName, $wp_styles->registered)) {
continue;
}
echo "<link rel='stylesheet' id='{$stdCssName}-css' href='" . site_url($wp_styles->registered[$stdCssName]->src) . "' type='text/css' media='all' />\n";
// Note: Wordpress also appends a ?ver=xx to the end of href (and encodes href with esc_attr)
}
}
// * Custom css
$customCss = $xmlCssData->getElementsByTagName("custom");
foreach ($customCss as $iCustomCss) {
if ($bUseEnqueue) {
$dependencies = false;
if (isset($iCustomCss->attributes->getNamedItem("dependencies")->nodeValue)) {
$dependencies = explode(";", $iCustomCss->attributes->getNamedItem("dependencies")->nodeValue);
}
wp_deregister_style($iCustomCss->attributes->getNamedItem("name")->nodeValue);
wp_register_style($iCustomCss->attributes->getNamedItem("name")->nodeValue, $iCustomCss->attributes->getNamedItem("src")->nodeValue, $dependencies, false);
wp_enqueue_style($iCustomCss->attributes->getNamedItem("name")->nodeValue);
} else {
$CssName = $iCustomCss->attributes->getNamedItem("name")->nodeValue;
$CssSrc = $iCustomCss->attributes->getNamedItem("src")->nodeValue;
echo "<link rel='stylesheet' id='{$CssName}-css' href='{$CssSrc}' type='text/css' media='all' />\n";
// Note: Wordpress also appends a ?ver=xx to the end of href (and encodes href with esc_attr)
}
}
// * Standard script
global $wp_scripts;
$standardScripts = $this->ExtractStandardScripts($xmlScriptData, !$bUseEnqueue);
// We don't need to explicitly handle dependencies if we use enqueue (since Wordpress does this for us)
foreach ($standardScripts as $iStdScript) {
if ($bUseEnqueue) {
wp_enqueue_script($iStdScript);
} else {
// Get all the default Wordpress scripts
// Note: This is done here for efficiency (if no standard wordpress script files are required, this will never be executed)
if (!$wp_scripts) {
$wp_scripts = new WP_Scripts();
wp_default_scripts($wp_scripts);
}
if (!array_key_exists($iStdScript, $wp_scripts->registered)) {
continue;
}
echo "<script type='text/javascript' src='" . site_url($wp_scripts->registered[$iStdScript]->src) . "'></script>";
}
}
// * Custom script
$customScripts = $xmlScriptData->getElementsByTagName("custom");
foreach ($customScripts as $iCustomScript) {
if ($bUseEnqueue) {
$dependencies = false;
if (isset($iCustomScript->attributes->getNamedItem("dependencies")->nodeValue)) {
$dependencies = explode(";", $iCustomScript->attributes->getNamedItem("dependencies")->nodeValue);
}
wp_deregister_script($iCustomScript->attributes->getNamedItem("name")->nodeValue);
wp_register_script($iCustomScript->attributes->getNamedItem("name")->nodeValue, $iCustomScript->attributes->getNamedItem("src")->nodeValue, $dependencies, false);
wp_enqueue_script($iCustomScript->attributes->getNamedItem("name")->nodeValue);
} else {
$ScriptName = $iCustomScript->attributes->getNamedItem("name")->nodeValue;
$ScriptSrc = $iCustomScript->attributes->getNamedItem("src")->nodeValue;
echo "<script type='text/javascript' src='{$ScriptSrc}'></script>";
// Note: Wordpress also appends a ?ver=xx to the end of src (and encodes href with esc_attr)
}
}
}