本文整理汇总了PHP中CSSMin::printCompressedCSS方法的典型用法代码示例。如果您正苦于以下问题:PHP CSSMin::printCompressedCSS方法的具体用法?PHP CSSMin::printCompressedCSS怎么用?PHP CSSMin::printCompressedCSS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSSMin
的用法示例。
在下文中一共展示了CSSMin::printCompressedCSS方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pp_enqueue_front_page_scripts
function pp_enqueue_front_page_scripts()
{
//enqueue frontend css files
$pp_advance_combine_css = get_option('pp_advance_combine_css');
//If enable animation
$pp_animation = get_option('pp_animation');
//Get theme cache folder
$upload_dir = wp_upload_dir();
$cache_dir = '';
$cache_url = '';
if (isset($upload_dir['basedir'])) {
$cache_dir = THEMEUPLOAD;
}
if (isset($upload_dir['baseurl'])) {
$cache_url = THEMEUPLOADURL;
}
if (!empty($pp_advance_combine_css)) {
if (!file_exists($cache_dir . "/combined.css")) {
$cssmin = new CSSMin();
$css_arr = array(get_template_directory() . '/css/reset.css', get_template_directory() . '/css/wordpress.css', get_template_directory() . '/css/animation.css', get_template_directory() . '/css/magnific-popup.css', get_template_directory() . '/css/jqueryui/custom.css', get_template_directory() . '/js/mediaelement/mediaelementplayer.css', get_template_directory() . '/js/flexslider/flexslider.css', get_template_directory() . '/css/tooltipster.css', get_template_directory() . '/css/odometer-theme-minimal.css', get_template_directory() . '/css/hw-parallax.css', get_template_directory() . '/css/screen.css');
//If using child theme
$pp_child_theme = get_option('pp_child_theme');
if (empty($pp_child_theme)) {
$css_arr[] = get_template_directory() . '/css/screen.css';
} else {
$css_arr[] = get_template_directory() . '/style.css';
}
$cssmin->addFiles($css_arr);
// Set original CSS from all files
$cssmin->setOriginalCSS();
$cssmin->compressCSS();
$css = $cssmin->printCompressedCSS();
file_put_contents($cache_dir . "combined.css", $css);
}
wp_enqueue_style("combined_css", $cache_url . "combined.css", false, "");
} else {
wp_enqueue_style("reset-css", get_template_directory_uri() . "/css/reset.css", false, "");
wp_enqueue_style("wordpress-css", get_template_directory_uri() . "/css/wordpress.css", false, "");
wp_enqueue_style("animation.css", get_template_directory_uri() . "/css/animation.css", false, "", "all");
wp_enqueue_style("magnific-popup", get_template_directory_uri() . "/css/magnific-popup.css", false, "", "all");
wp_enqueue_style("jquery-ui-css", get_template_directory_uri() . "/css/jqueryui/custom.css", false, "");
wp_enqueue_style("mediaelement", get_template_directory_uri() . "/js/mediaelement/mediaelementplayer.css", false, "", "all");
wp_enqueue_style("flexslider", get_template_directory_uri() . "/js/flexslider/flexslider.css", false, "", "all");
wp_enqueue_style("tooltipster", get_template_directory_uri() . "/css/tooltipster.css", false, "", "all");
wp_enqueue_style("odometer-theme", get_template_directory_uri() . "/css/odometer-theme-minimal.css", false, "", "all");
wp_enqueue_style("hw-parallax.css", get_template_directory_uri() . '/css/hw-parallax.css', false, "", "all");
wp_enqueue_style("screen.css", get_template_directory_uri() . '/css/screen.css', false, "", "all");
}
//Check menu layout
$tg_menu_layout = tg_menu_layout();
if ($tg_menu_layout == 'leftmenu') {
wp_enqueue_style("leftmenu.css", get_template_directory_uri() . '/css/leftmenu.css', false, "", "all");
}
//Add Font Awesome Support
wp_enqueue_style("fontawesome", get_template_directory_uri() . "/css/font-awesome.min.css", false, "", "all");
if (THEMEDEMO && isset($_GET['menu']) && !empty($_GET['menu'])) {
wp_enqueue_style("custom_css", get_template_directory_uri() . "/templates/custom-css.php?menu=" . $_GET['menu'], false, "", "all");
} else {
wp_enqueue_style("custom_css", get_template_directory_uri() . "/templates/custom-css.php", false, "", "all");
}
$tg_boxed = kirki_get_option('tg_boxed');
if (THEMEDEMO && isset($_GET['boxed']) && !empty($_GET['boxed'])) {
$tg_boxed = 1;
}
if (!empty($tg_boxed) && $tg_menu_layout != 'leftmenu') {
wp_enqueue_style("tg_boxed", get_template_directory_uri() . '/css/tg_boxed.css', false, "", "all");
}
//If using child theme
$pp_child_theme = get_option('pp_child_theme');
if (!empty($pp_child_theme)) {
wp_enqueue_style('child_theme', get_stylesheet_directory_uri() . "/style.css", false, "", "all");
}
//Get all Google Web font CSS
global $tg_google_fonts;
$tg_fonts_family = array();
if (is_array($tg_google_fonts) && !empty($tg_google_fonts)) {
foreach ($tg_google_fonts as $tg_font) {
$tg_fonts_family[] = kirki_get_option($tg_font);
}
}
$tg_fonts_family = array_unique($tg_fonts_family);
foreach ($tg_fonts_family as $key => $tg_google_font) {
if (!empty($tg_google_font) && $tg_google_font != 'serif' && $tg_google_font != 'sans-serif' && $tg_google_font != 'monospace') {
if (!is_ssl()) {
wp_enqueue_style('google_font' . $key, "http://fonts.googleapis.com/css?family=" . urlencode($tg_google_font) . ":300,400,700,400italic&subset=latin,cyrillic-ext,greek-ext,cyrillic", false, "", "all");
} else {
wp_enqueue_style('google_font' . $key, "https://fonts.googleapis.com/css?family=" . urlencode($tg_google_font) . ":300, 400,700,400italic&subset=latin,cyrillic-ext,greek-ext,cyrillic", false, "", "all");
}
}
}
//Enqueue javascripts
wp_enqueue_script("jquery");
$js_path = get_template_directory() . "/js/";
$js_arr = array('jquery.magnific-popup.js', 'jquery.easing.js', 'waypoints.min.js', 'jquery.isotope.js', 'jquery.masory.js', 'jquery.tooltipster.min.js', 'hw-parallax.js', 'custom_plugins.js', 'custom.js');
$js = "";
$pp_advance_combine_js = get_option('pp_advance_combine_js');
if (!empty($pp_advance_combine_js)) {
if (!file_exists($cache_dir . "combined.js")) {
foreach ($js_arr as $file) {
if ($file != 'jquery.js' && $file != 'jquery-ui.js') {
//.........这里部分代码省略.........
示例2: CSSMin
wp_enqueue_style("custom_css", get_stylesheet_directory_uri() . "/templates/custom-css.php", false, $pp_theme_version, "all");
}
}
?>
<?php
if (!empty($pp_advance_responsive)) {
if (!empty($pp_advance_combine_css)) {
if (!file_exists(get_stylesheet_directory_uri() . "/cache/combined_grid.css")) {
$cssmin = new CSSMin();
$css_arr = array(get_template_directory() . '/css/grid.css');
$cssmin->addFiles($css_arr);
// Set original CSS from all files
$cssmin->setOriginalCSS();
$cssmin->compressCSS();
$css = $cssmin->printCompressedCSS();
file_put_contents(get_template_directory() . "/cache/combined_grid.css", $css);
}
wp_enqueue_style("combined_grid_css", get_stylesheet_directory_uri() . "/cache/combined_grid.css", false, THEMEVERSION);
} else {
wp_enqueue_style('grid', get_stylesheet_directory_uri() . "/css/grid.css", false, "", "all");
}
}
?>
<?php
/* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such
* as styles, scripts, and meta tags.
*/
示例3: pp_enqueue_front_page_scripts
function pp_enqueue_front_page_scripts()
{
//Get all Google Web font CSS
global $gg_fonts;
$gg_fonts_family = array();
if (is_array($gg_fonts) && !empty($gg_fonts)) {
foreach ($gg_fonts as $gg_font) {
$gg_fonts_family[] = get_option($gg_font . '_value');
}
}
$gg_fonts_family = array_unique($gg_fonts_family);
foreach ($gg_fonts_family as $key => $gg_fonts_family_value) {
if (!empty($gg_fonts_family_value) && $gg_fonts_family_value != 'Helvetica' && $gg_fonts_family_value != 'Arial') {
wp_enqueue_style('google_font' . $key, "http://fonts.googleapis.com/css?family=" . urlencode($gg_fonts_family_value) . ":400,700,400italic&subset=latin,cyrillic-ext,greek-ext,cyrillic", false, "", "all");
}
}
if (isset($_GET['vegastyle']) && $_GET['vegastyle'] == 2 && THEMEDEMO) {
wp_enqueue_style('google_font_default_2', "http://fonts.googleapis.com/css?family=Oswald:400italic,700italic,400,700&subset=latin,cyrillic-ext,greek-ext,greek,cyrillic,latin-ext,vietnamese", false, "", "all");
}
if (isset($_GET['vegastyle']) && $_GET['vegastyle'] == 3 && THEMEDEMO) {
wp_enqueue_style('google_font_default_3', "http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700&subset=latin,cyrillic-ext,greek-ext,greek,cyrillic,latin-ext,vietnamese", false, "", "all");
}
//enqueue frontend css files
$pp_advance_combine_css = get_option('pp_advance_combine_css');
//If enable animation
$pp_animation = get_option('pp_animation');
if (!empty($pp_advance_combine_css)) {
if (!file_exists(get_template_directory_uri() . "/cache/combined.css")) {
$cssmin = new CSSMin();
$css_arr = array(get_template_directory() . '/css/screen.css', get_template_directory() . '/css/magnific-popup.css', get_template_directory() . '/js/flexslider/flexslider.css', get_template_directory() . '/js/mediaelement/mediaelementplayer.css');
if (empty($pp_animation)) {
$css_arr[] = get_template_directory() . '/css/animation.css';
}
$cssmin->addFiles($css_arr);
// Set original CSS from all files
$cssmin->setOriginalCSS();
$cssmin->compressCSS();
$css = $cssmin->printCompressedCSS();
file_put_contents(get_template_directory() . "/cache/combined.css", $css);
}
wp_enqueue_style("combined_css", get_template_directory_uri() . "/cache/combined.css", false, THEMEVERSION);
} else {
if (empty($pp_animation)) {
wp_enqueue_style("animation.css", get_template_directory_uri() . "/css/animation.css", false, THEMEVERSION, "all");
}
wp_enqueue_style("screen.css", get_template_directory_uri() . '/css/screen.css', false, THEMEVERSION, "all");
wp_enqueue_style("mediaelement", get_template_directory_uri() . "/js/mediaelement/mediaelementplayer.css", false, THEMEVERSION, "all");
wp_enqueue_style("magnific-popup", get_template_directory_uri() . "/css/magnific-popup.css", false, THEMEVERSION, "all");
wp_enqueue_style("flexslider", get_template_directory_uri() . "/js/flexslider/flexslider.css", false, THEMEVERSION, "all");
}
//Add Font Awesome Support
wp_enqueue_style("fontawesome", get_template_directory_uri() . "/css/font-awesome.min.css", false, THEMEVERSION, "all");
//Add custom colors and fonts
if (isset($_GET['vegastyle']) && THEMEDEMO) {
$custom_css_url = get_template_directory_uri() . "/templates/custom-css-dynamic.php?vegastyle=" . $_GET['vegastyle'];
wp_enqueue_style("custom_css", $custom_css_url, false, THEMEVERSION, "all");
} else {
wp_enqueue_style("custom_css", get_template_directory_uri() . "/templates/custom-css.php", false, THEMEVERSION, "all");
}
//Check if enable responsive layout
$pp_enable_responsive = get_option('pp_enable_responsive');
if (!empty($pp_enable_responsive)) {
wp_enqueue_style('grid', get_template_directory_uri() . "/css/grid.css", false, THEMEVERSION, "all");
}
//Enqueue javascripts
wp_enqueue_script("jquery");
wp_enqueue_script("google_maps", "http://maps.google.com/maps/api/js?sensor=false", false, THEMEVERSION, true);
if (THEMEDEMO) {
wp_enqueue_script("jquery.cookie", get_template_directory_uri() . "/js/jquery.cookie.js", false, THEMEVERSION);
}
$js_path = get_template_directory() . "/js/";
$js_arr = array('jquery.easing.min.js', 'waypoints.min.js', 'jquery.magnific-popup.js', 'jquery.touchwipe.1.1.1.js', 'gmap.js', 'jquery.isotope.js', 'flexslider/jquery.flexslider-min.js', 'jquery.masonry.js', 'mediaelement/mediaelement-and-player.min.js', 'jquery.stellar.js', 'custom_plugins.js', 'custom.js');
$js = "";
$pp_advance_combine_js = get_option('pp_advance_combine_js');
if (!empty($pp_advance_combine_js)) {
if (!file_exists(get_template_directory() . "/cache/combined.js")) {
foreach ($js_arr as $file) {
if ($file != 'jquery.js' && $file != 'jquery-ui.js') {
$js .= JSMin::minify(file_get_contents($js_path . $file));
}
}
file_put_contents(get_template_directory() . "/cache/combined.js", $js);
}
wp_enqueue_script("combined_js", get_template_directory_uri() . "/cache/combined.js", false, THEMEVERSION, true);
} else {
foreach ($js_arr as $file) {
if ($file != 'jquery.js' && $file != 'jquery-ui.js') {
wp_enqueue_script($file, get_template_directory_uri() . "/js/" . $file, false, THEMEVERSION, true);
}
}
}
}
示例4: pp_enqueue_front_page_scripts
function pp_enqueue_front_page_scripts()
{
//enqueue frontend css files
$pp_advance_combine_css = get_option('pp_advance_combine_css');
//If enable animation
$pp_animation = get_option('pp_animation');
if (!empty($pp_advance_combine_css)) {
wp_enqueue_style("jquery-ui", get_template_directory_uri() . "/functions/jquery-ui/css/custom-theme/jquery-ui-1.8.24.custom.css", false, THEMEVERSION, "all");
if (!file_exists(get_template_directory_uri() . "/cache/combined.css")) {
$cssmin = new CSSMin();
$css_arr = array(get_template_directory() . '/css/magnific-popup.css', get_template_directory() . '/js/mediaelement/mediaelementplayer.css', get_template_directory() . '/js/flexslider/flexslider.css', get_template_directory() . '/css/tooltipster.css', get_template_directory() . '/css/parallax.min.css', get_template_directory() . '/js/flexslider/flexslider.css', get_template_directory() . '/css/supersized.css', get_template_directory() . '/css/odometer-theme-minimal.css', get_template_directory() . '/css/screen.css');
if ($pp_animation) {
$css_arr[] = get_template_directory() . '/css/animation.css';
}
$cssmin->addFiles($css_arr);
// Set original CSS from all files
$cssmin->setOriginalCSS();
$cssmin->compressCSS();
$css = $cssmin->printCompressedCSS();
file_put_contents(get_template_directory() . "/cache/combined.css", $css);
}
wp_enqueue_style("combined_css", get_template_directory_uri() . "/cache/combined.css", false, THEMEVERSION);
$pp_child_theme = get_option('pp_child_theme');
if (!empty($pp_child_theme)) {
wp_enqueue_style("child-css", get_stylesheet_directory_uri() . "/style.css", false, THEMEVERSION);
}
} else {
if ($pp_animation) {
wp_enqueue_style("animation.css", get_template_directory_uri() . "/css/animation.css", false, THEMEVERSION, "all");
}
wp_enqueue_style("jquery-ui", get_template_directory_uri() . "/functions/jquery-ui/css/custom-theme/jquery-ui-1.8.24.custom.css", false, THEMEVERSION, "all");
wp_enqueue_style("magnific-popup", get_template_directory_uri() . "/css/magnific-popup.css", false, THEMEVERSION, "all");
wp_enqueue_style("flexslider", get_template_directory_uri() . "/js/flexslider/flexslider.css", false, THEMEVERSION, "all");
wp_enqueue_style("mediaelement", get_template_directory_uri() . "/js/mediaelement/mediaelementplayer.css", false, THEMEVERSION, "all");
wp_enqueue_style("tooltipster", get_template_directory_uri() . "/css/tooltipster.css", false, THEMEVERSION, "all");
wp_enqueue_style("parallax", get_template_directory_uri() . "/css/parallax.min.css", false, THEMEVERSION, "all");
wp_enqueue_style("flexslider-css", get_template_directory_uri() . "/js/flexslider/flexslider.css", false, THEMEVERSION, "all");
wp_enqueue_style("supersized", get_template_directory_uri() . "/css/supersized.css", false, THEMEVERSION, "all");
wp_enqueue_style("odometer-theme", get_template_directory_uri() . "/css/odometer-theme-minimal.css", false, THEMEVERSION, "all");
wp_enqueue_style("screen-css", get_template_directory_uri() . "/css/screen.css", false, THEMEVERSION);
$pp_child_theme = get_option('pp_child_theme');
if (!empty($pp_child_theme)) {
wp_enqueue_style("child-css", get_stylesheet_directory_uri() . "/style.css", false, THEMEVERSION);
}
}
//Add Font Awesome Support
wp_enqueue_style("fontawesome", get_template_directory_uri() . "/css/font-awesome.min.css", false, THEMEVERSION, "all");
//Add custom colors and fonts
wp_enqueue_style("custom_css", get_template_directory_uri() . "/templates/custom-css.php", false, THEMEVERSION, "all");
//Get all Google Web font CSS
global $gg_fonts;
$gg_fonts_family = array();
if (is_array($gg_fonts) && !empty($gg_fonts)) {
foreach ($gg_fonts as $gg_font) {
$gg_fonts_family[] = get_option($gg_font);
}
}
$gg_fonts_family = array_unique($gg_fonts_family);
foreach ($gg_fonts_family as $key => $gg_fonts_family_value) {
if (!empty($gg_fonts_family_value) && $gg_fonts_family_value != 'Helvetica' && $gg_fonts_family_value != 'Arial') {
wp_enqueue_style('google_font' . $key, "http://fonts.googleapis.com/css?family=" . $gg_fonts_family_value . ":200,300,400,500,600,700,400italic&subset=latin,cyrillic-ext,greek-ext,cyrillic", false, "", "all");
}
}
//Check if enable responsive layout
$pp_enable_responsive = get_option('pp_enable_responsive');
if (!empty($pp_enable_responsive)) {
if (!empty($pp_advance_combine_css)) {
wp_enqueue_style('responsive', get_template_directory_uri() . "/templates/responsive-css.php", false, "", "all");
} else {
wp_enqueue_style('responsive', get_template_directory_uri() . "/css/grid.css", false, "", "all");
}
}
//Enqueue javascripts
wp_enqueue_script("jquery");
wp_enqueue_script("google_maps", "http://maps.google.com/maps/api/js?sensor=false", false, THEMEVERSION, true);
wp_enqueue_script("parallax", get_template_directory_uri() . "/js/parallax.min.js", false, THEMEVERSION, true);
$js_path = get_template_directory() . "/js/";
$js_arr = array('jquery.easing.js', 'jquery.magnific-popup.js', 'waypoints.min.js', 'jquery.isotope.js', 'jquery.masory.js', 'jquery.tooltipster.min.js', 'custom_plugins.js', 'custom.js');
$js = "";
$pp_advance_combine_js = get_option('pp_advance_combine_js');
if (!empty($pp_advance_combine_js)) {
if (!file_exists(get_template_directory() . "/cache/combined.js")) {
foreach ($js_arr as $file) {
if ($file != 'jquery.js' && $file != 'jquery-ui.js') {
$js .= JSMin::minify(file_get_contents($js_path . $file));
}
}
file_put_contents(get_template_directory() . "/cache/combined.js", $js);
}
wp_enqueue_script("combined_js", get_template_directory_uri() . "/cache/combined.js", false, THEMEVERSION, true);
} else {
foreach ($js_arr as $file) {
if ($file != 'jquery.js' && $file != 'jquery-ui.js') {
wp_enqueue_script($file, get_template_directory_uri() . "/js/" . $file, false, THEMEVERSION, true);
}
}
}
}