/** * Registers the IdeaStream group extension and sets some globals * * @package WP Idea Stream * @subpackage buddypress/groups * * @since 2.0.0 * * @uses wp_idea_stream_root_slug() to get the IdeaStream root slug * @uses wp_idea_stream_archive_title() to get the IdeaStream archive page title * @uses WP_Idea_Stream_Group->enable_nav_item() to display or not the IdeaStream nav item for the group * @uses WP_Idea_Stream_Group::groups_activated() to check if BuddyPress group integration setting is on. * @uses BP_Group_Extension::init() */ public function init_vars() { $args = array('slug' => wp_idea_stream_root_slug(), 'name' => wp_idea_stream_archive_title(), 'visibility' => 'public', 'nav_item_position' => 61, 'enable_nav_item' => $this->enable_nav_item(), 'screens' => array('admin' => array('enabled' => self::groups_activated(), 'metabox_context' => 'side', 'metabox_priority' => 'core'), 'create' => array('position' => 61, 'enabled' => self::groups_activated()), 'edit' => array('position' => 61, 'enabled' => self::groups_activated(), 'show_in_admin_bar' => true))); /** * Used to catch groups to avoid requesting too many times the same groups * * @var object */ $this->group_ideastream = new StdClass(); $this->group_ideastream->idea_group = array(); parent::init($args); }
/** * Setup available nav items * * @package WP Idea Stream * @subpackage core/widgets * * @since 2.0.0 * * @uses wp_idea_stream_get_root_url() to get the root url * @uses wp_idea_stream_archive_title() to get the name of the archive page * @uses wp_idea_stream_get_form_url() to get the url of the add new form * @uses is_user_logged_in() to check we have a logged in user * @uses wp_idea_stream_users_get_logged_in_profile_url() to get current user's profile url * @uses apply_filters() call 'wp_idea_stream_widget_nav_items' to allow overrides */ public function set_available_nav_items() { // construct nav $this->nav_items_available = array('idea_archive' => array('url' => wp_idea_stream_get_root_url(), 'name' => wp_idea_stream_archive_title()), 'addnew' => array('url' => wp_idea_stream_get_form_url(), 'name' => __('New idea', 'wp-idea-stream'))); if (is_user_logged_in()) { $this->nav_items_available['current_user_profile'] = array('url' => wp_idea_stream_users_get_logged_in_profile_url(), 'name' => __('My profile', 'wp-idea-stream')); } /** * @param array the available nav items * @param string the widget's id base */ $this->nav_items_available = apply_filters('wp_idea_stream_widget_nav_items', $this->nav_items_available, $this->id_base); }
/** * Constructor method * * @package WP Idea Stream * @subpackage buddypress/loader * * @since 2.0.0 * * @uses wp_idea_stream_archive_title() to get the main archive page title * @uses wp_idea_stream_get_includes_dir() to get the plugin's includes dir */ public function __construct() { parent::start('ideastream', wp_idea_stream_archive_title(), trailingslashit(wp_idea_stream_get_includes_dir() . 'buddypress')); $this->includes(); $this->extend_ideastream(); }
/** * Reset the page (post) title depending on the context * * @package WP Idea Stream * @subpackage core/template-functions * * @since 2.0.0 * * @param string $context the context to build the title for * @uses wp_idea_stream_archive_title() to get the IdeaStream archive page title * @uses wp_idea_stream_user_can() to check for user's capability * @uses wp_idea_stream_get_root_url() to get IdeaStream's root url * @uses wp_idea_stream_get_form_url() to get IdeaStream's add new form url * @uses wp_idea_stream_get_term_name() to get the term name * @uses wp_idea_stream_users_get_displayed_user_displayname() to get the displayed user name * @uses apply_filters() call 'wp_idea_stream_reset_post_title' to override the title of the page * @return string the post title */ function wp_idea_stream_reset_post_title($context = '') { $post_title = wp_idea_stream_archive_title(); switch ($context) { case 'archive': if (wp_idea_stream_user_can('publish_ideas')) { $post_title = '<a href="' . esc_url(wp_idea_stream_get_root_url()) . '">' . $post_title . '</a>'; $post_title .= ' <a href="' . esc_url(wp_idea_stream_get_form_url()) . '" class="button wpis-title-button">' . esc_html__('Add new', 'wp-idea-stream') . '</a>'; } break; case 'taxonomy': $post_title = '<a href="' . esc_url(wp_idea_stream_get_root_url()) . '">' . $post_title . '</a>'; $post_title .= '<span class="idea-title-sep"></span>' . wp_idea_stream_get_term_name(); break; case 'user-profile': $post_title = '<a href="' . esc_url(wp_idea_stream_get_root_url()) . '">' . $post_title . '</a>'; $post_title .= '<span class="idea-title-sep"></span>' . sprintf(esc_html__('%s's profile', 'wp-idea-stream'), wp_idea_stream_users_get_displayed_user_displayname()); break; case 'new-idea': $post_title = '<a href="' . esc_url(wp_idea_stream_get_root_url()) . '">' . $post_title . '</a>'; $post_title .= '<span class="idea-title-sep"></span>' . __('New Idea', 'wp-idea-stream'); break; case 'edit-idea': $post_title = '<a href="' . esc_url(wp_idea_stream_get_root_url()) . '">' . $post_title . '</a>'; $post_title .= '<span class="idea-title-sep"></span>' . __('Edit Idea', 'wp-idea-stream'); break; case 'signup': $post_title = '<a href="' . esc_url(wp_idea_stream_get_root_url()) . '">' . $post_title . '</a>'; $post_title .= '<span class="idea-title-sep"></span>' . __('Create an account', 'wp-idea-stream'); break; } /** * @param string $post_title the title for the template * @param string $context the context */ return apply_filters('wp_idea_stream_reset_post_title', $post_title, $context); }
/** * Archive page title callback * * @package WP Idea Stream * @subpackage admin/settings * * @since 2.0.0 * * @uses esc_attr() to sanitize the attribute * @uses wp_idea_stream_archive_title() To get the archive page title * @return string HTML output */ function wp_idea_stream_archive_title_setting_callback() { ?> <input name="_ideastream_archive_title" id="_ideastream_archive_title" type="text" class="regular-text code" value="<?php echo esc_attr(wp_idea_stream_archive_title()); ?> " /> <?php }