/** * 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) { $reply_id = mb_get_reply_id($post->ID); /* Remove quick edit. */ if (isset($actions['inline hide-if-no-js'])) { unset($actions['inline hide-if-no-js']); } /* Add delete link for spam and orphan replies. */ if ((mb_is_reply_spam($reply_id) || mb_is_reply_orphan($reply_id)) && current_user_can('delete_post', $reply_id) && EMPTY_TRASH_DAYS) { $actions['delete'] = sprintf('<a class="submitdelete" href="%s">%s</a>', get_delete_post_link($reply_id, '', true), __('Delete Permanently', 'message-board')); } /* Add spam toggle link if user has permission. */ if (current_user_can('spam_reply', $reply_id) && !mb_is_reply_orphan($reply_id)) { /* Get post status objects. */ $spam_object = get_post_status_object(mb_get_spam_post_status()); /* Get spam link text. */ $spam_text = mb_is_reply_spam($reply_id) ? __('Not Spam', 'message-board') : $spam_object->label; /* Build spam toggle URL. */ $spam_url = remove_query_arg(array('reply_id', 'mb_reply_notice')); $spam_url = add_query_arg(array('reply_id' => $reply_id, 'action' => 'mb_toggle_spam'), $spam_url); $spam_url = wp_nonce_url($spam_url, "spam_reply_{$reply_id}"); /* Add toggle spam action link. */ $actions['mb_toggle_spam'] = sprintf('<a href="%s" class="%s">%s</a>', esc_url($spam_url), mb_is_reply_spam($reply_id) ? 'restore' : 'spam', $spam_text); } /* 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; }
/** * Handles forums, topics, and replies without titles. The titles will use the post ID. By default, * replies do not have titles and will be replaced with "Reply to: Topic Title". * * @since 1.0.0 * @access public * @param string $title * @param int $post * @return string */ function mb_post_title_empty($title, $post) { $post_id = is_object($post) ? $post->ID : $post; /* Forum post type. */ if (empty($title) && mb_is_forum($post_id)) { /* Translators: Empty forum title "%s" is the forum ID. */ $title = sprintf(__('Forum #%s', 'message-board'), $post_id); /* Topic post type. */ } elseif (empty($title) && mb_is_topic($post_id)) { /* Translators: Empty topic title "%s" is the topic ID. */ $title = sprintf(__('Topic #%s', 'message-board'), $post_id); /* Reply post type. */ } elseif (empty($title) && mb_is_reply($post_id)) { $post = get_post($post_id); /* If the reply doesn't have a parent topic. */ if (0 >= $post->post_parent || mb_is_reply_orphan($post_id)) { /* Translators: Empty reply title with no topic (orphan). "%s" is the reply ID. */ $title = sprintf(__('Reply #%s', 'message-board'), $post_id); /* If the reply does belong to a topic. */ } else { /* Translators: Empty reply title. "%s" is the topic title. */ $title = sprintf(__('Reply to: %s', 'message-board'), mb_get_topic_title($post->post_parent)); } } /* Return the filtered title. */ return $title; }