web/wp-content/plugins/bbpress/includes/admin/replies.php
changeset 196 5e8dcbe22c24
equal deleted inserted replaced
195:c7c0fbc09788 196:5e8dcbe22c24
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * bbPress Replies Admin Class
       
     5  *
       
     6  * @package bbPress
       
     7  * @subpackage Administration
       
     8  */
       
     9 
       
    10 // Exit if accessed directly
       
    11 if ( !defined( 'ABSPATH' ) ) exit;
       
    12 
       
    13 if ( !class_exists( 'BBP_Replies_Admin' ) ) :
       
    14 /**
       
    15  * Loads bbPress replies admin area
       
    16  *
       
    17  * @package bbPress
       
    18  * @subpackage Administration
       
    19  * @since bbPress (r2464)
       
    20  */
       
    21 class BBP_Replies_Admin {
       
    22 
       
    23 	/** Variables *************************************************************/
       
    24 
       
    25 	/**
       
    26 	 * @var The post type of this admin component
       
    27 	 */
       
    28 	private $post_type = '';
       
    29 
       
    30 	/** Functions *************************************************************/
       
    31 
       
    32 	/**
       
    33 	 * The main bbPress admin loader
       
    34 	 *
       
    35 	 * @since bbPress (r2515)
       
    36 	 *
       
    37 	 * @uses BBP_Replies_Admin::setup_globals() Setup the globals needed
       
    38 	 * @uses BBP_Replies_Admin::setup_actions() Setup the hooks and actions
       
    39 	 * @uses BBP_Replies_Admin::setup_actions() Setup the help text
       
    40 	 */
       
    41 	public function __construct() {
       
    42 		$this->setup_globals();
       
    43 		$this->setup_actions();
       
    44 	}
       
    45 
       
    46 	/**
       
    47 	 * Setup the admin hooks, actions and filters
       
    48 	 *
       
    49 	 * @since bbPress (r2646)
       
    50 	 * @access private
       
    51 	 *
       
    52 	 * @uses add_action() To add various actions
       
    53 	 * @uses add_filter() To add various filters
       
    54 	 * @uses bbp_get_forum_post_type() To get the forum post type
       
    55 	 * @uses bbp_get_topic_post_type() To get the topic post type
       
    56 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
    57 	 */
       
    58 	private function setup_actions() {
       
    59 
       
    60 		// Add some general styling to the admin area
       
    61 		add_action( 'bbp_admin_head',        array( $this, 'admin_head'       ) );
       
    62 
       
    63 		// Messages
       
    64 		add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );
       
    65 
       
    66 		// Reply column headers.
       
    67 		add_filter( 'manage_' . $this->post_type . '_posts_columns',  array( $this, 'replies_column_headers' ) );
       
    68 
       
    69 		// Reply columns (in post row)
       
    70 		add_action( 'manage_' . $this->post_type . '_posts_custom_column',  array( $this, 'replies_column_data' ), 10, 2 );
       
    71 		add_filter( 'post_row_actions',                                     array( $this, 'replies_row_actions' ), 10, 2 );
       
    72 
       
    73 		// Reply metabox actions
       
    74 		add_action( 'add_meta_boxes', array( $this, 'reply_attributes_metabox'      ) );
       
    75 		add_action( 'save_post',      array( $this, 'reply_attributes_metabox_save' ) );
       
    76 
       
    77 		// Check if there are any bbp_toggle_reply_* requests on admin_init, also have a message displayed
       
    78 		add_action( 'load-edit.php',  array( $this, 'toggle_reply'        ) );
       
    79 		add_action( 'admin_notices',  array( $this, 'toggle_reply_notice' ) );
       
    80 
       
    81 		// Anonymous metabox actions
       
    82 		add_action( 'add_meta_boxes', array( $this, 'author_metabox'      ) );
       
    83 		add_action( 'save_post',      array( $this, 'author_metabox_save' ) );
       
    84 
       
    85 		// Add ability to filter topics and replies per forum
       
    86 		add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown'  ) );
       
    87 		add_filter( 'bbp_request',           array( $this, 'filter_post_rows' ) );
       
    88 
       
    89 		// Contextual Help
       
    90 		add_action( 'load-edit.php',     array( $this, 'edit_help' ) );
       
    91 		add_action( 'load-post-new.php', array( $this, 'new_help'  ) );
       
    92 	}
       
    93 
       
    94 	/**
       
    95 	 * Should we bail out of this method?
       
    96 	 *
       
    97 	 * @since bbPress (r4067)
       
    98 	 * @return boolean
       
    99 	 */
       
   100 	private function bail() {
       
   101 		if ( !isset( get_current_screen()->post_type ) || ( $this->post_type != get_current_screen()->post_type ) )
       
   102 			return true;
       
   103 
       
   104 		return false;
       
   105 	}
       
   106 
       
   107 	/**
       
   108 	 * Admin globals
       
   109 	 *
       
   110 	 * @since bbPress (r2646)
       
   111 	 * @access private
       
   112 	 */
       
   113 	private function setup_globals() {
       
   114 		$this->post_type = bbp_get_reply_post_type();
       
   115 	}
       
   116 
       
   117 	/** Contextual Help *******************************************************/
       
   118 
       
   119 	/**
       
   120 	 * Contextual help for bbPress reply edit page
       
   121 	 *
       
   122 	 * @since bbPress (r3119)
       
   123 	 * @uses get_current_screen()
       
   124 	 */
       
   125 	public function edit_help() {
       
   126 
       
   127 		if ( $this->bail() ) return;
       
   128 
       
   129 		// Overview
       
   130 		get_current_screen()->add_help_tab( array(
       
   131 			'id'		=> 'overview',
       
   132 			'title'		=> __( 'Overview', 'bbpress' ),
       
   133 			'content'	=>
       
   134 				'<p>' . __( 'This screen provides access to all of your replies. You can customize the display of this screen to suit your workflow.', 'bbpress' ) . '</p>'
       
   135 		) );
       
   136 
       
   137 		// Screen Content
       
   138 		get_current_screen()->add_help_tab( array(
       
   139 			'id'		=> 'screen-content',
       
   140 			'title'		=> __( 'Screen Content', 'bbpress' ),
       
   141 			'content'	=>
       
   142 				'<p>' . __( 'You can customize the display of this screen&#8217;s contents in a number of ways:', 'bbpress' ) . '</p>' .
       
   143 				'<ul>' .
       
   144 					'<li>' . __( 'You can hide/display columns based on your needs and decide how many replies to list per screen using the Screen Options tab.',                                                                                                                                                                          'bbpress' ) . '</li>' .
       
   145 					'<li>' . __( 'You can filter the list of replies by reply status using the text links in the upper left to show All, Published, Draft, or Trashed replies. The default view is to show all replies.',                                                                                                                   'bbpress' ) . '</li>' .
       
   146 					'<li>' . __( 'You can view replies 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.',                                                                                                                                             'bbpress' ) . '</li>' .
       
   147 					'<li>' . __( 'You can refine the list to show only replies in a specific category or from a specific month by using the dropdown menus above the replies list. Click the Filter button after making your selection. You also can refine the list by clicking on the reply author, category or tag in the replies list.', 'bbpress' ) . '</li>' .
       
   148 				'</ul>'
       
   149 		) );
       
   150 
       
   151 		// Available Actions
       
   152 		get_current_screen()->add_help_tab( array(
       
   153 			'id'		=> 'action-links',
       
   154 			'title'		=> __( 'Available Actions', 'bbpress' ),
       
   155 			'content'	=>
       
   156 				'<p>' . __( 'Hovering over a row in the replies list will display action links that allow you to manage your reply. You can perform the following actions:', 'bbpress' ) . '</p>' .
       
   157 				'<ul>' .
       
   158 					'<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.',                                                                                 'bbpress' ) . '</li>' .
       
   159 					//'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.',                                                                  'bbpress' ) . '</li>' .
       
   160 					'<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.',                                                                                       'bbpress' ) . '</li>' .
       
   161 					'<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.',                                                                                   'bbpress' ) . '</li>' .
       
   162 					'<li>' . __( '<strong>Preview</strong> will show you what your draft reply will look like if you publish it. View will take you to your live site to view the reply. Which link is available depends on your reply&#8217;s status.', 'bbpress' ) . '</li>' .
       
   163 				'</ul>'
       
   164 		) );
       
   165 
       
   166 		// Bulk Actions
       
   167 		get_current_screen()->add_help_tab( array(
       
   168 			'id'		=> 'bulk-actions',
       
   169 			'title'		=> __( 'Bulk Actions', 'bbpress' ),
       
   170 			'content'	=>
       
   171 				'<p>' . __( 'You can also edit or move multiple replies to the trash at once. Select the replies you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.',           'bbpress' ) . '</p>' .
       
   172 				'<p>' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected replies at once. To remove a reply from the grouping, just click the x next to its name in the Bulk Edit area that appears.', 'bbpress' ) . '</p>'
       
   173 		) );
       
   174 
       
   175 		// Help Sidebar
       
   176 		get_current_screen()->set_help_sidebar(
       
   177 			'<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
       
   178 			'<p>' . __( '<a href="http://codex.bbpress.org" target="_blank">bbPress Documentation</a>',    'bbpress' ) . '</p>' .
       
   179 			'<p>' . __( '<a href="http://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
       
   180 		);
       
   181 	}
       
   182 
       
   183 	/**
       
   184 	 * Contextual help for bbPress reply edit page
       
   185 	 *
       
   186 	 * @since bbPress (r3119)
       
   187 	 * @uses get_current_screen()
       
   188 	 */
       
   189 	public function new_help() {
       
   190 
       
   191 		if ( $this->bail() ) return;
       
   192 
       
   193 		$customize_display = '<p>' . __( 'The title field and the big reply editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>';
       
   194 
       
   195 		get_current_screen()->add_help_tab( array(
       
   196 			'id'      => 'customize-display',
       
   197 			'title'   => __( 'Customizing This Display', 'bbpress' ),
       
   198 			'content' => $customize_display,
       
   199 		) );
       
   200 
       
   201 		get_current_screen()->add_help_tab( array(
       
   202 			'id'      => 'title-reply-editor',
       
   203 			'title'   => __( 'Title and Reply Editor', 'bbpress' ),
       
   204 			'content' =>
       
   205 				'<p>' . __( '<strong>Title</strong> - Enter a title for your reply. After you enter a title, you&#8217;ll see the permalink below, which you can edit.', 'bbpress' ) . '</p>' .
       
   206 				'<p>' . __( '<strong>Reply Editor</strong> - Enter the text for your reply. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your reply text. You can insert media files by clicking the icons above the reply editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular reply editor.', 'bbpress' ) . '</p>'
       
   207 		) );
       
   208 
       
   209 		$publish_box = '<p>' . __( '<strong>Publish</strong> - You can set the terms of publishing your reply in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a reply or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a reply to be published in the future or backdate a reply.', 'bbpress' ) . '</p>';
       
   210 
       
   211 		if ( current_theme_supports( 'reply-formats' ) && reply_type_supports( 'reply', 'reply-formats' ) ) {
       
   212 			$publish_box .= '<p>' . __( '<strong>reply Format</strong> - This designates how your theme will display a specific reply. For example, you could have a <em>standard</em> blog reply with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each reply format</a>. Your theme could enable all or some of 10 possible formats.', 'bbpress' ) . '</p>';
       
   213 		}
       
   214 
       
   215 		if ( current_theme_supports( 'reply-thumbnails' ) && reply_type_supports( 'reply', 'thumbnail' ) ) {
       
   216 			$publish_box .= '<p>' . __( '<strong>Featured Image</strong> - This allows you to associate an image with your reply without inserting it. This is usually useful only if your theme makes use of the featured image as a reply thumbnail on the home page, a custom header, etc.', 'bbpress' ) . '</p>';
       
   217 		}
       
   218 
       
   219 		get_current_screen()->add_help_tab( array(
       
   220 			'id'      => 'reply-attributes',
       
   221 			'title'   => __( 'Reply Attributes', 'bbpress' ),
       
   222 			'content' =>
       
   223 				'<p>' . __( 'Select the attributes that your reply should have:', 'bbpress' ) . '</p>' .
       
   224 				'<ul>' .
       
   225 					'<li>' . __( '<strong>Forum</strong> dropdown determines the parent forum that the reply belongs to. Select the forum, or leave the default (Use Forum of Topic) to post the reply in forum of the topic.', 'bbpress' ) . '</li>' .
       
   226 					'<li>' . __( '<strong>Topic</strong> determines the parent topic that the reply belongs to.', 'bbpress' ) . '</li>' .
       
   227 				'</ul>'
       
   228 		) );
       
   229 
       
   230 		get_current_screen()->add_help_tab( array(
       
   231 			'id'      => 'publish-box',
       
   232 			'title'   => __( 'Publish Box', 'bbpress' ),
       
   233 			'content' => $publish_box,
       
   234 		) );
       
   235 
       
   236 		get_current_screen()->add_help_tab( array(
       
   237 			'id'      => 'discussion-settings',
       
   238 			'title'   => __( 'Discussion Settings', 'bbpress' ),
       
   239 			'content' =>
       
   240 				'<p>' . __( '<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.', 'bbpress' ) . '</p>' .
       
   241 				'<p>' . __( '<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the reply, you can see them here and moderate them.', 'bbpress' ) . '</p>'
       
   242 		) );
       
   243 
       
   244 		get_current_screen()->set_help_sidebar(
       
   245 			'<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
       
   246 			'<p>' . __( '<a href="http://codex.bbpress.org" target="_blank">bbPress Documentation</a>',    'bbpress' ) . '</p>' .
       
   247 			'<p>' . __( '<a href="http://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>'
       
   248 		);
       
   249 	}
       
   250 
       
   251 	/**
       
   252 	 * Add the reply attributes metabox
       
   253 	 *
       
   254 	 * @since bbPress (r2746)
       
   255 	 *
       
   256 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
   257 	 * @uses add_meta_box() To add the metabox
       
   258 	 * @uses do_action() Calls 'bbp_reply_attributes_metabox'
       
   259 	 */
       
   260 	public function reply_attributes_metabox() {
       
   261 
       
   262 		if ( $this->bail() ) return;
       
   263 
       
   264 		add_meta_box (
       
   265 			'bbp_reply_attributes',
       
   266 			__( 'Reply Attributes', 'bbpress' ),
       
   267 			'bbp_reply_metabox',
       
   268 			$this->post_type,
       
   269 			'side',
       
   270 			'high'
       
   271 		);
       
   272 
       
   273 		do_action( 'bbp_reply_attributes_metabox' );
       
   274 	}
       
   275 
       
   276 	/**
       
   277 	 * Pass the reply attributes for processing
       
   278 	 *
       
   279 	 * @since bbPress (r2746)
       
   280 	 *
       
   281 	 * @param int $reply_id Reply id
       
   282 	 * @uses current_user_can() To check if the current user is capable of
       
   283 	 *                           editing the reply
       
   284 	 * @uses do_action() Calls 'bbp_reply_attributes_metabox_save' with the
       
   285 	 *                    reply id and parent id
       
   286 	 * @return int Parent id
       
   287 	 */
       
   288 	public function reply_attributes_metabox_save( $reply_id ) {
       
   289 
       
   290 		if ( $this->bail() ) return $reply_id;
       
   291 
       
   292 		// Bail if doing an autosave
       
   293 		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
       
   294 			return $reply_id;
       
   295 
       
   296 		// Bail if not a post request
       
   297 		if ( 'POST' != strtoupper( $_SERVER['REQUEST_METHOD'] ) )
       
   298 			return $reply_id;
       
   299 
       
   300 		// Check action exists
       
   301 		if ( empty( $_POST['action'] ) )
       
   302 			return $reply_id;
       
   303 
       
   304 		// Nonce check
       
   305 		if ( empty( $_POST['bbp_reply_metabox'] ) || !wp_verify_nonce( $_POST['bbp_reply_metabox'], 'bbp_reply_metabox_save' ) )
       
   306 			return $reply_id;
       
   307 
       
   308 		// Current user cannot edit this reply
       
   309 		if ( !current_user_can( 'edit_reply', $reply_id ) )
       
   310 			return $reply_id;
       
   311 
       
   312 		// Get the reply meta post values
       
   313 		$topic_id = !empty( $_POST['parent_id']    ) ? (int) $_POST['parent_id']    : 0;
       
   314 		$forum_id = !empty( $_POST['bbp_forum_id'] ) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id( $topic_id );
       
   315 
       
   316 		// Formally update the reply
       
   317 		bbp_update_reply( $reply_id, $topic_id, $forum_id );
       
   318 
       
   319 		// Allow other fun things to happen
       
   320 		do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id );
       
   321 
       
   322 		return $reply_id;
       
   323 	}
       
   324 
       
   325 	/**
       
   326 	 * Add the author info metabox
       
   327 	 *
       
   328 	 * Allows editing of information about an author
       
   329 	 *
       
   330 	 * @since bbPress (r2828)
       
   331 	 *
       
   332 	 * @uses bbp_get_topic() To get the topic
       
   333 	 * @uses bbp_get_reply() To get the reply
       
   334 	 * @uses bbp_get_topic_post_type() To get the topic post type
       
   335 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
   336 	 * @uses add_meta_box() To add the metabox
       
   337 	 * @uses do_action() Calls 'bbp_author_metabox' with the topic/reply
       
   338 	 *                    id
       
   339 	 */
       
   340 	public function author_metabox() {
       
   341 
       
   342 		if ( $this->bail() ) return;
       
   343 
       
   344 		// Bail if post_type is not a reply
       
   345 		if ( empty( $_GET['action'] ) || ( 'edit' != $_GET['action'] ) )
       
   346 			return;
       
   347 
       
   348 		// Add the metabox
       
   349 		add_meta_box(
       
   350 			'bbp_author_metabox',
       
   351 			__( 'Author Information', 'bbpress' ),
       
   352 			'bbp_author_metabox',
       
   353 			$this->post_type,
       
   354 			'side',
       
   355 			'high'
       
   356 		);
       
   357 
       
   358 		do_action( 'bbp_author_metabox', get_the_ID() );
       
   359 	}
       
   360 
       
   361 	/**
       
   362 	 * Save the author information for the topic/reply
       
   363 	 *
       
   364 	 * @since bbPress (r2828)
       
   365 	 *
       
   366 	 * @param int $post_id Topic or reply id
       
   367 	 * @uses bbp_get_topic() To get the topic
       
   368 	 * @uses bbp_get_reply() To get the reply
       
   369 	 * @uses current_user_can() To check if the current user can edit the
       
   370 	 *                           topic or reply
       
   371 	 * @uses bbp_filter_anonymous_post_data() To filter the anonymous user data
       
   372 	 * @uses update_post_meta() To update the anonymous user data
       
   373 	 * @uses do_action() Calls 'bbp_author_metabox_save' with the reply id and
       
   374 	 *                    anonymous data
       
   375 	 * @return int Topic or reply id
       
   376 	 */
       
   377 	public function author_metabox_save( $post_id ) {
       
   378 
       
   379 		if ( $this->bail() ) return $post_id;
       
   380 
       
   381 		// Bail if no post_id
       
   382 		if ( empty( $post_id ) )
       
   383 			return $post_id;
       
   384 
       
   385 		// Bail if not a post request
       
   386 		if ( 'POST' != strtoupper( $_SERVER['REQUEST_METHOD'] ) )
       
   387 			return $post_id;
       
   388 
       
   389 		// Bail if doing an autosave
       
   390 		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
       
   391 			return $post_id;
       
   392 
       
   393 		// Bail if user cannot edit replies or reply is not anonymous
       
   394 		if ( !current_user_can( 'edit_reply', $post_id ) )
       
   395 			return $post_id;
       
   396 
       
   397 		$anonymous_data = bbp_filter_anonymous_post_data();
       
   398 
       
   399 		update_post_meta( $post_id, '_bbp_anonymous_name',    $anonymous_data['bbp_anonymous_name']    );
       
   400 		update_post_meta( $post_id, '_bbp_anonymous_email',   $anonymous_data['bbp_anonymous_email']   );
       
   401 		update_post_meta( $post_id, '_bbp_anonymous_website', $anonymous_data['bbp_anonymous_website'] );
       
   402 
       
   403 		do_action( 'bbp_author_metabox_save', $post_id, $anonymous_data );
       
   404 
       
   405 		return $post_id;
       
   406 	}
       
   407 
       
   408 	/**
       
   409 	 * Add some general styling to the admin area
       
   410 	 *
       
   411 	 * @since bbPress (r2464)
       
   412 	 *
       
   413 	 * @uses bbp_get_forum_post_type() To get the forum post type
       
   414 	 * @uses bbp_get_topic_post_type() To get the topic post type
       
   415 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
   416 	 * @uses sanitize_html_class() To sanitize the classes
       
   417 	 * @uses do_action() Calls 'bbp_admin_head'
       
   418 	 */
       
   419 	public function admin_head() {
       
   420 
       
   421 		if ( $this->bail() ) return;
       
   422 
       
   423 		?>
       
   424 
       
   425 		<style type="text/css" media="screen">
       
   426 		/*<![CDATA[*/
       
   427 
       
   428 			strong.label {
       
   429 				display: inline-block;
       
   430 				width: 60px;
       
   431 			}
       
   432 
       
   433 			.column-bbp_forum_topic_count,
       
   434 			.column-bbp_forum_reply_count,
       
   435 			.column-bbp_topic_reply_count,
       
   436 			.column-bbp_topic_voice_count {
       
   437 				width: 8% !important;
       
   438 			}
       
   439 
       
   440 			.column-author,
       
   441 			.column-bbp_reply_author,
       
   442 			.column-bbp_topic_author {
       
   443 				width: 10% !important;
       
   444 			}
       
   445 
       
   446 			.column-bbp_topic_forum,
       
   447 			.column-bbp_reply_forum,
       
   448 			.column-bbp_reply_topic {
       
   449 				width: 10% !important;
       
   450 			}
       
   451 
       
   452 			.column-bbp_forum_freshness,
       
   453 			.column-bbp_topic_freshness {
       
   454 				width: 10% !important;
       
   455 			}
       
   456 
       
   457 			.column-bbp_forum_created,
       
   458 			.column-bbp_topic_created,
       
   459 			.column-bbp_reply_created {
       
   460 				width: 15% !important;
       
   461 			}
       
   462 
       
   463 			.status-closed {
       
   464 				background-color: #eaeaea;
       
   465 			}
       
   466 
       
   467 			.status-spam {
       
   468 				background-color: #faeaea;
       
   469 			}
       
   470 
       
   471 		/*]]>*/
       
   472 		</style>
       
   473 
       
   474 		<?php
       
   475 	}
       
   476 
       
   477 	/**
       
   478 	 * Toggle reply
       
   479 	 *
       
   480 	 * Handles the admin-side spamming/unspamming of replies
       
   481 	 *
       
   482 	 * @since bbPress (r2740)
       
   483 	 *
       
   484 	 * @uses bbp_get_reply() To get the reply
       
   485 	 * @uses current_user_can() To check if the user is capable of editing
       
   486 	 *                           the reply
       
   487 	 * @uses wp_die() To die if the user isn't capable or the post wasn't
       
   488 	 *                 found
       
   489 	 * @uses check_admin_referer() To verify the nonce and check referer
       
   490 	 * @uses bbp_is_reply_spam() To check if the reply is marked as spam
       
   491 	 * @uses bbp_unspam_reply() To unmark the reply as spam
       
   492 	 * @uses bbp_spam_reply() To mark the reply as spam
       
   493 	 * @uses do_action() Calls 'bbp_toggle_reply_admin' with success, post
       
   494 	 *                    data, action and message
       
   495 	 * @uses add_query_arg() To add custom args to the url
       
   496 	 * @uses wp_safe_redirect() Redirect the page to custom url
       
   497 	 */
       
   498 	public function toggle_reply() {
       
   499 
       
   500 		if ( $this->bail() ) return;
       
   501 
       
   502 		// Only proceed if GET is a reply toggle action
       
   503 		if ( 'GET' == $_SERVER['REQUEST_METHOD'] && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam' ) ) && !empty( $_GET['reply_id'] ) ) {
       
   504 			$action    = $_GET['action'];            // What action is taking place?
       
   505 			$reply_id  = (int) $_GET['reply_id'];    // What's the reply id?
       
   506 			$success   = false;                      // Flag
       
   507 			$post_data = array( 'ID' => $reply_id ); // Prelim array
       
   508 
       
   509 			// Get reply and die if empty
       
   510 			$reply = bbp_get_reply( $reply_id );
       
   511 			if ( empty( $reply ) ) // Which reply?
       
   512 				wp_die( __( 'The reply was not found!', 'bbpress' ) );
       
   513 
       
   514 			if ( !current_user_can( 'moderate', $reply->ID ) ) // What is the user doing here?
       
   515 				wp_die( __( 'You do not have the permission to do that!', 'bbpress' ) );
       
   516 
       
   517 			switch ( $action ) {
       
   518 				case 'bbp_toggle_reply_spam' :
       
   519 					check_admin_referer( 'spam-reply_' . $reply_id );
       
   520 
       
   521 					$is_spam = bbp_is_reply_spam( $reply_id );
       
   522 					$message = $is_spam ? 'unspammed' : 'spammed';
       
   523 					$success = $is_spam ? bbp_unspam_reply( $reply_id ) : bbp_spam_reply( $reply_id );
       
   524 
       
   525 					break;
       
   526 			}
       
   527 
       
   528 			$success = wp_update_post( $post_data );
       
   529 			$message = array( 'bbp_reply_toggle_notice' => $message, 'reply_id' => $reply->ID );
       
   530 
       
   531 			if ( false == $success || is_wp_error( $success ) )
       
   532 				$message['failed'] = '1';
       
   533 
       
   534 			// Do additional reply toggle actions (admin side)
       
   535 			do_action( 'bbp_toggle_reply_admin', $success, $post_data, $action, $message );
       
   536 
       
   537 			// Redirect back to the reply
       
   538 			$redirect = add_query_arg( $message, remove_query_arg( array( 'action', 'reply_id' ) ) );
       
   539 			wp_safe_redirect( $redirect );
       
   540 
       
   541 			// For good measure
       
   542 			exit();
       
   543 		}
       
   544 	}
       
   545 
       
   546 	/**
       
   547 	 * Toggle reply notices
       
   548 	 *
       
   549 	 * Display the success/error notices from
       
   550 	 * {@link BBP_Admin::toggle_reply()}
       
   551 	 *
       
   552 	 * @since bbPress (r2740)
       
   553 	 *
       
   554 	 * @uses bbp_get_reply() To get the reply
       
   555 	 * @uses bbp_get_reply_title() To get the reply title of the reply
       
   556 	 * @uses esc_html() To sanitize the reply title
       
   557 	 * @uses apply_filters() Calls 'bbp_toggle_reply_notice_admin' with
       
   558 	 *                        message, reply id, notice and is it a failure
       
   559 	 */
       
   560 	public function toggle_reply_notice() {
       
   561 
       
   562 		if ( $this->bail() ) return;
       
   563 
       
   564 		// Only proceed if GET is a reply toggle action
       
   565 		if ( 'GET' == $_SERVER['REQUEST_METHOD'] && !empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed' ) ) && !empty( $_GET['reply_id'] ) ) {
       
   566 			$notice     = $_GET['bbp_reply_toggle_notice'];         // Which notice?
       
   567 			$reply_id   = (int) $_GET['reply_id'];                  // What's the reply id?
       
   568 			$is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure?
       
   569 
       
   570 			// Empty? No reply?
       
   571 			if ( empty( $notice ) || empty( $reply_id ) )
       
   572 				return;
       
   573 
       
   574 			// Get reply and bail if empty
       
   575 			$reply = bbp_get_reply( $reply_id );
       
   576 			if ( empty( $reply ) )
       
   577 				return;
       
   578 
       
   579 			$reply_title = esc_html( bbp_get_reply_title( $reply->ID ) );
       
   580 
       
   581 			switch ( $notice ) {
       
   582 				case 'spammed' :
       
   583 					$message = $is_failure == true ? sprintf( __( 'There was a problem marking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully marked as spam.', 'bbpress' ), $reply_title );
       
   584 					break;
       
   585 
       
   586 				case 'unspammed' :
       
   587 					$message = $is_failure == true ? sprintf( __( 'There was a problem unmarking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully unmarked as spam.', 'bbpress' ), $reply_title );
       
   588 					break;
       
   589 			}
       
   590 
       
   591 			// Do additional reply toggle notice filters (admin side)
       
   592 			$message = apply_filters( 'bbp_toggle_reply_notice_admin', $message, $reply->ID, $notice, $is_failure );
       
   593 
       
   594 			?>
       
   595 
       
   596 			<div id="message" class="<?php echo $is_failure == true ? 'error' : 'updated'; ?> fade">
       
   597 				<p style="line-height: 150%"><?php echo $message; ?></p>
       
   598 			</div>
       
   599 
       
   600 			<?php
       
   601 		}
       
   602 	}
       
   603 
       
   604 	/**
       
   605 	 * Manage the column headers for the replies page
       
   606 	 *
       
   607 	 * @since bbPress (r2577)
       
   608 	 *
       
   609 	 * @param array $columns The columns
       
   610 	 * @uses apply_filters() Calls 'bbp_admin_replies_column_headers' with
       
   611 	 *                        the columns
       
   612 	 * @return array $columns bbPress reply columns
       
   613 	 */
       
   614 	public function replies_column_headers( $columns ) {
       
   615 
       
   616 		if ( $this->bail() ) return $columns;
       
   617 
       
   618 		$columns = array(
       
   619 			'cb'                => '<input type="checkbox" />',
       
   620 			'title'             => __( 'Title',   'bbpress' ),
       
   621 			'bbp_reply_forum'   => __( 'Forum',   'bbpress' ),
       
   622 			'bbp_reply_topic'   => __( 'Topic',   'bbpress' ),
       
   623 			'bbp_reply_author'  => __( 'Author',  'bbpress' ),
       
   624 			'bbp_reply_created' => __( 'Created', 'bbpress' ),
       
   625 		);
       
   626 
       
   627 		return apply_filters( 'bbp_admin_replies_column_headers', $columns );
       
   628 	}
       
   629 
       
   630 	/**
       
   631 	 * Print extra columns for the replies page
       
   632 	 *
       
   633 	 * @since bbPress (r2577)
       
   634 	 *
       
   635 	 * @param string $column Column
       
   636 	 * @param int $reply_id reply id
       
   637 	 * @uses bbp_get_reply_topic_id() To get the topic id of the reply
       
   638 	 * @uses bbp_topic_title() To output the reply's topic title
       
   639 	 * @uses apply_filters() Calls 'reply_topic_row_actions' with an array
       
   640 	 *                        of reply topic actions
       
   641 	 * @uses bbp_get_topic_permalink() To get the topic permalink
       
   642 	 * @uses bbp_get_topic_forum_id() To get the forum id of the topic of
       
   643 	 *                                 the reply
       
   644 	 * @uses bbp_get_forum_permalink() To get the forum permalink
       
   645 	 * @uses admin_url() To get the admin url of post.php
       
   646 	 * @uses add_query_arg() To add custom args to the url
       
   647 	 * @uses apply_filters() Calls 'reply_topic_forum_row_actions' with an
       
   648 	 *                        array of reply topic forum actions
       
   649 	 * @uses bbp_reply_author_display_name() To output the reply author name
       
   650 	 * @uses get_the_date() Get the reply creation date
       
   651 	 * @uses get_the_time() Get the reply creation time
       
   652 	 * @uses esc_attr() To sanitize the reply creation time
       
   653 	 * @uses bbp_get_reply_last_active_time() To get the time when the reply was
       
   654 	 *                                    last active
       
   655 	 * @uses do_action() Calls 'bbp_admin_replies_column_data' with the
       
   656 	 *                    column and reply id
       
   657 	 */
       
   658 	public function replies_column_data( $column, $reply_id ) {
       
   659 
       
   660 		if ( $this->bail() ) return;
       
   661 
       
   662 		// Get topic ID
       
   663 		$topic_id = bbp_get_reply_topic_id( $reply_id );
       
   664 
       
   665 		// Populate Column Data
       
   666 		switch ( $column ) {
       
   667 
       
   668 			// Topic
       
   669 			case 'bbp_reply_topic' :
       
   670 
       
   671 				// Output forum name
       
   672 				if ( !empty( $topic_id ) ) {
       
   673 
       
   674 					// Topic Title
       
   675 					$topic_title = bbp_get_topic_title( $topic_id );
       
   676 					if ( empty( $topic_title ) ) {
       
   677 						$topic_title = __( 'No Topic', 'bbpress' );
       
   678 					}
       
   679 
       
   680 					// Output the title
       
   681 					echo $topic_title;
       
   682 
       
   683 				// Reply has no topic
       
   684 				} else {
       
   685 					_e( 'No Topic', 'bbpress' );
       
   686 				}
       
   687 
       
   688 				break;
       
   689 
       
   690 			// Forum
       
   691 			case 'bbp_reply_forum' :
       
   692 
       
   693 				// Get Forum ID's
       
   694 				$reply_forum_id = bbp_get_reply_forum_id( $reply_id );
       
   695 				$topic_forum_id = bbp_get_topic_forum_id( $topic_id );
       
   696 
       
   697 				// Output forum name
       
   698 				if ( !empty( $reply_forum_id ) ) {
       
   699 
       
   700 					// Forum Title
       
   701 					$forum_title = bbp_get_forum_title( $reply_forum_id );
       
   702 					if ( empty( $forum_title ) ) {
       
   703 						$forum_title = __( 'No Forum', 'bbpress' );
       
   704 					}
       
   705 
       
   706 					// Alert capable users of reply forum mismatch
       
   707 					if ( $reply_forum_id != $topic_forum_id ) {
       
   708 						if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) {
       
   709 							$forum_title .= '<div class="attention">' . __( '(Mismatch)', 'bbpress' ) . '</div>';
       
   710 						}
       
   711 					}
       
   712 
       
   713 					// Output the title
       
   714 					echo $forum_title;
       
   715 
       
   716 				// Reply has no forum
       
   717 				} else {
       
   718 					_e( 'No Forum', 'bbpress' );
       
   719 				}
       
   720 
       
   721 				break;
       
   722 
       
   723 			// Author
       
   724 			case 'bbp_reply_author' :
       
   725 				bbp_reply_author_display_name ( $reply_id );
       
   726 				break;
       
   727 
       
   728 			// Freshness
       
   729 			case 'bbp_reply_created':
       
   730 
       
   731 				// Output last activity time and date
       
   732 				printf( __( '%1$s <br /> %2$s', 'bbpress' ),
       
   733 					get_the_date(),
       
   734 					esc_attr( get_the_time() )
       
   735 				);
       
   736 
       
   737 				break;
       
   738 
       
   739 			// Do action for anything else
       
   740 			default :
       
   741 				do_action( 'bbp_admin_replies_column_data', $column, $reply_id );
       
   742 				break;
       
   743 		}
       
   744 	}
       
   745 
       
   746 	/**
       
   747 	 * Reply Row actions
       
   748 	 *
       
   749 	 * Remove the quick-edit action link under the reply title and add the
       
   750 	 * content and spam link
       
   751 	 *
       
   752 	 * @since bbPress (r2577)
       
   753 	 *
       
   754 	 * @param array $actions Actions
       
   755 	 * @param array $reply Reply object
       
   756 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
   757 	 * @uses bbp_reply_content() To output reply content
       
   758 	 * @uses bbp_get_reply_permalink() To get the reply link
       
   759 	 * @uses bbp_get_reply_title() To get the reply title
       
   760 	 * @uses current_user_can() To check if the current user can edit or
       
   761 	 *                           delete the reply
       
   762 	 * @uses bbp_is_reply_spam() To check if the reply is marked as spam
       
   763 	 * @uses get_post_type_object() To get the reply post type object
       
   764 	 * @uses add_query_arg() To add custom args to the url
       
   765 	 * @uses remove_query_arg() To remove custom args from the url
       
   766 	 * @uses wp_nonce_url() To nonce the url
       
   767 	 * @uses get_delete_post_link() To get the delete post link of the reply
       
   768 	 * @return array $actions Actions
       
   769 	 */
       
   770 	public function replies_row_actions( $actions, $reply ) {
       
   771 
       
   772 		if ( $this->bail() ) return $actions;
       
   773 
       
   774 		unset( $actions['inline hide-if-no-js'] );
       
   775 
       
   776 		// Reply view links to topic
       
   777 		$actions['view'] = '<a href="' . bbp_get_reply_url( $reply->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>';
       
   778 
       
   779 		// User cannot view replies in trash
       
   780 		if ( ( bbp_get_trash_status_id() == $reply->post_status ) && !current_user_can( 'view_trash' ) )
       
   781 			unset( $actions['view'] );
       
   782 
       
   783 		// Only show the actions if the user is capable of viewing them
       
   784 		if ( current_user_can( 'moderate', $reply->ID ) ) {
       
   785 			if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) {
       
   786 				$spam_uri  = esc_url( wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_'  . $reply->ID ) );
       
   787 				if ( bbp_is_reply_spam( $reply->ID ) ) {
       
   788 					$actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . __( 'Not spam', 'bbpress' ) . '</a>';
       
   789 				} else {
       
   790 					$actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark this reply as spam',    'bbpress' ) . '">' . __( 'Spam',     'bbpress' ) . '</a>';
       
   791 				}
       
   792 			}
       
   793 		}
       
   794 
       
   795 		// Trash
       
   796 		if ( current_user_can( 'delete_reply', $reply->ID ) ) {
       
   797 			if ( bbp_get_trash_status_id() == $reply->post_status ) {
       
   798 				$post_type_object = get_post_type_object( bbp_get_reply_post_type() );
       
   799 				$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>";
       
   800 			} elseif ( EMPTY_TRASH_DAYS ) {
       
   801 				$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID ) ) . "'>" . __( 'Trash', 'bbpress' ) . "</a>";
       
   802 			}
       
   803 
       
   804 			if ( bbp_get_trash_status_id() == $reply->post_status || !EMPTY_TRASH_DAYS ) {
       
   805 				$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>";
       
   806 			} elseif ( bbp_get_spam_status_id() == $reply->post_status ) {
       
   807 				unset( $actions['trash'] );
       
   808 			}
       
   809 		}
       
   810 
       
   811 		return $actions;
       
   812 	}
       
   813 
       
   814 	/**
       
   815 	 * Add forum dropdown to topic and reply list table filters
       
   816 	 *
       
   817 	 * @since bbPress (r2991)
       
   818 	 *
       
   819 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
   820 	 * @uses bbp_get_topic_post_type() To get the topic post type
       
   821 	 * @uses bbp_dropdown() To generate a forum dropdown
       
   822 	 * @return bool False. If post type is not topic or reply
       
   823 	 */
       
   824 	public function filter_dropdown() {
       
   825 
       
   826 		if ( $this->bail() ) return;
       
   827 
       
   828 		// Add Empty Spam button
       
   829 		if ( !empty( $_GET['post_status'] ) && ( bbp_get_spam_status_id() == $_GET['post_status'] ) && current_user_can( 'moderate' ) ) {
       
   830 			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
       
   831 			$title = esc_attr__( 'Empty Spam', 'bbpress' );
       
   832 			submit_button( $title, 'button-secondary apply', 'delete_all', false );
       
   833 		}
       
   834 
       
   835 		// Get which forum is selected
       
   836 		$selected = !empty( $_GET['bbp_forum_id'] ) ? $_GET['bbp_forum_id'] : '';
       
   837 
       
   838 		// Show the forums dropdown
       
   839 		bbp_dropdown( array(
       
   840 			'selected'  => $selected,
       
   841 			'show_none' => __( 'In all forums', 'bbpress' )
       
   842 		) );
       
   843 	}
       
   844 
       
   845 	/**
       
   846 	 * Adjust the request query and include the forum id
       
   847 	 *
       
   848 	 * @since bbPress (r2991)
       
   849 	 *
       
   850 	 * @param array $query_vars Query variables from {@link WP_Query}
       
   851 	 * @uses is_admin() To check if it's the admin section
       
   852 	 * @uses bbp_get_topic_post_type() To get the topic post type
       
   853 	 * @uses bbp_get_reply_post_type() To get the reply post type
       
   854 	 * @return array Processed Query Vars
       
   855 	 */
       
   856 	public function filter_post_rows( $query_vars ) {
       
   857 
       
   858 		if ( $this->bail() ) return $query_vars;
       
   859 
       
   860 		// Add post_parent query_var if one is present
       
   861 		if ( !empty( $_GET['bbp_forum_id'] ) ) {
       
   862 			$query_vars['meta_key']   = '_bbp_forum_id';
       
   863 			$query_vars['meta_value'] = $_GET['bbp_forum_id'];
       
   864 		}
       
   865 
       
   866 		// Return manipulated query_vars
       
   867 		return $query_vars;
       
   868 	}
       
   869 
       
   870 	/**
       
   871 	 * Custom user feedback messages for reply post type
       
   872 	 *
       
   873 	 * @since bbPress (r3080)
       
   874 	 *
       
   875 	 * @global int $post_ID
       
   876 	 * @uses bbp_get_topic_permalink()
       
   877 	 * @uses wp_post_revision_title()
       
   878 	 * @uses esc_url()
       
   879 	 * @uses add_query_arg()
       
   880 	 *
       
   881 	 * @param array $messages
       
   882 	 *
       
   883 	 * @return array
       
   884 	 */
       
   885 	public function updated_messages( $messages ) {
       
   886 		global $post_ID;
       
   887 
       
   888 		if ( $this->bail() ) return $messages;
       
   889 
       
   890 		// URL for the current topic
       
   891 		$topic_url = bbp_get_topic_permalink( bbp_get_reply_topic_id( $post_ID ) );
       
   892 
       
   893 		// Current reply's post_date
       
   894 		$post_date = bbp_get_global_post_field( 'post_date', 'raw' );
       
   895 
       
   896 		// Messages array
       
   897 		$messages[$this->post_type] = array(
       
   898 			0 =>  '', // Left empty on purpose
       
   899 
       
   900 			// Updated
       
   901 			1 =>  sprintf( __( 'Reply updated. <a href="%s">View topic</a>', 'bbpress' ), $topic_url ),
       
   902 
       
   903 			// Custom field updated
       
   904 			2 => __( 'Custom field updated.', 'bbpress' ),
       
   905 
       
   906 			// Custom field deleted
       
   907 			3 => __( 'Custom field deleted.', 'bbpress' ),
       
   908 
       
   909 			// Reply updated
       
   910 			4 => __( 'Reply updated.', 'bbpress' ),
       
   911 
       
   912 			// Restored from revision
       
   913 			// translators: %s: date and time of the revision
       
   914 			5 => isset( $_GET['revision'] )
       
   915 					? sprintf( __( 'Reply restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) )
       
   916 					: false,
       
   917 
       
   918 			// Reply created
       
   919 			6 => sprintf( __( 'Reply created. <a href="%s">View topic</a>', 'bbpress' ), $topic_url ),
       
   920 
       
   921 			// Reply saved
       
   922 			7 => __( 'Reply saved.', 'bbpress' ),
       
   923 
       
   924 			// Reply submitted
       
   925 			8 => sprintf( __( 'Reply submitted. <a target="_blank" href="%s">Preview topic</a>', 'bbpress' ), esc_url( add_query_arg( 'preview', 'true', $topic_url ) ) ),
       
   926 
       
   927 			// Reply scheduled
       
   928 			9 => sprintf( __( 'Reply scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview topic</a>', 'bbpress' ),
       
   929 					// translators: Publish box date format, see http://php.net/date
       
   930 					date_i18n( __( 'M j, Y @ G:i', 'bbpress' ),
       
   931 					strtotime( $post_date ) ),
       
   932 					$topic_url ),
       
   933 
       
   934 			// Reply draft updated
       
   935 			10 => sprintf( __( 'Reply draft updated. <a target="_blank" href="%s">Preview topic</a>', 'bbpress' ), esc_url( add_query_arg( 'preview', 'true', $topic_url ) ) ),
       
   936 		);
       
   937 
       
   938 		return $messages;
       
   939 	}
       
   940 }
       
   941 endif; // class_exists check
       
   942 
       
   943 /**
       
   944  * Setup bbPress Replies Admin
       
   945  *
       
   946  * This is currently here to make hooking and unhooking of the admin UI easy.
       
   947  * It could use dependency injection in the future, but for now this is easier.
       
   948  *
       
   949  * @since bbPress (r2596)
       
   950  *
       
   951  * @uses BBP_Replies_Admin
       
   952  */
       
   953 function bbp_admin_replies() {
       
   954 	bbpress()->admin->replies = new BBP_Replies_Admin();
       
   955 }