spencer-f
12/27/2012 - 1:03 AM

Final code to override restriction on color chooser in Vantage when using child theme (thanks Tyler!)

Final code to override restriction on color chooser in Vantage when using child theme (thanks Tyler!)

// Add new color chooser for Vantage child themes 

add_action('admin_init', 'lab_va_featured_setup_tab_init');

function lab_va_featured_setup_tab_init() {
  global $admin_page_hooks;

	add_action( 'tabs_'.$admin_page_hooks['app-dashboard'].'_page_app-settings', array( 'LAB_Va_Featured_Settings_Tab', 'init' ) );
}

class LAB_Va_Featured_Settings_Tab {

	private static $page;

	static function init( $page ) {

		$page->tab_sections['general'][0] = array(
			'title' => __( 'LabZip ChildTheme Color Choices', APP_TD ),
			'fields' => array(
				array(
					'title' => __( 'Child Theme Color', APP_TD ),
					'type' => 'select',
					'name' => array( 'gateways', 'labcolor' ),
					'values' => _lab_va_get_labcolor_choices(),
					'tip' => __( 'Choose the overall child theme color.', APP_TD ),
				)
			)
		);
		ksort( $page->tab_sections['general'] );
	}
}

function _lab_va_get_labcolor_choices(){
	return array(
		'blue' => __( 'Blue', 'appthemes' ),
		'red' => __( 'Red', 'appthemes' ),
		'orange' => __( 'Orange', 'appthemes' ),
		'green' => __( 'Green', 'appthemes' ),
		'navy' => __( 'Navy Blue', 'appthemes' ),
		'purple' => __( 'Purple', 'appthemes' ),
		'pink' => __( 'Pink', 'appthemes' ),
		'gray' => __( 'Dark Gray', 'appthemes' ),
	);
}

// Override block on Vantage child theme in core.php for color chooser
add_action( 'after_setup_theme', 'lab_before_rendering_field' );
remove_action( 'after_setup_theme', 'before_rendering_field' );
function lab_before_rendering_field( $field ) {
		$field['extra'] = array( 'disabled' => false );
		return $field;
	}
	
	
// Change the ability to use color chooser with child themes
remove_action( 'template_redirect', 'va_add_style' );
add_action( 'template_redirect', 'lab_va_add_style' );

function lab_va_add_style() {
	global $va_options;
	$color = $va_options->gateways['labcolor'];
	wp_enqueue_style(
		'at-color',
		get_template_directory_uri() . '/styles/' . $color . '.css',
		array(),
		VA_VERSION
	);
}