/** * Render the widget frontend output. * * @param array $args The sidebar arguments. * @param array $instance The widget instance parameters. * @return void * @author Paul Hughes * @since 3.0.2 */ public function widget($args, $instance) { // Do not show widget on the main forum page. if (Muut_Post_Utility::getForumPageId() == get_the_ID() && !apply_filters('muut_force_online_widget_display', false) || apply_filters('muut_hide_online_widget_display', false)) { return; } // Make sure the Muut resources get loaded (only stuff in the footer will work, as this happens // partway through page load. add_filter('muut_requires_muut_resources', '__return_true'); muut()->enqueueFrontendScripts(); $title = isset($instance['title']) ? $instance['title'] : ''; $num_online_html = ''; if ($instance['show_number_online'] && !empty($title)) { $num_online_html = '<span class="num-logged-in"></span>'; } // Render widget. echo $args['before_widget']; echo $args['before_title'] . $title . $num_online_html . $args['after_title']; include muut()->getPluginPath() . 'views/widgets/widget-online-users.php'; echo $args['after_widget']; }
/** * Render the widget frontend output. * * @param array $args The sidebar arguments. * @param array $instance The widget instance parameters. * @return void * @author Paul Hughes * @since 3.0.2 */ public function widget($args, $instance) { if (Muut_Post_Utility::getForumPageId() == get_the_ID() && !apply_filters('muut_force_my_feed_widget_display', false) || apply_filters('muut_hide_my_feed_widget_display', false)) { return; } // Make sure the Muut resources get loaded (only stuff in the footer will work, as this happens // partway through page load. add_filter('muut_requires_muut_resources', '__return_true'); muut()->enqueueFrontendScripts(); if (isset($instance['disable_uploads'])) { $embed_args['allow-uploads'] = !$instance['disable_uploads'] ? 'true' : 'false'; } $embed_args['title'] = isset($instance['title']) ? $instance['title'] : ''; // Render widget. echo $args['before_widget']; echo $args['before_title'] . $embed_args['title'] . $args['after_title']; $path = 'feed'; echo '<div id="muut-widget-my-feed-wrapper" class="muut_widget_wrapper muut_widget_my_feed_wrapper">'; Muut_Channel_Utility::getChannelEmbedMarkup($path, $embed_args, true); echo '<div id="muut-widget-my-feed-login"><a href="#" class="muut_login">' . __('Login', 'muut') . '</a></div>'; echo '</div>'; echo $args['after_widget']; }
/** * Render the widget frontend output. * * @param array $args The sidebar arguments. * @param array $instance The widget instance parameters. * @return void * @author Paul Hughes * @since 3.0.2 */ public function widget($args, $instance) { // Make sure webhooks are active, or don't bother. if (Muut_Post_Utility::getForumPageId() == get_the_ID() && !apply_filters('muut_force_online_widget_display', false) || apply_filters('muut_hide_channel_embed_display', false)) { return; } // Default to always NOT showing online users. Can be modified with filter. $embed_args['show-online'] = apply_filters('muut_channel_embed_widget_show_online', false, $args, $instance); if (isset($instance['disable_uploads'])) { $embed_args['allow-uploads'] = !$instance['disable_uploads'] ? 'true' : 'false'; } $embed_args['share'] = 'false'; $embed_args['title'] = isset($instance['title']) ? $instance['title'] : ''; $embed_args['channel'] = $instance['title'] ? $instance['title'] : ''; $path = $instance['muut_path']; // Render widget. echo $args['before_widget']; echo $args['before_title'] . $embed_args['title'] . $args['after_title']; echo '<div id="muut-widget-channel-embed-wrapper" class="muut_widget_wrapper muut_widget_channel_embed_wrapper">'; Muut_Channel_Utility::getChannelEmbedMarkup($path, $embed_args, true); echo '</div>'; echo $args['after_widget']; }
/** * Gets the ID of the page set as the forum page. * * @return int|false Returns the ID of the page set as the main forum page, or false if not set. * @author Paul Hughes * @since 3.0 */ function muut_get_forum_page_id() { return Muut_Post_Utility::getForumPageId(); }
/** * Gets the proper Muut template, if necessary. * * @param string $template The current template being requested. * @return string The revised template path to load. * @author Paul Hughes * @since 3.0 */ public function getProperTemplate($template) { if (is_page() && Muut_Post_Utility::isMuutPost(get_the_ID())) { //TODO: Allow for other forum templates to get loaded (not just the one). if (Muut_Post_Utility::getForumPageId() == get_the_ID() && apply_filters('muut_use_packaged_forum_template', true)) { $template = 'forum-page.php'; $located = $this->locateTemplate($template); $template = $located != '' ? $located : $template; } } return $template; }
/** * Get a row markup for given row data. * * @param int $post_id The ID of the post we are fetching the row data for. * @param mixed $timestamp The timestamp we are saying was the time for the post, or the template placeholder. * @param mixed $user_obj The user object in the format from the webhook. * @return string The Markup. * @author Paul Hughes * @since 3.0.2 */ public function getRowMarkup($post_id, $timestamp, $user_obj) { if (is_numeric($timestamp)) { $time_since = time() - $timestamp; if ($time_since < 60) { $list_time = _x('just now', 'comment-just-posted', 'muut'); } elseif ($time_since < 60 * 60) { $list_time = floor($time_since / 60) . _x('m', 'abbreviation-for-minutes', 'muut'); } elseif ($time_since < 60 * 60 * 24) { $list_time = floor($time_since / (60 * 60)) . _x('h', 'abbreviation-for-hours', 'muut'); } elseif ($time_since < 60 * 60 * 24 * 7) { $list_time = floor($time_since / (60 * 60 * 24)) . _x('d', 'abbreviation-for-days', 'muut'); } else { $list_time = floor($time_since / (60 * 60 * 24 * 7)) . _x('w', 'abbreviation-for-weeks', 'muut'); } } else { $list_time = '%LISTTIME%'; } if (is_numeric($post_id)) { $permalink = get_permalink($post_id); $title = get_the_title($post_id); } else { $permalink = '%POST_PERMALINK%'; $title = '%POST_TITLE%'; } $user_link_path = Muut_Post_Utility::getForumPageId() && Muut_Post_Utility::getForumPageId() != get_the_ID() ? get_permalink(Muut_Post_Utility::getForumPageId()) . '#!/' . $user_obj->path . '"' : false; $html = '<li class="muut_recentcomments" data-post-id="' . $post_id . '" data-timestamp="' . $timestamp . '" data-username="******">'; $html .= apply_filters('muut_latest_comments_show_avatar', true) ? muut_get_user_facelink_avatar($user_obj->path, $user_obj->displayname, false, $user_link_path, $user_obj->img, false) : ''; $html .= '<span class="recent-comments-post-title"><a href="' . $permalink . '">' . $title . '</a></span>'; $html .= '<div class="muut-post-time-since">' . $list_time . '</div>'; $html .= '</li>'; return $html; }
/** * Displays the dismissible admin notice regarding the latest update. * * @return void * @author Paul Hughes * @since 3.0.3 */ public function maybeShowUpdateNotice() { $dismissed_notices = muut()->getOption('dismissed_notices', array()); if (!isset($dismissed_notices['update_notice']) || !$dismissed_notices['update_notice']) { $forum_page_id = Muut_Post_Utility::getForumPageId(); if ($forum_page_id) { echo '<div class="updated muut_admin_notice" id="muut_update_notice">'; wp_nonce_field('muut_dismiss_notice', 'dismiss_nonce'); echo '<span class="dismiss_notice_button"><a href="#" class="dismiss_notice">X</a></span>'; echo '<p>' . sprintf(__('The %sMuut Plugin%s update to version 3.0.3 revised the default Forum Template (just a little!). You might want to head over to your %sForum Page%s and make sure it all looks as you expect! Check the post on our %sWordPress support forum%s about the latest release for details or help.', 'muut'), '<b>', '</b>', '<a href="' . get_permalink($forum_page_id) . '">', '</a>', '<a target="_blank" href="https://muut.com/forum/#!/wordpress">', '</a>') . '</p>'; echo '<p>' . __('Happy Muuting! :-)') . '</p>'; echo '</div>'; } else { $dismissed_notices['update_notice'] = true; muut()->setOption('dismissed_notices', $dismissed_notices); } } }
/** * Redirect to the forum page for Muut threads. * * @param string $permalink The current permalink. * @param WP_Post $post The post. * @return string The filtered permalink. * @author Paul Hughes * @since 3.0.2 */ public function permalinkToForum($permalink, $post) { if (class_exists('Muut_Custom_Post_Types') && $post->post_type == Muut_Custom_Post_Types::MUUT_THREAD_CPT_NAME) { $forum_page_id = Muut_Post_Utility::getForumPageId(); $path = get_post_meta($post->ID, 'muut_path', true); $path = str_replace(array('/' . muut()->getForumName(), '#'), array('', ':'), $path); if (!empty($forum_page_id)) { $permalink = get_permalink($forum_page_id) . '#!' . $path; } else { $permalink = 'http://' . Muut::MUUTSERVERS . '/' . muut()->getForumName() . '/#!' . $path; } } return $permalink; }
* The post/page editor tab for forum preferences. * * @package Muut * @copyright 2014 Muut Inc */ global $post; $tab; $meta_name = $tab['meta_name']; $forum_settings = Muut_Post_Utility::getPostOption($post->ID, 'forum_settings'); $forum_defaults = muut()->getOption('forum_defaults'); $forum_update_default = muut()->getOption('show_comments_in_forum_default'); $forum_defaults['show_comments_in_forum'] = $forum_update_default ? $forum_update_default : $forum_defaults['show_comments_in_forum']; $hide_online = isset($forum_settings['hide_online']) ? $forum_settings['hide_online'] : $forum_defaults['hide_online']; $disable_uploads = isset($forum_settings['disable_uploads']) ? $forum_settings['disable_uploads'] : $forum_defaults['disable_uploads']; $forum_show_comments = isset($forum_settings['show_comments_in_forum']) ? $forum_settings['show_comments_in_forum'] : $forum_defaults['show_comments_in_forum']; $forum_page_id = Muut_Post_Utility::getForumPageId(); if (!$forum_page_id || $forum_page_id == $post->ID) { ?> <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 checked($active_tab, $tab['name']); ?>
/** * Runs the actions for active tabspost/page's Muut information. * * @param int $post_id The id of the post (page) being saved. * @param WP_Post $post The post (page) object that is being saved. * @return void * @author Paul Hughes * @since 3.0 */ public function saveMuutPostSettings($post_id, $post) { $tabs = $this->getMetaBoxTabsForCurrentPostType(); $has_last_active = false; $last_active = '0'; foreach ($tabs as $tab_slug => $tab) { // Execute actions for active tabs. // Next line the $_POST index could be a new hidden, if multiple tabs should be saved. if (isset($_POST['muut_tab_last_active_' . $tab['name']]) && $_POST['muut_tab_last_active_' . $tab['name']] == '1') { $has_last_active = true; $last_active = $tab['name']; update_post_meta($post_id, 'muut_last_active_tab', $tab['name']); } if (isset($_POST['muut_tab_last_active_' . $tab['name']]) && $_POST['muut_tab_last_active_' . $tab['name']]) { do_action('muut_save_post_tab', $tab, $post_id, $post); do_action('muut_save_post_tab_' . $tab['name'], $tab, $post_id, $post); } } if (!$has_last_active) { update_post_meta($post_id, 'muut_last_active_tab', '0'); } if ((!$last_active || $last_active != 'forum-tab') && Muut_Post_Utility::getForumPageId() == $post_id) { Muut_Post_Utility::removeAsForumPage($post_id); } }