Remove Custom Networks When Network Add-On is Installed

If the official Network add-on is installed and activated by the theme user to a later time point we should remove our custom networks:

// Core and Networks addon loaded.
if ( prefix_can_use_plugin( 'mashsharer/mashshare.php' ) && prefix_can_use_plugin( 'mashshare-networks/mashshare-networks.php' ) ) {
 add_action( 'init', 'prefix_mashshare_unregister_new_networks' );

 * Deregister custom networks
function prefix_mashshare_unregister_new_networks() {
	$networks = get_option( 'mashsb_networks' );
	// We need to remove our custom networks if the Networks addon is loaded and current networks list contains only our custom networks.
	if ( count( $networks ) === 5 ) {
		foreach ( $networks as $network_index => $network_name ) {
			// Remove custom.
			if ( in_array( $network_name, array( 'Google', 'Pinterest' ), true ) ) {
				unset( $networks[ $network_index ] );
		// Update db.
		update_option( 'mashsb_networks', $networks );
		// Run activation function again to load addon networks.


If the MashShare Core plugin and the network add-on is installed we fire our custom unregister function before the activation hook of the network add-on gets started. As the MashShare core plugin contains 3 default buttons (Facebook, Twitter, Subscribe) and we added earlier 2 custom buttons to the theme we check first if the array contains a total of 5 buttons. When this is true lets update the db options and fire the activation routine of the network add-on.

Still need help? Contact Us Contact Us