Exemplo n.º 1
0
 /**
  * Callback function for handling post status changes.
  *
  * @since  1.0.0
  * @access public
  * @return void
  */
 public function handler()
 {
     /* Checks if the close toggle link was clicked. */
     if (isset($_GET['mb_toggle_status']) && isset($_GET['forum_id'])) {
         $forum_id = absint(mb_get_forum_id($_GET['forum_id']));
         /* Assume the changed failed. */
         $notice = 'failure';
         if ('open' === $_GET['mb_toggle_status'] && !mb_is_forum_open($forum_id)) {
             /* Verify the nonce. */
             check_admin_referer("open_forum_{$forum_id}");
             /* Update the post status. */
             $updated = mb_open_forum($forum_id);
             /* If the status was updated, add notice slug. */
             if ($updated && !is_wp_error($updated)) {
                 $notice = mb_get_open_post_status();
             }
         } elseif ('close' === $_GET['mb_toggle_status'] && !mb_is_forum_closed($forum_id)) {
             /* Verify the nonce. */
             check_admin_referer("close_forum_{$forum_id}");
             /* Update the post status. */
             $updated = mb_close_forum($forum_id);
             /* If the status was updated, add notice slug. */
             if ($updated && !is_wp_error($updated)) {
                 $notice = mb_get_close_post_status();
             }
         } elseif ('archive' === $_GET['mb_toggle_status'] && !mb_is_forum_archived($forum_id)) {
             /* Verify the nonce. */
             check_admin_referer("archive_forum_{$forum_id}");
             /* Update the post status. */
             $updated = mb_archive_forum($forum_id);
             /* If the status was updated, add notice slug. */
             if ($updated && !is_wp_error($updated)) {
                 $notice = mb_get_archive_post_status();
             }
         }
         /* Redirect to correct admin page. */
         $redirect = add_query_arg(array('forum_id' => $forum_id, 'mb_forum_notice' => $notice), remove_query_arg(array('action', 'mb_toggle_status', 'forum_id', '_wpnonce')));
         wp_safe_redirect($redirect);
         /* Always exit for good measure. */
         exit;
     }
 }
Exemplo n.º 2
0
/**
 * Handles adding the post status to the post title for specific statuses.
 *
 * @since  1.0.0
 * @access public
 * @param  string  $title
 * @param  int     $post
 * @return string
 */
function mb_post_title_status($title, $post)
{
    if (is_admin()) {
        return $title;
    }
    $post_id = is_object($post) ? $post->ID : $post;
    /* Hidden forums/topics. */
    if (mb_is_forum($post_id) && mb_is_forum_hidden($post_id) || mb_is_topic($post_id) && mb_is_topic_hidden($post_id)) {
        /* Translators: Hidden title. */
        $title = sprintf(__('Hidden: %s', 'message-board'), $title);
        /* Private forums/topics. */
    } elseif (mb_is_forum($post_id) && mb_is_forum_private($post_id) || mb_is_topic($post_id) && mb_is_topic_private($post_id)) {
        /* Translators: Private title. */
        $title = sprintf(__('Private: %s', 'message-board'), $title);
        /* Closed forums/topics. */
    } elseif (mb_is_forum($post_id) && mb_is_forum_closed($post_id) || mb_is_topic($post_id) && mb_is_topic_closed($post_id)) {
        /* Translators: Closed title. */
        $title = sprintf(__('Closed: %s', 'message-board'), $title);
        /* Archived forums. */
    } elseif (mb_is_forum($post_id) && mb_is_forum_archived($post_id)) {
        /* Translators: Archived title. */
        $title = sprintf(__('Archived: %s', 'message-board'), $title);
    }
    /* Return the filtered title. */
    return $title;
}