WordPressの掲示板bbpressをアレンジしてみた

WordPressの掲示板bbpressは、そのままだと気になる部分があるのでアレンジしてみました。
Wordpressの掲示板bbpressは、PPHで作られているのですが、PPHについては基本的な知識しか無いので苦労しました。

投稿時にurlを入力するのを削除したいのでpluginsの中の
wp-content・・・plugins・・・bbpress・・・templates・・・default・・・bbpress・・・form-anonymous.php
を変更しました。

<p>
<label for=”bbp_anonymous_website”><?php esc_html_e( ‘Website:’, ‘bbpress’ ); ?></label><br />
<input type=”text” id=”bbp_anonymous_website” value=”<?php bbp_author_url(); ?>” size=”40″ maxlength=”200″ name=”bbp_anonymous_website” />
</p>

の部分を削除しました。

トピック一覧からトピック作成者の表示を削除することにしました。
pluginsの中の
templates・・・default・・・bbpress・・・loop-single-topic.php
を変更しました。

<?php do_action( ‘bbp_theme_before_topic_started_by’ ); ?>

<span class=”bbp-topic-started-by”><?php printf( __( ‘Started by: %1$s’, ‘bbpress’ ), bbp_get_topic_author_link( array( ‘size’ => ’14’ ) ) ); ?></span>

<?php do_action( ‘bbp_theme_after_topic_started_by’ ); ?>

の部分と

<p class=”bbp-topic-meta”>

<?php do_action( ‘bbp_theme_before_topic_freshness_author’ ); ?>

<span class=”bbp-topic-freshness-author”><?php bbp_author_link( array( ‘post_id’ => bbp_get_topic_last_active_id(), ‘size’ => 14 ) ); ?></span>

<?php do_action( ‘bbp_theme_after_topic_freshness_author’ ); ?>

</p>

の部分を削除しました。

「このフォーラムには1件のトピックが含まれ、2 時間、 40 分前に 俊 さんが最後の更新を行いました。」というのも削除する事にしました。

pluginsの中の
includes・・・forums・・・template.php
の2150行付近にある

// Forum has active data
if ( !empty( $last_active ) ) {

if ( !empty( $reply_count ) ) {

if ( bbp_is_forum_category( $forum_id ) ) {
$retstr = sprintf( esc_html__( ‘This category contains %1$s and %2$s, and was last updated by %3$s %4$s.‘, ‘bbpress’ ), $topic_text, $reply_text, $last_updated_by, $time_since );
} else {
$retstr = sprintf( esc_html__( ‘This forum contains %1$s and %2$s, and was last updated by %3$s %4$s.‘, ‘bbpress’ ), $topic_text, $reply_text, $last_updated_by, $time_since );
}

} else {

if ( bbp_is_forum_category( $forum_id ) ) {
$retstr = sprintf( esc_html__( ‘This category contains %1$s, and was last updated by %2$s %3$s.‘, ‘bbpress’ ), $topic_text, $last_updated_by, $time_since );
} else {
$retstr = sprintf( esc_html__( ‘This forum contains %1$s, and was last updated by %2$s %3$s.’, ‘bbpress‘ ), $topic_text, $last_updated_by, $time_since );
}
}

// Forum has no last active data
} else {

if ( !empty( $reply_count ) ) {

if ( bbp_is_forum_category( $forum_id ) ) {
$retstr = sprintf( esc_html__( ‘This category contains %1$s and %2$s.’, ‘bbpress’ ), $topic_text, $reply_text );
} else {
$retstr = sprintf( esc_html__( ‘This forum contains %1$s and %2$s.’, ‘bbpress’ ), $topic_text, $reply_text );
}

} else {

if ( !empty( $topic_count ) ) {

if ( bbp_is_forum_category( $forum_id ) ) {
$retstr = sprintf( esc_html__( ‘This category contains %1$s.’, ‘bbpress’ ), $topic_text );
} else {
$retstr = sprintf( esc_html__( ‘This forum contains %1$s.’, ‘bbpress’ ), $topic_text );
}

} else {
$retstr = esc_html__( ‘This forum is empty.’, ‘bbpress’ );
}
}
}

の青色の部分を削除しました。

「このトピックには 0件の返信 、 1人の参加者 が含まれます。 最終更新 by syun 5 日、 22 時間前.」も削除する事にしました。

