register(); } /** * Register init function */ function register() { add_action('init', array(&$this, 'init')); add_action('wp_ajax_author-avatars-editor-popup', array(&$this, 'render_tinymce_popup')); } /** * Register button filters and actions */ function init() { // Don't bother adding the button if the current user lacks permissions if ( current_user_can('edit_posts') || current_user_can('edit_pages') ) { // Add only in Rich Editor mode if ( get_user_option('rich_editing') == 'true') { add_filter('mce_external_plugins', array(&$this, 'add_tinymce_plugin')); add_filter('mce_buttons', array(&$this, 'add_tinymce_button')); } // In wordpress < 2.7 only the POST parameter "action" is used in admin-ajax.php // but we're using the GET parameter for the tinymce popup iframe, therefore manually // set the POST parameter for the popup calls. if (defined('DOING_AJAX') && DOING_AJAX == true) { $p = 'author-avatars-editor-popup'; if (isset($_GET['action']) && $_GET['action'] == $p && !isset($_POST['action'])) { $_POST['action'] = $_GET['action']; } } } } /** * Filter 'mce_external_plugins': add the authoravatars tinymce plugin */ function add_tinymce_plugin($plugin_array) { $plugin_array['authoravatars'] = WP_PLUGIN_URL.'/author-avatars/tinymce/editor_plugin.js'; return $plugin_array; } /** * Filter 'mce_buttons': add the authoravatars tinymce button */ function add_tinymce_button($buttons) { array_push( $buttons, 'separator', 'authoravatars' ); return $buttons; } /** * Renders the tinymce editor popup */ function render_tinymce_popup() { echo '' ."\n"; $this->render_tinymce_popup_head(); echo "\n"; $this->render_tinymce_popup_body(); echo "\n"; echo ''; exit(); } /** * Builds the html head for the tinymce popup * * @access private * @return string Popup head */ function render_tinymce_popup_head() { echo '
'; echo "\n\t".'