示例#1
0
 static function loadStylesheets($style, $templateObj)
 {
     $actionBoxObj = $templateObj->_actionbox_obj;
     $meta = $actionBoxObj->getMeta();
     switch ($style) {
         case 'user':
             //get user style key
             $userStyleKey = $meta['userstyle'];
             //use style set by user
             $mabStylesheet = mab_get_settings_stylesheet_path($userStyleKey);
             //create stylesheet file if its not created yet
             if (!file_exists($mabStylesheet) || trim(mab_get_settings_stylesheet_contents($userStyleKey)) == '') {
                 mab_create_stylesheet($userStyleKey);
             }
             if (file_exists($mabStylesheet)) {
                 //actionbox specific stylesheet
                 wp_enqueue_style('mab-user-style-' . $userStyleKey, mab_get_settings_stylesheet_url($userStyleKey), array('mab-base-style'), filemtime($mabStylesheet));
             }
             break;
             // ===================
         // ===================
         case 'none':
             break;
         default:
             /** LOAD PRECONFIGURED STYLESHEET **/
             //$other_style_location = MAB_ASSETS_URL . 'css/style-';
             /* TODO: be able to load type specific stylesheets style-{TYPE}.css */
             //use one of the preconfigured styles
             //$preconfigured_style = $other_style_location . $style . '.css';
             $preconfigured_style = $templateObj->getTemplateStyleUrl() . "style.css";
             //if( file_exists( $preconfigured_style  ) ){ this is a url.. tsk.
             wp_enqueue_style("mab-preconfigured-style-{$style}", $preconfigured_style, array('mab-base-style'), MAB_VERSION);
             //} else {
             //wp_enqueue_style( "mab-style-default", MAB_ASSETS_URL . 'css/style-default.css', array(), "1.0" );
             //}
             //wp_redirect( "{$preconfigured_style}" );
             break;
             // ==========================
     }
     //endswitch
 }
示例#2
0
/**
 * Uses the mapping output to write the beautified CSS to a file.
 *
 * @author Gary Jones
 * @since 0.9.6
 * @version 1.0
 */
function mab_create_settings_stylesheet($key, $section = 'all')
{
    mab_make_stylesheet_path_writable();
    $css = '/* ' . __('This file is auto-generated from the style design settings. Any direct edits here will be lost if the style is saved or updated', 'mab') . ' */' . "\n";
    $css .= mab_prepare_settings_stylesheet($key, $section);
    $handle = @fopen(mab_get_settings_stylesheet_path($key), 'w');
    @fwrite($handle, $css);
    @fclose($handle);
}