/**
  * Custom row actions below the post title.
  *
  * @since  1.0.0
  * @access public
  * @param  array   $actions
  * @param  object  $post
  * @return array
  */
 function row_actions($actions, $post)
 {
     $forum_id = mb_get_forum_id($post->ID);
     /* Remove quick edit. */
     if (isset($actions['inline hide-if-no-js'])) {
         unset($actions['inline hide-if-no-js']);
     }
     /* Add open/close toggle link if user has permission and forum is not spam. */
     if (current_user_can('open_forum', $forum_id) && !mb_is_forum_open($forum_id)) {
         /* Get post status objects. */
         $open_object = get_post_status_object(mb_get_open_post_status());
         /* Build open/close toggle URL. */
         $open_url = remove_query_arg(array('forum_id', 'mb_forum_notice'));
         $open_url = add_query_arg(array('forum_id' => $forum_id, 'mb_toggle_status' => 'open'), $open_url);
         $open_url = wp_nonce_url($open_url, "open_forum_{$forum_id}");
         /* Add toggle open/close action link. */
         $actions['mb_toggle_open'] = sprintf('<a href="%s" class="%s">%s</a>', esc_url($open_url), 'open', $open_object->mb_label_verb);
     }
     /* Add open/close toggle link if user has permission and forum is not spam. */
     if (current_user_can('close_forum', $forum_id) && !mb_is_forum_closed($forum_id)) {
         /* Get post status objects. */
         $close_object = get_post_status_object(mb_get_close_post_status());
         /* Build open/close toggle URL. */
         $close_url = remove_query_arg(array('forum_id', 'mb_forum_notice'));
         $close_url = add_query_arg(array('forum_id' => $forum_id, 'mb_toggle_status' => 'close'), $close_url);
         $close_url = wp_nonce_url($close_url, "close_forum_{$forum_id}");
         /* Add toggle open/close action link. */
         $actions['mb_toggle_close'] = sprintf('<a href="%s" class="%s">%s</a>', esc_url($close_url), 'close', $close_object->mb_label_verb);
     }
     /* Add open/close toggle link if user has permission and forum is not spam. */
     if (current_user_can('archive_forum', $forum_id) && !mb_is_forum_archived($forum_id)) {
         /* Get post status objects. */
         $archive_object = get_post_status_object(mb_get_archive_post_status());
         /* Build open/close toggle URL. */
         $archive_url = remove_query_arg(array('forum_id', 'mb_forum_notice'));
         $archive_url = add_query_arg(array('forum_id' => $forum_id, 'mb_toggle_status' => 'archive'), $archive_url);
         $archive_url = wp_nonce_url($archive_url, "archive_forum_{$forum_id}");
         /* Add toggle open/close action link. */
         $actions['mb_toggle_archive'] = sprintf('<a href="%s" class="%s">%s</a>', esc_url($archive_url), 'open', $archive_object->mb_label_verb);
     }
     /* Move view action to the end. */
     if (isset($actions['view'])) {
         $view_action = $actions['view'];
         unset($actions['view']);
         if (mb_get_spam_post_status() !== get_query_var('post_status')) {
             $actions['view'] = $view_action;
         }
     }
     return $actions;
 }
/**
 * Changes a reply's post status to "spam" if it has a different status.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $reply_id
 * @return int|WP_Error
 */
function mb_spam_reply($reply_id)
{
    return mb_update_post_status($reply_id, mb_get_spam_post_status());
}
Example #3
0
function mb_get_reply_toggle_spam_link($reply_id = 0)
{
    $reply_id = mb_get_reply_id($reply_id);
    if (!current_user_can('spam_reply', $reply_id)) {
        return '';
    }
    $text = mb_is_reply_spam($reply_id) ? __('Unspam', 'message-board') : get_post_status_object(mb_get_spam_post_status())->mb_label_verb;
    $link = sprintf('<a class="toggle-spam-link" href="%s">%s</a>', mb_get_reply_toggle_spam_url($reply_id), $text);
    return $link;
}
 /**
  * Displays admin notices for the edit forum screen.
  *
  * @since  1.0.0
  * @access public
  * @return void
  */
 public function admin_notices()
 {
     $allowed_notices = array('restore', mb_get_spam_post_status(), mb_get_open_post_status(), mb_get_close_post_status(), 'sticky', 'unsticky', 'super', 'unsuper');
     if (isset($_GET['mb_topic_notice']) && in_array($_GET['mb_topic_notice'], $allowed_notices) && isset($_GET['topic_id'])) {
         $notice = $_GET['mb_topic_notice'];
         $topic_id = mb_get_topic_id(absint($_GET['topic_id']));
         if (mb_get_spam_post_status() === $notice) {
             $text = sprintf(__('The topic "%s" was successfully marked as spam.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif ('restore' === $notice) {
             $text = sprintf(__('The topic "%s" was successfully removed from spam.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif (mb_get_close_post_status() === $notice) {
             $text = sprintf(__('The topic "%s" was successfully closed.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif (mb_get_open_post_status() === $notice) {
             $text = sprintf(__('The topic "%s" was successfully opened.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif ('sticky' === $notice) {
             $text = sprintf(__('The topic "%s" was successfully added as a sticky topic.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif ('unsticky' === $notice) {
             $text = sprintf(__('The topic "%s" was successfully removed from sticky topics.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif ('super' === $notice) {
             $text = sprintf(__('The topic "%s" was successfully added as a super sticky topic.', 'message-board'), mb_get_topic_title($topic_id));
         } elseif ('unsuper' === $notice) {
             $text = sprintf(__('The topic "%s" was successfully removed from super sticky topics.', 'message-board'), mb_get_topic_title($topic_id));
         }
         if (!empty($text)) {
             printf('<div class="updated"><p>%s</p></div>', $text);
         }
     }
 }
 /**
  * Displays admin notices for the edit forum screen.
  *
  * @since  1.0.0
  * @access public
  * @return void
  */
 public function admin_notices()
 {
     $allowed_notices = array('restore', mb_get_spam_post_status());
     if (isset($_GET['mb_reply_notice']) && in_array($_GET['mb_reply_notice'], $allowed_notices) && isset($_GET['reply_id'])) {
         $notice = $_GET['mb_reply_notice'];
         $reply_id = mb_get_reply_id(absint($_GET['reply_id']));
         if (mb_get_spam_post_status() === $notice) {
             $text = sprintf(__('The reply "%s" was successfully marked as spam.', 'message-board'), mb_get_reply_title($reply_id));
         } elseif ('restore' === $notice) {
             $text = sprintf(__('The reply "%s" was successfully removed from spam.', 'message-board'), mb_get_reply_title($reply_id));
         }
         if (!empty($text)) {
             printf('<div class="updated"><p>%s</p></div>', $text);
         }
     }
 }