Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Fuskeduske

    (@fuskeren)

    I see i missed out on some information:

    It is breaking funcitonality for tnis piece:

    public function bbp_list_forums( $html ){
    global $wpdb;
    $user_id = get_current_user_id();
    $new_topics_array = (array) get_user_meta( $user_id, ‘bbp_new_topics’, true );
    $new_tag = ‘<span class=”new-topic-notifier”>’ . __( ‘New’, ‘new-topics’ ) . ‘</span> ‘;

    $pattern = ‘/<a.*?href\=”.*?\/([^\/]*?)\/”/’;
    preg_match_all( $pattern, $html, $matches );
    for ( $i = 0, $ic = count($matches[0]); $i < $ic; $i++ ) {
    $to_replace = $matches[0][$i];
    $forum_name = $matches[1][$i];
    $forum_id = $wpdb->get_var( ‘SELECT ID FROM ‘ . $wpdb->prefix . ‘posts WHERE post_name = “‘ . $forum_name . ‘” LIMIT 1;’ );
    if ( $forum_id !== null ) {
    $new_query = ‘SELECT ID as post_id FROM ‘ . $wpdb->prefix . ‘posts WHERE post_type = “topic” AND post_status = “publish” AND post_parent = “‘ . $forum_id . ‘”;’;
    $result = $wpdb->get_results( $new_query );
    foreach( $result as $row ) {
    if ( in_array( (int) $row->post_id, array_filter( $new_topics_array ) ) && !strpos( $html, $new_tag . $to_replace ) ) {
    $html = str_replace( $to_replace, $new_tag . $to_replace , $html );
    }
    }
    }

    This is which shows a “new” tag on the main index”

    It does not break for when you enter a subforum, which uses the following:

    public function bbp_theme_before_forum_title(){
    $user_id = get_current_user_id();
    $forum_id = bbp_get_forum_id();
    $new_topics_array = (array) get_user_meta( $user_id, ‘bbp_new_topics’, true );

    global $wpdb;
    $new_query = ‘SELECT ID as post_id FROM ‘ . $wpdb->prefix . ‘posts WHERE post_type = “topic” AND post_status = “publish” AND post_parent = “‘ . $forum_id. ‘”;’;

    $result = $wpdb->get_results( $new_query );

    foreach( $result as $row ) {
    if ( in_array( (int) $row->post_id, array_filter( $new_topics_array ) ) ) {
    echo ‘<span class=”new-topic-notifier”>’ . __( ‘New’, ‘new-topics’ ) . ‘</span> ‘;
    }
    }

    Plugin Author Robin W

    (@robin-w)

    ok, thanks for posting.

    I’m a bit confused.

    I can’t see the code above in either bbpress or the new-topics plugin – where is this code?

    Thread Starter Fuskeduske

    (@fuskeren)

    The code is a “modification” for showing the “new” tag in the root index, it can be found here:

    https://eyga.net/en/wp-content/uploads/sites/2/2016/01/bbpress-new-topics.zip

    It works as intended without bbp private groups, but once your plugin is enabled it stops working.

    Plugin Author Robin W

    (@robin-w)

    ok, thanks I can see this now.

    Both plugins are filtering on the same bbpress function (bbp_list_forums) – mine to stop showing forums , and new topics to add the new topics.

    I am not keen to change code to work specifically with new topics, but suggest you try the following

    in private groups/includes/forums-filters.php

    change line 286 from

    echo $r['before'] . $output . $r['after'];

    to

    echo apply_filters( 'custom_list_forums', $r['before'] . $output . $r['after'], $r );

    then in bbpress new topics

    change line 54 from

    add_action( 'bbp_list_forums', array( $this, 'bbp_list_forums' ) );

    to

    add_action( 'custom_list_forums', array( $this, 'bbp_list_forums' ) );

    If that all works, then I’ll add my code as a permanent to the next version, but you’ll need to re-add the new topics code above if/each time the author releases new versions.

    Thread Starter Fuskeduske

    (@fuskeren)

    Hi Robin,

    It seems to be working, thank you a thousand times, it would’ve taken me close to a hundred years to figure out, i will reopen if i find anything that is not working as intended.

    -Mads

    Plugin Author Robin W

    (@robin-w)

    great !

    On the next release I’ll add the code

    Thread Starter Fuskeduske

    (@fuskeren)

    Ignore this, found out ??

    Thanks for your time spent on this plugin and the support, not often seen that plugin authors help out after the plugin is released.

    Plugin Author Robin W

    (@robin-w)

    ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Does not work together with bbpress New-topics’ is closed to new replies.