Skip to content

Instantly share code, notes, and snippets.

@johnpbloch
Created December 9, 2011 00:30
Show Gist options
  • Save johnpbloch/1449457 to your computer and use it in GitHub Desktop.
Save johnpbloch/1449457 to your computer and use it in GitHub Desktop.
TinyMCE Advanced Network Fixer
<?php
/*
* Plugin Name: TinyMCE Advanced Multisite Fixer
* Description: Forces TinyMCE Advanced to use site options for its settings when it's network activated.
* Version: 0.1
* Author: John P. Bloch
* Author URI: http://www.johnpbloch.com/
*/
namespace JPB\TADVNetwork;
if( !is_multisite() || !in_array( WP_PLUGIN_DIR . '/tinymce-advanced/tinymce-advanced.php', wp_get_active_network_plugins() ) ) {
return;
}
foreach( get_tadv_options() as $tadv_option_name ) {
add_filter( "pre_option_$tadv_option_name", '\\JPB\\TADVNetwork\\pre_get_option' );
}
unset( $tadv_option_name );
add_action( 'update_option', '\\JPB\\TADVNetwork\\pre_update_option', 10, 3 );
add_action( 'add_option', '\\JPB\\TADVNetwork\\pre_add_option', 10, 2 );
function get_tadv_options() {
return array(
'tadv_toolbars',
'tadv_options',
'tadv_plugins',
'tadv_btns1',
'tadv_btns2',
'tadv_btns3',
'tadv_btns4',
'tadv_allbtns',
'tadv_version',
);
}
function pre_get_option( $false ) {
$optionName = preg_replace( '@^pre_option_@i', '', current_filter() );
if( !in_array( $optionName, get_tadv_options() ) )
return $false;
return get_site_option( $optionName, array( ) );
}
function pre_update_option( $optionName, $oldValue, $newValue ) {
if( in_array( $optionName, get_tadv_options() ) )
update_site_option( $optionName, $newValue );
}
function pre_add_option( $optionName, $value ) {
if( in_array( $optionName, get_tadv_options() ) )
update_site_option( $optionName, $value );
}
@Rubi86
Copy link

Rubi86 commented May 21, 2013

Hi, thanks for your post. I wonder if the namespace you are using is related to repository or data base, if so, do I need a column in wp_options? or what do I have to use instead of \JPB\TADVNetwork. Thanks in advance

@ItsNatoriousB
Copy link

Checking to see if this still solves the issue? The plug-in is activated on all sites, but there are advanced options missing only available to Super Admins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment