Forums

Join
bbPress Support ForumsThemesModifying core functions with functions.php

Info

Modifying core functions with functions.php

  1. I would like to modify the bb_list_tags to show who the author of that tag was (to moderators)

    So I created a functions.php in my theme and have copied function bb_list_tags from functions.bb-templates.php file. And done the following (note the changes to the function have not yet been made)

    <?php
    // to override bb_list_tags to show tag author
    
    remove_filter('bb_list_tags', 'bb_list_tag');
    
    function bb_list_tag( $args = null ) {
    	$defaults = array(
    		'tags' => false,
    		'format' => 'list',
    		'topic' => 0,
    		'list_id' => 'tags-list'
    	);
    
    	$args = wp_parse_args( $args, $defaults );
    	extract( $args, EXTR_SKIP );
    
    	if ( !$topic = get_topic( get_topic_id( $topic ) ) )
    		return false;
    
    	if ( !is_array($tags) )
    		$tags = bb_get_topic_tags( $topic->topic_id );
    
    	if ( !$tags )
    		return false;
    
    	$list_id = attribute_escape( $list_id );
    
    	$r = '';
    	switch ( strtolower($format) ) :
    	case 'table' :
    		break;
    	case 'list' :
    	default :
    		$args['format'] = 'list';
    		$r .= "<ul id='$list_id' class='tags-list list:tag'>\n";
    		foreach ( $tags as $tag )
    			$r .= _bb_list_tag_item( $tag, $args );
    		$r .= "</ul>";
    	endswitch;
    	echo $r;
    }
    
    add_filter('bb_list_tags', 'bb_list_tag');
    
    ?>

    Is this the correct way to change a core function? Changing anything within it doesn't appear to override the original function.

  2. You must log in to post.