/** * Return the value of reply to field * * @since bbPress (r4944) * * @uses bbp_get_reply_id() To validate the reply to * @uses apply_filters() Calls 'bbp_get_form_reply_to' with the reply to * @return string Value of reply to field */ function bbp_get_form_reply_to() { // Set initial value $reply_to = 0; // Get $_REQUEST data if (isset($_REQUEST['bbp_reply_to'])) { $reply_to = (int) $_REQUEST['bbp_reply_to']; } // If empty, get from meta if (empty($reply_to)) { $reply_to = bbp_get_reply_to(); } // Validate $reply_to = bbp_get_reply_id($reply_to); return (int) apply_filters('bbp_get_form_reply_to', $reply_to); }
/** * Split topic handler * * Handles the front end split topic submission * * @since bbPress (r2756) * * @param string $action The requested action to compare this function to * @uses bbp_add_error() To add an error message * @uses bbp_get_reply() To get the reply * @uses bbp_get_topic() To get the topics * @uses bbp_verify_nonce_request() To verify the nonce and check the request * @uses current_user_can() To check if the current user can edit the topics * @uses bbp_get_topic_post_type() To get the topic post type * @uses is_wp_error() To check if the value retrieved is a {@link WP_Error} * @uses do_action() Calls 'bbp_pre_split_topic' with the from reply id, source * and destination topic ids * @uses bbp_get_topic_subscribers() To get the source topic subscribers * @uses bbp_add_user_subscription() To add the user subscription * @uses bbp_get_topic_favoriters() To get the source topic favoriters * @uses bbp_add_user_favorite() To add the user favorite * @uses wp_get_post_terms() To get the source topic tags * @uses wp_set_post_terms() To set the topic tags * @uses bbp_get_reply_post_type() To get the reply post type * @uses wpdb::prepare() To prepare our sql query * @uses wpdb::get_results() To execute the sql query and get results * @uses wp_update_post() To update the replies * @uses bbp_update_reply_topic_id() To update the reply topic id * @uses bbp_get_topic_forum_id() To get the topic forum id * @uses bbp_update_reply_forum_id() To update the reply forum id * @uses do_action() Calls 'bbp_split_topic_reply' with the reply id and * destination topic id * @uses bbp_update_topic_last_reply_id() To update the topic last reply id * @uses bbp_update_topic_last_active_time() To update the topic last active meta * @uses do_action() Calls 'bbp_post_split_topic' with the destination and * source topic ids and source topic's forum id * @uses bbp_get_topic_permalink() To get the topic permalink * @uses wp_safe_redirect() To redirect to the topic link */ function bbp_split_topic_handler($action = '') { // Bail if action is not 'bbp-split-topic' if ('bbp-split-topic' !== $action) { return; } global $wpdb; // Prevent debug notices $from_reply_id = $destination_topic_id = 0; $destination_topic_title = ''; $destination_topic = $from_reply = $source_topic = ''; $split_option = false; /** Split Reply ***********************************************************/ if (empty($_POST['bbp_reply_id'])) { bbp_add_error('bbp_split_topic_reply_id', __('<strong>ERROR</strong>: Reply ID to split the topic from not found!', 'bbpress')); } else { $from_reply_id = (int) $_POST['bbp_reply_id']; } $from_reply = bbp_get_reply($from_reply_id); // Reply exists if (empty($from_reply)) { bbp_add_error('bbp_split_topic_r_not_found', __('<strong>ERROR</strong>: The reply you want to split from was not found.', 'bbpress')); } /** Topic to Split ********************************************************/ // Get the topic being split $source_topic = bbp_get_topic($from_reply->post_parent); // No topic if (empty($source_topic)) { bbp_add_error('bbp_split_topic_source_not_found', __('<strong>ERROR</strong>: The topic you want to split was not found.', 'bbpress')); } // Nonce check failed if (!bbp_verify_nonce_request('bbp-split-topic_' . $source_topic->ID)) { bbp_add_error('bbp_split_topic_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress')); return; } // Use cannot edit topic if (!current_user_can('edit_topic', $source_topic->ID)) { bbp_add_error('bbp_split_topic_source_permission', __('<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress')); } // How to Split if (!empty($_POST['bbp_topic_split_option'])) { $split_option = (string) trim($_POST['bbp_topic_split_option']); } // Invalid split option if (empty($split_option) || !in_array($split_option, array('existing', 'reply'))) { bbp_add_error('bbp_split_topic_option', __('<strong>ERROR</strong>: You need to choose a valid split option.', 'bbpress')); // Valid Split Option } else { // What kind of split switch ($split_option) { // Into an existing topic case 'existing': // Get destination topic id if (empty($_POST['bbp_destination_topic'])) { bbp_add_error('bbp_split_topic_destination_id', __('<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress')); } else { $destination_topic_id = (int) $_POST['bbp_destination_topic']; } // Get the destination topic $destination_topic = bbp_get_topic($destination_topic_id); // No destination topic if (empty($destination_topic)) { bbp_add_error('bbp_split_topic_destination_not_found', __('<strong>ERROR</strong>: The topic you want to split to was not found!', 'bbpress')); } // User cannot edit the destination topic if (!current_user_can('edit_topic', $destination_topic->ID)) { bbp_add_error('bbp_split_topic_destination_permission', __('<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress')); } break; // Split at reply into a new topic // Split at reply into a new topic case 'reply': default: // User needs to be able to publish topics if (current_user_can('publish_topics')) { // Use the new title that was passed if (!empty($_POST['bbp_topic_split_destination_title'])) { $destination_topic_title = esc_attr(strip_tags($_POST['bbp_topic_split_destination_title'])); // Use the source topic title } else { $destination_topic_title = $source_topic->post_title; } // Update the topic $destination_topic_id = wp_update_post(array('ID' => $from_reply->ID, 'post_title' => $destination_topic_title, 'post_name' => false, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $source_topic->post_parent, 'menu_order' => 0, 'guid' => '')); $destination_topic = bbp_get_topic($destination_topic_id); // Make sure the new topic knows its a topic bbp_update_topic_topic_id($from_reply->ID); // Shouldn't happen if (false === $destination_topic_id || is_wp_error($destination_topic_id) || empty($destination_topic)) { bbp_add_error('bbp_split_topic_destination_reply', __('<strong>ERROR</strong>: There was a problem converting the reply into the topic. Please try again.', 'bbpress')); } // User cannot publish posts } else { bbp_add_error('bbp_split_topic_destination_permission', __('<strong>ERROR</strong>: You do not have the permissions to create new topics. The reply could not be converted into a topic.', 'bbpress')); } break; } } // Bail if there are errors if (bbp_has_errors()) { return; } /** No Errors - Do the Spit ***********************************************/ // Update counts, etc... do_action('bbp_pre_split_topic', $from_reply->ID, $source_topic->ID, $destination_topic->ID); /** Date Check ************************************************************/ // Check if the destination topic is older than the from reply if (strtotime($from_reply->post_date) < strtotime($destination_topic->post_date)) { // Set destination topic post_date to 1 second before from reply $destination_post_date = date('Y-m-d H:i:s', strtotime($from_reply->post_date) - 1); // Update destination topic wp_update_post(array('ID' => $destination_topic_id, 'post_date' => $destination_post_date, 'post_date_gmt' => get_gmt_from_date($destination_post_date))); } /** Subscriptions *********************************************************/ // Copy the subscribers if (!empty($_POST['bbp_topic_subscribers']) && "1" === $_POST['bbp_topic_subscribers'] && bbp_is_subscriptions_active()) { // Get the subscribers $subscribers = bbp_get_topic_subscribers($source_topic->ID); if (!empty($subscribers)) { // Add subscribers to new topic foreach ((array) $subscribers as $subscriber) { bbp_add_user_subscription($subscriber, $destination_topic->ID); } } } /** Favorites *************************************************************/ // Copy the favoriters if told to if (!empty($_POST['bbp_topic_favoriters']) && "1" === $_POST['bbp_topic_favoriters']) { // Get the favoriters $favoriters = bbp_get_topic_favoriters($source_topic->ID); if (!empty($favoriters)) { // Add the favoriters to new topic foreach ((array) $favoriters as $favoriter) { bbp_add_user_favorite($favoriter, $destination_topic->ID); } } } /** Tags ******************************************************************/ // Copy the tags if told to if (!empty($_POST['bbp_topic_tags']) && "1" === $_POST['bbp_topic_tags']) { // Get the source topic tags $source_topic_tags = wp_get_post_terms($source_topic->ID, bbp_get_topic_tag_tax_id(), array('fields' => 'names')); if (!empty($source_topic_tags)) { wp_set_post_terms($destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true); } } /** Split Replies *********************************************************/ // get_posts() is not used because it doesn't allow us to use '>=' // comparision without a filter. $replies = (array) $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_date >= %s AND {$wpdb->posts}.post_parent = %d AND {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.post_date ASC", $from_reply->post_date, $source_topic->ID, bbp_get_reply_post_type())); // Make sure there are replies to loop through if (!empty($replies) && !is_wp_error($replies)) { // Calculate starting point for reply positions switch ($split_option) { // Get topic reply count for existing topic case 'existing': $reply_position = bbp_get_topic_reply_count($destination_topic->ID); break; // Account for new lead topic // Account for new lead topic case 'reply': $reply_position = 1; break; } // Save reply ids $reply_ids = array(); // Change the post_parent of each reply to the destination topic id foreach ($replies as $reply) { // Bump the reply position each iteration through the loop $reply_position++; // Update the reply wp_update_post(array('ID' => $reply->ID, 'post_title' => sprintf(__('Reply To: %s', 'bbpress'), $destination_topic->post_title), 'post_name' => false, 'post_parent' => $destination_topic->ID, 'menu_order' => $reply_position, 'guid' => '')); // Gather reply ids $reply_ids[] = $reply->ID; // Adjust reply meta values bbp_update_reply_topic_id($reply->ID, $destination_topic->ID); bbp_update_reply_forum_id($reply->ID, bbp_get_topic_forum_id($destination_topic->ID)); // Adjust reply to values $reply_to = bbp_get_reply_to($reply->ID); // Not a reply to a reply that moved over if (!in_array($reply_to, $reply_ids)) { bbp_update_reply_to($reply->ID, 0); } // New topic from reply can't be a reply to if ($from_reply->ID === $destination_topic->ID && $from_reply->ID === $reply_to) { bbp_update_reply_to($reply->ID, 0); } // Do additional actions per split reply do_action('bbp_split_topic_reply', $reply->ID, $destination_topic->ID); } // Remove reply to from new topic if ($from_reply->ID === $destination_topic->ID) { delete_post_meta($from_reply->ID, '_bbp_reply_to'); } // Set the last reply ID and freshness $last_reply_id = $reply->ID; $freshness = $reply->post_date; // Set the last reply ID and freshness to the from_reply } else { $last_reply_id = $from_reply->ID; $freshness = $from_reply->post_date; } // It is a new topic and we need to set some default metas to make // the topic display in bbp_has_topics() list if ('reply' === $split_option) { bbp_update_topic_last_reply_id($destination_topic->ID, $last_reply_id); bbp_update_topic_last_active_id($destination_topic->ID, $last_reply_id); bbp_update_topic_last_active_time($destination_topic->ID, $freshness); } // Update source topic ID last active bbp_update_topic_last_reply_id($source_topic->ID); bbp_update_topic_last_active_id($source_topic->ID); bbp_update_topic_last_active_time($source_topic->ID); /** Successful Split ******************************************************/ // Update counts, etc... do_action('bbp_post_split_topic', $from_reply->ID, $source_topic->ID, $destination_topic->ID); // Redirect back to the topic wp_safe_redirect(bbp_get_topic_permalink($destination_topic->ID)); // For good measure exit; }
/** * Move reply handler * * Handles the front end move reply submission * * @since bbPress (r4521) * * @param string $action The requested action to compare this function to * @uses bbp_add_error() To add an error message * @uses bbp_get_reply() To get the reply * @uses bbp_get_topic() To get the topics * @uses bbp_verify_nonce_request() To verify the nonce and check the request * @uses current_user_can() To check if the current user can edit the reply and topics * @uses bbp_get_topic_post_type() To get the topic post type * @uses is_wp_error() To check if the value retrieved is a {@link WP_Error} * @uses do_action() Calls 'bbp_pre_move_reply' with the from reply id, source * and destination topic ids * @uses bbp_get_reply_post_type() To get the reply post type * @uses wpdb::prepare() To prepare our sql query * @uses wpdb::get_results() To execute the sql query and get results * @uses wp_update_post() To update the replies * @uses bbp_update_reply_topic_id() To update the reply topic id * @uses bbp_get_topic_forum_id() To get the topic forum id * @uses bbp_update_reply_forum_id() To update the reply forum id * @uses do_action() Calls 'bbp_split_topic_reply' with the reply id and * destination topic id * @uses bbp_update_topic_last_reply_id() To update the topic last reply id * @uses bbp_update_topic_last_active_time() To update the topic last active meta * @uses do_action() Calls 'bbp_post_split_topic' with the destination and * source topic ids and source topic's forum id * @uses bbp_get_topic_permalink() To get the topic permalink * @uses wp_safe_redirect() To redirect to the topic link */ function bbp_move_reply_handler($action = '') { // Bail if action is not 'bbp-move-reply' if ('bbp-move-reply' !== $action) { return; } // Prevent debug notices $move_reply_id = $destination_topic_id = 0; $destination_topic_title = ''; $destination_topic = $move_reply = $source_topic = ''; /** Move Reply ***********************************************************/ if (empty($_POST['bbp_reply_id'])) { bbp_add_error('bbp_move_reply_reply_id', __('<strong>ERROR</strong>: Reply ID to move not found!', 'bbpress')); } else { $move_reply_id = (int) $_POST['bbp_reply_id']; } $move_reply = bbp_get_reply($move_reply_id); // Reply exists if (empty($move_reply)) { bbp_add_error('bbp_mover_reply_r_not_found', __('<strong>ERROR</strong>: The reply you want to move was not found.', 'bbpress')); } /** Topic to Move From ***************************************************/ // Get the reply's current topic $source_topic = bbp_get_topic($move_reply->post_parent); // No topic if (empty($source_topic)) { bbp_add_error('bbp_move_reply_source_not_found', __('<strong>ERROR</strong>: The topic you want to move from was not found.', 'bbpress')); } // Nonce check failed if (!bbp_verify_nonce_request('bbp-move-reply_' . $move_reply->ID)) { bbp_add_error('bbp_move_reply_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress')); return; } // Use cannot edit topic if (!current_user_can('edit_topic', $source_topic->ID)) { bbp_add_error('bbp_move_reply_source_permission', __('<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress')); } // How to move if (!empty($_POST['bbp_reply_move_option'])) { $move_option = (string) trim($_POST['bbp_reply_move_option']); } // Invalid move option if (empty($move_option) || !in_array($move_option, array('existing', 'topic'))) { bbp_add_error('bbp_move_reply_option', __('<strong>ERROR</strong>: You need to choose a valid move option.', 'bbpress')); // Valid move option } else { // What kind of move switch ($move_option) { // Into an existing topic case 'existing': // Get destination topic id if (empty($_POST['bbp_destination_topic'])) { bbp_add_error('bbp_move_reply_destination_id', __('<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress')); } else { $destination_topic_id = (int) $_POST['bbp_destination_topic']; } // Get the destination topic $destination_topic = bbp_get_topic($destination_topic_id); // No destination topic if (empty($destination_topic)) { bbp_add_error('bbp_move_reply_destination_not_found', __('<strong>ERROR</strong>: The topic you want to move to was not found!', 'bbpress')); } // User cannot edit the destination topic if (!current_user_can('edit_topic', $destination_topic->ID)) { bbp_add_error('bbp_move_reply_destination_permission', __('<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress')); } // Bump the reply position $reply_position = bbp_get_topic_reply_count($destination_topic->ID) + 1; // Update the reply wp_update_post(array('ID' => $move_reply->ID, 'post_title' => sprintf(__('Reply To: %s', 'bbpress'), $destination_topic->post_title), 'post_name' => false, 'post_parent' => $destination_topic->ID, 'menu_order' => $reply_position, 'guid' => '')); // Adjust reply meta values bbp_update_reply_topic_id($move_reply->ID, $destination_topic->ID); bbp_update_reply_forum_id($move_reply->ID, bbp_get_topic_forum_id($destination_topic->ID)); break; // Move reply to a new topic // Move reply to a new topic case 'topic': default: // User needs to be able to publish topics if (current_user_can('publish_topics')) { // Use the new title that was passed if (!empty($_POST['bbp_reply_move_destination_title'])) { $destination_topic_title = esc_attr(strip_tags($_POST['bbp_reply_move_destination_title'])); // Use the source topic title } else { $destination_topic_title = $source_topic->post_title; } // Update the topic $destination_topic_id = wp_update_post(array('ID' => $move_reply->ID, 'post_title' => $destination_topic_title, 'post_name' => false, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $source_topic->post_parent, 'guid' => '')); $destination_topic = bbp_get_topic($destination_topic_id); // Make sure the new topic knows its a topic bbp_update_topic_topic_id($move_reply->ID); // Shouldn't happen if (false === $destination_topic_id || is_wp_error($destination_topic_id) || empty($destination_topic)) { bbp_add_error('bbp_move_reply_destination_reply', __('<strong>ERROR</strong>: There was a problem converting the reply into the topic. Please try again.', 'bbpress')); } // User cannot publish posts } else { bbp_add_error('bbp_move_reply_destination_permission', __('<strong>ERROR</strong>: You do not have the permissions to create new topics. The reply could not be converted into a topic.', 'bbpress')); } break; } } // Bail if there are errors if (bbp_has_errors()) { return; } /** No Errors - Clean Up **************************************************/ // Update counts, etc... do_action('bbp_pre_move_reply', $move_reply->ID, $source_topic->ID, $destination_topic->ID); /** Date Check ************************************************************/ // Check if the destination topic is older than the move reply if (strtotime($move_reply->post_date) < strtotime($destination_topic->post_date)) { // Set destination topic post_date to 1 second before from reply $destination_post_date = date('Y-m-d H:i:s', strtotime($move_reply->post_date) - 1); // Update destination topic wp_update_post(array('ID' => $destination_topic_id, 'post_date' => $destination_post_date, 'post_date_gmt' => get_gmt_from_date($destination_post_date))); } // Set the last reply ID and freshness to the move_reply $last_reply_id = $move_reply->ID; $freshness = $move_reply->post_date; // Get the reply to $parent = bbp_get_reply_to($move_reply->ID); // Fix orphaned children $children = get_posts(array('post_type' => bbp_get_reply_post_type(), 'meta_key' => '_bbp_reply_to', 'meta_value' => $move_reply->ID)); foreach ($children as $child) { bbp_update_reply_to($child->ID, $parent); } // Remove reply_to from moved reply delete_post_meta($move_reply->ID, '_bbp_reply_to'); // It is a new topic and we need to set some default metas to make // the topic display in bbp_has_topics() list if ('topic' === $move_option) { bbp_update_topic_last_reply_id($destination_topic->ID, $last_reply_id); bbp_update_topic_last_active_id($destination_topic->ID, $last_reply_id); bbp_update_topic_last_active_time($destination_topic->ID, $freshness); // Otherwise update the existing destination topic } else { bbp_update_topic_last_reply_id($destination_topic->ID); bbp_update_topic_last_active_id($destination_topic->ID); bbp_update_topic_last_active_time($destination_topic->ID); } // Update source topic ID last active bbp_update_topic_last_reply_id($source_topic->ID); bbp_update_topic_last_active_id($source_topic->ID); bbp_update_topic_last_active_time($source_topic->ID); /** Successful Move ******************************************************/ // Update counts, etc... do_action('bbp_post_move_reply', $move_reply->ID, $source_topic->ID, $destination_topic->ID); // Redirect back to the topic wp_safe_redirect(bbp_get_topic_permalink($destination_topic->ID)); // For good measure exit; }
/** * Return a select box allowing to pick which topic/reply a reply belongs. * * @since 2.6.0 bbPress (r5387) * * @param int $reply_id * * @uses BBP_Reply_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_reply_id() To get the reply ID * @uses bbp_get_reply_to() To get the reply to ID * @uses bbp_get_reply_topic_id() To get the replies topic ID * @uses bbp_get_reply_post_type() To get the reply post type * @uses bbp_get_public_status_id() To get the reply status * @uses bbp_thread_replies_depth() To get the threaded replies depth * * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown * and args * @return string The dropdown */ function bbp_get_reply_to_dropdown($reply_id = 0) { // Validate the reply data $reply_id = bbp_get_reply_id($reply_id); $reply_to = bbp_get_reply_to($reply_id); $topic_id = bbp_get_reply_topic_id($reply_id); // Get the replies $posts = get_posts(array('post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'post_parent' => $topic_id, 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); // Append `reply_to` for each reply so it can be walked foreach ($posts as &$post) { // Check for reply post type $_reply_to = bbp_get_reply_to($post->ID); // Make sure it's a reply to a reply if (empty($_reply_to) || $topic_id === $_reply_to) { $_reply_to = 0; } // Add reply_to to the post object so we can walk it later $post->reply_to = $_reply_to; } // Get the dropdown and return it $retval = bbp_get_dropdown(array('show_none' => sprintf(esc_attr__('%1$s - %2$s', 'bbpress'), $topic_id, bbp_get_topic_title($topic_id)), 'select_id' => 'bbp_reply_to', 'select_class' => 'bbp_dropdown', 'exclude' => $reply_id, 'selected' => $reply_to, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'max_depth' => bbp_thread_replies_depth(), 'page' => 1, 'per_page' => -1, 'walker' => new BBP_Walker_Reply_Dropdown(), 'posts' => $posts)); // Filter and return return apply_filters('bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id); }
/** * Reply metabox * * The metabox that holds all of the additional reply information * * @since bbPress (r2464) * * @uses bbp_get_topic_post_type() To get the topic post type * @uses do_action() Calls 'bbp_reply_metabox' */ function bbp_reply_metabox() { // Post ID $post_id = get_the_ID(); // Get some meta $reply_topic_id = bbp_get_reply_topic_id($post_id); $reply_forum_id = bbp_get_reply_forum_id($post_id); $reply_to = bbp_get_reply_to($post_id); // Allow individual manipulation of reply forum if (current_user_can('edit_others_replies') || current_user_can('moderate')) { ?> <p> <strong class="label"><?php esc_html_e('Forum:', 'bbpress'); ?> </strong> <label class="screen-reader-text" for="bbp_forum_id"><?php esc_html_e('Forum', 'bbpress'); ?> </label> <?php bbp_dropdown(array('post_type' => bbp_get_forum_post_type(), 'selected' => $reply_forum_id, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'walker' => '', 'exclude' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => __('— No parent —', 'bbpress'), 'disable_categories' => current_user_can('edit_forums'), 'disabled' => '')); ?> </p> <?php } ?> <p> <strong class="label"><?php esc_html_e('Topic:', 'bbpress'); ?> </strong> <label class="screen-reader-text" for="parent_id"><?php esc_html_e('Topic', 'bbpress'); ?> </label> <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr($reply_topic_id); ?> " /> </p> <p> <strong class="label"><?php esc_html_e('Reply To:', 'bbpress'); ?> </strong> <label class="screen-reader-text" for="bbp_reply_to"><?php esc_html_e('Reply To', 'bbpress'); ?> </label> <input name="bbp_reply_to" id="bbp_reply_to" type="text" value="<?php echo esc_attr($reply_to); ?> " /> </p> <input name="ping_status" type="hidden" id="ping_status" value="open" /> <?php wp_nonce_field('bbp_reply_metabox_save', 'bbp_reply_metabox'); do_action('bbp_reply_metabox', $post_id); }
/** * @covers ::bbp_reply_to * @covers ::bbp_get_reply_to */ public function test_bbp_get_reply_to() { $f = $this->factory->forum->create(); $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f))); $r1 = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t))); $r2 = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t, 'reply_to' => $r1))); $reply_to = bbp_get_reply_to($r2); $this->assertSame($r1, $reply_to); }
/** * Register support for GES with RBE. * * Since other GES plugins like BP Multiple Forum Post works by delaying GES * email sending to remove duplicate emails {@see bpmfp_interrupt_original_activity_notification()}, * we need to let RBE's listener know about it. * * @since 1.0-RC4 * * @param BP_Reply_By_Email $rbe */ public function ges_extend_listener($rbe) { // We've already done this, so stop! // @todo Remove this once we're ready to drop extend_activity_listener(). if (isset($rbe->listener) && $this->id === $rbe->listener->component) { return; } // If activity type does not match our bbPress types, stop now! if ($this->temp_activity->type != $this->activity_type && $this->temp_activity->type != 'bbp_topic_create') { return; } $rbe->listener->component = $this->id; $rbe->listener->item_id = $this->temp_activity->item_id; $rbe->listener->secondary_item_id = $this->temp_activity->secondary_item_id; $rbe->listener->reply_to_id = $this->temp_activity->secondary_item_id; $rbe->listener->user_id = $this->temp_activity->user_id; // If activity type is a bbPress reply, we need to grab the topic ID manually. if ($this->temp_activity->type === $this->activity_type) { $rbe->listener->secondary_item_id = bbp_get_reply_topic_id($this->temp_activity->secondary_item_id); $rbe->listener->reply_to_id = bbp_get_reply_to($this->temp_activity->secondary_item_id); } }