/** * Prepares the contents of the export file. * * @author Gary Jones * @since 0.9.6 * @return array $output multi-dimensional array holding CSS data * @uses premise_get_mapping() * @version 1.0 */ function premise_prepare_export($key) { $mapping = premise_get_mapping(); foreach ($mapping as $selector => $declaration) { if (!is_array($declaration)) { $output[$selector] = premise_get_design_option($declaration, $key); } else { foreach ($declaration as $property => $value) { if (!is_array($value)) { $output[$selector][$property] = premise_get_design_option($value, $key); } else { foreach ($value as $index => $composite_value) { $val = $composite_value[0]; $type = $composite_value[1]; if ('fixed_string' == $type) { $output[$selector][$property][$index]['value'] = $val; } else { $output[$selector][$property][$index]['value'] = premise_get_design_option($val, $key); } $output[$selector][$property][$index]['type'] = $type; } } } } } // Add in contents of custom stylesheet $css = file_get_contents(premise_get_custom_stylesheet_path()); $output['custom_css'] = $css; return apply_filters('premise_prepare_export', $output); }
/** * Merges style.css, settings stylesheet and custom.css, then minifies it into * one minified.css file. Also creates individual beautified settings stylesheet * so they are in sync, and attempts to create custom stylesheet if it doesn't * exist. * * @author Gary Jones * @since 0.9.7 * @version 1.0 */ function premise_create_stylesheets() { premise_make_stylesheet_path_writable(); global $premise_design_settings, $premise_base; $styles = $premise_design_settings->get_settings(); $base_css = file_get_contents($premise_base->get_theme_directory() . '/style.css'); $css_prefix = '/* ' . __('This file is auto-generated from the style.css, the settings page and custom.css. Any direct edits here will be lost if the settings page is saved', 'premise') . ' */' . "\n"; foreach ($styles as $key => $style) { $css = $base_css . premise_prepare_settings_stylesheet($key); if (premise_is_custom_stylesheet_used()) { $css .= file_get_contents(premise_get_custom_stylesheet_path()); } $css = $css_prefix . premise_minify_css($css); $handle = @fopen(premise_get_minified_stylesheet_path($key), 'w'); @fwrite($handle, $css); @fclose($handle); premise_create_settings_stylesheet($key); premise_create_custom_stylesheet($key); } }
function enqueue_theme_scripts_css() { global $premise_base; $post_id = $this->get_post_id(); $meta = $premise_base->get_premise_meta($post_id); $key = $meta['style']; if (!file_exists(premise_get_settings_stylesheet_path($key)) || trim(premise_get_settings_stylesheet_contents($key)) == '') { premise_create_stylesheets(); } if (!file_exists(premise_get_custom_buttons_stylesheet_path())) { $premise_base->save_configured_buttons_stylesheet(array(), $premise_base->get_configured_buttons()); } if ($this->_use_premise_theme && file_exists(premise_get_settings_stylesheet_path($key))) { if (!premise_is_minified($key)) { wp_enqueue_style('premise', PREMISE_THEMES_URL . 'premise/style.css', array(), filemtime(PREMISE_DIR . 'themes/premise/style.css')); wp_enqueue_style('premise_settings_stylesheet', premise_get_settings_stylesheet_url($key), false, filemtime(premise_get_settings_stylesheet_path($key))); if (is_file(premise_get_custom_stylesheet_path($key))) { wp_enqueue_style('premise_custom_stylesheet', premise_get_custom_stylesheet_url($key), false, filemtime(premise_get_custom_stylesheet_path($key))); } } else { // Otherwise, if minified, then add reference to minified stylesheet, and remove style.css reference wp_enqueue_style('premise_minified_stylesheet', premise_get_minified_stylesheet_url($key), false, filemtime(premise_get_minified_stylesheet_path($key))); } } wp_enqueue_style('premise_custom_buttons', premise_get_custom_buttons_stylesheet_url()); wp_enqueue_script('premise_easing', PREMISE_THEMES_URL . 'premise/js/jquery-easing.js', array('jquery'), PREMISE_VERSION); wp_enqueue_script('premise_coda_slider', PREMISE_THEMES_URL . 'premise/js/jquery-coda.js', array('jquery', 'premise_easing'), PREMISE_VERSION); wp_enqueue_script('premise_pretty_photo', PREMISE_THEMES_URL . 'premise/js/jquery-overlay.js', array('jquery'), PREMISE_VERSION); }
/** * CSS to edit. * * @author StudioPress * @since 1.5.0 */ function custom_css() { global $premise_design_settings; foreach ($premise_design_settings->get_settings() as $key => $style) { $custom_css = premise_is_custom_stylesheet_used($key) ? file_get_contents(premise_get_custom_stylesheet_path($key)) : ''; if (strlen($custom_css < 3 && isset($style['premise_custom_css']))) { $custom_css = $style['premise_custom_css']; } printf(__('<h4>Style: %1$s</h4>', 'premise'), esc_html($style['premise_style_title'])); printf('<textarea name="%1$s[%2$s]" id="%1$s[%2$s]" cols="80" rows="22">%3$s</textarea>', $this->get_field_name('css'), $key, esc_textarea($custom_css)); } }