/** * Move our custom separator above our custom post types * * @since bbPress (r2957) * * @param array $menu_order Menu Order * @uses bbp_get_forum_post_type() To get the forum post type * @return array Modified menu order */ function bbp_admin_menu_order($menu_order) { // Bail if user cannot see any top level bbPress menus if (empty($menu_order) || false === bbpress()->admin->show_separator) { return $menu_order; } // Initialize our custom order array $bbp_menu_order = array(); // Menu values $second_sep = 'separator2'; $custom_menus = array('separator-bbpress', 'edit.php?post_type=' . bbp_get_forum_post_type(), 'edit.php?post_type=' . bbp_get_topic_post_type(), 'edit.php?post_type=' . bbp_get_reply_post_type()); // Loop through menu order and do some rearranging foreach ($menu_order as $item) { // Position bbPress menus above appearance if ($second_sep == $item) { // Add our custom menus foreach ($custom_menus as $custom_menu) { if (array_search($custom_menu, $menu_order)) { $bbp_menu_order[] = $custom_menu; } } // Add the appearance separator $bbp_menu_order[] = $second_sep; // Skip our menu items } elseif (!in_array($item, $custom_menus)) { $bbp_menu_order[] = $item; } } // Return our custom order return $bbp_menu_order; }
function settings_map_cap($caps, $cap, $user_id, $args) { if ($cap == 'bbpvotes_settings') { $caps = array(bbpress()->admin->minimum_capability); } return $caps; }
public function get_all_forums() { $bbp_f = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => 'any', 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'ignore_sticky_posts' => true, 'orderby' => 'menu_order title', 'order' => 'ASC'), 'has_forums'); $bbp = bbpress(); $bbp->forum_query = new WP_Query($bbp_f); $data = array(); foreach ($bbp->forum_query->posts as $post) { $type = 'forum'; $is_parent = false; $is_category = bbp_forum_get_subforums($post->ID); if ($is_category) { $type = 'category'; $parent = true; } $settings = $this->wlm->GetOption('bbpsettings'); if ($settings && count($settings) > 0) { foreach ($settings as $setting) { if ($setting["id"] == $post->ID) { $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => $setting["sku"], "protection" => $setting["protection"], "type" => $type, "parent" => $parent, "date" => ""); } } if (!isset($data[$post->ID])) { $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => ""); } } else { $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => ""); } } echo json_encode($data); die; }
/** * Remove all filter * @param String $tag * @param boolean $priority * @return boolean */ function learn_press_remove_all_filters($tag, $priority = false) { global $wp_filter, $merged_filters; if (!function_exists('bbpress')) { return; } $bbp = bbpress(); // Filters exist if (isset($wp_filter[$tag])) { // Filters exist in this priority if (!empty($priority) && isset($wp_filter[$tag][$priority])) { // Store filters in a backup $bbp->filters->wp_filter[$tag][$priority] = $wp_filter[$tag][$priority]; // Unset the filters unset($wp_filter[$tag][$priority]); // Priority is empty } else { // Store filters in a backup $bbp->filters->wp_filter[$tag] = $wp_filter[$tag]; // Unset the filters unset($wp_filter[$tag]); } } // Check merged filters if (isset($merged_filters[$tag])) { // Store filters in a backup $bbp->filters->merged_filters[$tag] = $merged_filters[$tag]; // Unset the filters unset($merged_filters[$tag]); } return true; }
/** * Component global variables * * @since bbPress (r2626) * @access private * @uses bbp_get_version() To get the bbPress version * @uses get_stylesheet_directory() To get the stylesheet path * @uses get_stylesheet_directory_uri() To get the stylesheet uri */ private function setup_globals() { $bbp = bbpress(); $this->id = 'bbp-twentyten'; $this->name = __('Twenty Ten (bbPress)', 'bbpress'); $this->version = bbp_get_version(); $this->dir = trailingslashit($bbp->themes_dir . 'bbp-twentyten'); $this->url = trailingslashit($bbp->themes_url . 'bbp-twentyten'); }
/** * Component global variables * * Note that this function is currently commented out in the constructor. * It will only be used if you copy this file into your current theme and * uncomment the line above. * * You'll want to customize the values in here, so they match whatever your * needs are. * * @since bbPress (r3732) * @access private */ private function setup_globals() { $bbp = bbpress(); $this->id = 'default'; $this->name = __('bbPress Default', 'bbpress'); $this->version = bbp_get_version(); $this->dir = trailingslashit($bbp->themes_dir . 'default'); $this->url = trailingslashit($bbp->themes_url . 'default'); }
static function settings_meta_caps($caps, $cap) { switch ($cap) { default: $caps = array(bbpress()->admin->minimum_capability); break; } return $caps; }
/** * Maps settings capabilities * * @param array $caps Capabilities for meta capability * @param string $cap Capability name * * @return array Actual capabilities for meta capability */ public function meta_caps($caps, $cap) { switch ($cap) { case 'bbp_settings_block': // User blocking settings $caps = array(bbpress()->admin->minimum_capability); break; } return $caps; }
/** * Filter bbPress arguments * * @param $bbp_args * * @return mixed */ public function bbp_after_has_search_results_parse_args($bbp_args) { $bbp = bbpress(); $bbp->search_query = new WPSOLR_Query($bbp_args); // Remove the 's' parameter, to prevent bbPress executing it's own wp_query if (!empty($bbp_args['s'])) { unset($bbp_args['s']); } return $bbp_args; }
function tf_get_search_pagination_links() { $bbp = bbpress(); $pagination_links = $bbp->search_query->pagination_links; $pagination_links = str_replace('page-numbers current', 'current', $pagination_links); $pagination_links = str_replace('page-numbers', 'inactive', $pagination_links); $pagination_links = str_replace('prev inactive', 'pagination-prev', $pagination_links); $pagination_links = str_replace('next inactive', 'pagination-next', $pagination_links); $pagination_links = str_replace('←', __('Previous', 'Avada') . '<span class="page-prev"></span>', $pagination_links); $pagination_links = str_replace('→', __('Next', 'Avada') . '<span class="page-next"></span>', $pagination_links); return $pagination_links; }
/** * Loads BP Registration Options files only if BuddyPress is present * * @package BP-Registration-Options * */ function bp_registration_options_init() { # Not using bp_includes because we want to be able to be run with just bbPress as well. if (function_exists('buddypress')) { $bp = buddypress(); } if (function_exists('bbpress')) { $bbp = bbpress(); } if (isset($bp) && version_compare($bp->version, '1.7.0', '>=') || isset($bbp) && version_compare($bbp->version, '2.0.0', '>=')) { require dirname(__FILE__) . '/bp-registration-options.php'; $bp_registration_options = new BP_Registration_Options(); $bp_registration_compatibility = new BP_Registration_Compatibility(); } }
/** * Get version of the bbPress. * * @param string $ret what version format to return: code or version * @return mixed version value */ function d4p_bbpress_version($ret = 'code') { if (function_exists('bbpress')) { $bbp = bbpress(); } else { global $bbp; } if (isset($bbp->version)) { if ($ret == 'code') { return substr(str_replace('.', '', $bbp->version), 0, 2); } else { return $bbp->version; } } return null; }
/** * Loads BP Registration Options files only if BuddyPress is present * * @package BP-Registration-Options * */ function bp_registration_options_init() { $bp = ''; $bbp = ''; # Not using bp_includes because we want to be able to be run with just bbPress as well. if (function_exists('buddypress')) { $bp = buddypress(); } if (function_exists('bbpress')) { $bbp = bbpress(); } if (bp_registration_should_init($bp, $bbp)) { require_once dirname(__FILE__) . '/bp-registration-options.php'; $bp_registration_options = new BP_Registration_Options(); add_action('init', 'bp_registration_options_compat_init'); } }
/** * Possibly intercept the template being loaded * * Listens to the 'template_include' filter and waits for any bbPress specific * template condition to be met. If one is met and the template file exists, * it will be used; otherwise * * Note that the _edit() checks are ahead of their counterparts, to prevent them * from being stomped on accident. * * @since bbPress (r3032) * * @param string $template * * @uses bbp_is_single_user() To check if page is single user * @uses bbp_get_single_user_template() To get user template * @uses bbp_is_single_user_edit() To check if page is single user edit * @uses bbp_get_single_user_edit_template() To get user edit template * @uses bbp_is_single_view() To check if page is single view * @uses bbp_get_single_view_template() To get view template * @uses bbp_is_forum_edit() To check if page is forum edit * @uses bbp_get_forum_edit_template() To get forum edit template * @uses bbp_is_topic_merge() To check if page is topic merge * @uses bbp_get_topic_merge_template() To get topic merge template * @uses bbp_is_topic_split() To check if page is topic split * @uses bbp_get_topic_split_template() To get topic split template * @uses bbp_is_topic_edit() To check if page is topic edit * @uses bbp_get_topic_edit_template() To get topic edit template * @uses bbp_is_reply_edit() To check if page is reply edit * @uses bbp_get_reply_edit_template() To get reply edit template * @uses bbp_set_theme_compat_template() To set the global theme compat template * * @return string The path to the template file that is being used */ function bbp_template_include_theme_supports($template = '') { // Editing a user if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) { // Viewing a user } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) { // Single View } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) { // Forum edit } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) { // Single Forum } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) { // Forum Archive } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) { // Topic merge } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) { // Topic split } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) { // Topic edit } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) { // Single Topic } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) { // Topic Archive } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) { // Editing a reply } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) { // Single Reply } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) { // Editing a topic tag } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) { // Viewing a topic tag } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) { } // bbPress template file exists if (!empty($new_template)) { // Override the WordPress template with a bbPress one $template = $new_template; // @see: bbp_template_include_theme_compat() bbpress()->theme_compat->bbpress_template = true; } return apply_filters('bbp_template_include_theme_supports', $template); }
/** * Requires and creates the BuddyPress extension, and adds component creation * action to bp_init hook. @see bbp_setup_buddypress_component() * * @since bbPress (r3395) * @return If BuddyPress is not active */ function bbp_setup_buddypress() { if (!function_exists('buddypress')) { /** * Helper for BuddyPress 1.6 and earlier * * @since bbPress (r4395) * @return BuddyPress */ function buddypress() { return isset($GLOBALS['bp']) ? $GLOBALS['bp'] : false; } } // Bail if in maintenance mode if (!buddypress() || buddypress()->maintenance_mode) { return; } // Include the BuddyPress Component require bbpress()->includes_dir . 'extend/buddypress/loader.php'; // Instantiate BuddyPress for bbPress bbpress()->extend->buddypress = new BBP_Forums_Component(); }
/** * This function filters the list of forums based on the users rank as set by the Mebmers plugin */ function tehnik_bpp_filter_forums_by_permissions($args = '') { $bbp = bbpress(); // Setup possible post__not_in array $post_stati[] = bbp_get_public_status_id(); // Check if user can read private forums if (current_user_can('read_private_forums')) { $post_stati[] = bbp_get_private_status_id(); } // Check if user can read hidden forums if (current_user_can('read_hidden_forums')) { $post_stati[] = bbp_get_hidden_status_id(); } // The default forum query for most circumstances $meta_query = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => bbp_is_forum_archive() ? 0 : bbp_get_forum_id(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC'); //Get an array of IDs which the current user has permissions to view $allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($meta_query)); // The default forum query with allowed forum ids array added $meta_query['post__in'] = $allowed_forums; $bbp_f = bbp_parse_args($args, $meta_query, 'has_forums'); // Run the query $bbp->forum_query = new WP_Query($bbp_f); return apply_filters('bpp_filter_forums_by_permissions', $bbp->forum_query->have_posts(), $bbp->forum_query); }
/** * Get the array of available repair tools * * @since 2.6.0 bbPress (r5885) * * @return array */ function bbp_get_admin_repair_tools() { // Get tools array $tools = !empty(bbpress()->admin->tools) ? bbpress()->admin->tools : array(); return apply_filters('bbp_get_admin_repair_tools', $tools); }
/** * Setup bbPress Replies Admin * * This is currently here to make hooking and unhooking of the admin UI easy. * It could use dependency injection in the future, but for now this is easier. * * @since 2.0.0 bbPress (r2596) * * @uses BBP_Replies_Admin */ function bbp_admin_replies() { bbpress()->admin->replies = new BBP_Replies_Admin(); }
/** * Return the unique id of the topic tag taxonomy * * @since 2.0.0 bbPress (r3348) * * @uses apply_filters() Calls 'bbp_get_topic_tag_tax_id' with the topic tax id * @return string The unique topic tag taxonomy */ function bbp_get_topic_tag_tax_id() { return apply_filters('bbp_get_topic_tag_tax_id', bbpress()->topic_tag_tax_id); }
/** * Is a bbPress template being included? * * @since bbPress (r4975) * @return bool True if yes, false if no */ function bbp_is_template_included() { return !empty(bbpress()->theme_compat->bbpress_template); }
/** * Filter default options and allow them to be overloaded from inside the * $bbp->user_options array. * * @since 2.1.0 bbPress (r3910) * * @param bool $value Optional. Default value false * @return mixed false if not overloaded, mixed if set */ function bbp_filter_get_user_option($value = false, $option = '', $user = 0) { $bbp = bbpress(); // Check the options global for preset value if (isset($user->ID) && isset($bbp->user_options[$user->ID]) && !empty($bbp->user_options[$user->ID][$option])) { $value = $bbp->user_options[$user->ID][$option]; } // Always return a value, even if false return $value; }
/** * Can the current user see a specific UI element? * * Used when registering post-types and taxonomies to decide if 'show_ui' should * be set to true or false. Also used for fine-grained control over which admin * sections are visible under what conditions. * * This function is in bbp-core-caps.php rather than in /bbp-admin so that it * can be used during the bbp_register_post_types action. * * @since bbPress (r3944) * * @uses current_user_can() To check the 'moderate' capability * @uses bbp_get_forum_post_type() * @uses bbp_get_topic_post_type() * @uses bbp_get_reply_post_type() * @uses bbp_get_topic_tag_tax_id() * @uses is_plugin_active() * @uses is_super_admin() * @return bool Results of current_user_can( 'moderate' ) check. */ function bbp_current_user_can_see($component = '') { // Define local variable $retval = false; // Which component are we checking UI visibility for? switch ($component) { /** Everywhere ********************************************************/ case bbp_get_forum_post_type(): // Forums // Forums case bbp_get_topic_post_type(): // Topics // Topics case bbp_get_reply_post_type(): // Replies // Replies case bbp_get_topic_tag_tax_id(): // Topic-Tags $retval = current_user_can('moderate'); break; /** Admin Exclusive ***************************************************/ /** Admin Exclusive ***************************************************/ case 'bbp_settings_buddypress': // BuddyPress Extension $retval = is_plugin_active('buddypress/bp-loader.php') && defined('BP_VERSION') && is_super_admin(); break; case 'bbp_settings_akismet': // Akismet Extension $retval = is_plugin_active('akismet/akismet.php') && defined('AKISMET_VERSION') && is_super_admin(); break; case 'bbp_tools_page': // Tools Page // Tools Page case 'bbp_tools_repair_page': // Tools - Repair Page // Tools - Repair Page case 'bbp_tools_import_page': // Tools - Import Page // Tools - Import Page case 'bbp_tools_reset_page': // Tools - Reset Page // Tools - Reset Page case 'bbp_settings?page': // Settings Page // Settings Page case 'bbp_settings_main': // Settings - General // Settings - General case 'bbp_settings_theme_compat': // Settings - Theme compat // Settings - Theme compat case 'bbp_settings_root_slugs': // Settings - Root slugs // Settings - Root slugs case 'bbp_settings_single_slugs': // Settings - Single slugs // Settings - Single slugs case 'bbp_settings_per_page': // Settings - Single slugs // Settings - Single slugs case 'bbp_settings_per_page_rss': // Settings - Single slugs // Settings - Single slugs default: // Anything else $retval = current_user_can(bbpress()->admin->minimum_capability); break; } return (bool) apply_filters('bbp_current_user_can_see', (bool) $retval, $component); }
/** * Display possible errors & messages inside a template file * * @since bbPress (r2688) * * @uses WP_Error bbPress::errors::get_error_codes() To get the error codes * @uses WP_Error bbPress::errors::get_error_data() To get the error data * @uses WP_Error bbPress::errors::get_error_messages() To get the error * messages * @uses is_wp_error() To check if it's a {@link WP_Error} */ function bbp_template_notices() { // Bail if no notices or errors if (!bbp_has_errors()) { return; } // Define local variable(s) $errors = $messages = array(); // Get bbPress $bbp = bbpress(); // Loop through notices foreach ($bbp->errors->get_error_codes() as $code) { // Get notice severity $severity = $bbp->errors->get_error_data($code); // Loop through notices and separate errors from messages foreach ($bbp->errors->get_error_messages($code) as $error) { if ('message' == $severity) { $messages[] = $error; } else { $errors[] = $error; } } } // Display errors first... if (!empty($errors)) { ?> <div class="bbp-template-notice error"> <p> <?php echo implode("</p>\n<p>", $errors); ?> </p> </div> <?php } // ...and messages last if (!empty($messages)) { ?> <div class="bbp-template-notice"> <p> <?php echo implode("</p>\n<p>", $messages); ?> </p> </div> <?php } }
/** * Return topic pagination links * * @since bbPress (r2519) * * @uses apply_filters() Calls 'bbp_get_topic_pagination_links' with the * pagination links * @return string Topic pagination links */ function bbp_get_topic_pagination_links() { $bbp = bbpress(); if (!isset($bbp->reply_query->pagination_links) || empty($bbp->reply_query->pagination_links)) { return false; } return apply_filters('bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links); }
/** * Convert passwords from previous platfrom encryption to WordPress encryption. * * @since bbPress (r3813) * @global WPDB $wpdb */ function bbp_user_maybe_convert_pass() { // Bail if no username $username = !empty($_POST['log']) ? $_POST['log'] : ''; if (empty($username)) { return; } global $wpdb; // Bail if no user password to convert $row = $wpdb->get_row("SELECT * FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON user_id = ID WHERE meta_key = '_bbp_class' AND user_login = '******' LIMIT 1"); if (empty($row) || is_wp_error($row)) { return; } // Setup admin (to include converter) require_once bbpress()->includes_dir . 'admin/admin.php'; // Create the admin object bbp_admin(); // Convert password require_once bbpress()->admin->admin_dir . 'converter.php'; require_once bbpress()->admin->admin_dir . 'converters/' . $row->meta_value . '.php'; // Create the converter $converter = bbp_new_converter($row->meta_value); // Try to call the conversion method if (is_a($converter, 'BBP_Converter_Base') && method_exists($converter, 'callback_pass')) { $converter->callback_pass($username, $_POST['pwd']); } }
protected function callback_html($field) { require_once bbpress()->admin->admin_dir . 'parser.php'; $bbcode = BBCode::getInstance(); return html_entity_decode($bbcode->Parse($field)); }
/** * Get the id used for paginated requests * * @since 2.4.0 bbPress (r4926) * * @return string */ function bbp_get_paged_rewrite_id() { return bbpress()->paged_id; }
/** * Output a select box allowing to pick which forum/topic a new * topic/reply belongs in. * * @since bbPress (r2746) * * @param mixed $args The function supports these args: * - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum) * - selected: Selected ID, to not have any value as selected, pass * anything smaller than 0 (due to the nature of select * box, the first value would of course be selected - * though you can have that as none (pass 'show_none' arg)) * - orderby: Defaults to 'menu_order title' * - post_parent: Post parent. Defaults to 0 * - post_status: Which all post_statuses to find in? Can be an array * or CSV of publish, category, closed, private, spam, * trash (based on post type) - if not set, these are * automatically determined based on the post_type * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get * all posts * - walker: Which walker to use? Defaults to * {@link BBP_Walker_Dropdown} * - select_id: ID of the select box. Defaults to 'bbp_forum_id' * - tab: Tabindex value. False or integer * - options_only: Show only <options>? No <select>? * - show_none: False or something like __( '(No Forum)', 'bbpress' ), * will have value="" * - none_found: False or something like * __( 'No forums to post to!', 'bbpress' ) * - disable_categories: Disable forum categories and closed forums? * Defaults to true. Only for forums and when * the category option is displayed. * @uses BBP_Walker_Dropdown() As the default walker to generate the * dropdown * @uses current_user_can() To check if the current user can read * private forums * @uses bbp_get_forum_post_type() To get the forum post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses walk_page_dropdown_tree() To generate the dropdown using the * walker * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown * and args * @return string The dropdown */ function stachestack_bbp_get_dropdown($args = '') { /** Arguments *********************************************************/ // Parse arguments against default values $r = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => null, 'post_status' => null, 'selected' => 0, 'exclude' => array(), 'numberposts' => -1, 'orderby' => 'menu_order title', 'order' => 'ASC', 'walker' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => false, 'none_found' => false, 'disable_categories' => true, 'disabled' => ''), 'get_dropdown'); if (empty($r['walker'])) { $r['walker'] = new BBP_Walker_Dropdown(); $r['walker']->tree_type = $r['post_type']; } // Force 0 if (is_numeric($r['selected']) && $r['selected'] < 0) { $r['selected'] = 0; } // Force array if (!empty($r['exclude']) && !is_array($r['exclude'])) { $r['exclude'] = explode(',', $r['exclude']); } /** Setup variables ***************************************************/ $retval = ''; $posts = get_posts(array('post_type' => $r['post_type'], 'post_status' => $r['post_status'], 'exclude' => $r['exclude'], 'post_parent' => $r['post_parent'], 'numberposts' => $r['numberposts'], 'orderby' => $r['orderby'], 'order' => $r['order'], 'walker' => $r['walker'], 'disable_categories' => $r['disable_categories'])); /** Drop Down *********************************************************/ // Items found if (!empty($posts)) { // Build the opening tag for the select element if (empty($r['options_only'])) { // Should this select appear disabled? $disabled = disabled(isset(bbpress()->options[$r['disabled']]), true, false); // Setup the tab index attribute $tab = !empty($r['tab']) ? ' tabindex="' . intval($r['tab']) . '"' : ''; // Build the opening tag $retval .= '<select class="form-control" name="' . esc_attr($r['select_id']) . '" id="' . esc_attr($r['select_id']) . '"' . $disabled . $tab . '>' . "\n"; } // Get the options $retval .= !empty($r['show_none']) ? "\t<option value=\"\" class=\"level-0\">" . esc_html($r['show_none']) . '</option>' : ''; $retval .= walk_page_dropdown_tree($posts, 0, $r); // Build the closing tag for the select element if (empty($r['options_only'])) { $retval .= '</select>'; } // No items found - Display feedback if no custom message was passed } elseif (empty($r['none_found'])) { // Switch the response based on post type switch ($r['post_type']) { // Topics case bbp_get_topic_post_type(): $retval = __('No topics available', 'bbpress'); break; // Forums // Forums case bbp_get_forum_post_type(): $retval = __('No forums available', 'bbpress'); break; // Any other // Any other default: $retval = __('None available', 'bbpress'); break; } } return apply_filters('bbp_get_dropdown', $retval, $r); }
/** * Update all bbPress forums across all sites * * @since bbPress (r3689) * * @global WPDB $wpdb * @uses get_blog_option() * @uses wp_remote_get() */ public static function network_update_screen() { global $wpdb; // Get action $action = isset($_GET['action']) ? $_GET['action'] : ''; ?> <div class="wrap"> <div id="icon-edit" class="icon32 icon32-posts-topic"><br /></div> <h2><?php esc_html_e('Update Forums', 'bbpress'); ?> </h2> <?php // Taking action switch ($action) { case 'bbpress-update': // Site counter $n = isset($_GET['n']) ? intval($_GET['n']) : 0; // Get blogs 5 at a time $blogs = $wpdb->get_results("SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A); // No blogs so all done! if (empty($blogs)) { ?> <p><?php esc_html_e('All done!', 'bbpress'); ?> </p> <a class="button" href="update-core.php?page=bbpress-update"><?php esc_html_e('Go Back', 'bbpress'); ?> </a> <?php // Still have sites to loop through } else { ?> <ul> <?php foreach ((array) $blogs as $details) { $siteurl = get_blog_option($details['blog_id'], 'siteurl'); ?> <li><?php echo $siteurl; ?> </li> <?php // Get the response of the bbPress update on this site $response = wp_remote_get(trailingslashit($siteurl) . 'wp-admin/index.php?page=bbp-update&action=bbp-update', array('timeout' => 30, 'httpversion' => '1.1')); // Site errored out, no response? if (is_wp_error($response)) { wp_die(sprintf(__('Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>', 'bbpress'), $siteurl, $response->get_error_message())); } // Switch to the new blog switch_to_blog($details['blog_id']); $basename = bbpress()->basename; // Run the updater on this site if (is_plugin_active_for_network($basename) || is_plugin_active($basename)) { bbp_version_updater(); } // restore original blog restore_current_blog(); // Do some actions to allow plugins to do things too do_action('after_bbpress_upgrade', $response); do_action('bbp_upgrade_site', $details['blog_id']); } ?> </ul> <p> <?php esc_html_e('If your browser doesn’t start loading the next page automatically, click this link:', 'bbpress'); ?> <a class="button" href="update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo $n + 5; ?> "><?php esc_html_e('Next Forums', 'bbpress'); ?> </a> </p> <script type='text/javascript'> <!-- function nextpage() { location.href = 'update-core.php?page=bbpress-update&action=bbpress-update&n=<?php echo $n + 5; ?> '; } setTimeout( 'nextpage()', 250 ); //--> </script><?php } break; case 'show': default: ?> <p><?php esc_html_e('You can update all the forums on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.', 'bbpress'); ?> </p> <p><a class="button" href="update-core.php?page=bbpress-update&action=bbpress-update"><?php esc_html_e('Update Forums', 'bbpress'); ?> </a></p> <?php break; } ?> </div><?php }
/** * Add the default role to the current user if needed * * This function will bail if the forum is not global in a multisite * installation of WordPress, or if the user is marked as spam or deleted. * * @since bbPress (r3380) * * @uses is_user_logged_in() To bail if user is not logged in * @uses bbp_get_user_role() To bail if user already has a role * @uses bbp_is_user_inactive() To bail if user is inactive * @uses bbp_allow_global_access() To know whether to save role to database * @uses bbp_get_user_role_map() To get the WP to BBP role map array * @uses bbp_get_default_role() To get the site's default forums role * @uses get_option() * * @return If not multisite, not global, or user is deleted/spammed */ function bbp_set_current_user_default_role() { /** Sanity ****************************************************************/ // Bail if deactivating bbPress if (bbp_is_deactivation()) { return; } // Catch all, to prevent premature user initialization if (!did_action('set_current_user')) { return; } // Bail if not logged in or already a member of this site if (!is_user_logged_in()) { return; } // Get the current user ID $user_id = bbp_get_current_user_id(); // Bail if user already has a forums role if (bbp_get_user_role($user_id)) { return; } // Bail if user is marked as spam or is deleted if (bbp_is_user_inactive($user_id)) { return; } /** Ready *****************************************************************/ // Load up bbPress once $bbp = bbpress(); // Get whether or not to add a role to the user account $add_to_site = bbp_allow_global_access(); // Get the current user's WordPress role. Set to empty string if none found. $user_role = bbp_get_user_blog_role($user_id); // Get the role map $role_map = bbp_get_user_role_map(); /** Forum Role ************************************************************/ // Use a mapped role if (isset($role_map[$user_role])) { $new_role = $role_map[$user_role]; // Use the default role } else { $new_role = bbp_get_default_role(); } /** Add or Map ************************************************************/ // Add the user to the site if (true === $add_to_site) { // Make sure bbPress roles are added bbp_add_forums_roles(); $bbp->current_user->add_role($new_role); // Don't add the user, but still give them the correct caps dynamically } else { $bbp->current_user->caps[$new_role] = true; $bbp->current_user->get_role_caps(); } }