Esempio n. 1
0
/**
 * Get the default plugin's options and their values.
 *
 * @package WP Idea Stream
 * @subpackage core/options
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_get_version()
 * @uses   wp_idea_stream_is_pretty_links() to check if pretty links are on
 * @uses   apply_filters() call 'wp_idea_stream_get_default_options' to override options values
 * @return array Filtered option names and values
 */
function wp_idea_stream_get_default_options()
{
    // Default options
    $default_options = array('_ideastream_version' => wp_idea_stream_get_version(), '_ideastream_archive_title' => 'IdeaStream', '_ideastream_submit_status' => 'publish', '_ideastream_editor_image' => 1, '_ideastream_editor_link' => 1, '_ideastream_moderation_message' => '', '_ideastream_login_message' => '', '_ideastream_hint_list' => '', '_ideastream_sticky_ideas' => 1, '_ideastream_disjoin_comments' => 1, '_ideastream_allow_comments' => 1, '_ideastream_embed_profile' => 0, '_ideastream_featured_images' => 1);
    // Pretty links customization
    if (wp_idea_stream_is_pretty_links()) {
        $default_options = array_merge($default_options, array('_ideastream_root_slug' => _x('ideastream', 'default root slug', 'wp-idea-stream'), '_ideastream_idea_slug' => _x('idea', 'default idea slug', 'wp-idea-stream'), '_ideastream_category_slug' => _x('category', 'default category slug', 'wp-idea-stream'), '_ideastream_tag_slug' => _x('tag', 'default tag slug', 'wp-idea-stream'), '_ideastream_user_slug' => _x('user', 'default user slug', 'wp-idea-stream'), '_ideastream_user_comments_slug' => _x('comments', 'default comments slug', 'wp-idea-stream'), '_ideastream_user_rates_slug' => _x('ratings', 'default ratings slug', 'wp-idea-stream'), '_ideastream_signup_slug' => _x('sign-up', 'default sign-up action slug', 'wp-idea-stream'), '_ideastream_action_slug' => _x('action', 'default action slug', 'wp-idea-stream'), '_ideastream_addnew_slug' => _x('add', 'default add idea action slug', 'wp-idea-stream'), '_ideastream_edit_slug' => _x('edit', 'default edit idea action slug', 'wp-idea-stream'), '_ideastream_cpage_slug' => _x('cpage', 'default comments pagination slug', 'wp-idea-stream')));
    }
    // Multisite options
    if (is_multisite()) {
        $default_options = array_merge($default_options, array('_ideastream_allow_signups' => 0, '_ideastream_user_new_idea_set_role' => 0));
    }
    /**
     * Used internally to merge options of the previous verions
     * of the plugin with new ones during upgrade routine.
     *
     * @see  core/upgrade wp_idea_stream_merge_legacy_options()
     *
     * @param  array $default_options list of options
     */
    return apply_filters('wp_idea_stream_get_default_options', $default_options);
}
Esempio n. 2
0
/**
 * The different fields for setting sections
 *
 * @package WP Idea Stream
 * @subpackage admin/settings
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_is_pretty_links() to check if the permalink structure is custom
 * @uses   apply_filters() call 'wp_idea_stream_get_settings_fields' to add/edit/remove sections
 * @return array the settings fields
 */
function wp_idea_stream_get_settings_fields()
{
    $setting_fields = array('ideastream_settings_core' => array('_ideastream_archive_title' => array('title' => __('IdeaStream archive page', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_archive_title_setting_callback', 'sanitize_callback' => 'sanitize_text_field', 'args' => array()), '_ideastream_submit_status' => array('title' => __('New ideas status', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_submit_status_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_status', 'args' => array()), '_ideastream_editor_image' => array('title' => __('Images', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_editor_image_setting_callback', 'sanitize_callback' => 'absint', 'args' => array()), '_ideastream_featured_images' => array('title' => __('Featured images', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_editor_featured_images_setting_callback', 'sanitize_callback' => 'wp_idea_stream_editor_featured_images_sanitize', 'args' => array()), '_ideastream_editor_link' => array('title' => __('Links', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_editor_link_setting_callback', 'sanitize_callback' => 'absint', 'args' => array()), '_ideastream_moderation_message' => array('title' => __('Moderation message', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_moderation_message_setting_callback', 'sanitize_callback' => 'sanitize_text_field', 'args' => array()), '_ideastream_login_message' => array('title' => __('Not logged in message', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_login_message_setting_callback', 'sanitize_callback' => 'sanitize_text_field', 'args' => array()), '_ideastream_hint_list' => array('title' => __('Rating stars hover captions', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_hint_list_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_hint_list', 'args' => array()), '_ideastream_sticky_ideas' => array('title' => __('Sticky ideas', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_sticky_ideas_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sticky_sanitize', 'args' => array()), '_ideastream_disjoin_comments' => array('title' => __('Idea comments', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_disjoin_comments_setting_callback', 'sanitize_callback' => 'absint', 'args' => array()), '_ideastream_allow_comments' => array('title' => __('Comments', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_allow_comments_setting_callback', 'sanitize_callback' => 'absint', 'args' => array()), '_ideastream_embed_profile' => array('title' => __('Embed Profile', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_embed_profile_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_embed_profile', 'args' => array())));
    if (wp_idea_stream_is_pretty_links()) {
        /** Rewrite Section ***********************************************************/
        $setting_fields['ideastream_settings_rewrite'] = array('_ideastream_root_slug' => array('title' => __('IdeaStream root slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_root_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_idea_slug' => array('title' => __('Single idea slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_idea_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_category_slug' => array('title' => __('Category slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_category_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_tag_slug' => array('title' => __('Tag slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_tag_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_user_slug' => array('title' => __('User slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_user_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_user_comments_slug' => array('title' => __('User comments slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_user_comments_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_cpage_slug' => array('title' => __('User comments paging slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_cpage_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_comments_page_slug', 'args' => array()), '_ideastream_user_rates_slug' => array('title' => __('User ratings slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_user_rates_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_signup_slug' => array('title' => __('Sign-up slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_signup_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_action_slug' => array('title' => __('Action slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_action_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_addnew_slug' => array('title' => __('New form slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_addnew_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()), '_ideastream_edit_slug' => array('title' => __('Edit form slug', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_edit_slug_setting_callback', 'sanitize_callback' => 'wp_idea_stream_sanitize_slug', 'args' => array()));
    }
    if (is_multisite()) {
        /** Multisite Section *********************************************************/
        $setting_fields['ideastream_settings_multisite'] = array();
        if (wp_idea_stream_is_signup_allowed()) {
            $setting_fields['ideastream_settings_multisite']['_ideastream_allow_signups'] = array('title' => __('Sign-ups', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_allow_signups_setting_callback', 'sanitize_callback' => 'absint', 'args' => array());
        }
        $setting_fields['ideastream_settings_multisite']['_ideastream_user_new_idea_set_role'] = array('title' => __('Default role for network users', 'wp-idea-stream'), 'callback' => 'wp_idea_stream_user_new_idea_set_role_setting_callback', 'sanitize_callback' => 'absint', 'args' => array());
    }
    /**
     * Used internally to add the BuddyPress settings fields
     * @see  buddypress/settings for an example of use.
     *
     * @param array $setting_fields the setting fields
     */
    return (array) apply_filters('wp_idea_stream_get_settings_fields', $setting_fields);
}
Esempio n. 3
0
/**
 * Displays the Orderby form
 *
 * @package WP Idea Stream
 * @subpackage ideas/tags
 *
 * @since 2.0.0
 *
 * @uses   wp_idea_stream_ideas_get_order_options() to get available orders
 * @uses   get_query_var() to get the selected order
 * @uses   wp_idea_stream_get_category() to get ideas category rewrite id (which is also its identifier)
 * @uses   wp_idea_stream_get_tag() to get ideas tag rewrite id (which is also its identifier)
 * @uses   esc_html() to sanitize output value
 * @uses   wp_idea_stream_is_pretty_links() to check if a custom permalink structure is set
 * @uses   wp_idea_stream_get_post_type() to get the post type identifier
 * @uses   wp_idea_stream_get_tag_url() to get the url to the current tag
 * @uses   wp_idea_stream_get_category_url() to get the url to the current category
 * @uses   wp_idea_stream_get_root_url() to get the main ideas archive page url
 * @uses   esc_url() to sanitize the url
 * @uses   esc_attr() to sanitize attributes
 * @uses   selected() to add the selected attribute to the selected option
 * @uses   apply_filters() call 'wp_idea_stream_ideas_order_form_action_url' to override the base url
 *                         call 'wp_idea_stream_ideas_order_form' to override the orderby form output
 * @return string Output for the search form.
 */
function wp_idea_stream_ideas_order_form()
{
    $order_options = wp_idea_stream_ideas_get_order_options();
    $order_value = get_query_var('orderby');
    $category = get_query_var(wp_idea_stream_get_category());
    $tag = get_query_var(wp_idea_stream_get_tag());
    $action = '';
    $hidden = '';
    if (!empty($order_value)) {
        $order_value = esc_html($order_value);
    } else {
        $order_value = 'date';
    }
    if (!wp_idea_stream_is_pretty_links()) {
        if (!empty($category)) {
            $hidden = "\n" . '<input type="hidden" name="' . esc_attr(wp_idea_stream_get_category()) . '" value="' . $category . '"/>';
        } else {
            if (!empty($tag)) {
                $hidden = "\n" . '<input type="hidden" name="' . esc_attr(wp_idea_stream_get_tag()) . '" value="' . $tag . '"/>';
            } else {
                $hidden = "\n" . '<input type="hidden" name="post_type" value="' . wp_idea_stream_get_post_type() . '"/>';
            }
        }
        // We need to set the action url
    } else {
        // Viewing tags
        if (wp_idea_stream_is_tag()) {
            $action = wp_idea_stream_get_tag_url($tag);
            // Viewing categgories
        } else {
            if (wp_idea_stream_is_category()) {
                $action = wp_idea_stream_get_category_url($category);
                // Defaults to roout url
            } else {
                $action = wp_idea_stream_get_root_url();
            }
        }
        /**
         * @param string $action the action form attribute
         * @param string the current category term slug if set
         * @param string the current tag term slug if set
         */
        $action = apply_filters('wp_idea_stream_ideas_order_form_action_url', $action, $category, $tag);
    }
    $order_form_html = '<form action="' . esc_url($action) . '" method="get" id="ideas-order-form" class="nav-form">' . $hidden;
    $order_form_html .= '<label><select name="orderby" id="ideas-order-box">';
    foreach ($order_options as $query_var => $label) {
        $order_form_html .= '<option value="' . esc_attr($query_var) . '" ' . selected($order_value, $query_var, false) . '>' . esc_html($label) . '</option>';
    }
    $order_form_html .= '</select></label>';
    $order_form_html .= '<input type="submit" id="ideas-order-submit" value="' . esc_attr__('Sort', 'wp-idea-stream') . '" /></form>';
    echo apply_filters('wp_idea_stream_ideas_order_form', $order_form_html);
}
Esempio n. 4
0
 /**
  * Gets the help tabs for a given IdeaStream Administration screen
  *
  * @package WP Idea Stream
  * @subpackage admin/admin
  *
  * @since 2.0.0
  *
  * @param  string  $screen_id the IdeaStream Administration screen ID
  * @uses   apply_filters() call 'wp_idea_stream_get_help_tabs' to add/edit/remove help tabs
  * @return array         the help tabs
  */
 public function get_help_tabs($screen_id = '')
 {
     // Help urls
     $plugin_forum = '<a href="http://wordpress.org/support/plugin/wp-idea-stream">';
     $plugin_posts_archive = '<a href="http://imathi.eu/tag/ideastream/">';
     $help_tabs = false;
     $nav_menu_page = '<a href="' . esc_url(admin_url('nav-menus.php')) . '">';
     $widgets_page = '<a href="' . esc_url(admin_url('widgets.php')) . '">';
     /**
      * Used internally to add sticky/ratings/BuddyPress groups help tabs
      * if enabled.
      *
      * @param array associative array to list the help tabs
      */
     $help = array('edit-ideas' => array('add_help_tab' => array(array('id' => 'edit-ideas-overview', 'title' => esc_html__('Overview', 'wp-idea-stream'), 'content' => array(esc_html__('This screen provides access to all the ideas users of your site shared. You can customize the display of this screen to suit your workflow.', 'wp-idea-stream'), esc_html__('You can customize the display of this screen&#39;s contents in a number of ways:', 'wp-idea-stream'), array(esc_html__('You can hide/display columns based on your needs and decide how many ideas to list per screen using the Screen Options tab.', 'wp-idea-stream'), esc_html__('You can filter the list of ideas by post status using the text links in the upper left to show All, Published, Private or Trashed ideas. The default view is to show all ideas.', 'wp-idea-stream'), esc_html__('You can view ideas in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.', 'wp-idea-stream')))), array('id' => 'edit-ideas-row-actions', 'title' => esc_html__('Actions', 'wp-idea-stream'), 'content' => array(esc_html__('Hovering over a row in the ideas list will display action links that allow you to manage an idea. You can perform the following actions:', 'wp-idea-stream'), array(esc_html__('Edit takes you to the editing screen for that idea. You can also reach that screen by clicking on the idea title.', 'wp-idea-stream'), esc_html__('Trash removes the idea from this list and places it in the trash, from which you can permanently delete it.', 'wp-idea-stream'), esc_html__('View opens the idea in the IdeaStream&#39;s part of your site.', 'wp-idea-stream')))), array('id' => 'edit-ideas-bulk-actions', 'title' => esc_html__('Bulk Actions', 'wp-idea-stream'), 'content' => array(esc_html__('You can also move multiple ideas to the trash at once. Select the ideas you want to trash using the checkboxes, then select the &#34;Move to Trash&#34; action from the Bulk Actions menu and click Apply.', 'wp-idea-stream'))), array('id' => 'edit-ideas-sort-filter', 'title' => esc_html__('Sorting & filtering', 'wp-idea-stream'), 'content' => array(esc_html__('Clicking on specific column headers will sort the ideas list. You can sort the ideas alphabetically using the Title column header or by popularity:', 'wp-idea-stream'), array(esc_html__('Click on the column header having a dialog buble icon to sort by number of comments.', 'wp-idea-stream'), esc_html__('Click on the column header having a star icon to sort by rating.', 'wp-idea-stream')), esc_html__('Inside the rows, you can filter the ideas by categories or tags clicking on the corresponding terms.', 'wp-idea-stream'))))), 'ideas' => array('add_help_tab' => array(array('id' => 'ideas-overview', 'title' => esc_html__('Overview', 'wp-idea-stream'), 'content' => array(esc_html__('The title field and the big Idea Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to hide/show boxes.', 'wp-idea-stream'))))), 'settings_page_ideastream' => array('add_help_tab' => array(array('id' => 'settings-overview', 'title' => esc_html__('Overview', 'wp-idea-stream'), 'content' => array(esc_html__('This is the place where you can customize the behavior of IdeaStream.', 'wp-idea-stream'), esc_html__('Please see the additional help tabs for more information on each individual section.', 'wp-idea-stream'))), array('id' => 'settings-main', 'title' => esc_html__('Main Settings', 'wp-idea-stream'), 'content' => array(sprintf(esc_html__('Just before the first option, you will find the link to the main archive page of the plugin. If you wish, you can use it to define a new custom link %1$smenu item%2$s.', 'wp-idea-stream'), $nav_menu_page, '</a>'), sprintf(esc_html__('If you do so, do not forget to update the link in case you change your permalink settings. Another possible option is to use the %1$sIdeaStream Navigation%2$s widget in one of your dynamic sidebars.', 'wp-idea-stream'), $widgets_page, '</a>'), esc_html__('In the Main Settings you have a number of options:', 'wp-idea-stream'), array(esc_html__('IdeaStream archive page: you can customize the title of this page. It will appear on every IdeaStream&#39;s page, except the single idea one.', 'wp-idea-stream'), esc_html__('New ideas status: this is the default status to apply to the ideas submitted by the user. If this setting is set to &#34;Pending&#34;, it will be possible to edit the moderation message once this setting has been saved.', 'wp-idea-stream'), esc_html__('Images & Links are settings about the IdeaStream&#39;s editor. If you wish to disable the image or link buttons, you can disable the corresponding setting.', 'wp-idea-stream'), esc_html__('Featured images is a setting that requires the Editor Images button to be active. It allows your users to select an image they inserted and set it as the featured image for the idea. You must know this image will be uploaded inside your WordPress site.', 'wp-idea-stream'), esc_html__('Moderation message: if New ideas status is defined to Pending, it is the place to customize the awaiting moderation message the user will see once he submited his idea.', 'wp-idea-stream'), esc_html__('Not logged in message: if a user reaches the IdeaStream&#39;s front end submit form without being logged in, a message will invite him to do so. If you wish to use a custom message, use this setting.', 'wp-idea-stream'), esc_html__('Rating stars hover captions: fill a comma separated list of captions to replace default one. On front end, the number of rating stars will depend on the number of comma separated captions you defined in this setting.', 'wp-idea-stream'), esc_html__('Sticky ideas: choose whether to allow or not Administrators to stick ideas to the top of the IdeaStream&#39;s archive first page.', 'wp-idea-stream'), esc_html__('Idea comments: if on, comments about ideas will be separated from other post types comments and you will be able to moderate comments about ideas from the comments submenu of the IdeaStream&#39;s main Administration menu. If you uncheck this setting, ideas comments will be mixed up with other post types comments into the main Comments Administration menu', 'wp-idea-stream'), esc_html__('Comments: you can completely disable commenting about ideas by activating this option', 'wp-idea-stream'), esc_html__('Embed profile: if this setting is active, your users profiles will include a sharing button to let your visitors copy the embed code and share it into their website.', 'wp-idea-stream')))))), 'edit-category-ideas' => array('add_help_tab' => array(array('id' => 'ideas-category-overview', 'title' => esc_html__('Overview', 'wp-idea-stream'), 'content' => array(esc_html__('Idea Categories can only be created by the site Administrator. To add a new idea category please fill the following fields:', 'wp-idea-stream'), array(esc_html__('Name - The name is how it appears on your site (in the category checkboxes of the idea front end submit form, in the idea&#39;s footer part or in the title of IdeaStream&#39;s category archive pages).', 'wp-idea-stream'), esc_html__('Slug - The &#34;slug&#34; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'wp-idea-stream'), esc_html__('Description - If you set a description for your category, it will be displayed over the list of ideas in the category archive page.', 'wp-idea-stream')), esc_html__('You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.', 'wp-idea-stream'))))), 'edit-tag-ideas' => array('add_help_tab' => array(array('id' => 'ideas-tag-overview', 'title' => esc_html__('Overview', 'wp-idea-stream'), 'content' => array(esc_html__('Idea Tags can be created by any logged in user of the site from the idea front end submit form. From this screen, to add a new idea tag please fill the following fields:', 'wp-idea-stream'), array(esc_html__('Name - The name is how it appears on your site (in the tag cloud, in the tags editor of the idea front end submit form, in the idea&#39;s footer part or in the title of IdeaStream&#39;s tag archive pages).', 'wp-idea-stream'), esc_html__('Slug - The &#34;slug&#34; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'wp-idea-stream'), esc_html__('Description - If you set a description for your tag, it will be displayed over the list of ideas in the tag archive page.', 'wp-idea-stream')), esc_html__('You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.', 'wp-idea-stream'))))));
     if (wp_idea_stream_is_pretty_links()) {
         $help['settings_page_ideastream']['add_help_tab'][] = array('id' => 'settings-slugs', 'title' => esc_html__('Pretty Links', 'wp-idea-stream'), 'content' => array(esc_html__('The Pretty Links section allows you to control the permalink structure of the plugin by defining custom slugs.', 'wp-idea-stream'), esc_html__('The IdeaStream root slug is the most important one. Make sure the slug you chose is unique. Once saved, IdeaStream will check for an eventual slug collision with WordPress (Posts, Pages or subsites in case of a MultiSite Config), bbPress or BuddyPress, and will display a warning next to the option field.', 'wp-idea-stream'), esc_html__('In the case of a slug collision, I strongly advise you to change the IdeaStream root slug.', 'wp-idea-stream'), esc_html__('Concerning the text you will enter in the slug fields, make sure it is all lowercase and contains only letters, numbers, and hyphens.', 'wp-idea-stream')));
     }
     /**
      * Used internally to add sticky/ratings/BuddyPress groups help tabs
      * if enabled.
      *
      * @param array $help associative array to list the help tabs
      */
     $help = apply_filters('wp_idea_stream_get_help_tabs', $help);
     if (!empty($help[$screen_id])) {
         $help_tabs = array_merge($help[$screen_id], array('set_help_sidebar' => array(array('strong' => esc_html__('For more information:', 'wp-idea-stream'), 'content' => array(sprintf(esc_html_x('%1$sSupport Forums (en)%2$s', 'help tab links', 'wp-idea-stream'), $plugin_forum, '</a>'), sprintf(esc_html_x('%1$sIdeaStream posts (fr)%2$s', 'help tab links', 'wp-idea-stream'), $plugin_posts_archive, '</a>'))))));
     }
     return $help_tabs;
 }
Esempio n. 5
0
 /**
  * Constructor
  *
  * @package WP Idea Stream
  * @subpackage comment/tags
  *
  * @since 2.0.0
  *
  * @param  array $args the loop args
  * @uses   wp_idea_stream_ideas_per_page() to get the per page setting
  * @uses   wp_idea_stream_is_current_user_profile() to check if on a user's profile
  * @uses   wp_idea_stream_cpage_rewrite_id() to get the comment pagination rewrite id
  * @uses   get_query_var() to get the value of a query var
  * @uses   wp_parse_args() to merge custom args with default ones
  * @uses   wp_idea_stream_get_post_type() to get the idea post type identifier
  * @uses   wp_idea_stream_comments_count_comments() to count the comments for the user
  * @uses   get_comments() to get the comments matching the arguments
  * @uses   wp_list_pluck() to pluck a certain field out of each object in a list.
  * @uses   get_posts() to get the posts corresponding to comments
  * @uses   wp_idea_stream_set_idea_var() to globalize a value for a later use
  * @uses   wp_idea_stream_is_pretty_links() to check if permalink structure is not default one
  * @uses   add_query_arg() to build an url
  * @uses   wp_idea_stream_users_get_user_comments_url() to get user's profile comment part url
  * @uses   wp_idea_stream_users_displayed_user_id() to get the displayed user ID
  * @uses   wp_idea_stream_users_get_displayed_user_username() to get the displayed user nicename
  * @uses   wp_idea_stream_cpage_slug() to get the slug for the comments pagination
  * @uses   WP_Idea_Stream_Loop::start() to build the user comments loop
  */
 public function __construct($args = array())
 {
     $default = array('post_status' => 'publish', 'status' => 'approve', 'user_id' => 0, 'number' => wp_idea_stream_ideas_per_page());
     // All post status if user is viewing his profile
     if (wp_idea_stream_is_current_user_profile() || current_user_can('read_private_ideas')) {
         $default['post_status'] = '';
     }
     //Merge default with requested
     $r = wp_parse_args($args, $default);
     // Set which pagination page
     if (get_query_var(wp_idea_stream_cpage_rewrite_id())) {
         $paged = get_query_var(wp_idea_stream_cpage_rewrite_id());
     } else {
         if (!empty($_GET[wp_idea_stream_cpage_rewrite_id()])) {
             $paged = absint($_GET[wp_idea_stream_cpage_rewrite_id()]);
         } else {
             if (!empty($r['page'])) {
                 $paged = absint($r['page']);
                 // Set default page (first page)
             } else {
                 $paged = 1;
             }
         }
     }
     $comments_args = array('post_type' => wp_idea_stream_get_post_type(), 'post_status' => $r['post_status'], 'status' => $r['status'], 'user_id' => (int) $r['user_id'], 'number' => (int) $r['number'], 'offset' => intval(($paged - 1) * $r['number']), 'page' => (int) $paged);
     if (!empty($comments_args)) {
         foreach ($comments_args as $key => $value) {
             $this->{$key} = $value;
         }
     } else {
         return false;
     }
     if (empty($this->user_id)) {
         $comment_count = 0;
     } else {
         $comment_count = wp_idea_stream_comments_count_comments($this->user_id);
     }
     // Get the comments
     $comments = get_comments($comments_args);
     if (!empty($comments)) {
         $post_ids = wp_list_pluck($comments, 'comment_post_ID');
         // Get all posts in the object cache.
         $posts = get_posts(array('include' => $post_ids, 'post_type' => wp_idea_stream_get_post_type()));
         // Reset will need to be done at the end of the loop
         wp_idea_stream_set_idea_var('needs_reset', true);
         // Build a new post array indexed by post ID
         $p = array();
         foreach ($posts as $post) {
             $p[$post->ID] = $post;
         }
         // Attach the corresponding post to each comment
         foreach ($comments as $key => $comment) {
             if (!empty($p[$comment->comment_post_ID])) {
                 $comments[$key]->idea = $p[$comment->comment_post_ID];
             }
         }
     }
     $params = array('plugin_prefix' => 'wp_idea_stream', 'item_name' => 'comment', 'item_name_plural' => 'comments', 'items' => $comments, 'total_item_count' => $comment_count, 'page' => $this->page, 'per_page' => $this->number);
     $paginate_args = array();
     if (!wp_idea_stream_is_pretty_links()) {
         $paginate_args['base'] = add_query_arg(wp_idea_stream_cpage_rewrite_id(), '%#%');
     } else {
         $paginate_args['base'] = trailingslashit(wp_idea_stream_users_get_displayed_profile_url('comments')) . '%_%';
         $paginate_args['format'] = wp_idea_stream_cpage_slug() . '/%#%/';
     }
     parent::start($params, apply_filters('wp_idea_stream_comments_pagination_args', $paginate_args));
 }
Esempio n. 6
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));
 }