Wordpress theme wrapper
class Your_theme_name {
    private static $ins;
    public static function init() {
        if ( !isset( self::$ins ) ) {
            $cn = __CLASS__;
            self::$ins = new $cn;
        }   
    }
    /**
      * Use theme method in your template files like this
      * Your_theme_name::some_method()
      */
    public static function some_method() {
        return self::$ins->special_posts;
    }
    private $special_posts = array();
    /**
      * Your theme logic goes here
      */
    public function __construct() {
        add_action( 
            'wp_enqueue_scripts', 
            array( $this, 'enqueue_scripts' ) 
        );
        $this->load_special_posts();
    }
    public function enqueue_scripts() {
        // Your scripts and css goes here
    }
    private function load_special_posts() {
        $this->special_posts = get_posts(....);
    }
}
Your_theme_name::init();Written by Kaspars
Related protips
1 Response
nice 1
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Wordpress 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#

 
 
