Skip to:

Overwriting core functions

  • Ok I am trying to integrate bbpress here and have a couple of questions.

    I have my installation set up as such:

    2.0 plugin installed



    All the forum specific stuff is in the child theme.

    I want to change the freshness link to be something like > topic title – 2 hours ago by kode.

    My issue is that loop-forums.php uses bbp_forum_freshness_link, which in turn calls the function bbp_get_forum_freshness_link, both of which are in the core plugin, so if I edit either of these, when I upgrade the plugin my changes will dissapear, what do I need to do to overwrite it, or is there a better way to deal with it?

    My second question is how would I get the amount of forums / topics / posts etc?

    Currently in my header I have.

    $bbforums = $wpdb->get_row(“SELECT COUNT(ID) as forum_count FROM wp_posts WHERE post_type = ‘forum’ AND post_status = ‘publish'”);

    $bbtopics = $wpdb->get_row(“SELECT COUNT(ID) as topic_count FROM wp_posts WHERE post_type = ‘topic’ AND post_status = ‘publish'”);

    $bbreplies = $wpdb->get_row(“SELECT COUNT(ID) as reply_count FROM wp_posts WHERE post_type = ‘reply’ AND post_status = ‘publish'”);

    <h2>Forums <span class=”info-text pop”><?php echo $bbforums->forum_count.” forum(s) / “.$bbtopics->topic_count.” topic(s) / “.$bbreplies->reply_count.” post(s)”; ?></span></h2>

    But this is bringing back 5 forums (correct, I have 5 public forums and 1 private forum), 7 topics (incorrect, 2 of those are from the private forum, so I guess I need to left join the forum as well), 15 posts (this is the one that is confusing me, it should be 19, or 22 if it was bringing back the private ones) My ip has changed on my home address so I can’t bring up phpmyadmin to check until my host responds, so if anyone has any ideas in the mean time, please let me know.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Anyone have any ideas? =/

    Ok, I’ve worked out that the posts things is only counting replies (including from the private forum) and doesn’t count the original topic, so I guess all I need to do is add replies to topics to get the full amount of posts.

    Still not sure what to do to overwrite a core function though.

    I’ve changed it to

    extract( bbp_get_statistics(), EXTR_SKIP );

    <h2>Forums <span class=”info-text pop”><?php echo $forum_count.” forum(s) / “.$topic_count.” topic(s) / “.$reply_count.” post(s)”; ?></span></h2>

    But I’m getting exactly the same numbers, which doesn’t make sense as a quick look at the code seems to indicate the amount of topics that displays will depend on the users permissions.

    So when logged in as admin 7 topics would be right as there are 5 in public forums and 2 in a private forum, but when logged out it should say 5.

    However, it says 7 topics either way, and 23 replies

    Ok after reviewing the code again, it seems this is either by design or a bug?

    It calculates how many total topics there are, THEN if the user has permission counts how many private topics etc there are, but this has no effect on the total amount.

    This doesn’t make any sense to me?

    I can’t even count how many private topics there are and take it away from the total amount, because it only counts this if the user has permission to see private forums anyway.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar