/** * Handle the processing and feedback of the admin tools page. * * @since BuddyPress (2.0.0) */ function bp_admin_repair_handler() { if (!bp_is_post_request()) { return; } if (empty($_POST['bp-tools-submit'])) { return; } check_admin_referer('bp-do-counts'); // Stores messages $messages = array(); wp_cache_flush(); foreach ((array) bp_admin_repair_list() as $item) { if (isset($item[2]) && isset($_POST[$item[0]]) && 1 === absint($_POST[$item[0]]) && is_callable($item[2])) { $messages[] = call_user_func($item[2]); } } if (count($messages)) { foreach ($messages as $message) { bp_admin_tools_feedback($message[1]); } } }
/** * Handle the processing and feedback of the admin tools page. * * @since 2.0.0 */ function bp_admin_repair_handler() { if (!bp_is_post_request() || empty($_POST['bp-tools-submit'])) { return; } check_admin_referer('bp-do-counts'); // Bail if user cannot moderate. $capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options'; if (!bp_current_user_can($capability)) { return; } wp_cache_flush(); $messages = array(); foreach ((array) bp_admin_repair_list() as $item) { if (isset($item[2]) && isset($_POST[$item[0]]) && 1 === absint($_POST[$item[0]]) && is_callable($item[2])) { $messages[] = call_user_func($item[2]); } } if (count($messages)) { foreach ($messages as $message) { bp_admin_tools_feedback($message[1]); } } }
/** * Handle creating of private messages or sitewide notices * * @since BuddyPress (2.4.0) This function was split from messages_screen_compose(). See #6505. * * @return boolean */ function bp_messages_action_create_message() { // Bail if not posting to the compose message screen if (!bp_is_post_request() || !bp_is_messages_component() || !bp_is_current_action('compose')) { return false; } // Check the nonce check_admin_referer('messages_send_message'); // Define local variables $redirect_to = ''; $feedback = ''; $success = false; // Missing subject or content if (empty($_POST['subject']) || empty($_POST['content'])) { $success = false; if (empty($_POST['subject'])) { $feedback = __('Your message was not sent. Please enter a subject line.', 'buddypress'); } else { $feedback = __('Your message was not sent. Please enter some content.', 'buddypress'); } // Subject and content present } else { // Setup the link to the logged-in user's messages $member_messages = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug()); // Site-wide notice if (isset($_POST['send-notice'])) { // Attempt to save the notice and redirect to notices if (messages_send_notice($_POST['subject'], $_POST['content'])) { $success = true; $feedback = __('Notice successfully created.', 'buddypress'); $redirect_to = trailingslashit($member_messages . 'notices'); // Notice could not be sent } else { $success = false; $feedback = __('Notice was not created. Please try again.', 'buddypress'); } // Private conversation } else { // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) $autocomplete_recipients = (array) explode(',', $_POST['send-to-input']); $typed_recipients = (array) explode(' ', $_POST['send_to_usernames']); $recipients = array_merge($autocomplete_recipients, $typed_recipients); /** * Filters the array of recipients to receive the composed message. * * @since BuddyPress (1.2.10) * * @param array $recipients Array of recipients to receive message. */ $recipients = apply_filters('bp_messages_recipients', $recipients); // Attempt to send the message $thread_id = messages_new_message(array('recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'])); // Send the message and redirect to it if (!empty($thread_id)) { $success = true; $feedback = __('Message successfully sent.', 'buddypress'); $view = trailingslashit($member_messages . 'view'); $redirect_to = trailingslashit($view . $thread_id); // Message could not be sent } else { $success = false; $feedback = __('Message was not sent. Please try again.', 'buddypress'); } } } // Feedback if (!empty($feedback)) { // Determine message type $type = true === $success ? 'success' : 'error'; // Add feedback message bp_core_add_message($feedback, $type); } // Maybe redirect if (!empty($redirect_to)) { bp_core_redirect($redirect_to); } }
/** * The main action used for handling theme-side POST requests * * @since BuddyPress (1.9.0) * @uses do_action() */ function bp_post_request() { // Bail if not a POST action if (!bp_is_post_request()) { return; } // Bail if no action if (empty($_POST['action'])) { return; } // This dynamic action is probably the one you want to use. It narrows down // the scope of the 'action' without needing to check it in your function. do_action('bp_post_request_' . $_POST['action']); // Use this static action if you don't mind checking the 'action' yourself. do_action('bp_post_request', $_POST['action']); }
/** * The main action used for handling theme-side POST requests * * @since BuddyPress (1.9.0) * @uses do_action() */ function bp_post_request() { // Bail if not a POST action if (!bp_is_post_request()) { return; } // Bail if no action if (empty($_POST['action'])) { return; } // Sanitize the POST action $action = sanitize_key($_POST['action']); /** * Fires at the end of the bp_post_request function. * * This dynamic action is probably the one you want to use. It narrows down * the scope of the 'action' without needing to check it in your function. * * @since BuddyPress (1.9.0) */ do_action('bp_post_request_' . $action); /** * Fires at the end of the bp_post_request function. * * Use this static action if you don't mind checking the 'action' yourself. * * @since BuddyPress (1.9.0) * * @param string $action The action being run. */ do_action('bp_post_request', $action); }