- このトピックには1件の返信、2人の参加者があり、最後に
yokohama-clbeにより4ヶ月、 1週前に更新されました。
-
投稿者投稿
-
2025年9月21日 2:09 AM #101
seisuke3333
参加者今日会える方
2025年9月27日 8:47 AM #133
yokohama-clbeキーマスターcapability = apply_filters( ‘bbp_private_replies_capability’, $this->capability );
}/**
* Retrieves the no reply address.
*
* @since 1.3.3
*
* @return string
*/
public function get_no_reply() {
return apply_filters( ‘bbp_private_replies_no_reply_address’, bbp_get_do_not_reply_address() );
}/**
* Outputs the “Set as private reply” checkbox in reply form.
*
* @since 1.0
*
* @return void
*/
public function checkbox() {
$reply_id = bbp_get_reply_id();
$checked = checked( ‘1’, $this->is_private( $reply_id ), false );
$tab_index = bbp_tab_index();
?>
is_private( $reply_id ) ) {
$current_user = is_user_logged_in() ? wp_get_current_user() : false;
$topic_author = bbp_get_topic_author_id();
$reply_author = bbp_get_reply_author_id( $reply_id );$can_view = false;
// 返信者本人は閲覧可
if ( ! empty( $current_user ) && $current_user->ID === $reply_author ) {
$can_view = true;
}// トピック作成者は閲覧可(ただし返信者がモデレーターである場合などフィルタ条件も考慮可能)
if ( ! empty( $current_user ) && $current_user->ID === $topic_author && user_can( $reply_author, $this->capability ) ) {
$can_view = true;
}// モデレーター(または指定キャパビリティ保有者)はすべて閲覧可能
if ( current_user_can( $this->capability ) ) {
$can_view = true;
}if ( ! $can_view ) {
return __( ‘This reply has been marked as private.’, ‘bbp_private_replies’ );
}
}return $content;
}/**
* Prevents subscription email for private replies (通常通知を遮断)
*
* @since 1.0
*
* @param string $message メール本文
* @param int $reply_id レプライ ID
* @param int $topic_id トピック ID
* @return mixed
*/
public function prevent_subscription_email( $message, $reply_id, $topic_id ) {
if ( $this->is_private( $reply_id ) ) {
$this->subscription_email( $message, $reply_id, $topic_id );
return false;
}
return $message;
}/**
* プライベート返信のとき、モデレーターなどに通知メールを BCC で送る処理
*
* @since 1.2
*
* @param string $message 通知メール本文
* @param int $reply_id レプライ ID
* @param int $topic_id トピック ID
* @return void
*/
public function subscription_email( $message, $reply_id, $topic_id ) {
if ( ! $this->is_private( $reply_id ) ) {
return;
}$topic_author = bbp_get_topic_author_id( $topic_id );
$reply_author = bbp_get_reply_author_id( $reply_id );
$reply_author_name = bbp_get_reply_author_display_name( $reply_id );$topic_title = strip_tags( bbp_get_topic_title( $topic_id ) );
$reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
$reply_url = bbp_get_reply_url( $reply_id );
$blog_name = wp_specialchars_decode( get_option( ‘blogname’ ), ENT_QUOTES );$subject = apply_filters( ‘bbp_subscription_mail_title’, ‘[‘ . $blog_name . ‘] ‘ . $topic_title, $reply_id, $topic_id );
$headers = array();
$headers[] = ‘From: ‘ . get_bloginfo( ‘name’ ) . ‘ <' . $this->get_no_reply() . ‘>’;$user_ids = bbp_get_topic_subscribers( $topic_id, true );
if ( empty( $user_ids ) ) {
return;
}foreach ( (array) $user_ids as $user_id ) {
if ( (int) $user_id === (int) $reply_author ) {
continue;
}
$should_notify_op = user_can( $reply_author, $this->capability ) && ( (int) $topic_author === (int) $user_id );
if ( user_can( $user_id, $this->capability ) || $should_notify_op ) {
$headers[] = ‘Bcc: ‘ . sanitize_email( get_userdata( $user_id )->user_email );
}
}// 通知先を明示的に設定(To: に管理者メールなど)
$to_address = get_option( ‘admin_email’ );
wp_mail( $to_address, $subject, $message, $headers );
}/**
* Adds a class name to replies that are private.
*
* @since 1.0
*
* @param array $classes 現在のクラス名配列
* @return array
*/
public function reply_post_class( $classes ) {
$reply_id = bbp_get_reply_id();
if ( bbp_get_reply_post_type() !== get_post_type( $reply_id ) ) {
return $classes;
}
if ( $this->is_private( $reply_id ) ) {
$classes[] = ‘bbp-private-reply’;
}
return $classes;
}/**
* Enqueues the plugin CSS file.
*
* @since 1.0
*
* @return void
*/
public function register_plugin_styles() {
$css_path = plugin_dir_path( __FILE__ ) . ‘css/front-end.css’;
if ( file_exists( $css_path ) ) {
wp_enqueue_style(
‘bbp_private_replies_style’,
plugin_dir_url( __FILE__ ) . ‘css/front-end.css’,
array(),
filemtime( $css_path )
);
}
}
}// instantiate our plugin’s class
$GLOBALS[‘bbp_private_replies’] = new BBP_Private_Replies();endif;
-
投稿者投稿
- このトピックに返信するにはログインが必要です。