/** * Setup BuddyBar navigation * Sets up user tabs * */ public function setup_nav($main_nav = array(), $main_nav = array()) { // Define local variables $sub_nav = array(); $screen = BuddyBlog_Screens::get_instance(); //instance of the blog screen $total_posts = 0; if (bp_is_my_profile()) { $total_posts = buddyblog_get_total_posted(bp_displayed_user_id()); } else { $total_posts = buddyblog_get_total_published_posts(bp_displayed_user_id()); } // // Add 'Blog' to the main navigation $main_nav = array('name' => sprintf(__('Blog <span>%d</span>', 'buddyblog'), $total_posts), 'slug' => $this->slug, 'position' => 70, 'screen_function' => array($screen, 'my_posts'), 'default_subnav_slug' => BUDDYBLOG_ARCHIVE_SLUG, 'item_css_id' => $this->id); //whether to link to logged in user or displayed user if (!bp_is_my_profile()) { $blog_link = trailingslashit(bp_displayed_user_domain() . $this->slug); } else { $blog_link = trailingslashit(bp_loggedin_user_domain() . $this->slug); } // Add the Group Invites nav item $sub_nav[] = array('name' => __('Posts', 'buddyblog'), 'slug' => BUDDYBLOG_ARCHIVE_SLUG, 'parent_url' => $blog_link, 'parent_slug' => $this->slug, 'screen_function' => array($screen, 'my_posts'), 'position' => 30); $sub_nav[] = array('name' => __('New Post', 'buddyblog'), 'slug' => 'edit', 'parent_url' => $blog_link, 'parent_slug' => $this->slug, 'screen_function' => array($screen, 'new_post'), 'user_has_access' => bp_is_my_profile(), 'position' => 30); parent::setup_nav($main_nav, $sub_nav); }
/** * get remaining no. of posts to be activated * @param type $user_id * @return type */ function buddyblog_get_remaining_posts($user_id = false) { $total_allowed = buddyblog_get_allowed_no_of_posts($user_id); return intval($total_allowed - buddyblog_get_total_published_posts($user_id)); }