Ejemplo n.º 1
0
/**
 * Gets the url to the form to submit new ideas
 *
 * So far only adding new ideas is supported, but
 * there will surely be an edit action to allow users
 * to edit their ideas. Reason of the $type param
 *
 * @package WP Idea Stream
 * @subpackage core/functions
 *
 * @since 2.0.0
 *
 * @global $wp_rewrite
 * @param  string $type action (defaults to new)
 * @param  string $idea_name the post name of the idea to edit
 * @uses   wp_idea_stream_addnew_slug() can be customized through plugin's settings
 * @uses   apply_filters() call 'wp_idea_stream_pre_get_form_url' to customize the form url before it has been built
 * @uses   wp_idea_stream_action_slug()
 * @uses   wp_idea_stream_action_rewrite_id()
 * @uses   home_url()
 * @uses   user_trailingslashit()
 * @uses   wp_idea_stream_edit_slug() to get the edit slug
 * @uses   apply_filters() call 'wp_idea_stream_get_form_url' to customize the form url after it has been built
 * @return string the url of the form to add ideas
 */
function wp_idea_stream_get_form_url($type = '', $idea_name = '')
{
    global $wp_rewrite;
    if (empty($type)) {
        $type = wp_idea_stream_addnew_slug();
    }
    /**
     * Early filter to override form url before being built
     *
     * @param mixed false or url to override
     * @param string $type (only add new for now)
     */
    $early_form_url = apply_filters('wp_idea_stream_pre_get_form_url', false, $type, $idea_name);
    if (!empty($early_form_url)) {
        return $early_form_url;
    }
    // Pretty permalinks
    if ($wp_rewrite->using_permalinks()) {
        $url = $wp_rewrite->root . wp_idea_stream_action_slug() . '/%' . wp_idea_stream_action_rewrite_id() . '%';
        $url = str_replace('%' . wp_idea_stream_action_rewrite_id() . '%', $type, $url);
        $url = home_url(user_trailingslashit($url));
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(wp_idea_stream_action_rewrite_id() => $type), home_url('/'));
    }
    if ($type == wp_idea_stream_edit_slug() && !empty($idea_name)) {
        $url = add_query_arg(wp_idea_stream_get_post_type(), $idea_name, $url);
    }
    /**
     * Filter to override form url after being built
     *
     * @param string url to override
     * @param string $type add new or edit
     * @param string $idea_name the post name of the idea to edit
     */
    return apply_filters('wp_idea_stream_get_form_url', $url, $type, $idea_name);
}
Ejemplo n.º 2
0
 /**
  * Buils the link to the add new idea form
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @param  mixed   $form_url false or the url to use
  * @param  string  $type     the context of the form ('add' or 'edit')
  * @param  string $idea_name the post name of the idea to edit
  * @uses   wp_idea_stream_addnew_slug() to get the add slug
  * @uses   bp_get_group_permalink() to get the group's permalink
  * @uses   groups_get_current_group() to get the current group's object
  * @uses   wp_idea_stream_action_slug() to get the action slug
  * @uses   wp_idea_stream_edit_slug() to get the edit slug
  * @uses   add_query_arg() to a add query vars to an url
  * @uses   wp_idea_stream_get_post_type() to get the ideas post type identifier
  * @return string            the form url
  */
 public function group_form_url($form_url = false, $type = '', $idea_name = '')
 {
     if (bp_is_group()) {
         // If no type fallback to new
         if (empty($type)) {
             $type = wp_idea_stream_addnew_slug();
         }
         $form_url = trailingslashit(bp_get_group_permalink(groups_get_current_group()) . wp_idea_stream_action_slug() . '/' . $type);
         if ($type == wp_idea_stream_edit_slug() && !empty($idea_name)) {
             $form_url = add_query_arg(wp_idea_stream_get_post_type(), $idea_name, $form_url);
         }
     }
     return $form_url;
 }
Ejemplo n.º 3
0
 /**
  * Setup the rewrite ids and slugs
  *
  * @package WP Idea Stream
  * @subpackage core/classes
  *
  * @since 2.0.0
  *
  * @uses  wp_idea_stream_user_rewrite_id()
  * @uses  wp_idea_stream_user_rates_rewrite_id()
  * @uses  wp_idea_stream_user_comments_rewrite_id()
  * @uses  wp_idea_stream_cpage_rewrite_id()
  * @uses  wp_idea_stream_action_rewrite_id()
  * @uses  wp_idea_stream_search_rewrite_id()
  * @uses  wp_idea_stream_user_slug()
  * @uses  wp_idea_stream_user_rates_slug()
  * @uses  wp_idea_stream_user_comments_slug()
  * @uses  wp_idea_stream_cpage_slug()
  * @uses  wp_idea_stream_action_slug()
  */
 private function setup_globals()
 {
     /** Rewrite ids ***************************************************************/
     $this->page_rid = 'paged';
     // WordPress built-in global var
     $this->user_rid = wp_idea_stream_user_rewrite_id();
     $this->user_rates_rid = wp_idea_stream_user_rates_rewrite_id();
     $this->user_comments_rid = wp_idea_stream_user_comments_rewrite_id();
     $this->cpage_rid = wp_idea_stream_cpage_rewrite_id();
     $this->action_rid = wp_idea_stream_action_rewrite_id();
     $this->search_rid = wp_idea_stream_search_rewrite_id();
     /** Rewrite slugs *************************************************************/
     $this->user_slug = wp_idea_stream_user_slug();
     $this->user_rates_slug = wp_idea_stream_user_rates_slug();
     $this->user_comments_slug = wp_idea_stream_user_comments_slug();
     $this->cpage_slug = wp_idea_stream_cpage_slug();
     $this->action_slug = wp_idea_stream_action_slug();
 }
Ejemplo n.º 4
0
/**
 * Gets the signup url
 *
 * @package WP Idea Stream
 * @subpackage users/functions
 *
 * @since 2.1.0
 *
 * @global  $wp_rewrite
 * @return string signup url
 */
function wp_idea_stream_users_get_signup_url()
{
    global $wp_rewrite;
    /**
     * Early filter to override form url before being built
     *
     * @param mixed false or url to override
     */
    $early_signup_url = apply_filters('wp_idea_stream_users_pre_get_signup_url', false);
    if (!empty($early_signup_url)) {
        return $early_signup_url;
    }
    // Pretty permalinks
    if ($wp_rewrite->using_permalinks()) {
        $signup_url = $wp_rewrite->root . wp_idea_stream_action_slug() . '/%' . wp_idea_stream_action_rewrite_id() . '%';
        $signup_url = str_replace('%' . wp_idea_stream_action_rewrite_id() . '%', wp_idea_stream_signup_slug(), $signup_url);
        $signup_url = home_url(user_trailingslashit($signup_url));
        // Unpretty permalinks
    } else {
        $signup_url = add_query_arg(array(wp_idea_stream_action_rewrite_id() => wp_idea_stream_signup_slug()), home_url('/'));
    }
    /**
     * Filter to override form url after being built
     *
     * @param string url to override
     */
    return apply_filters('wp_idea_stream_get_form_url', $signup_url);
}