= 6846 && 'true' == get_user_option('rich_editing') ) { add_filter( 'mce_external_plugins', 'adsense_plugin'); add_filter( 'mce_buttons', 'adsense_button'); } ### WordPress 2.1+ elseif ( 3664 <= $wp_db_version && 'true' == get_user_option('rich_editing') ) { add_filter("mce_plugins", "adsense_plugin"); add_filter('mce_buttons', 'adsense_button'); add_action('tinymce_before_init','adsense_button_script'); } } ### used to insert button in wordpress 2.1x & 2.5x editor function adsense_button($buttons) { array_push($buttons, "separator", "adsense"); return $buttons; } ### adding to TinyMCE function adsense_plugin($plugins) { global $adsense_root,$wp_db_version; if ( $wp_db_version >= 6846 ) $plugins['adsense'] = $adsense_root.'editor_plugin.js'; else array_push($plugins, "-adsense"); return $plugins; } ### Load the TinyMCE plugin : editor_plugin.js (wp2.1) function adsense_button_script() { global $adsense_root,$wp_db_version; $pluginURL = $adsense_root ; $fns = getAllformNames(); echo 'var placeholder="'.__('placeholder for:','adsense').'";'; echo 'var formnames=new Array('.$fns.');'; echo 'tinyMCE.loadPlugin("adsense", "'.$pluginURL.'");'."\n"; echo 'var purl="'.$pluginURL.'";'."\n"; return; } ### retrieve all form names function getAllformNames() { $options = get_option(ADSDEL_OPTIONS_ID); $fns = ''; $forms =count($options['ads']); if($forms > 0) { foreach ($options['ads'] as $key=>$val) { $fns .= '"'.$key.'",'; } } return substr($fns,0,-1); } ### Load the Script for the Button(wp2.1) function insert_adsense_script() { global $adsense_root, $wp_db_version, $adsenseSettings; $options = ''; $optionsads = get_option(ADSDEL_OPTIONS_ID); if(!empty($optionsads)) { foreach ($optionsads['ads'] as $key=>$val) { $options .= ''; } }else { $options .= ''; } $fns = getAllformNames(); ?>