12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on May 3, 2019

How to remove Monarch from Oxygen editor

Sridhar Katakam

This tutorial provides the steps to get rid of Monarch sharing plugin’s sidebar of social icons in the Oxygen editor.

Before:

After:

Step 1

Install and activate Code Snippets plugin.

Step 2

Go to Snippets > Add New.

Title: Remove Monarch from Oxygen editor

Code:

add_action( 'wp_enqueue_scripts', 'custom_monarch_oxy_editor', 20 );
/**
 * Dequeues Monarch's assets and enqueues them everywhere except in Oxygen Builder.
 */
function custom_monarch_oxy_editor() {
	wp_dequeue_style( 'et_monarch-css' );

	wp_dequeue_script( 'et_monarch-idle' );
	wp_dequeue_script( 'et_monarch-custom-js' );
	wp_dequeue_script( 'et-core-common' );

	if ( ! defined( 'SHOW_CT_BUILDER' ) ) {
		wp_enqueue_style( 'et_monarch-css', ET_MONARCH_PLUGIN_URI . '/css/style.css' );

		wp_enqueue_script( 'et_monarch-idle', ET_MONARCH_PLUGIN_URI . '/js/idle-timer.min.js', array( 'jquery' ), '', true );
		wp_enqueue_script( 'et_monarch-custom-js', ET_MONARCH_PLUGIN_URI . '/js/custom.js', array( 'jquery' ), '', true );
		wp_enqueue_script( 'et-core-common', ET_CORE_URL . 'admin/js/common.js', array( 'jquery' ), ET_CORE_VERSION, true );
	}
}

add_action( 'wp_footer', 'custom_remove_monarch_html_oxy_builder' );
/**
 * Remove Monarch's elements from the DOM in Oxygen editor.
 */
function custom_remove_monarch_html_oxy_builder() {
	if ( defined( 'SHOW_CT_BUILDER' ) ) { ?>
		<script>
		jQuery(document).ready(function(){
			jQuery('.et_social_pin_images_outer, .et_social_sidebar_networks, .et_social_mobile_button, .et_social_mobile, .et_social_mobile_overlay, .et_social_totalcount').remove();
		})
		</script>
	<?php }
}

Set the snippet to run everywhere.

Save changes and activate.

That’s it!

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right