• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bbp_is_topic_trash函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中bbp_is_topic_trash函数的典型用法代码示例。如果您正苦于以下问题:PHP bbp_is_topic_trash函数的具体用法?PHP bbp_is_topic_trash怎么用?PHP bbp_is_topic_trash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了bbp_is_topic_trash函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: bbp_get_topic_trash_link

/**
 * Return the trash link of the topic
 *
 * @since 2.0.0 bbPress (r2727)
 *
 * @param array $args This function supports these args:
 *  - id: Optional. Topic id
 *  - link_before: Before the link
 *  - link_after: After the link
 *  - sep: Links separator
 *  - trash_text: Trash text
 *  - restore_text: Restore text
 *  - delete_text: Delete text
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses current_user_can() To check if the current user can delete the
 *                           topic
 * @uses bbp_is_topic_trash() To check if the topic is trashed
 * @uses bbp_get_topic_status() To get the topic status
 * @uses add_query_arg() To add custom args to the url
 * @uses wp_nonce_url() To nonce the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_trash_link' with the link
 *                        and args
 * @return string Topic trash link
 */
function bbp_get_topic_trash_link($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('id' => 0, 'link_before' => '', 'link_after' => '', 'sep' => ' | ', 'trash_text' => esc_html__('Trash', 'bbpress'), 'restore_text' => esc_html__('Restore', 'bbpress'), 'delete_text' => esc_html__('Delete', 'bbpress')), 'get_topic_trash_link');
    $topic = bbp_get_topic($r['id']);
    if (empty($topic) || !current_user_can('delete_topic', $topic->ID)) {
        return;
    }
    $actions = array();
    if (bbp_is_topic_trash($topic->ID)) {
        $actions['untrash'] = '<a title="' . esc_attr__('Restore this item from the Trash', 'bbpress') . '" href="' . esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID)), 'untrash-' . $topic->post_type . '_' . $topic->ID)) . '" class="bbp-topic-restore-link">' . $r['restore_text'] . '</a>';
    } elseif (EMPTY_TRASH_DAYS) {
        $actions['trash'] = '<a title="' . esc_attr__('Move this item to the Trash', 'bbpress') . '" href="' . esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID)), 'trash-' . $topic->post_type . '_' . $topic->ID)) . '" class="bbp-topic-trash-link">' . $r['trash_text'] . '</a>';
    }
    if (bbp_is_topic_trash($topic->ID) || !EMPTY_TRASH_DAYS) {
        $actions['delete'] = '<a title="' . esc_attr__('Delete this item permanently', 'bbpress') . '" href="' . esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID)), 'delete-' . $topic->post_type . '_' . $topic->ID)) . '" onclick="return confirm(\'' . esc_js(__('Are you sure you want to delete that permanently?', 'bbpress')) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>';
    }
    // Process the admin links
    $retval = $r['link_before'] . implode($r['sep'], $actions) . $r['link_after'];
    return apply_filters('bbp_get_topic_trash_link', $retval, $r, $args);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:47,代码来源:template.php


示例2: bbp_new_reply_handler


//.........这里部分代码省略.........
        // Default
    } else {
        $reply_status = bbp_get_public_status_id();
    }
    /** Reply To **************************************************************/
    // Handle Reply To of the reply; $_REQUEST for non-JS submissions
    if (isset($_REQUEST['bbp_reply_to'])) {
        $reply_to = bbp_validate_reply_to($_REQUEST['bbp_reply_to']);
    }
    /** Topic Closed **********************************************************/
    // If topic is closed, moderators can still reply
    if (bbp_is_topic_closed($topic_id) && !current_user_can('moderate')) {
        bbp_add_error('bbp_reply_topic_closed', __('<strong>ERROR</strong>: Topic is closed.', 'bbpress'));
    }
    /** Topic Tags ************************************************************/
    // Either replace terms
    if (bbp_allow_topic_tags() && current_user_can('assign_topic_tags') && !empty($_POST['bbp_topic_tags'])) {
        $terms = esc_attr(strip_tags($_POST['bbp_topic_tags']));
        // ...or remove them.
    } elseif (isset($_POST['bbp_topic_tags'])) {
        $terms = '';
        // Existing terms
    } else {
        $terms = bbp_get_topic_tag_names($topic_id);
    }
    /** Additional Actions (Before Save) **************************************/
    do_action('bbp_new_reply_pre_extras', $topic_id, $forum_id);
    // Bail if errors
    if (bbp_has_errors()) {
        return;
    }
    /** No Errors *************************************************************/
    // Add the content of the form to $reply_data as an array
    // Just in time manipulation of reply data before being created
    $reply_data = apply_filters('bbp_new_reply_pre_insert', array('post_author' => $reply_author, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_status' => $reply_status, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'comment_status' => 'closed', 'menu_order' => bbp_get_topic_reply_count($topic_id, false) + 1));
    // Insert reply
    $reply_id = wp_insert_post($reply_data);
    /** No Errors *************************************************************/
    // Check for missing reply_id or error
    if (!empty($reply_id) && !is_wp_error($reply_id)) {
        /** Topic Tags ********************************************************/
        // Just in time manipulation of reply terms before being edited
        $terms = apply_filters('bbp_new_reply_pre_set_terms', $terms, $topic_id, $reply_id);
        // Insert terms
        $terms = wp_set_post_terms($topic_id, $terms, bbp_get_topic_tag_tax_id(), false);
        // Term error
        if (is_wp_error($terms)) {
            bbp_add_error('bbp_reply_tags', __('<strong>ERROR</strong>: There was a problem adding the tags to the topic.', 'bbpress'));
        }
        /** Trash Check *******************************************************/
        // If this reply starts as trash, add it to pre_trashed_replies
        // for the topic, so it is properly restored.
        if (bbp_is_topic_trash($topic_id) || $reply_data['post_status'] === bbp_get_trash_status_id()) {
            // Trash the reply
            wp_trash_post($reply_id);
            // Only add to pre-trashed array if topic is trashed
            if (bbp_is_topic_trash($topic_id)) {
                // Get pre_trashed_replies for topic
                $pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
                // Add this reply to the end of the existing replies
                $pre_trashed_replies[] = $reply_id;
                // Update the pre_trashed_reply post meta
                update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
            }
            /** Spam Check ********************************************************/
            // If reply or topic are spam, officially spam this reply
        } elseif (bbp_is_topic_spam($topic_id) || $reply_data['post_status'] === bbp_get_spam_status_id()) {
            add_post_meta($reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
            // Only add to pre-spammed array if topic is spam
            if (bbp_is_topic_spam($topic_id)) {
                // Get pre_spammed_replies for topic
                $pre_spammed_replies = get_post_meta($topic_id, '_bbp_pre_spammed_replies', true);
                // Add this reply to the end of the existing replies
                $pre_spammed_replies[] = $reply_id;
                // Update the pre_spammed_replies post meta
                update_post_meta($topic_id, '_bbp_pre_spammed_replies', $pre_spammed_replies);
            }
        }
        /** Update counts, etc... *********************************************/
        do_action('bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to);
        /** Additional Actions (After Save) ***********************************/
        do_action('bbp_new_reply_post_extras', $reply_id);
        /** Redirect **********************************************************/
        // Redirect to
        $redirect_to = bbp_get_redirect_to();
        // Get the reply URL
        $reply_url = bbp_get_reply_url($reply_id, $redirect_to);
        // Allow to be filtered
        $reply_url = apply_filters('bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id);
        /** Successful Save ***************************************************/
        // Redirect back to new reply
        wp_safe_redirect($reply_url);
        // For good measure
        exit;
        /** Errors ****************************************************************/
    } else {
        $append_error = is_wp_error($reply_id) && $reply_id->get_error_message() ? $reply_id->get_error_message() . ' ' : '';
        bbp_add_error('bbp_reply_error', __('<strong>ERROR</strong>: The following problem(s) have been found with your reply:' . $append_error . 'Please try again.', 'bbpress'));
    }
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:functions.php


示例3: bbp_get_reply_admin_links

/**
 * Return admin links for reply
 *
 * @since bbPress (r2667)
 *
 * @param array $args This function supports these arguments:
 *  - id: Optional. Reply id
 *  - before: HTML before the links. Defaults to
 *             '<span class="bbp-admin-links">'
 *  - after: HTML after the links. Defaults to '</span>'
 *  - sep: Separator. Defaults to ' | '
 *  - links: Array of the links to display. By default, edit, trash,
 *            spam, reply move, and topic split links are displayed
 * @uses bbp_is_topic() To check if it's the topic page
 * @uses bbp_is_reply() To check if it's the reply page
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply_edit_link() To get the reply edit link
 * @uses bbp_get_reply_trash_link() To get the reply trash link
 * @uses bbp_get_reply_spam_link() To get the reply spam link
 * @uses bbp_get_reply_move_link() To get the reply move link
 * @uses bbp_get_topic_split_link() To get the topic split link
 * @uses current_user_can() To check if the current user can edit or
 *                           delete the reply
 * @uses apply_filters() Calls 'bbp_get_reply_admin_links' with the
 *                        reply admin links and args
 * @return string Reply admin links
 */
function bbp_get_reply_admin_links($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('id' => 0, 'before' => '<span class="bbp-admin-links">', 'after' => '</span>', 'sep' => ' | ', 'links' => array()), 'get_reply_admin_links');
    $r['id'] = bbp_get_reply_id((int) $r['id']);
    // If post is a topic, return the topic admin links instead
    if (bbp_is_topic($r['id'])) {
        return bbp_get_topic_admin_links($args);
    }
    // If post is not a reply, return
    if (!bbp_is_reply($r['id'])) {
        return;
    }
    // If topic is trashed, do not show admin links
    if (bbp_is_topic_trash(bbp_get_reply_topic_id($r['id']))) {
        return;
    }
    // If no links were passed, default to the standard
    if (empty($r['links'])) {
        $r['links'] = apply_filters('bbp_reply_admin_links', array('edit' => bbp_get_reply_edit_link($r), 'move' => bbp_get_reply_move_link($r), 'split' => bbp_get_topic_split_link($r), 'trash' => bbp_get_reply_trash_link($r), 'spam' => bbp_get_reply_spam_link($r), 'reply' => bbp_get_reply_to_link($r)), $r['id']);
    }
    // See if links need to be unset
    $reply_status = bbp_get_reply_status($r['id']);
    if (in_array($reply_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id()))) {
        // Spam link shouldn't be visible on trashed topics
        if (bbp_get_trash_status_id() === $reply_status) {
            unset($r['links']['spam']);
            // Trash link shouldn't be visible on spam topics
        } elseif (bbp_get_spam_status_id() === $reply_status) {
            unset($r['links']['trash']);
        }
    }
    // Process the admin links
    $links = implode($r['sep'], array_filter($r['links']));
    $retval = $r['before'] . $links . $r['after'];
    return apply_filters('bbp_get_reply_admin_links', $retval, $r, $args);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:64,代码来源:template.php


示例4: row_actions

 /**
  * Topic Row actions
  *
  * Remove the quick-edit action link under the topic title and add the
  * content and close/stick/spam links
  *
  * @since 2.0.0 bbPress (r2485)
  *
  * @param array $actions Actions
  * @param array $topic Topic object
  * @uses bbp_get_topic_post_type() To get the topic post type
  * @uses bbp_topic_content() To output topic content
  * @uses bbp_get_topic_permalink() To get the topic link
  * @uses bbp_get_topic_title() To get the topic title
  * @uses current_user_can() To check if the current user can edit or
  *                           delete the topic
  * @uses bbp_is_topic_open() To check if the topic is open
  * @uses bbp_is_topic_spam() To check if the topic is marked as spam
  * @uses bbp_is_topic_sticky() To check if the topic is a sticky or a
  *                              super sticky
  * @uses get_post_type_object() To get the topic 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 topic
  * @return array $actions Actions
  */
 public function row_actions($actions, $topic)
 {
     if ($this->bail()) {
         return $actions;
     }
     unset($actions['inline hide-if-no-js']);
     // Show view link if it's not set, the topic is trashed and the user can view trashed topics
     if (empty($actions['view']) && bbp_get_trash_status_id() === $topic->post_status && current_user_can('view_trash')) {
         $actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
     }
     // Only show the actions if the user is capable of viewing them :)
     if (current_user_can('moderate', $topic->ID)) {
         // Pending
         // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
         $approve_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'approve-topic_' . $topic->ID);
         if (bbp_is_topic_published($topic->ID)) {
             $actions['unapproved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Unapprove this topic', 'bbpress') . '">' . _x('Unapprove', 'Unapprove Topic', 'bbpress') . '</a>';
         } elseif (!bbp_is_topic_private($topic->ID)) {
             $actions['approved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Approve this topic', 'bbpress') . '">' . _x('Approve', 'Approve Topic', 'bbpress') . '</a>';
             $actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
         }
         // Close
         // Show the 'close' and 'open' link on published and closed posts only
         if (in_array($topic->post_status, array(bbp_get_public_status_id(), bbp_get_closed_status_id()))) {
             $close_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'close-topic_' . $topic->ID);
             if (bbp_is_topic_open($topic->ID)) {
                 $actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Close this topic', 'bbpress') . '">' . _x('Close', 'Close a Topic', 'bbpress') . '</a>';
             } else {
                 $actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Open this topic', 'bbpress') . '">' . _x('Open', 'Open a Topic', 'bbpress') . '</a>';
             }
         }
         // Sticky
         // Dont show sticky if topic links is spam, trash or pending
         if (!bbp_is_topic_spam($topic->ID) && !bbp_is_topic_trash($topic->ID) && !bbp_is_topic_pending($topic->ID)) {
             $stick_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
             if (bbp_is_topic_sticky($topic->ID)) {
                 $actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Unstick this topic', 'bbpress') . '">' . esc_html__('Unstick', 'bbpress') . '</a>';
             } else {
                 $super_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
                 $actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Stick this topic to its forum', 'bbpress') . '">' . esc_html__('Stick', 'bbpress') . '</a> <a href="' . esc_url($super_uri) . '" title="' . esc_attr__('Stick this topic to front', 'bbpress') . '">' . esc_html__('(to front)', 'bbpress') . '</a>';
             }
         }
         // Spam
         $spam_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'spam-topic_' . $topic->ID);
         if (bbp_is_topic_spam($topic->ID)) {
             $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark the topic as not spam', 'bbpress') . '">' . esc_html__('Not spam', 'bbpress') . '</a>';
         } else {
             $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark this topic as spam', 'bbpress') . '">' . esc_html__('Spam', 'bbpress') . '</a>';
         }
     }
     // Do not show trash links for spam topics, or spam links for trashed topics
     if (current_user_can('delete_topic', $topic->ID)) {
         if (bbp_get_trash_status_id() === $topic->post_status) {
             $post_type_object = get_post_type_object(bbp_get_topic_post_type());
             $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash', 'bbpress') . "' href='" . wp_nonce_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $topic->ID))), 'untrash-' . $topic->post_type . '_' . $topic->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_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID))) . "'>" . esc_html__('Trash', 'bbpress') . "</a>";
         }
         if (bbp_get_trash_status_id() === $topic->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_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID, '', true))) . "'>" . esc_html__('Delete Permanently', 'bbpress') . "</a>";
         } elseif (bbp_get_spam_status_id() === $topic->post_status) {
             unset($actions['trash']);
         }
     }
     return $actions;
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:93,代码来源:topics.php


