yad4u Accessing class from Wordpress filter

Accessing class from Wordpress filter

I'm probably making a mess of this...

I'm trying to add a filter to the_content that will add a method from an external class, but keep going round in circles.

Can anyone point me in the right direction??

class MyClass {      var foo;     var bar;      function myMethod($id) {             // some code     } } 

I'm stuck on accessing myMethod($id) from within a plugin filter like so:

function extendPost($content, '') {     global $post;     $id = $post->ID;     $class = new MyClass();     // this is where i get stuck     $myMethod = $class->myMethod($id) // ??;     $content.= "<div>" . $myMethod . "</div>"; }  add_filter('the_content', 'extendPost'); 

Any help would be ace. I'd really like to get some sleep tonight ;)

Remove author prefix on WordPress [closed]


Outputting wordpress custom date field in different format
add_filter() takes a standard PHP callback as an argument..
Conditional if statement / is_page not working in WordPress 3.0
To apply the extendPost() method of the object $myObject;.
WordPress: first lower case p of each word not showing in main content area
add_filter('the_content', array(&myObject, 'extendPost')); 
To apply the extendPost() method of the class myClass;.
Implement custom template (static web - HTML) on WordPress
add_filter('the_content', array('myClass', 'extendPost')); 

change the function wp_list_pages in wordpress

82 out of 100 based on 62 user ratings 262 reviews