bp_nouveau_ajax_star_thread_messages ()

AJAX用星号标记消息。

描述

文件:bp-templates / bp-nouveau包括/信息/ ajax.php

function bp_nouveau_ajax_star_thread_messages() {if (empty($_POST['action'])) {wp_send_json_error();} $ action =(“消息大小写不敏感 _', '', $_ 文章['行动']);if ('star' === $action) {$error_message = __('有一个问题,你的消息。请再试一次。”、“buddyboss”);} else {$error_message = __('删除你的消息时出现了问题。请再试一次。”、“buddyboss”);} $response = array('feedback' => esc_html($error_message), 'type' => 'error',);if (false === bp_is_active('messages', 'star') || empty($_POST['id'])) {wp_send_json_error($response); } // Check capability. if ( ! is_user_logged_in() || ! bp_core_can_edit_settings() ) { wp_send_json_error( $response ); } $ids = wp_parse_id_list( $_POST['id'] ); $messages = array(); // Use global nonce for bulk actions involving more than one id if ( 1 !== count( $ids ) ) { if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_messages' ) ) { wp_send_json_error( $response ); } foreach ( $ids as $mid ) { if ( 'star' === $action ) { bp_messages_star_set_action( array( 'action' => 'star', 'message_id' => $mid, ) ); } else { $thread_id = messages_get_message_thread_id( $mid ); bp_messages_star_set_action( array( 'action' => 'unstar', 'thread_id' => $thread_id, 'bulk' => true ) ); } $messages[ $mid ] = array( 'star_link' => bp_get_the_message_star_action_link( array( 'message_id' => $mid, 'url_only' => true, ) ), 'is_starred' => 'star' === $action, ); } // Use global star nonce for bulk actions involving one id or regular action } else { $id = reset( $ids ); if ( empty( $_POST['star_nonce'] ) || ! wp_verify_nonce( $_POST['star_nonce'], 'bp-messages-star-' . $id ) ) { wp_send_json_error( $response ); } bp_messages_star_set_action( array( 'action' => $action, 'message_id' => $id, ) ); $messages[ $id ] = array( 'star_link' => bp_get_the_message_star_action_link( array( 'message_id' => $id, 'url_only' => true, ) ), 'is_starred' => 'star' === $action, ); } if ( 'star' === $action ) { $success_message = __( 'Messages successfully starred.', 'buddyboss' ); } else { $success_message = __( 'Messages successfully unstarred.', 'buddyboss' ); } wp_send_json_success( array( 'feedback' => esc_html( $success_message ), 'type' => 'success', 'messages' => $messages, ) ); }

更新日志

更新日志
版本 描述
BuddyPress 3.0.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队