Example #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);
 }
Example #2
0
/**
 * Displays a bottom nav on single template
 *
 * @package WP Idea Stream
 * @subpackage ideas/tags
 *
 * @since 2.0.0
 *
 * @uses   previous_post_link() to get the previous adjacent idea
 * @uses   esc_url() to sanitize url
 * @uses   wp_idea_stream_get_root_url() to get main archive page url
 * @uses   next_post_link() to get the next adjacent idea
 * @return string the bottom nav output
 */
function wp_idea_stream_ideas_bottom_navigation()
{
    ?>
	<ul class="idea-nav-single">
		<li class="idea-nav-previous"><?php 
    previous_post_link('%link', '<span class="meta-nav">' . _x('&larr;', 'Previous post link', 'wp-idea-stream') . '</span> %title');
    ?>
</li>
		<li class="idea-nav-all"><span class="meta-nav">&uarr;</span> <a href="<?php 
    echo esc_url(wp_idea_stream_get_root_url());
    ?>
" title="<?php 
    esc_attr_e('All Ideas', 'wp-idea-stream');
    ?>
"><?php 
    esc_html_e('All Ideas', 'wp-idea-stream');
    ?>
</a></li>
		<li class="idea-nav-next"><?php 
    next_post_link('%link', '%title <span class="meta-nav">' . _x('&rarr;', 'Next post link', 'wp-idea-stream') . '</span>');
    ?>
</li>
	</ul>
	<?php 
}
/**
 * Filters nav menus looking for the root page to eventually make it current if not the
 * case although it's IdeaStream's territory
 *
 * @package WP Idea Stream
 * @subpackage core/template-functions
 *
 * @since 2.0.0
 *
 * @param  array  $sorted_menu_items list of menu items of the wp_nav menu
 * @param  array  $args
 * @uses   wp_idea_stream_is_ideastream() to make sure it's plugin's territory
 * @uses   apply_filters() call 'wp_idea_stream_wp_nav' to override the menu items classes
 * @return array  the menu items with specific classes if needed
 */
