Exemplo n.º 1
0
 /**
  * Reply Row actions
  *
  * Remove the quick-edit action link under the reply title and add the
  * content and spam link
  *
  * @since 2.0.0 bbPress (r2577)
  *
  * @param array $actions Actions
  * @param array $reply Reply object
  * @uses bbp_get_reply_post_type() To get the reply post type
  * @uses bbp_reply_content() To output reply content
  * @uses bbp_get_reply_url() To get the reply link
  * @uses bbp_get_reply_title() To get the reply title
  * @uses current_user_can() To check if the current user can edit or
  *                           delete the reply
  * @uses bbp_is_reply_spam() To check if the reply is marked as spam
  * @uses get_post_type_object() To get the reply post type object
  * @uses add_query_arg() To add custom args to the url
  * @uses remove_query_arg() To remove custom args from the url
  * @uses wp_nonce_url() To nonce the url
  * @uses get_delete_post_link() To get the delete post link of the reply
  * @return array $actions Actions
  */
 public function row_actions($actions, $reply)
 {
     if ($this->bail()) {
         return $actions;
     }
     unset($actions['inline hide-if-no-js']);
     // Reply view links to topic
     $actions['view'] = '<a href="' . esc_url(bbp_get_reply_url($reply->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'bbpress'), bbp_get_reply_title($reply->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
     // User cannot view replies in trash
     if (bbp_get_trash_status_id() === $reply->post_status && !current_user_can('view_trash')) {
         unset($actions['view']);
     }
     // Only show the actions if the user is capable of viewing them
     if (current_user_can('moderate', $reply->ID)) {
         // Show the 'approve' link on pending posts only and 'unapprove' on published posts only
         $approve_uri = wp_nonce_url(add_query_arg(array('reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_approve'), remove_query_arg(array('bbp_reply_toggle_notice', 'reply_id', 'failed', 'super'))), 'approve-reply_' . $reply->ID);
         if (bbp_is_reply_published($reply->ID)) {
             $actions['unapproved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Unapprove this reply', 'bbpress') . '">' . _x('Unapprove', 'Unapprove reply', 'bbpress') . '</a>';
         } elseif (!bbp_is_reply_private($reply->ID)) {
             $actions['approved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Approve this reply', 'bbpress') . '">' . _x('Approve', 'Approve reply', 'bbpress') . '</a>';
         }
         // Show the 'spam' link on published and pending replies and 'not spam' on spammed replies
         if (in_array($reply->post_status, array(bbp_get_public_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id()))) {
             $spam_uri = 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);
             if (bbp_is_reply_spam($reply->ID)) {
                 $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark the reply as not spam', 'bbpress') . '">' . esc_html__('Not spam', 'bbpress') . '</a>';
             } else {
                 $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark this reply as spam', 'bbpress') . '">' . esc_html__('Spam', 'bbpress') . '</a>';
             }
         }
     }
     // Trash
     if (current_user_can('delete_reply', $reply->ID)) {
         if (bbp_get_trash_status_id() === $reply->post_status) {
             $post_type_object = get_post_type_object(bbp_get_reply_post_type());
             $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash', 'bbpress') . "' href='" . esc_url(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))) . "'>" . esc_html__('Restore', 'bbpress') . "</a>";
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash', 'bbpress') . "' href='" . esc_url(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))) . "'>" . esc_html__('Trash', 'bbpress') . "</a>";
         }
         if (bbp_get_trash_status_id() === $reply->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently', 'bbpress') . "' href='" . esc_url(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))) . "'>" . esc_html__('Delete Permanently', 'bbpress') . "</a>";
         } elseif (bbp_get_spam_status_id() === $reply->post_status) {
             unset($actions['trash']);
         }
     }
     return $actions;
 }
Exemplo n.º 2
0
 /**
  * @covers ::bbp_is_reply_private
  */
 public function test_bbp_is_reply_private()
 {
     $forum_id = $this->factory->forum->create();
     $topic_id = $this->factory->topic->create(array('post_parent' => $forum_id, 'topic_meta' => array('forum_id' => $forum_id)));
     $reply_id = $this->factory->reply->create(array('post_parent' => $topic_id, 'reply_meta' => array('forum_id' => $forum_id, 'topic_id' => $topic_id)));
     $reply_private = bbp_is_reply_private($reply_id);
     $this->assertFalse($reply_private);
     $r = $this->factory->reply->create(array('post_parent' => $topic_id, 'post_status' => bbp_get_private_status_id(), 'reply_meta' => array('forum_id' => $forum_id, 'topic_id' => $topic_id)));
     $reply_private = bbp_is_reply_private($r);
     $this->assertTrue($reply_private);
 }