I am working a website which utilises a highly complex theme (essentially a whole bunch of other software tacked onto WordPress), so complex in fact, that child themes wont work with it.

I want to override a function (inside a class) within the theme by using a functionality plugin. When I refer to the class from within the plugin, I get this error message:

Fatal error: Class ‘OptimizePress_Default_Asset’ not found in [redacted]\wp-content\plugins\functions.php on line 17

class Foo extends OptimizePress_Default_Asset {
   function recent_posts($atts){

        // Decode encoded chars
        $atts = op_urldecode($atts);

            'style' => '',
            'posts_num' => ''
        ), $atts));

        //Get recent posts
        $recent_posts = wp_get_recent_posts(array(
            'numberposts' => $posts_num,
            'post_status' => 'publish'
        $recent_html = '';
        foreach( $recent_posts as $recent ){
            $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($recent['ID']), 'single-post-thumbnail');
            $img_src = $img_src[0];
            if ( is_front_page() ) {
                $date = "";
            else {
                $date = '<span>'.date(OP_DATE_POSTS, strtotime($recent['post_date'])).'</span>';
            $recent_html .= '<li><div class="thumb"><img src="'.$img_src.'" class="scale-with-grid" /></div><div class="content"><a href="'.get_permalink($recent["ID"]).'">'.$recent["post_title"].'</a>'.$date.'</div></li>';


        return '
            <ul class="recent-posts-style-'.$style.'">

Is it possible to refer to a class in a theme from within a plugin? If so how can this be done? Is this something which has to be referred to after theme set-up?

Thank you in advance

Leave a Reply

Your email address will not be published.