Skip to:
Content
Pages
Categories
Search
Top
Bottom

Customize Topic Labels

  • In bb-includes/formatting-functions.php the values of the closed and sticky labels are hard coded:

    function bb_closed_label( $label ) {
    global $topic;
    if ( '0' === $topic->topic_open )
    return sprintf(__('[closed] %s'), $label);
    return $label;
    }

    I want to change ‘closed’ to ‘Read Only’. I know I can just hack the file, but there should be a way to use theme functions and I’m just not thawed out enough to think of it.

Viewing 4 replies - 1 through 4 (of 4 total)

  • _ck_
    Participant

    @_ck_

    You don’t have to hack anything, it’s done via a filter.

    ie.

    add_filter('bb_topic_labels', 'bb_closed_label', 10);
    add_filter('bb_topic_labels', 'bb_sticky_label', 20);

    simply remove the filter via a plugin and replace it with your own routine.

    remove_filter('bb_topic_labels', 'bb_closed_label');
    add_filter('bb_topic_labels', 'my_closed_label');
    function my_closed_label( $label ) {
    global $topic;
    if ( '0' === $topic->topic_open )
    return sprintf(__('[Read Only] %s'), $label);
    return $label;
    }

    Doy!

    I put that in functions.php in my theme and it works. Thanks!

    I need to thaw my brain out.

    Okay, now it’s weird. It works perfect for bb_closed_label, but remove_filter('bb_topic_labels', 'bb_sticky_label'); does nothing.

    What I tried was

    remove_filter('bb_topic_labels', 'bb_sticky_label');
    function my_sticky_label( $label ) {
    global $topic;
    if (is_front()) {
    if ( '2' === $topic->topic_sticky ) {
    return sprintf(__('<img src="/images/sticky.png" /> %s'), $label);
    }
    } else {
    if ( '1' === $topic->topic_sticky || '2' === $topic->topic_sticky ) {
    return sprintf(__('<img src="/images/sticky.png" /> %s'), $label);
    }
    }
    return $label;
    }
    add_filter('bb_topic_labels', 'my_sticky_label');

    When I do that I get [sticky] and then my image. Which is close…

    remove_filter('bb_topic_labels', 'bb_sticky_label', 20); worked.

    Now it has images :)

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