Skip to content

Instantly share code, notes, and snippets.

@aaroneaton
Created June 20, 2013 23:50
Show Gist options
  • Save aaroneaton/5827793 to your computer and use it in GitHub Desktop.
Save aaroneaton/5827793 to your computer and use it in GitHub Desktop.
Copy and paste into your child theme functions.php to allow anonymous users to make use of the control panel.
<?php
remove_action('et_header_top','et_chameleon_control_panel');
add_action('et_header_top','demo06_chameleon_control_panel');
function demo06_chameleon_control_panel(){
if ( get_option('chameleon_show_control_panel') <> 'on' ) return;
global $et_bg_texture_urls, $et_google_fonts; ?>
<div id="et-control-panel">
<div id="control-panel-main">
<a id="et-control-close" href="#"></a>
<div id="et-control-inner">
<h3 class="control_title">Example Colors</h3>
<a href="#" class="et-control-colorpicker" id="et-control-background"></a>
<div class="clear"></div>
<?php
$sample_colors = array( '6a8e94', '8da49c', 'b0b083', '859a7c', 'c6bea6', 'b08383', 'a4869d', 'f5f5f5', '4e4e4e', '556f6a', '6f5555', '6f6755' );
for ( $i=1; $i<=12; $i++ ) { ?>
<a class="et-sample-setting" id="et-sample-color<?php echo $i; ?>" href="#" rel="<?php echo esc_attr( $sample_colors[$i-1] ); ?>" title="#<?php echo esc_attr($sample_colors[$i-1]); ?>"><span class="et-sample-overlay"></span></a>
<?php } ?>
<p>or define your own in ePanel</p>
<h3 class="control_title">Texture Overlays</h3>
<div class="clear"></div>
<?php
$sample_textures = $et_bg_texture_urls;
for ( $i=1; $i<=count($et_bg_texture_urls); $i++ ) { ?>
<a title="<?php echo esc_attr($sample_textures[$i-1]); ?>" class="et-sample-setting et-texture" id="et-sample-texture<?php echo $i; ?>" href="#" rel="bg<?php echo $i+1; ?>"><span class="et-sample-overlay"></span></a>
<?php } ?>
<p>or define your own in ePanel</p>
<?php
$google_fonts = $et_google_fonts;
$font_setting = 'Kreon';
$body_font_setting = 'Droid+Sans';
if ( isset( $_COOKIE['et_chameleon_header_font'] ) ) $font_setting = $_COOKIE['et_chameleon_header_font'];
if ( isset( $_COOKIE['et_chameleon_body_font'] ) ) $body_font_setting = $_COOKIE['et_chameleon_body_font'];
?>
<h3 class="control_title">Fonts</h3>
<div class="clear"></div>
<label for="et_control_header_font">Header
<select name="et_control_header_font" id="et_control_header_font">
<?php foreach( $google_fonts as $google_font ) { ?>
<?php $encoded_value = urlencode($google_font); ?>
<option value="<?php echo esc_attr($encoded_value); ?>" <?php selected( $font_setting, $encoded_value ); ?>><?php echo esc_html($google_font); ?></option>
<?php } ?>
</select>
</label>
<a href="#" class="et-control-colorpicker et-font-control" id="et-control-headerfont_bg"></a>
<div class="clear"></div>
<label for="et_control_body_font">Body
<select name="et_control_body_font" id="et_control_body_font">
<?php foreach( $google_fonts as $google_font ) { ?>
<?php $encoded_value = urlencode($google_font); ?>
<option value="<?php echo esc_attr($encoded_value); ?>" <?php selected( $body_font_setting, $encoded_value ); ?>><?php echo esc_html($google_font); ?></option>
<?php } ?>
</select>
</label>
<a href="#" class="et-control-colorpicker et-font-control" id="et-control-bodyfont_bg"></a>
<div class="clear"></div>
</div> <!-- end #et-control-inner -->
</div> <!-- end #control-panel-main -->
</div> <!-- end #et-control-panel -->
<?php
}
remove_action( 'template_redirect', 'et_load_chameleon_scripts' );
add_action( 'template_redirect', 'demo06_load_chameleon_scripts' );
function demo06_load_chameleon_scripts(){
$et_slider_type = apply_filters( 'et_slider_type', get_option('chameleon_slider_type') );
if ( 'on' == get_option('chameleon_responsive_layout') ) $et_slider_type = 'flexslider';
$template_dir = get_template_directory_uri();
wp_enqueue_script('jquery_cycle', $template_dir . '/js/jquery.cycle.all.min.js', array('jquery'), '1.0', false);
if ( $et_slider_type == 'nivo' )
wp_enqueue_script('jquery_nivo', $template_dir . '/js/jquery.nivo.slider.pack.js', array('jquery'), '1.0', true);
if ( $et_slider_type == 'flexslider' ){
wp_enqueue_script('fitvids', $template_dir . '/js/jquery.fitvids.js', array('jquery'), '1.0', true);
wp_enqueue_script('flexslider', $template_dir . '/js/jquery.flexslider-min.js', array('jquery'), '1.0', true);
}
wp_enqueue_script($et_slider_type . '_script', $template_dir . '/js/et_'.$et_slider_type.'.js', array('jquery'), '1.0', true);
wp_enqueue_script('et_colorpicker', $template_dir . '/epanel/js/colorpicker.js', array('jquery'), '1.0', true);
wp_enqueue_script('et_eye', $template_dir . '/epanel/js/eye.js', array('jquery'), '1.0', true);
wp_enqueue_script('et_cookie', $template_dir . '/js/jquery.cookie.js', array('jquery'), '1.0', true);
wp_enqueue_script('et_control_panel', $template_dir . '/js/et_control_panel.js', array('jquery'), '1.0', true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment