本文整理汇总了PHP中WP_Styles::all_deps方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Styles::all_deps方法的具体用法?PHP WP_Styles::all_deps怎么用?PHP WP_Styles::all_deps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Styles
的用法示例。
在下文中一共展示了WP_Styles::all_deps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* wp_print_styles()
*
* @return void
**/
static function wp_print_styles()
{
static $done = false;
if ($done) {
return;
}
$done = true;
global $wp_styles;
if (!$wp_styles instanceof WP_Styles) {
$wp_styles = new WP_Styles();
}
$queue = $wp_styles->queue;
$wp_styles->all_deps($queue);
if (!$wp_styles->to_do) {
return;
}
$todo = array();
$css = array();
$dirs = array(content_url(), plugins_url(), includes_url());
foreach ($wp_styles->to_do as $key => $handle) {
$cssPath = $wp_styles->registered[$handle]->src;
if (!asset_cache::startsWith($cssPath, site_url())) {
$cssPath = site_url() . $cssPath;
}
$inDir = false;
foreach ($dirs as $dir) {
if (asset_cache::startsWith($cssPath, $dir)) {
$inDir = true;
break;
}
}
$suffixMatch = asset_cache::endsWith($cssPath, ".css");
if ($inDir && $suffixMatch) {
$css[$handle] = $wp_styles->registered[$handle]->ver;
$todo[] = $handle;
unset($wp_styles->to_do[$key]);
$wp_styles->done[] = $handle;
}
}
if ($todo) {
$file = '/assets/' . md5(serialize($css)) . '.css';
if (!cache_fs::exists($file)) {
asset_cache::concat_styles($file, $todo);
}
$wp_styles->default_version = null;
wp_enqueue_style('styles_concat', content_url() . '/cache' . $file);
}
// $wp_styles->do_concat = true;
// $wp_styles->do_items();
}
示例2: sp_combine_plugin_css_files
function sp_combine_plugin_css_files()
{
global $sp_plugin_styles, $spDevice;
if (!is_a($sp_plugin_styles, 'WP_Styles')) {
$sp_plugin_styles = new WP_Styles();
}
# save copy of styles in case of failure writing
$saved_styles = clone $sp_plugin_styles;
# check for standard theme or mobile
if ($spDevice == 'mobile') {
$option = 'sp_css_concat_mobile';
} else {
if ($spDevice == 'tablet') {
$option = 'sp_css_concat_tablet';
} else {
$option = 'sp_css_concat';
}
}
$css_concat = sp_get_option($option);
if (!is_array($css_concat)) {
$css_concat = array();
}
$css_files_modify = array();
$css_files = array();
if (is_array($sp_plugin_styles->queue)) {
# is there anything in the queue?
$sp_plugin_styles->all_deps($sp_plugin_styles->queue);
# preparing the queue taking dependencies into account
foreach ($css_concat as $css => $value) {
# going through all the already found css files, checking that they are still required
if (!in_array(substr($css, 4), $sp_plugin_styles->to_do) && substr($css, 0, 4) == 'css-') {
# if the css is not queued, rewrite the file
$css_media = $value['type'];
$css_files_modify[$css_media] = true;
unset($css_concat[$css]);
}
}
foreach ($sp_plugin_styles->to_do as $css) {
$css_src = $sp_plugin_styles->registered[$css]->src;
$css_media = $sp_plugin_styles->registered[$css]->args;
# is the css is hosted localy AND is a css file?
if ((!(strpos($css_src, get_bloginfo('url')) === false) || substr($css_src, 0, 1) === '/' || substr($css_src, 0, 1) === '.') && (substr($css_src, strrpos($css_src, '.'), 4) == '.css' || substr($css_src, strrpos($css_src, '.'), 4) == '.php')) {
if (!is_array($css_files) || !array_key_exists($css_media, $css_files)) {
$css_files[$css_media] = array();
}
if (strpos($css_src, get_bloginfo('url')) === false) {
$css_relative_url = substr($css_src, 1);
} else {
$css_relative_url = substr($css_src, strlen(get_bloginfo('url')) + 1);
}
if (strpos($css_relative_url, '?')) {
$css_relative_url = substr($css_relative_url, 0, strpos($css_relative_url, '?'));
}
# removing parameters
$css_m_time = null;
@($css_m_time = filemtime($css_relative_url));
# getting the mofified time of the css file. extracting the file's dir
if ($css_m_time) {
# only add the file if it's accessible
# check for php theme file indicating main theme file and save whole url vs just relative
if (substr($css_src, strrpos($css_src, '.'), 4) == '.php') {
array_push($css_files[$css_media], $css_src);
} else {
array_push($css_files[$css_media], $css_relative_url);
}
if (!file_exists(SP_COMBINED_CACHE_DIR . SP_COMBINED_CSS_BASE_NAME . $css_media . '.css') || isset($css_concat['css-' . $css]) && ($css_m_time != $css_concat['css-' . $css]['modified'] || $css_concat['css-' . $css]['type'] != $css_media) || !isset($css_concat['css-' . $css])) {
# css file is first identified
$css_files_modify[$css_media] = true;
# the combined file containing this media type css should be changed
if (isset($css_concat['css-' . $css]) && $css_concat['css-' . $css]['type'] != $css_media) {
# if the media type changed - rewrite both css files
$tmp = $css_concat['css-' . $css]['type'];
$css_files_modify[$tmp] = true;
}
if (!is_array($css_concat['css-' . $css])) {
$css_concat['css-' . $css] = array();
}
$css_concat['css-' . $css]['modified'] = $css_m_time;
# write the new modified date
$css_concat['css-' . $css]['type'] = $css_media;
}
$sp_plugin_styles->remove($css);
# removes the css file from the queue
}
}
}
}
foreach ($css_files_modify as $key => $value) {
$combined_file = fopen(SP_COMBINED_CACHE_DIR . SP_COMBINED_CSS_BASE_NAME . $key . '.css', 'w');
if ($combined_file) {
$css_content = '';
if (is_array($css_files[$key])) {
foreach ($css_files[$key] as $css_src) {
$css_content .= "\n" . sp_get_css_content($css_src) . "\n";
}
}
if (!isset($css_concat['ver'][$key])) {
$css_concat['ver'][$key] = 0;
}
$css_concat['ver'][$key]++;
//.........这里部分代码省略.........