function wp_idea_stream_wp_nav($sorted_menu_items = array(), $args = array())
{
    if (!wp_idea_stream_is_ideastream()) {
        return $sorted_menu_items;
    }
    foreach ($sorted_menu_items as $key => $menu) {
        if (wp_idea_stream_get_root_url() != $menu->url) {
            // maybe unset parent page if not the ideas root
            if (in_array('current_page_parent', $menu->classes)) {
                $sorted_menu_items[$key]->classes = array_diff($menu->classes, array('current_page_parent'));
            }
        } else {
            if (!in_array('current-menu-item', $menu->classes)) {
                $sorted_menu_items[$key]->classes = array_merge($menu->classes, array('current-menu-item'));
            }
        }
    }
    return apply_filters('wp_idea_stream_wp_nav', $sorted_menu_items);
}
Example #4
0
 /**
  * Constructor
  *
  * @package WP Idea Stream
  * @subpackage idea/tags
  *
  * @since 2.0.0
  *
  * @param  array $args the loop args
  * @uses   get_query_var()
  * @uses   wp_idea_stream_get_idea_var() to get the globalized query loop
  * @uses   wp_idea_stream_ideas_get_idea_by_name() to get the idea object thanks to its post_name
  * @uses   wp_idea_stream_reset_post() to reset the $wp_query->post data
  * @uses   wp_idea_stream_set_idea_var() to globalized the need for a reset postdata
  * @uses   wp_idea_stream_ideas_get_ideas() get all matching ideas
  * @uses   wp_idea_stream_is_pretty_links() do we have a custom permalink structure ?
  * @uses   add_query_arg() to build the url in case default permalink is set
  * @uses   wp_idea_stream_is_idea_archive() to check an idea archive page is being displayed
  * @uses   wp_idea_stream_get_root_url() to get ideas archive url
  * @uses   wp_idea_stream_is_category() to check a category page is being displayed
  * @uses   wp_idea_stream_get_category_url() to get the category url
  * @uses   wp_idea_stream_is_tag() to check a tag page is being displayed
  * @uses   wp_idea_stream_get_tag_url() to get the category url
  * @uses   wp_idea_stream_is_user_profile_rates() to check the rates user's profile page is displayed
  * @uses   wp_idea_stream_users_get_displayed_profile_url() to get user's profile url
  * @uses   wp_idea_stream_is_user_profile_ideas() to check the main user's profile page is displayed
  * @uses   wp_idea_stream_paged_slug() to get the pagination slug
  * @uses   wp_idea_stream_search_rewrite_id() to get the search rewrite id
  * @uses   WP_Idea_Stream_Loop::start() to launch the loop
  * @uses   apply_filters() call 'wp_idea_stream_ideas_pagination_args' to override paginate args
  */
 public function __construct($args = array())
 {
     if (!empty($args) && empty($args['is_widget'])) {
         $paged = get_query_var('paged');
         // Set which pagination page
         if (!empty($paged)) {
             $args['page'] = $paged;
             // Checking query string just in case
         } else {
             if (!empty($_GET['paged'])) {
                 $args['page'] = absint($_GET['paged']);
                 // Checking in page args
             } else {
                 if (!empty($args['page'])) {
                     $args['page'] = absint($args['page']);
                     // Default to first page
                 } else {
                     $args['page'] = 1;
                 }
             }
         }
     }
     // Only get the idea requested
     if (!empty($args['idea_name'])) {
         $query_loop = wp_idea_stream_get_idea_var('query_loop');
         if (empty($query_loop->idea)) {
             $idea = wp_idea_stream_ideas_get_idea_by_name($args['idea_name']);
         } else {
             $idea = $query_loop->idea;
         }
         // can't do this too ealy
         $reset_data = array_merge((array) $idea, array('is_page' => true));
         wp_idea_stream_reset_post($reset_data);
         // this needs a "reset postdata"!
         wp_idea_stream_set_idea_var('needs_reset', true);
         $ideas = array('ideas' => array($idea), 'total' => 1, 'get_args' => array('page' => 1, 'per_page' => 1));
         // Get the ideas
     } else {
         $ideas = wp_idea_stream_ideas_get_ideas($args);
     }
     if (!empty($ideas['get_args'])) {
         foreach ($ideas['get_args'] as $key => $value) {
             $this->{$key} = $value;
         }
     } else {
         return false;
     }
     $params = array('plugin_prefix' => 'wp_idea_stream', 'item_name' => 'idea', 'item_name_plural' => 'ideas', 'items' => $ideas['ideas'], 'total_item_count' => $ideas['total'], 'page' => $this->page, 'per_page' => $this->per_page);
     $paginate_args = array();
     // No pretty links
     if (!wp_idea_stream_is_pretty_links()) {
         $paginate_args['base'] = add_query_arg('paged', '%#%');
     } else {
         // Is it the main archive page ?
         if (wp_idea_stream_is_idea_archive()) {
             $base = trailingslashit(wp_idea_stream_get_root_url()) . '%_%';
             // Or the category archive page ?
         } else {
             if (wp_idea_stream_is_category()) {
                 $base = trailingslashit(wp_idea_stream_get_category_url()) . '%_%';
                 // Or the tag archive page ?
             } else {
                 if (wp_idea_stream_is_tag()) {
                     $base = trailingslashit(wp_idea_stream_get_tag_url()) . '%_%';
                     // Or the displayed user rated ideas ?
                 } else {
                     if (wp_idea_stream_is_user_profile_rates()) {
                         $base = trailingslashit(wp_idea_stream_users_get_displayed_profile_url('rates')) . '%_%';
                         // Or the displayed user published ideas ?
                     } else {
                         if (wp_idea_stream_is_user_profile_ideas()) {
                             $base = trailingslashit(wp_idea_stream_users_get_displayed_profile_url()) . '%_%';
                             // Or nothing i've planed ?
                         } else {
                             /**
                              * Create your own pagination base if not handled by the plugin
                              *
                              * @param string empty string
                              */
                             $base = apply_filters('wp_idea_stream_ideas_pagination_base', '');
                         }
                     }
                 }
             }
         }
         $paginate_args['base'] = $base;
         $paginate_args['format'] = wp_idea_stream_paged_slug() . '/%#%/';
     }
     // Is this a search ?
     if (wp_idea_stream_get_idea_var('is_search')) {
         $paginate_args['add_args'] = array(wp_idea_stream_search_rewrite_id() => $_GET[wp_idea_stream_search_rewrite_id()]);
     }
     // Do we have a specific order to use ?
     $orderby = wp_idea_stream_get_idea_var('orderby');
     if (!empty($orderby) && 'date' != $orderby) {
         $merge = array();
         if (!empty($paginate_args['add_args'])) {
             $merge = $paginate_args['add_args'];
         }
         $paginate_args['add_args'] = array_merge($merge, array('orderby' => $orderby));
     }
     /**
      * Use this filter to override the pagination
      *
      * @param array $paginate_args the pagination arguments
      */
     parent::start($params, apply_filters('wp_idea_stream_ideas_pagination_args', $paginate_args));
 }
/**
 * Gets a global redirect url
 *
 * Used after posting an idea failed
 * Defaults to root url
 *
 * @package WP Idea Stream
 * @subpackage core/functions
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_get_root_url()
 * @uses   apply_filters() call 'wp_idea_stream_get_redirect_url' to customize the redirect url
 * @return string the url to redirect the user to
 */
function wp_idea_stream_get_redirect_url()
{
    return apply_filters('wp_idea_stream_get_redirect_url', wp_idea_stream_get_root_url());
}
Example #6
0
/**
 * Some text to introduce the core settings section
 *
 * @package WP Idea Stream
 * @subpackage admin/settings
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_get_root_url() to get the main IdeaStream archive page
 * @return string HTML output
 */
function wp_idea_stream_settings_core_section_callback()
{
    ?>

	<p><?php 
    _e('Customize IdeaStream features', 'wp-idea-stream');
    ?>
</p>
	<p class="description"><?php 
    printf(esc_html__('Url of IdeaStream&#39;s main page: %s', 'wp-idea-stream'), '<code>' . wp_idea_stream_get_root_url() . '</code>');
    ?>
</p>

	<?php 
}