/** * Initializes the hooks required to make the root blog show sitewide posts. * * This functionality, if required, can be overridden by other code by * defining the constant CLASS_BLOGS_SHOW_SITEWIDE_POSTS_ON_FRONT_PAGE. If * it is given a value of false, the root blog will never be populated with * the sitewide post data. * * @access private * @since 0.2 */ public function _initialize_root_blog_hooks() { // Allow external code to prevent the main page of the root blog from // being populated with the sitewide posts $allow_posts = true; if (defined('CLASS_BLOGS_SHOW_SITEWIDE_POSTS_ON_FRONT_PAGE')) { $allow_posts = CLASS_BLOGS_SHOW_SITEWIDE_POSTS_ON_FRONT_PAGE; } // Feed all sitewide posts to the front page of the parent blog if we // are allowed to do so, are running in multisite mode, are on the root // blog, and are on the home page if ($allow_posts && ClassBlogs_Utils::is_multisite() && ClassBlogs_Utils::is_root_blog() && (is_home() || is_front_page())) { add_action('loop_end', array($this, 'reset_blog_on_loop_end')); add_action('loop_start', array($this, 'restore_sitewide_post_ids')); add_action('the_post', array($this, 'use_correct_blog_for_sitewide_post')); add_filter('the_posts', array($this, '_use_sitewide_posts')); add_filter('page_link', array($this, '_use_correct_page_url'), 10, 2); // Use the post's excerpt if that option has been set if ($this->get_option('root_use_excerpt')) { add_filter('the_content', array($this, '_use_post_excerpt')); } } }
/** * Register the link-list widget if not on the root blog. * * @access private * @since 0.2 */ public function _register_widget() { if (!ClassBlogs_Utils::is_root_blog()) { $uid = $this->get_uid(); nxt_register_sidebar_widget($uid, $this->get_option('title'), array($this, '_render_link_list'), array('classname' => $uid)); } }
/** * Registers a widget that should only be available on the root blog. * * This makes the widget only appear as a selection on the admin side if the * user is an admin on the root blog and the root blog is being edited, but * will show the widget to any user viewing the root blog. * * @param object $widget an instance of the widget class * * @since 0.2 */ public static function register_root_only_widget($widget) { global $blog_id; // If we're currently on the root blog, see if we're either viewing the // public-facing part of the blog or are a user with admin rights viewing // the admin side. If so, register the widget. if (ClassBlogs_Utils::is_root_blog() && (!is_admin() || ClassBlogs_Utils::current_user_is_admin_on_root_blog())) { register_widget($widget); } }