示例5: bbp_get_topic_trash_link

/**
 * Return the trash link of the topic
 *
 * @since bbPress (r2727)
 *
 * @param mixed $args This function supports these args:
 *  - id: Optional. Topic id
 *  - link_before: Before the link
 *  - link_after: After the link
 *  - sep: Links separator
 *  - trash_text: Trash text
 *  - restore_text: Restore text
 *  - delete_text: Delete text
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses current_user_can() To check if the current user can delete the
 *                           topic
 * @uses bbp_is_topic_trash() To check if the topic is trashed
 * @uses bbp_get_topic_status() To get the topic status
 * @uses add_query_arg() To add custom args to the url
 * @uses wp_nonce_url() To nonce the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_trash_link' with the link
 *                        and args
 * @return string Topic trash link
 */
function bbp_get_topic_trash_link($args = '')
{
    $defaults = array('id' => 0, 'link_before' => '', 'link_after' => '', 'sep' => ' | ', 'trash_text' => __('Trash', 'bbpress'), 'restore_text' => __('Restore', 'bbpress'), 'delete_text' => __('Delete', 'bbpress'));
    $r = bbp_parse_args($args, $defaults, 'get_topic_trash_link');
    extract($r);
    $actions = array();
    $topic = bbp_get_topic(bbp_get_topic_id((int) $id));
    if (empty($topic) || !current_user_can('delete_topic', $topic->ID)) {
        return;
    }
    if (bbp_is_topic_trash($topic->ID)) {
        $actions['untrash'] = '<a title="' . esc_attr__('Restore this item from the Trash', 'bbpress') . '" href="' . esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID)), 'untrash-' . $topic->post_type . '_' . $topic->ID)) . '">' . esc_html($restore_text) . '</a>';
    } elseif (EMPTY_TRASH_DAYS) {
        $actions['trash'] = '<a title="' . esc_attr__('Move this item to the Trash', 'bbpress') . '" href="' . esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID)), 'trash-' . $topic->post_type . '_' . $topic->ID)) . '">' . esc_html($trash_text) . '</a>';
    }
    if (bbp_is_topic_trash($topic->ID) || !EMPTY_TRASH_DAYS) {
        $actions['delete'] = '<a title="' . esc_attr__('Delete this item permanently', 'bbpress') . '" href="' . esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID)), 'delete-' . $topic->post_type . '_' . $topic->ID)) . '" onclick="return confirm(\'' . esc_js(__('Are you sure you want to delete that permanently?', 'bbpress')) . '\' );">' . esc_html($delete_text) . '</a>';
    }
    // Process the admin links
    $retval = $link_before . implode($sep, $actions) . $link_after;
    return apply_filters('bbp_get_topic_trash_link', $retval, $args);
}
开发者ID:rmccue,项目名称:bbPress,代码行数:48,代码来源:bbp-topic-template.php


