/**
  * 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'];
 }
 /**
  * Renders a given forum page's forum (returns the Muut JS anchor element).
  *
  * @param int $page_id The page ID whose forum we are rendering.
  * @param bool $echo Whether to echo the anchor or return the markup.
  * @return string|void The anchor markup or void, if it is set to be echoed.
  * @author Paul Hughes
  * @since 3.0
  */
 public static function forumPageEmbedMarkup($page_id, $echo = true)
 {
     if (!is_numeric($page_id) || !self::isMuutPost($page_id)) {
         return false;
     }
     $settings = ' ';
     if (self::isMuutChannelPage($page_id)) {
         $post_options = self::getPostOption($page_id, 'channel_settings');
         $type_of_embed = 'channel';
     } elseif (self::isMuutForumPage($page_id)) {
         $post_options = self::getPostOption($page_id, 'forum_settings');
         $type_of_embed = 'forum';
     } else {
         return;
     }
     if (isset($post_options['hide_online'])) {
         $args['show-online'] = !$post_options['hide_online'] ? 'true' : 'false';
     }
     if (isset($post_options['disable_uploads'])) {
         $args['allow-uploads'] = !$post_options['disable_uploads'] ? 'true' : 'false';
     }
     $args['title'] = get_the_title($page_id);
     $args['channel'] = get_the_title($page_id);
     $settings = muut()->getEmbedAttributesString($args);
     if ($type_of_embed == 'channel') {
         $path = self::getChannelRemotePathForPage($page_id);
         $embed = Muut_Channel_Utility::getChannelEmbedMarkup($path, $args);
     } elseif ($type_of_embed == 'forum') {
         ob_start();
         include muut()->getPluginPath() . 'views/blocks/forum-page-embed.php';
         $embed = ob_get_clean();
         $embed = apply_filters('muut_forum_page_embed_content', $embed, $page_id);
     } else {
         return;
     }
     $embed = apply_filters('muut_embed_content', $embed, $page_id);
     if ($echo) {
         echo $embed;
     } else {
         return $embed;
     }
 }