Microthemer customizations when deactived.

This topic contains 5 replies, has 2 voices, and was last updated by  Sebastian 4 years, 10 months ago.

Author Posts

ryan

Notice: this information was written when Microthemer version 2 was current. On Dec 26th, 2014 version 3 was released with a completely new interface. Some of the information may be redundant, but as much of the functionality remains the same in version 3 we haven't deleted this post.

Maybe I’m missing the settings but, does Microthemer need to be activated in order for the customizations to stick?

I noticed the customization is gone when I deactivate Microthemer.

Thanks


Sebastian

Hi Ryan,

Yes Microthemer needs to be active in order for the /wp-content/micro-themes/active-styles.css stylesheet to be included in the of the HTML document by WordPress. However, if you’d rather not have Microthemer active, you can manually call active-styles.css by adding the following code to your Theme’s functions.php file:

Note, the following code was updated Jan 26th, 2018 (when version 5.1.4.2 was current). For the most up to date code, always see the Microthemer Preferences > Inactive tab

/* Begin Microthemer Code */
if (!defined('MT_IS_ACTIVE')) {
	function add_microthemer_css() {
		$p = get_option('preferences_themer_loader');
		$mtv = '?mtv=' . (!empty($p['version']) ? $p['version'] : 1);
		$mts = '?mts=' . (!empty($p['num_saves']) ? $p['num_saves'] : 0);
		if (!empty($p['g_fonts_used'])){
			$p['g_url'] = !empty($p['gfont_subset']) ? $p['g_url'] . $p['gfont_subset'] : $p['g_url'];
			$h = 'microthemer_g_font'; wp_register_style($h, $p['g_url'], false); wp_enqueue_style($h);
		}
		$r = content_url() . '/micro-themes/'; $css_min = !empty($p['minify_css']) ? 'min.' : '';
		$h = 'microthemer'; wp_register_style($h, $r.$css_min.'active-styles.css'.$mts); wp_enqueue_style($h);
		global $is_IE; if ($is_IE) {
			global $wp_styles; foreach ($p['ie_css']as $key => $cond){
				if (!empty($key)) {
					$h = 'tvr_ie_'.$key; wp_register_style($h, $r.$css_min.'ie-'.$key.'.css'.$mts); wp_enqueue_style($h);
					$wp_styles->add_data($h, 'conditional', $cond);
				}
			}
		}
		if (!empty($p['load_js'])) {
			$h = 'mt_user_js'; wp_register_script($h, $r.'active-scripts.js'.$mts); wp_enqueue_script($h);
		} if (!empty($p['active_events'])) {
			$h = 'mt_animation_events'; wp_register_script($h, $r.'animation-events.js'.$mtv, array('jquery')); wp_enqueue_script($h);
			wp_localize_script( $h, 'MT_Events_Data', json_decode($p['active_events']) );
		}
	}
	function add_microthemer_body_classes($classes){
		global $post; if (isset($post)) {
			$classes[] = 'mt-'.$post->ID; $classes[] = 'mt-'.$post->post_type.'-'.$post->post_name;
		}
		return $classes;
	}
	add_action('wp_enqueue_scripts', 'add_microthemer_css');
	add_filter( 'body_class', 'add_microthemer_body_classes');
}
/* End Microthemer Code */

In this example I’ve used the same “Handle” in the wp_register_style() function that Microthemer users (microthemer) so that if Microthemer is active, the active-styles.css stylesheet will only be included in the once. If Microthemer isn’t active, your theme will still include active-styles.css and so the customizations will stick.

I hope that’s useful. Let me know if you need help with anything else.

Cheers,

Sebastian


ryan

Thank you for the fast reply 🙂


Sebastian

You’re welcome!


Sebastian

PS the technique of adding code to the functions.php to call active-styles.css will also work if Microthemer is completely uninstalled.


Sebastian

And if you want to reinstall/reactivate Microthemer at any point all of your settings will still display in the Microthemer interface.

You must login or register to reply to this topic.