示例6: bbp_new_reply_handler


//.........这里部分代码省略.........
    $reply_title = apply_filters('bbp_new_reply_pre_title', $reply_title);
    // No reply title
    if (empty($reply_title)) {
        bbp_add_error('bbp_reply_title', __('<strong>ERROR</strong>: Your reply needs a title.', 'bbpress'));
    }
    /** Reply Content *********************************************************/
    if (!empty($_POST['bbp_reply_content'])) {
        $reply_content = $_POST['bbp_reply_content'];
    }
    // Filter and sanitize
    $reply_content = apply_filters('bbp_new_reply_pre_content', $reply_content);
    // No reply content
    if (empty($reply_content)) {
        bbp_add_error('bbp_reply_content', __('<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress'));
    }
    /** Reply Flooding ********************************************************/
    if (!bbp_check_for_flood($anonymous_data, $reply_author)) {
        bbp_add_error('bbp_reply_flood', __('<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress'));
    }
    /** Reply Duplicate *******************************************************/
    if (!bbp_check_for_duplicate(array('post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data))) {
        bbp_add_error('bbp_reply_duplicate', __('<strong>ERROR</strong>: Duplicate reply detected; it looks as though you&#8217;ve already said that!', 'bbpress'));
    }
    /** Reply Blacklist *******************************************************/
    if (!bbp_check_for_blacklist($anonymous_data, $reply_author, $reply_title, $reply_content)) {
        bbp_add_error('bbp_reply_blacklist', __('<strong>ERROR</strong>: Your reply cannot be created at this time.', 'bbpress'));
    }
    /** Reply Moderation ******************************************************/
    $post_status = bbp_get_public_status_id();
    if (!bbp_check_for_moderation($anonymous_data, $reply_author, $reply_title, $reply_content)) {
        $post_status = bbp_get_pending_status_id();
    }
    /** Topic Tags ************************************************************/
    if (!empty($_POST['bbp_topic_tags'])) {
        $terms = esc_attr(strip_tags($_POST['bbp_topic_tags']));
    }
    /** Additional Actions (Before Save) **************************************/
    do_action('bbp_new_reply_pre_extras', $topic_id, $forum_id);
    // Bail if errors
    if (bbp_has_errors()) {
        return;
    }
    /** No Errors *************************************************************/
    // Add the content of the form to $reply_data as an array
    // Just in time manipulation of reply data before being created
    $reply_data = apply_filters('bbp_new_reply_pre_insert', array('post_author' => $reply_author, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'post_status' => $post_status, 'post_type' => bbp_get_reply_post_type(), 'comment_status' => 'closed', 'menu_order' => (int) (bbp_get_topic_reply_count($topic_id) + 1)));
    // Insert reply
    $reply_id = wp_insert_post($reply_data);
    /** No Errors *************************************************************/
    // Check for missing reply_id or error
    if (!empty($reply_id) && !is_wp_error($reply_id)) {
        /** Topic Tags ********************************************************/
        // Just in time manipulation of reply terms before being edited
        $terms = apply_filters('bbp_new_reply_pre_set_terms', $terms, $topic_id, $reply_id);
        // Insert terms
        $terms = wp_set_post_terms($topic_id, $terms, bbp_get_topic_tag_tax_id(), false);
        // Term error
        if (is_wp_error($terms)) {
            bbp_add_error('bbp_reply_tags', __('<strong>ERROR</strong>: There was a problem adding the tags to the topic.', 'bbpress'));
        }
        /** Trash Check *******************************************************/
        // If this reply starts as trash, add it to pre_trashed_replies
        // for the topic, so it is properly restored.
        if (bbp_is_topic_trash($topic_id) || $reply_data['post_status'] == bbp_get_trash_status_id()) {
            // Trash the reply
            wp_trash_post($reply_id);
            // Get pre_trashed_replies for topic
            $pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
            // Add this reply to the end of the existing replies
            $pre_trashed_replies[] = $reply_id;
            // Update the pre_trashed_reply post meta
            update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
        }
        /** Spam Check ********************************************************/
        // If reply or topic are spam, officially spam this reply
        if (bbp_is_topic_spam($topic_id) || $reply_data['post_status'] == bbp_get_spam_status_id()) {
            add_post_meta($reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
        }
        /** Update counts, etc... *********************************************/
        do_action('bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author);
        /** Additional Actions (After Save) ***********************************/
        do_action('bbp_new_reply_post_extras', $reply_id);
        /** Redirect **********************************************************/
        // Redirect to
        $redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
        // Get the reply URL
        $reply_url = bbp_get_reply_url($reply_id, $redirect_to);
        // Allow to be filtered
        $reply_url = apply_filters('bbp_new_reply_redirect_to', $reply_url, $redirect_to, $reply_id);
        /** Successful Save ***************************************************/
        // Redirect back to new reply
        wp_safe_redirect($reply_url);
        // For good measure
        exit;
        /** Errors ****************************************************************/
    } else {
        $append_error = is_wp_error($reply_id) && $reply_id->get_error_message() ? $reply_id->get_error_message() . ' ' : '';
        bbp_add_error('bbp_reply_error', __('<strong>ERROR</strong>: The following problem(s) have been found with your reply:' . $append_error . 'Please try again.', 'bbpress'));
    }
}
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:bbp-reply-functions.php


示例7: bbp_get_reply_admin_links

/**
 * Return admin links for reply
 *
 * @since bbPress (r2667)
 *
 * @param mixed $args This function supports these arguments:
 *  - id: Optional. Reply id
 *  - before: HTML before the links. Defaults to
 *             '<span class="bbp-admin-links">'
 *  - after: HTML after the links. Defaults to '</span>'
 *  - sep: Separator. Defaults to ' | '
 *  - links: Array of the links to display. By default, edit, trash,
 *            spam and topic split links are displayed
 * @uses bbp_is_topic() To check if it's the topic page
 * @uses bbp_is_reply() To check if it's the reply page
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply_edit_link() To get the reply edit link
 * @uses bbp_get_reply_trash_link() To get the reply trash link
 * @uses bbp_get_reply_spam_link() To get the reply spam link
 * @uses bbp_get_topic_split_link() To get the topic split link
 * @uses current_user_can() To check if the current user can edit or
 *                           delete the reply
 * @uses apply_filters() Calls 'bbp_get_reply_admin_links' with the
 *                        reply admin links and args
 * @return string Reply admin links
 */
function bbp_get_reply_admin_links($args = '')
{
    $defaults = array('id' => 0, 'before' => '<span class="bbp-admin-links">', 'after' => '</span>', 'sep' => ' | ', 'links' => array());
    $r = bbp_parse_args($args, $defaults, 'get_reply_admin_links');
    $r['id'] = bbp_get_reply_id((int) $r['id']);
    // If post is a topic, return the topic admin links instead
    if (bbp_is_topic($r['id'])) {
        return bbp_get_topic_admin_links($args);
    }
    // If post is not a reply, return
    if (!bbp_is_reply($r['id'])) {
        return;
    }
    // Make sure user can edit this reply
    if (!current_user_can('edit_reply', $r['id'])) {
        return;
    }
    // If topic is trashed, do not show admin links
    if (bbp_is_topic_trash(bbp_get_reply_topic_id($r['id']))) {
        return;
    }
    // If no links were passed, default to the standard
    if (empty($r['links'])) {
        $r['links'] = array('edit' => bbp_get_reply_edit_link($r), 'split' => bbp_get_topic_split_link($r), 'trash' => bbp_get_reply_trash_link($r), 'spam' => bbp_get_reply_spam_link($r));
    }
    // Check caps for trashing the topic
    if (!current_user_can('delete_reply', $r['id']) && !empty($r['links']['trash'])) {
        unset($r['links']['trash']);
    }
    // See if links need to be unset
    $reply_status = bbp_get_reply_status($r['id']);
    if (in_array($reply_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id()))) {
        // Spam link shouldn't be visible on trashed topics
        if ($reply_status == bbp_get_trash_status_id()) {
            unset($r['links']['spam']);
            // Trash link shouldn't be visible on spam topics
        } elseif (isset($r['links']['trash']) && bbp_get_spam_status_id() == $reply_status) {
            unset($r['links']['trash']);
        }
    }
    // Process the admin links
    $links = implode($r['sep'], array_filter($r['links']));
    $retval = $r['before'] . $links . $r['after'];
    return apply_filters('bbp_get_reply_admin_links', $retval, $args);
}
开发者ID:hscale,项目名称:webento,代码行数:71,代码来源:template-tags.php


示例8: post


//.........这里部分代码省略.........
     if (user_can($user_id, 'unfiltered_html')) {
         remove_filter('bbp_new_reply_pre_title', 'wp_filter_kses');
         remove_filter('bbp_new_reply_pre_content', 'wp_filter_kses');
     }
     /** REPLY DATA ***************************************************/
     // setup a dummy reply title b/c bbP requires it
     $reply_title = sprintf(__('Reply To: Topic ID %d', 'bp-rbe'), $topic_id);
     // Filter and sanitize
     $reply_content = apply_filters('bbp_new_reply_pre_content', $data['content']);
     /** REPLY MODERATION *********************************************/
     // Reply Flooding
     if (!bbp_check_for_flood($anonymous_data, $reply_author)) {
         //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_flood' );
         //bbp_add_error( 'bbp_reply_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) );
         return new WP_Error('bbp_reply_flood', '', $data);
     }
     // Reply Duplicate
     if (!bbp_check_for_duplicate(array('post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data))) {
         //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_duplicate' );
         return new WP_Error('bbp_reply_duplicate', '', $data);
     }
     // Reply Blacklist
     if (!bbp_check_for_blacklist($anonymous_data, $reply_author, $reply_title, $reply_content)) {
         //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_blacklist' );
         return new WP_Error('bbp_reply_blacklist', '', $data);
     }
     // Reply Status
     // Maybe put into moderation
     if (!bbp_check_for_moderation($anonymous_data, $reply_author, $reply_title, $reply_content)) {
         $reply_status = bbp_get_pending_status_id();
         // Default
     } else {
         $reply_status = bbp_get_public_status_id();
     }
     /** POSTING TIME! ************************************************/
     // get forum ID
     $forum_id = bbp_get_topic_forum_id($topic_id);
     // bbP hook before save
     do_action('bbp_new_reply_pre_extras', $topic_id, $forum_id);
     // Setup reply data
     $reply_data = apply_filters('bbp_new_reply_pre_insert', array('post_author' => $reply_author, 'post_title' => $reply_title, 'post_content' => $reply_content, 'post_status' => $reply_status, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'comment_status' => 'closed', 'menu_order' => bbp_get_topic_reply_count($topic_id, false) + 1));
     // Insert reply
     $reply_id = wp_insert_post($reply_data);
     // Reply posted!
     if (!is_wp_error($reply_id)) {
         // more internal logging
         bp_rbe_log('Message #' . $i . ': bbPress reply successfully posted!');
         // Problem posting
     } else {
         //do_action( 'bp_rbe_imap_no_match', $connection, $i, $headers, 'bbp_reply_error' );
         return new WP_Error('bbp_reply_error', '', $data);
     }
     /** AFTER POSTING ************************************************/
     // stuff that needs to happen after a bbP reply is posted occurs here... bbP
     // should preferably do the following at the 'bbp_new_reply' hook, until then
     // do what bbP does inline.
     // Trash Check ////////////////////////////////////////////////////
     // If this reply starts as trash, add it to pre_trashed_replies
     // for the topic, so it is properly restored.
     if (bbp_is_topic_trash($topic_id) || $reply_data['post_status'] == bbp_get_trash_status_id()) {
         // Trash the reply
         wp_trash_post($reply_id);
         // Only add to pre-trashed array if topic is trashed
         if (bbp_is_topic_trash($topic_id)) {
             // Get pre_trashed_replies for topic
             $pre_trashed_replies = get_post_meta($topic_id, '_bbp_pre_trashed_replies', true);
             // Add this reply to the end of the existing replies
             $pre_trashed_replies[] = $reply_id;
             // Update the pre_trashed_reply post meta
             update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
         }
         // Spam Check /////////////////////////////////////////////////////
         // If reply or topic are spam, officially spam this reply
     } elseif (bbp_is_topic_spam($topic_id) || $reply_data['post_status'] == bbp_get_spam_status_id()) {
         add_post_meta($reply_id, '_bbp_spam_meta_status', bbp_get_public_status_id());
         // Only add to pre-spammed array if topic is spam
         if (bbp_is_topic_spam($topic_id)) {
             // Get pre_spammed_replies for topic
             $pre_spammed_replies = get_post_meta($topic_id, '_bbp_pre_spammed_replies', true);
             // Add this reply to the end of the existing replies
             $pre_spammed_replies[] = $reply_id;
             // Update the pre_spammed_replies post meta
             update_post_meta($topic_id, '_bbp_pre_spammed_replies', $pre_spammed_replies);
         }
     }
     // Reply By Email /////////////////////////////////////////////////
     // Add a RBE marker to the post's meta
     // Could potentially show that post was made via email on the frontend
     add_post_meta($reply_id, 'bp_rbe', 1);
     /** POST HOOKS ***************************************************/
     // RBE Custom Hooks ///////////////////////////////////////////////
     // change activity action
     add_filter('bbp_before_record_activity_parse_args', array($this, 'change_activity_action'));
     // add RBE's special activity hook
     add_action('bp_activity_after_save', array($this, 'activity_rbe_hook'));
     // bbPress Reply Hooks ////////////////////////////////////////////
     do_action('bbp_new_reply', $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, false, $reply_to);
     do_action('bbp_new_reply_post_extras', $reply_id);
     return array('bbp_reply_id' => $reply_id);
 }
开发者ID:r-a-y,项目名称:bp-reply-by-email,代码行数:101,代码来源:bp-rbe-extend-bbpress.php



注:本文中的bbp_is_topic_trash函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bbp_is_user_favorite函数代码示例发布时间:2022-05-24
下一篇:
PHP bbp_is_topic_tag_edit函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap