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".''. __('Author avatars shortcodes', 'author-avatars') . ''; echo "\n\t".''; wp_print_scripts(array('jquery', 'jquery-ui-resizable', 'tinymce-popup', 'author-avatars-tinymce-popup')); wp_print_styles(array('admin-form')); echo "\n".''; } /** * Builds the html body for the tinymce popup * * @access private * @return string Popup body */ function render_tinymce_popup_body() { require_once('AuthorAvatarsForm.class.php'); $form = new AuthorAvatarsForm(); // BASIC TAB $basic_left = $form->renderFieldShortcodeType(); $basic_left .= '
'; $basic_left .= $form->renderFieldEmail(); $basic_left .= $form->renderFieldAlignment(); $basic_left .= '
'; $basic_left .= '
'; $basic_left .= $form->renderFieldRoles(array('administrator', 'editor')); $basic_left .= $form->renderFieldDisplayOptions(); $basic_left .= $form->renderFieldUserLink('authorpage'); $basic_left .= '
'; $basic_right = $form->renderFieldAvatarSize(); $basic_tab = $form->renderTabStart(__('Basic', 'author-avatars')); $basic_tab .= $form->renderColumns($basic_left, $basic_right); $basic_tab .= $form->renderTabEnd(); // ADVANCED TAB $adv_left = $form->renderFieldOrder('display_name'); $adv_left .= $form->renderFieldSortDirection('asc'); $adv_left .= $form->renderFieldLimit(); $adv_left .= $form->renderFieldMinPostCount(); $adv_left .= $form->renderFieldHiddenUsers(); $adv_right = ''; if (AA_is_wpmu()) { global $blog_id; // default value: current blog $adv_right .= $form->renderFieldBlogs($blog_id); } $adv_right .= $form->renderFieldGroupBy(); $advanced_tab = $form->renderTabStart(__('Advanced', 'author-avatars')); $advanced_tab .= $form->renderColumns($adv_left, $adv_right); $advanced_tab .= $form->renderTabEnd(); $tabs = $basic_tab . $advanced_tab; $html = '
'. $form->renderTabList() . $tabs .'
'; $html .= "\n\t".'
'; $html .= "\n\t".'
'; $html .= "\n\t".''; $html .= "\n\t".'
'; $html .= "\n\t".'
'; $html .= "\n\t".''; $html .= "\n\t".'
'; $html .= "\n\t".'
'; echo ''. $html . "\n" .''; } } ?>