當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_default_styles函數代碼示例

本文整理匯總了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');
開發者ID:papayalabs,項目名稱:htdocs,代碼行數:31,代碼來源:load-styles.php

示例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)
         }
     }
 }
開發者ID:elviosc,項目名稱:crankyads,代碼行數:80,代碼來源:ContentController.php


注:本文中的wp_default_styles函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。