$stylesheet_time) asia_garden_customizer_duplicate_theme_options($theme_slug, $stylesheet_slug, $theme_time);
// If main theme (template) is activated and 'duplicate_options' == 'child'
// (duplicate options only from template to the child-theme) - regenerate CSS with custom colors and fonts
} else if ($duplicate == 'child' && $theme_time > 0) {
asia_garden_customizer_save_css();
}
}
}
}
// Duplicate theme options between template and child-theme
if (!function_exists('asia_garden_customizer_duplicate_theme_options')) {
function asia_garden_customizer_duplicate_theme_options($from, $to, $timestamp = 0) {
if ($timestamp == 0) $timestamp = get_option("asia_garden_options_timestamp_{$from}");
$from = "theme_mods_{$from}";
$from_options = get_option($from);
$to = "theme_mods_{$to}";
$to_options = get_option($to);
if (is_array($from_options)) {
if (!is_array($to_options)) $to_options = array();
$theme_options = asia_garden_storage_get('options');
foreach ($from_options as $k => $v) {
if (isset($theme_options[$k])) $to_options[$k] = $v;
}
update_option($to, $to_options);
update_option("asia_garden_options_timestamp_{$to}", $timestamp);
}
}
}
//--------------------------------------------------------------
//-- New panel in the Customizer Controls
//--------------------------------------------------------------
// Theme init priorities:
// 3 - add/remove Theme Options elements
if (!function_exists('asia_garden_customizer_setup3')) {
add_action( 'after_setup_theme', 'asia_garden_customizer_setup3', 3 );
function asia_garden_customizer_setup3() {
asia_garden_storage_merge_array('options', '', array(
'cpt' => array(
"title" => esc_html__('Plugins settings', 'asia-garden'),
"desc" => '',
"priority" => 400,
"type" => "panel"
)
)
);
}
}
// 3 - add/remove Theme Options elements
if (!function_exists('asia_garden_customizer_setup9999')) {
add_action( 'after_setup_theme', 'asia_garden_customizer_setup9999', 9999 );
function asia_garden_customizer_setup9999() {
asia_garden_storage_merge_array('options', '', array(
'cpt_end' => array(
"type" => "panel_end"
)
)
);
}
}
//--------------------------------------------------------------
//-- Register Customizer Controls
//--------------------------------------------------------------
define('ASIA_GARDEN_CUSTOMIZE_PRIORITY', 200); // Start priority for the new controls
if (!function_exists('asia_garden_customizer_register_controls')) {
add_action( 'customize_register', 'asia_garden_customizer_register_controls', 11 );
function asia_garden_customizer_register_controls( $wp_customize ) {
$refresh_auto = asia_garden_get_theme_setting('custmize_refresh') != 'manual';
$panels = array('');
$p = 0;
$sections = array('');
$s = 0;
$i = ASIA_GARDEN_CUSTOMIZE_PRIORITY;
// Reload Theme Options before create controls
if (is_admin()) {
asia_garden_storage_set('options_reloaded', true);
asia_garden_load_theme_options();
}
$options = asia_garden_storage_get('options');
foreach ($options as $id=>$opt) {
$i = !empty($opt['priority'])
? $opt['priority']
: (in_array($opt['type'], array('panel', 'section'))
? ASIA_GARDEN_CUSTOMIZE_PRIORITY
: $i++
);
if (!empty($opt['hidden'])) continue;
if ($opt['type'] == 'panel') {
$sec = $wp_customize->get_panel( $id );
if ( is_object($sec) && !empty($sec->title) ) {
$sec->title = $opt['title'];
$sec->description= $opt['desc'];
if ( !empty($opt['priority']) ) $sec->priority = $opt['priority'];
} else {
$wp_customize->add_panel( esc_attr($id) , array(
'title' => $opt['title'],
'description'=> $opt['desc'],
'priority' => $i
) );
}
array_push($panels, $id);
$p++;
} else if ($opt['type'] == 'panel_end') {
array_pop($panels);
$p--;
} else if ($opt['type'] == 'section') {
$sec = $wp_customize->get_section( $id );
if ( is_object($sec) && !empty($sec->title) ) {
$sec->title = $opt['title'];
$sec->description= $opt['desc'];
if ( !empty($opt['priority']) ) $sec->priority = $opt['priority'];
} else {
$wp_customize->add_section( esc_attr($id) , array(
'title' => $opt['title'],
'description'=> $opt['desc'],
'panel' => esc_attr($panels[$p]),
'priority' => $i
) );
}
array_push($sections, $id);
$s++;
} else if ($opt['type'] == 'section_end') {
array_pop($sections);
$s--;
} else if ($opt['type'] == 'select') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'type' => 'select',
'choices' => apply_filters('asia_garden_filter_options_get_list_choises', $opt['options'], $id)
) );
} else if ($opt['type'] == 'radio') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'type' => 'radio',
'choices' => apply_filters('asia_garden_filter_options_get_list_choises', $opt['options'], $id)
) );
} else if ($opt['type'] == 'switch') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Switch_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'choices' => apply_filters('asia_garden_filter_options_get_list_choises', $opt['options'], $id),
'input_attrs' => array(
'value' => asia_garden_get_theme_option($id),
)
) ) );
} else if ($opt['type'] == 'checkbox') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'type' => 'checkbox'
) );
} else if ($opt['type'] == 'color') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_hex_color',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
) ) );
} else if ($opt['type'] == 'image') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
) ) );
} else if (in_array($opt['type'], array('media', 'audio', 'video'))) {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
) ) );
} else if ($opt['type'] == 'icon') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Icon_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'input_attrs' => array(
'value' => asia_garden_get_theme_option($id),
)
) ) );
} else if ($opt['type'] == 'checklist') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Checklist_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'choices' => apply_filters('asia_garden_filter_options_get_list_choises', $opt['options'], $id),
'input_attrs' => array(
'value' => asia_garden_get_theme_option($id),
'sortable' => !empty($opt['sortable']),
'dir' => !empty($opt['dir']) ? $opt['dir'] : 'horizontal'
)
) ) );
} else if ($opt['type'] == 'scheme_editor') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Scheme_Editor_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'input_attrs' => array(
'value' => asia_garden_get_theme_option($id),
)
) ) );
} else if ($opt['type'] == 'button') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'sanitize_text_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Button_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'input_attrs' => array(
'caption' => $opt['caption'],
'action' => $opt['action']
),
'section' => esc_attr($sections[$s]),
'priority' => $i,
) ) );
} else if ($opt['type'] == 'info') {
$wp_customize->add_setting( $id, array(
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
'transport' => 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Info_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
) ) );
} else if ($opt['type'] == 'hidden') {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => 'asia_garden_sanitize_html',
'transport' => 'postMessage'
) );
$wp_customize->add_control( new ASIA_GARDEN_Customize_Hidden_Control( $wp_customize, $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
) ) );
} else { // if (in_array($opt['type'], array('text', 'textarea'))) {
$wp_customize->add_setting( $id, array(
'default' => asia_garden_get_theme_option($id),
'sanitize_callback' => $opt['type'] == 'text' ? 'sanitize_text_field' : 'sanitize_textarea_field',
'transport' => $refresh_auto && (!isset($opt['refresh']) || $opt['refresh']) ? 'refresh' : 'postMessage'
) );
$wp_customize->add_control( $id, array(
'label' => $opt['title'],
'description' => $opt['desc'],
'section' => esc_attr($sections[$s]),
'priority' => $i,
'type' => $opt['type'] //'text' | 'textarea'
) );
}
}
// Setup standard WP Controls
// ---------------------------------
// Reorder standard WP sections
$sec = $wp_customize->get_panel( 'nav_menus' );
if (is_object($sec)) $sec->priority = 1000;
$sec = $wp_customize->get_panel( 'widgets' );
if (is_object($sec)) $sec->priority = 1010;
$sec = $wp_customize->get_section( 'static_front_page' );
if (is_object($sec)) $sec->priority = 1020;
$sec = $wp_customize->get_section( 'custom_css' );
if (is_object($sec)) $sec->priority = 2000;
// Modify standard WP controls
$sec = $wp_customize->get_control( 'blogname' );
if (is_object($sec))
$sec->description = esc_html__('Use "[[" and "]]" to modify style and color of parts of the text, "||" to break current line',
'asia-garden');
$sec = $wp_customize->get_setting( 'blogname' );
if (is_object($sec)) $sec->transport = 'postMessage';
$sec = $wp_customize->get_setting( 'blogdescription' );
if (is_object($sec)) $sec->transport = 'postMessage';
$sec = $wp_customize->get_section( 'header_image' );
$sec2 = $wp_customize->get_control( 'header_image_info' );
$sec2->description = (!empty($sec2->description) ? $sec2->description . '
' : '') . $sec->description;
$sec = $wp_customize->get_control( 'header_image' );
if (is_object($sec)) {
$sec->priority = 300;
$sec->section = 'header';
}
$sec = $wp_customize->get_control( 'header_video' );
if (is_object($sec)) {
$sec->priority = 310;
$sec->section = 'header';
}
$sec = $wp_customize->get_control( 'external_header_video' );
if (is_object($sec)) {
$sec->priority = 320;
$sec->section = 'header';
}
$sec = $wp_customize->get_section( 'background_image' );
if (is_object($sec)) {
$sec->title = esc_html__('Background', 'asia-garden');
$sec->priority = 310;
$sec->description = esc_html__('Used only if "General settings - Body style" equal to "boxed"', 'asia-garden');
}
$sec = $wp_customize->get_control( 'background_color' );
if (is_object($sec)) {
$sec->priority = 10;
$sec->section = 'background_image';
}
// Remove unused sections
$wp_customize->remove_section( 'colors');
$wp_customize->remove_section( 'header_image');
}
}
// Create custom controls for customizer
if (!function_exists('asia_garden_customizer_custom_controls')) {
add_action( 'customize_register', 'asia_garden_customizer_custom_controls' );
function asia_garden_customizer_custom_controls( $wp_customize ) {
class ASIA_GARDEN_Customize_Info_Control extends WP_Customize_Control {
public $type = 'info';
public function render_content() {
?>label)) {
?>label ); ?>description)) {
?>description ); ?>link(); ?> />id),
array(
'type' => 'icons',
'button' => true,
'icons' => true
),
$this->input_attrs['value']
)
);
?>label)) {
?>label ); ?>description)) {
?>description ); ?>link(); ?> />id),
array(
'type' => 'checklist',
'options' => $this->choices,
'sortable' => !empty($this->input_attrs['sortable']),
'dir' => !empty($this->input_attrs['dir']) ? $this->input_attrs['dir'] : 'horizontal'
),
$this->input_attrs['value']
)
);
?>label)) {
?>label ); ?>description)) {
?>description ); ?>
link(); ?> value="">label)) {
?>label ); ?>description)) {
?>description ); ?>link(); ?> />id),
array('type' => 'scheme_editor'),
asia_garden_unserialize($this->input_attrs['value'])
)
);
?>settings();
// Store new schemes colors
$schemes = asia_garden_unserialize($settings['scheme_storage']->value());
if (is_array($schemes) && count($schemes) > 0)
asia_garden_storage_set('schemes', $schemes);
// Store new fonts parameters
$fonts = asia_garden_get_theme_fonts();
foreach ($fonts as $tag=>$v) {
foreach ($v as $css_prop=>$css_value) {
if (in_array($css_prop, array('title', 'description'))) continue;
$fonts[$tag][$css_prop] = $settings["{$tag}_{$css_prop}"]->value();
}
}
asia_garden_storage_set('theme_fonts', $fonts);
// Collect options from the external storages
$options = asia_garden_storage_get('options');
$external_storages = array();
foreach ($options as $k=>$v) {
// Skip non-data options - sections, info, etc.
if (!isset($v['std']) || empty($v['options_storage'])) continue;
// Get option value from Customizer
$value = isset($settings[$k])
? $settings[$k]->value()
: ($v['type']=='checkbox' ? 0 : '');
if (!isset($external_storages[$v['options_storage']]))
$external_storages[$v['options_storage']] = array();
$external_storages[$v['options_storage']][$k] = $value;
}
// Update options in the external storages
foreach ($external_storages as $storage_name => $storage_values) {
$storage = get_option($storage_name, false);
if (is_array($storage)) {
foreach ($storage_values as $k=>$v)
$storage[$k] = $v;
update_option($storage_name, $storage);
}
}
// Update ThemeOptions save timestamp
$stylesheet_slug = get_option('stylesheet');
$stylesheet_time = time();
update_option("asia_garden_options_timestamp_{$stylesheet_slug}", $stylesheet_time);
// Sinchronize theme options between child and parent themes
if (asia_garden_get_theme_setting('duplicate_options') == 'both') {
$theme_slug = get_option('template');
if ($theme_slug != $stylesheet_slug) {
asia_garden_customizer_duplicate_theme_options($stylesheet_slug, $theme_slug, $stylesheet_time);
}
}
// Regenerate CSS with new colors
asia_garden_customizer_save_css();
}
}
// Save CSS with custom colors and fonts into custom.css
if (!function_exists('asia_garden_customizer_save_css')) {
add_action('trx_addons_action_save_options', 'asia_garden_customizer_save_css');
function asia_garden_customizer_save_css() {
$msg = '/* ' . esc_html__("ATTENTION! This file was generated automatically! Don't change it!!!", 'asia-garden')
. "\n----------------------------------------------------------------------- */\n";
// Save CSS with custom colors and fonts into custom.css
$css = asia_garden_customizer_get_css();
$file = asia_garden_get_file_dir('css/__colors.css');
if (file_exists($file)) asia_garden_fpc($file, $msg . $css );
// Merge stylesheets
$list = apply_filters( 'asia_garden_filter_merge_styles', array() );
$css = '';
foreach ($list as $f) {
$css .= asia_garden_fgc(asia_garden_get_file_dir($f));
}
if ( $css != '') {
asia_garden_fpc( asia_garden_get_file_dir('css/__styles.css'), $msg . apply_filters( 'asia_garden_filter_prepare_css', $css, true ) );
}
// Merge scripts
$list = apply_filters( 'asia_garden_filter_merge_scripts', array(
'js/skip-link-focus.js',
'js/bideo.js',
'js/jquery.tubular.js',
'js/_utils.js',
'js/_init.js'
)
);
$js = '';
foreach ($list as $f) {
$js .= asia_garden_fgc(asia_garden_get_file_dir($f));
}
if ( $js != '') {
asia_garden_fpc( asia_garden_get_file_dir('js/__scripts.js'), $msg . apply_filters( 'asia_garden_filter_prepare_js', $js, true ) );
}
}
}
//--------------------------------------------------------------
// Customizer JS and CSS
//--------------------------------------------------------------
// Binds JS listener to make Customizer color_scheme control.
// Passes color scheme data as colorScheme global.
if ( !function_exists( 'asia_garden_customizer_control_js' ) ) {
add_action( 'customize_controls_enqueue_scripts', 'asia_garden_customizer_control_js' );
function asia_garden_customizer_control_js() {
wp_enqueue_style( 'asia_garden-customizer', asia_garden_get_file_url('theme-options/theme.customizer.css') );
wp_enqueue_script( 'asia_garden-customizer',
asia_garden_get_file_url('theme-options/theme.customizer.js'),
array( 'customize-controls', 'iris', 'underscore', 'wp-util' ), null, true );
wp_localize_script( 'asia_garden-customizer', 'asia_garden_color_schemes', asia_garden_storage_get('schemes') );
wp_localize_script( 'asia_garden-customizer', 'asia_garden_simple_schemes', asia_garden_storage_get('schemes_simple') );
wp_localize_script( 'asia_garden-customizer', 'asia_garden_theme_fonts', asia_garden_storage_get('theme_fonts') );
wp_localize_script( 'asia_garden-customizer', 'asia_garden_customizer_vars', array(
'max_load_fonts' => asia_garden_get_theme_setting('max_load_fonts'),
'msg_refresh' => esc_html__('Refresh', 'asia-garden'),
'msg_reset' => esc_html__('Reset', 'asia-garden'),
'msg_reset_confirm' => esc_html__('Are you sure you want to reset all Theme Options?', 'asia-garden'),
) );
wp_localize_script( 'asia_garden-customizer', 'asia_garden_dependencies', asia_garden_get_theme_dependencies() );
}
}
// Binds JS handlers to make the Customizer preview reload changes asynchronously.
if ( !function_exists( 'asia_garden_customizer_preview_js' ) ) {
add_action( 'customize_preview_init', 'asia_garden_customizer_preview_js' );
function asia_garden_customizer_preview_js() {
wp_enqueue_script( 'asia_garden-customizer-preview',
asia_garden_get_file_url('theme-options/theme.customizer.preview.js'),
array( 'customize-preview' ), null, true );
}
}
// Output an Underscore template for generating CSS for the color scheme.
// The template generates the css dynamically for instant display in the Customizer preview.
if ( !function_exists( 'asia_garden_customizer_css_template' ) ) {
add_action( 'customize_controls_print_footer_scripts', 'asia_garden_customizer_css_template' );
function asia_garden_customizer_css_template() {
$colors = array();
foreach (asia_garden_get_scheme_colors() as $k=>$v)
$colors[$k] = '{{ data.'.esc_attr($k).' }}';
$tmpl_holder = 'script';
$schemes = array_keys(asia_garden_get_list_schemes());
if (count($schemes) > 0) {
foreach ($schemes as $scheme) {
asia_garden_show_layout(asia_garden_customizer_get_css( $colors, false, false, $scheme ),
'<' . esc_html($tmpl_holder) . ' type="text/html" id="tmpl-asia_garden-color-scheme-'.esc_attr($scheme).'">',
'' . esc_html($tmpl_holder) . '>');
}
}
// Fonts
$fonts = asia_garden_get_theme_fonts();
if (is_array($fonts) && count($fonts) > 0) {
foreach ($fonts as $tag => $font) {
$fonts[$tag]['font-family'] = '{{ data["'.$tag.'"]["font-family"] }}';
$fonts[$tag]['font-size'] = '{{ data["'.$tag.'"]["font-size"] }}';
$fonts[$tag]['line-height'] = '{{ data["'.$tag.'"]["line-height"] }}';
$fonts[$tag]['font-weight'] = '{{ data["'.$tag.'"]["font-weight"] }}';
$fonts[$tag]['font-style'] = '{{ data["'.$tag.'"]["font-style"] }}';
$fonts[$tag]['text-decoration'] = '{{ data["'.$tag.'"]["text-decoration"] }}';
$fonts[$tag]['text-transform'] = '{{ data["'.$tag.'"]["text-transform"] }}';
$fonts[$tag]['letter-spacing'] = '{{ data["'.$tag.'"]["letter-spacing"] }}';
$fonts[$tag]['margin-top'] = '{{ data["'.$tag.'"]["margin-top"] }}';
$fonts[$tag]['margin-bottom'] = '{{ data["'.$tag.'"]["margin-bottom"] }}';
}
asia_garden_show_layout(asia_garden_customizer_get_css( false, $fonts, false, false ),
'<'.trim($tmpl_holder).' type="text/html" id="tmpl-asia_garden-fonts">',
''.trim($tmpl_holder).'>');
}
}
}
// Add scheme name in each selector in the CSS (priority 100 - after complete css)
if (!function_exists('asia_garden_customizer_add_scheme_in_css')) {
add_action( 'asia_garden_filter_get_css', 'asia_garden_customizer_add_scheme_in_css', 100, 4 );
function asia_garden_customizer_add_scheme_in_css($css, $colors, $fonts, $scheme) {
if ($colors && !empty($css['colors'])) {
$rez = '';
$in_comment = $in_rule = false;
$allow = true;
$scheme_class = sprintf('.scheme_%s ', $scheme);
$self_class = '.scheme_self';
$self_class_len = strlen($self_class);
$css_str = str_replace(array('{{', '}}'), array('[[',']]'), $css['colors']);
for ($i=0; $i 0 ? substr($css_str, $i, $pos-$i) : '';
if (strpos($selector, $self_class) !== false) {
$rez .= str_replace($self_class, trim($scheme_class), $selector);
$i += strlen($selector) - 1;
} else {
$rez .= $scheme_class . trim($ch);
}
$allow = false;
} else
$rez .= $ch;
} else {
$rez .= $ch;
}
}
}
$rez = str_replace(array('[[',']]'), array('{{', '}}'), $rez);
$css['colors'] = $rez;
}
return $css;
}
}
// Load theme options and styles
require_once ASIA_GARDEN_THEME_DIR . 'theme-specific/theme.setup.php';
require_once ASIA_GARDEN_THEME_DIR . 'theme-specific/theme.styles.php';
require_once ASIA_GARDEN_THEME_DIR . 'theme-options/theme.options.php';
require_once ASIA_GARDEN_THEME_DIR . 'theme-options/theme.meta-box.php';
?>