Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
/**
 * Redirect the loggedin user to its profile as already a member
 * Or redirect WP (non multisite) register form to IdeaStream signup form
 *
 * @package WP Idea Stream
 * @subpackage users/functions
 *
 * @since 2.1.0
 *
 * @param  string $context the template context
 */
function wp_idea_stream_user_signup_redirect($context = '')
{
    // Bail if signup is not allowed
    if (!wp_idea_stream_is_signup_allowed_for_current_blog()) {
        return;
    }
    if (is_user_logged_in() && 'signup' == $context) {
        wp_safe_redirect(wp_idea_stream_users_get_logged_in_profile_url());
        exit;
    } else {
        if (!empty($_SERVER['SCRIPT_NAME']) && false !== strpos($_SERVER['SCRIPT_NAME'], 'wp-login.php') && !empty($_REQUEST['action']) && 'register' == $_REQUEST['action']) {
            wp_safe_redirect(wp_idea_stream_users_get_signup_url());
            exit;
        } else {
            if ('signup' == $context) {
                /**
                 * If we are here the IdeaStream signup url has been requested
                 * Before using it let plugins override it. Used internally to
                 * let BuddyPress handle signups if needed
                 */
                do_action('wp_idea_stream_user_signup_override');
            }
            return;
        }
    }
}