[Bb-trac] [bbPress] #604: Template functions should explicitly
depend on globals
bbPress
bb-trac at lists.bbpress.org
Mon Mar 5 06:23:45 GMT 2007
#604: Template functions should explicitly depend on globals
----------------------+-----------------------------------------------------
Reporter: mdawaffe | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.0
Component: Back-end | Version: 0.8.1
Severity: normal | Keywords:
----------------------+-----------------------------------------------------
get_topic_title(), for example, should not poison the global well.
So let's do something like the following.
{{{
-function get_topic_id() {
+function get_topic_id( $id = 0 ) {
global $topic;
- return $topic->topic_id;
+ $id = (int) $id;
+ if ( $id )
+ $_topic = get_topic( $id );
+ else
+ $_topic =& $topic;
+ return $_topic->topic_id;
}
function get_topic_title( $id = 0 ) {
- global $topic;
- if ( $id )
- $topic = get_topic( $id );
+ $topic = get_topic( get_topic_id( $id ) );
return apply_filters( 'get_topic_title', $topic->topic_title,
$topic->topic_id );
}
}}}
--
Ticket URL: <http://trac.bbpress.org/ticket/604>
bbPress <http://bbpress.org/>
Innovative forum development
More information about the Bb-trac
mailing list