本文整理汇总了PHP中cssJSToolbox::getURI方法的典型用法代码示例。如果您正苦于以下问题:PHP cssJSToolbox::getURI方法的具体用法?PHP cssJSToolbox::getURI怎么用?PHP cssJSToolbox::getURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cssJSToolbox
的用法示例。
在下文中一共展示了cssJSToolbox::getURI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: linkFooterStyleSheets
/**
* put your comment there...
*
*/
public function linkFooterStyleSheets()
{
// Initialize.
$styles = array();
// Get queued style sheets!
global $wp_styles;
$queuedStyles =& $wp_styles->queue;
// Process only 'cjt' templates,
foreach ($queuedStyles as $index => $styleName) {
if (strpos($styleName, 'cjt-css-template-') === 0) {
// Get style name src file, prepend to Wordpress absolute path.
$style = $wp_styles->registered[$styleName];
$styles[] = home_url($style->src);
// Stop Wordpress from output <link> tag outside head tag
// as it has no effect.
unset($queuedStyles[$index]);
}
}
// Enqueue Style Sheet loader javascript if there is any
// styles need to be loaded.
if (!empty($styles)) {
// jQuery is dpendency object required by the loader.
wp_enqueue_script('jquery');
// Enqueue footer style sheet loader.
wp_enqueue_script('cjt-coupling-footer-css-loader', cssJSToolbox::getURI('controllers:coupling:js:footer-stylesheet-loader.js'));
// Output Javascript array to be filled with the styles!
$jsStyleSheetsList = json_encode($styles);
require cssJSToolbox::resolvePath('controllers:coupling:html:load-footer-style.html.php');
}
}
示例2: useStyles
/**
* put your comment there...
*
*/
public static function useStyles($className, $styles = null)
{
wp_enqueue_style('Just Load Default Styles, this works great!!!!');
// Use current class name is $className is not provided!
if (!$className) {
$className = __CLASS__;
}
// Accept variable number of args of script list.
$allPassedArgs = func_get_args();
$styles = self::trigger("{$className}.usestyles", is_array($styles) ? $styles : array_slice($allPassedArgs, 1));
if (!$styles) {
throw new Exception('CJTView::useStyles method must has at least on script parameter passed!');
}
// Script name Reg Exp pattern.
$nameExp = '/\\:?(\\{((\\w+)-)\\})?([\\w\\-\\.]+)$/';
// For every script, Enqueue and localize, only if localization file found/exists.
foreach ($styles as $style) {
// Get script name.
preg_match($nameExp, $style, $styleObject);
// [[2]Prefix], [4] name. Prefix may be not presented.
$name = "{$styleObject[2]}{$styleObject[4]}";
if (!isset($GLOBALS['wp_styles']->registered[$name])) {
// Make all enqueued styles names unique from enqueued scripts.
// This is useful when merging styles & scripts is required.
$name = "CSS-{$name}";
// Any JS lib file should named the same as the parent folder with the extension added.
$libPath = ":{$styleObject[4]}";
// Get css file URI.
$cssFile = cssJSToolbox::getURI(preg_replace($nameExp, "{$libPath}.css", $style));
// Register + Enqueue style.
wp_enqueue_style($name, $cssFile);
} else {
// Enqueue already registered styles.
wp_enqueue_style($name);
}
}
}