예제 #1
0
<?php

/**
 * Module Name: Custom CSS
 * Module Description: Customize your site’s CSS without modifying your theme.
 * Sort Order: 2
 * First Introduced: 1.7
 * Requires Connection: No
 * Auto Activate: Yes
 * Module Tags: Appearance
 */
function jetpack_load_custom_css()
{
    include dirname(__FILE__) . "/custom-css/custom-css.php";
}
add_action('jetpack_modules_loaded', 'custom_css_loaded');
function custom_css_loaded()
{
    Jetpack::enable_module_configurable(__FILE__);
    Jetpack::module_configuration_load(__FILE__, 'custom_css_configuration_load');
}
function custom_css_configuration_load()
{
    wp_safe_redirect(admin_url('themes.php?page=editcss#settingsdiv'));
    exit;
}
jetpack_load_custom_css();
 /**
  * Parse some CSS and make sure it's valid before outputting it in the page
  */
 function parse_css($css = null)
 {
     if (empty($css)) {
         return null;
     }
     if (!defined('JETPACK__VERSION')) {
         return $this->inst_css_parser($css);
     } else {
         if (!class_exists('Jetpack_Custom_CSS', false)) {
             if (function_exists('jetpack_load_custom_css')) {
                 jetpack_load_custom_css();
             }
             // Still here? Load module manually.
             if (!class_exists('Jetpack_Custom_CSS', false)) {
                 require JETPACK__PLUGIN_DIR . 'modules/custom-css/custom-css.php';
             }
         }
         $css = @Jetpack_Custom_CSS::minify($css, 'sass');
         if (empty($css)) {
             return null;
         }
         return $css;
     }
 }