/** * The singleton method. * * @return Muut_Admin_Post_Editor The instance. * @author Paul Hughes * @since 3.0 */ public static function instance() { if (!is_a(self::$instance, __CLASS__)) { self::$instance = new self(); } return self::$instance; }
/** * Initializes the admin post editor. * * @return void * @author Paul Hughes * @since 3.0 */ public function initPostEditor() { $class = 'Muut_Admin_Post_Editor'; if (!in_array($class, $this->alreadyInit)) { require_once muut()->getPluginPath() . 'lib/admin/admin-post-editor.class.php'; if (class_exists($class)) { Muut_Admin_Post_Editor::instance(); } $this->alreadyInit[] = $class; } }
<?php /** * The post/page editor tab for commenting. * * @package Muut * @copyright 2014 Muut Inc */ global $post; $tab; $post_type_tabs = Muut_Admin_Post_Editor::instance()->getMetaBoxTabsForCurrentPostType(); unset($post_type_tabs[$tab['slug']]); $post_type_object = get_post_type_object($post->post_type); $post_type_label = $post_type_object->labels->singular_name; $meta_name = $tab['meta_name']; $comments_settings = Muut_Post_Utility::getPostOption($post->ID, 'commenting_settings'); $commenting_defaults = muut()->getOption('commenting_defaults'); $type = isset($comments_settings['type']) ? $comments_settings['type'] : $commenting_defaults['type']; $disable_uploads = isset($comments_settings['disable_uploads']) ? $comments_settings['disable_uploads'] : $commenting_defaults['disable_uploads']; ?> <p> <span class="checkbox_row"><input type="checkbox" name="<?php echo $tab['meta_name']; ?> [enabled-tab]" class="muut_enable_<?php echo $tab['name']; ?> " id="muut_enable_tab-<?php echo $tab['name']; ?> " <?php
if ($post->post_status == 'auto-draft' && $tab['name'] == 'commenting-tab') { $active_tab = $tab['name']; $active_value = '1'; } } echo '<li class="' . $class . '" id="muut_tab-' . $tab['name'] . '" data-muut_tab="' . $tab['name'] . '"><a href="#muut_tab_content-' . $tab['name'] . '" class="muut_metabox_tab">' . $tab['label'] . '</a><input type="hidden" class="muut_tab_last_active" name="muut_tab_last_active_' . $tab['name'] . '" value="' . $active_value . '" /></li>'; } ?> </ul> <?php foreach ($tabs as $slug => $tab) { $class = 'wp-tab-panel muut-tab-panel '; if ($tab['name'] != $active_tab) { $class .= 'hidden '; } if (!Muut_Admin_Post_Editor::instance()->isTabEnabled($slug, $post->ID)) { $class .= 'disabled '; } else { $class .= 'enabled '; } echo '<div id="muut_tab_content-' . $tab['name'] . '" class="' . $class . '">'; ?> <?php include $tab['template_location']; echo '</div>'; } ?> </div> </div> <div id="muut_tabs_disable_dialog" class="hidden"> <?php
/** * Adds the contextual help tab items to the post/page editing page. * * @return void * @author Paul Hughes * @since 3.0 */ public function addMuutPostEditorHelp() { $screen = get_current_screen(); $tabs = Muut_Admin_Post_Editor::instance()->getMetaBoxTabsForCurrentPostType(); $help_tabs = array('commenting-tab' => array('id' => 'muut_post_editor_help_commenting_tab', 'title' => __('Muut Commenting', 'muut'), 'callback' => array($this, 'renderPostEditorHelpCommentingTabContent')), 'channel-tab' => array('id' => 'muut_post_editor_help_channel_tab', 'title' => __('Muut Channel', 'muut'), 'callback' => array($this, 'renderPostEditorHelpChannelTabContent')), 'forum-tab' => array('id' => 'muut_post_editor_help_forum_tab', 'title' => __('Muut Forum', 'muut'), 'callback' => array($this, 'renderPostEditorHelpForumTabContent'))); // Add the help tabs for the post editor, depending on which tabs are visible/being used. foreach ($tabs as $tab) { $screen->add_help_tab($help_tabs[$tab['name']]); } }