/** */ protected function init() { // make sure component is supported if ($this->supported()) { parent::init(); if (is_admin() && !is_dir(get_template_directory() . '/members') && !is_dir(get_stylesheet_directory() . '/members')) { bp_core_add_admin_notice(__("You have BuddyPress activated, but the templates are missing from your theme!", infinity_text_domain)); return false; } $this->setup_theme(); // addtl filters add_filter('bp_no_access_mode', array($this, 'use_wplogin')); add_filter('bp_get_activity_action_pre_meta', array($this, 'secondary_avatars'), 10, 2); // addtl actions add_action('open_sidebar', array($this, 'message_notices')); } }
/** * Display an admin notice upon member type bulk update. * * @since 2.7.0 */ public function users_type_change_notice() { $updated = isset($_REQUEST['updated']) ? $_REQUEST['updated'] : false; // Display feedback. if ($updated && in_array($updated, array('member-type-change-error', 'member-type-change-success'), true)) { if ('member-type-change-error' === $updated) { $notice = __('There was an error while changing member type. Please try again.', 'buddypress'); $type = 'error'; } else { $notice = __('Member type was changed successfully.', 'buddypress'); $type = 'updated'; } bp_core_add_admin_notice($notice, $type); } }
/** * Catch requests to mark individual users as spam/ham from users.php. * * @since 2.0.0 */ function bp_core_admin_user_manage_spammers() { // Print our inline scripts on non-Multisite. add_action('admin_footer', 'bp_core_admin_user_spammed_js'); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false; $updated = isset($_REQUEST['updated']) ? $_REQUEST['updated'] : false; $mode = isset($_POST['mode']) ? $_POST['mode'] : false; // If this is a multisite, bulk request, stop now! if ('list' == $mode) { return; } // Process a spam/ham request. if (!empty($action) && in_array($action, array('spam', 'ham'))) { check_admin_referer('bp-spam-user'); $user_id = !empty($_REQUEST['user']) ? intval($_REQUEST['user']) : false; if (empty($user_id)) { return; } $redirect = wp_get_referer(); $status = $action == 'spam' ? 'spam' : 'ham'; // Process the user. bp_core_process_spammer_status($user_id, $status); $redirect = add_query_arg(array('updated' => 'marked-' . $status), $redirect); wp_redirect($redirect); } // Display feedback. if (!empty($updated) && in_array($updated, array('marked-spam', 'marked-ham'))) { if ('marked-spam' === $updated) { $notice = __('User marked as spammer. Spam users are visible only to site admins.', 'buddypress'); } else { $notice = __('User removed from spam.', 'buddypress'); } bp_core_add_admin_notice($notice); } }
/** * Verify that some BP prerequisites are set up properly, and notify the admin if not * * On every Dashboard page, this function checks the following: * - that pretty permalinks are enabled * - that every BP component that needs a WP page for a directory has one * - that no WP page has multiple BP components associated with it * The administrator will be shown a notice for each check that fails. * * @global WPDB $wpdb WordPress DB object * @global WP_Rewrite $wp_rewrite * @since BuddyPress (1.2) */ function bp_core_activation_notice() { global $wpdb, $wp_rewrite; $bp = buddypress(); // Only the super admin gets warnings if (!bp_current_user_can('bp_moderate')) { return; } // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) { return; } /** * Check to make sure that the blog setup routine has run. This can't happen during the * wizard because of the order which the components are loaded. We check for multisite here * on the off chance that someone has activated the blogs component and then disabled MS */ if (bp_is_active('blogs')) { $count = $wpdb->get_var("SELECT COUNT(*) FROM {$bp->blogs->table_name}"); if (empty($count)) { bp_blogs_record_existing_blogs(); } } /** * Are pretty permalinks enabled? */ if (isset($_POST['permalink_structure'])) { return; } if (empty($wp_rewrite->permalink_structure)) { bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php'))); } /** * Check for orphaned BP components (BP component is enabled, no WP page exists) */ $orphaned_components = array(); $wp_page_components = array(); // Only components with 'has_directory' require a WP page to function foreach (array_keys($bp->loaded_components) as $component_id) { if (!empty($bp->{$component_id}->has_directory)) { $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id)); } } // Activate and Register are special cases. They are not components but they need WP pages. // If user registration is disabled, we can skip this step. if (bp_get_signup_allowed()) { $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress')); $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress')); } // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message. if (empty($bp->pages->members)) { $bp->pages = bp_core_get_directory_pages(); } foreach ($wp_page_components as $component) { if (!isset($bp->pages->{$component['id']})) { $orphaned_components[] = $component['name']; } } // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is // not correctly set up, don't show a nag. (In these cases, it's probably the case that the // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292 if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) { $forum_key = array_search($bp->forums->name, $orphaned_components); unset($orphaned_components[$forum_key]); $orphaned_components = array_values($orphaned_components); } if (!empty($orphaned_components)) { $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php')); $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>'); bp_core_add_admin_notice($notice); } // BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found. $dupe_names = array(); $page_ids = (array) bp_core_get_directory_page_ids(); $dupes = array_diff_assoc($page_ids, array_unique($page_ids)); if (!empty($dupes)) { foreach (array_keys($dupes) as $dupe_component) { $dupe_names[] = $bp->pages->{$dupe_component}->title; } // Make sure that there are no duplicate duplicates :) $dupe_names = array_unique($dupe_names); } // If there are duplicates, post a message about them if (!empty($dupe_names)) { $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php')); $notice = sprintf(__('Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $dupe_names) . '</strong>'); bp_core_add_admin_notice($notice); } }
/** * Verify that some BP prerequisites are set up properly, and notify the admin if not * * On every Dashboard page, this function checks the following: * - that pretty permalinks are enabled * - that a BP-compatible theme is activated * - that every BP component that needs a WP page for a directory has one * - that no WP page has multiple BP components associated with it * The administrator will be shown a notice for each check that fails. * * @package BuddyPress Core */ function bp_core_activation_notice() { global $wp_rewrite, $wpdb, $bp; // Only the super admin gets warnings if (!bp_current_user_can('bp_moderate')) { return; } // On multisite installs, don't load on a non-root blog, unless do_network_admin is // overridden if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) { return; } // Don't show these messages during setup or upgrade if (!empty($bp->maintenance_mode)) { return; } /** * Check to make sure that the blog setup routine has run. This can't happen during the * wizard because of the order which the components are loaded. We check for multisite here * on the off chance that someone has activated the blogs component and then disabled MS */ if (bp_is_active('blogs')) { $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$bp->blogs->table_name}")); if (empty($count)) { bp_blogs_record_existing_blogs(); } } /** * Are pretty permalinks enabled? */ if (isset($_POST['permalink_structure'])) { return false; } if (empty($wp_rewrite->permalink_structure)) { bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php'))); } /** * Are you using a BP-compatible theme? */ // Get current theme info $ct = wp_get_theme(); // Make sure tags is an array to suppress notices if (!isset($ct->tags)) { $ct->tags = array(); } else { $ct->tags = (array) $ct->tags; } // The best way to remove this notice is to add a "buddypress" tag to // your active theme's CSS header. if (!defined('BP_SILENCE_THEME_NOTICE') && !in_array('buddypress', $ct->tags)) { bp_core_add_admin_notice(sprintf(__("You'll need to <a href='%s'>activate a <strong>BuddyPress-compatible theme</strong></a> to take advantage of all of BuddyPress's features. We've bundled a default theme, but you can always <a href='%s'>install some other compatible themes</a> or <a href='%s'>update your existing WordPress theme</a>.", 'buddypress'), admin_url('themes.php'), network_admin_url('theme-install.php?type=tag&s=buddypress&tab=search'), network_admin_url('plugin-install.php?type=term&tab=search&s=%22bp-template-pack%22'))); } /** * Check for orphaned BP components (BP component is enabled, no WP page exists) */ $orphaned_components = array(); $wp_page_components = array(); // Only components with 'has_directory' require a WP page to function foreach ($bp->loaded_components as $component_id => $is_active) { if (!empty($bp->{$component_id}->has_directory)) { $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id)); } } // Activate and Register are special cases. They are not components but they need WP pages. // If user registration is disabled, we can skip this step. if (bp_get_signup_allowed()) { $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress')); $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress')); } foreach ($wp_page_components as $component) { if (!isset($bp->pages->{$component['id']})) { $orphaned_components[] = $component['name']; } } // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is // not correctly set up, don't show a nag. (In these cases, it's probably the case that the // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292 if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) { $forum_key = array_search($bp->forums->name, $orphaned_components); unset($orphaned_components[$forum_key]); $orphaned_components = array_values($orphaned_components); } if (!empty($orphaned_components)) { $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php')); $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>'); bp_core_add_admin_notice($notice); } /** * BP components cannot share a single WP page. Check for duplicate assignments, and post * a message if found. */ $dupe_names = array(); $page_ids = (array) bp_core_get_directory_page_ids(); $dupes = array_diff_assoc($page_ids, array_unique($page_ids)); if (!empty($dupes)) { foreach ($dupes as $dupe_component => $dupe_id) { $dupe_names[] = $bp->pages->{$dupe_component}->title; } // Make sure that there are no duplicate duplicates :) $dupe_names = array_unique($dupe_names); } // If there are duplicates, post a message about them if (!empty($dupe_names)) { $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php')); $notice = sprintf(__('Each BuddyPress Component needs its own WordPress page. The following WordPress Pages have more than one component associated with them: %2$s. <a href="%1$s" class="button-secondary">Repair</a>', 'buddypress'), $admin_url, '<strong>' . implode('</strong>, <strong>', $dupe_names) . '</strong>'); bp_core_add_admin_notice($notice); } }
/** * Creates the upload dir and htaccess file * * @uses buddydrive_get_upload_data() to get BuddyDrive upload datas * @uses wp_mkdir_p() to create the dir * @uses insert_with_markers() to create the htaccess file */ public function activation_notice() { // we need to eventually create the upload dir and the .htaccess file $buddydrive_upload = buddydrive_get_upload_data(); if (empty($buddydrive_upload['dir']) || !file_exists($buddydrive_upload['dir'])) { bp_core_add_admin_notice(__('The main BuddyDrive directory is missing', 'buddydrive')); } }