pluginsの中の
includes・・・topics・・・template.php
の3368行付近の

function bbp_get_single_topic_description( $args = ” ) {

// Parse arguments against default values
$r = bbp_parse_args( $args, array(
‘topic_id’ => 0,
‘before’ => ‘<div class=”bbp-template-notice info”><p class=”bbp-topic-description”>’,
‘after’ => ‘</p></div>’,
‘size’ => 14
), ‘get_single_topic_description’ );

// Validate topic_id
$topic_id = bbp_get_topic_id( $r[‘topic_id’] );

// Unhook the ‘view all’ query var adder
remove_filter( ‘bbp_get_topic_permalink’, ‘bbp_add_view_all’ );

// Build the topic description
$vc_int = bbp_get_topic_voice_count ( $topic_id, true );
$voice_count = bbp_get_topic_voice_count ( $topic_id, false );
$reply_count = bbp_get_topic_replies_link ( $topic_id );
$time_since = bbp_get_topic_freshness_link( $topic_id );

// Singular/Plural
$voice_count = sprintf( _n( ‘%s voice’, ‘%s voices’, $vc_int, ‘bbpress’ ), $voice_count );

// Topic has replies
$last_reply = bbp_get_topic_last_reply_id( $topic_id );
if ( !empty( $last_reply ) ) {
$last_updated_by = bbp_get_author_link( array( ‘post_id’ => $last_reply, ‘size’ => $r[‘size’] ) );
$retstr = sprintf( esc_html__( ‘This topic contains %1$s, has %2$s, and was last updated by %3$s %4$s.‘, ‘bbpress’ ), $reply_count, $voice_count, $last_updated_by, $time_since );

// Topic has no replies
} elseif ( ! empty( $voice_count ) && ! empty( $reply_count ) ) {
$retstr = sprintf( esc_html__( ‘This topic contains %1$s and has %2$s.‘, ‘bbpress’ ), $voice_count, $reply_count );

// Topic has no replies and no voices
} elseif ( empty( $voice_count ) && empty( $reply_count ) ) {
$retstr = sprintf( esc_html__( ‘This topic has no replies.‘, ‘bbpress’ ), $voice_count, $reply_count );
}

// Add the ‘view all’ filter back
add_filter( ‘bbp_get_topic_permalink’, ‘bbp_add_view_all’ );

// Combine the elements together
$retstr = $r[‘before’] . $retstr . $r[‘after’];

// Return filtered result
return apply_filters( ‘bbp_get_single_topic_description’, $retstr, $r );
}

の青色の部分を削除しました。

余計な部分を削除して、すっきりしたと思います。

メールの登録しなくても投稿できるようにしました。
https://www.cherrypieweb.com/5357 を参考に
bbpress/includes/common/functions.php に
次のコードを追加します。
場所はどこでも良いですが
50行付近の

function bbp_get_redirect_to() {

// Check ‘redirect_to’ request parameter
$retval = ! empty( $_REQUEST[‘redirect_to’] )
? $_REQUEST[‘redirect_to’]
: ”;

// Filter & return
return apply_filters( ‘bbp_get_redirect_to’, $retval );
}

の下に

function bbp_set_default_email( $post_author_email ) {
if ( empty( $post_author_email ) ) {
$post_author_email = ‘anonymous@example.com’;
}
return $post_author_email;
}
add_filter( ‘bbp_pre_anonymous_post_author_email’, ‘bbp_set_default_email’, 10, 1 );

function bbp_remove_default_email( $r, $args ) {
if ( $r[‘bbp_anonymous_email’] == ‘anonymous@example.com’ ) {
$r[‘bbp_anonymous_email’] = ”;
}
return $r;
}
add_filter( ‘bbp_filter_anonymous_post_data’, ‘bbp_remove_default_email’, 10, 2 );

を追加しました。

wp-content・・・plugins・・・bbpress・・・templates・・・default・・・bbpress・・・form-anonymous.php
を変更しました。

30行付近の
<label for=”bbp_anonymous_email”><?php esc_html_e( ‘Mail (will not be published) (required):’, ‘bbpress’ ); ?></label><br />
<input type=”text” id=”bbp_anonymous_email” value=”<?php bbp_author_email(); ?>” size=”40″ maxlength=”100″ name=”bbp_anonymous_email” />

の青色部分を削除しました。

 

コメントを残す

メールアドレスが公開されることはありません。