public static function Init()
    {
        add_filter('template_include',function($t){
        return get_template_directory().'/index.php';
        });
        add_filter('theme_templates', array('Balise\AnchorFramework\Anchor', 'loadThemeTemplates'), 10, 4);
        $types = array('index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'embed', 'home', 'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment');
        foreach ($types as $type) {
            add_filter("{$type}_template", array('Balise\AnchorFramework\Anchor', 'getThemeTemplate'), 10, 3);
        }
        
        if (!self::$renderer) {
            $paths = new \SplPriorityQueue;
            $paths->insert(get_template_directory() . '/app/views', 200);
            $paths->insert(dirname(__DIR__) . '/views', 100);
            self::$renderer = new BladeRenderer($paths, array('cache_path' => get_template_directory() . '/public/views/'));
            self::$renderer->addCustomCompiler('wp_head', function ($expression) {
                return '<?php wp_head(); ?>';
            });
            self::$renderer->addCustomCompiler('doquery', function ($expression) {
                return '<?php
                if (!isset($__posts)) { $posts = array(); }
                $__posts[] = $posts;
                
                $args = '.$expression.';

                if (@!$args["paged"]) {
                   $args["paged"] = get_query_var( "paged", 1 );
                }
                $query = new WP_Query($args);
                $posts = array_map(function($post){
                    return new \Balise\AnchorFramework\PostWrapper($post, true);
                }, $query->posts);

                ?>
                ';
            });
            self::$renderer->addCustomCompiler('endquery', function () {
                return '<?php
                $posts = array_pop($__posts);

                ?>
                ';
            });

            self::$renderer->addCustomCompiler('wp_footer', function ($expression) {
                return '<?php wp_footer(); ?>';
            });
        }
    }
public static function Init()
    {
        add_filter('template_include',function($t){
        return get_template_directory().'/index.php';
        });
        add_filter('theme_templates', array('Balise\AnchorFramework\Anchor', 'loadThemeTemplates'), 10, 4);
        $types = array('index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'embed', 'home', 'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment');
        foreach ($types as $type) {
            add_filter("{$type}_template", array('Balise\AnchorFramework\Anchor', 'getThemeTemplate'), 10, 3);
        }
        
        if (!self::$renderer) {
            $paths = new \SplPriorityQueue;
            $paths->insert(get_template_directory() . '/app/views', 200);
            $paths->insert(dirname(__DIR__) . '/views', 100);
            self::$renderer = new BladeRenderer($paths, array('cache_path' => get_template_directory() . '/public/views/'));
            self::$renderer->addCustomCompiler('wp_head', function ($expression) {
                return '<?php wp_head(); ?>';
            });
            self::$renderer->addCustomCompiler('doquery', function ($expression) {
                return '<?php
                if (!isset($__posts)) { $posts = array(); }
                $__posts[] = $posts;
                
                $args = '.$expression.';

                if (@!$args["paged"]) {
                   $args["paged"] = get_query_var( "paged", 1 );
                }
                $query = new WP_Query($args);
                $posts = array_map(function($post){
                    return new \Balise\AnchorFramework\PostWrapper($post, true);
                }, $query->posts);

                ?>
                ';
            });
            self::$renderer->addCustomCompiler('endquery', function () {
                return '<?php
                $posts = array_pop($__posts);

                ?>
                ';
            });

            self::$renderer->addCustomCompiler('wp_footer', function ($expression) {
                return '<?php wp_footer(); ?>';
            });
        }
    }
public static function Init ( ) { add_filter ( 'template_include' , function ( $ t ) { return get_template_directory ( ) . '/index.php' ; } ) ; add_filter ( 'theme_templates' , array ( 'Balise\AnchorFramework\Anchor' , 'loadThemeTemplates' ) , 10 , 4 ) ; $ types = array ( 'index' , '404' , 'archive' , 'author' , 'category' , 'tag' , 'taxonomy' , 'date' , 'embed' , 'home' , 'frontpage' , 'page' , 'paged' , 'search' , 'single' , 'singular' , 'attachment' ) ; foreach ( $ types as $ type ) { add_filter ( "{$type}_template" , array ( 'Balise\AnchorFramework\Anchor' , 'getThemeTemplate' ) , 10 , 3 ) ; } if ( ! self :: $ renderer ) { $ paths = new \ SplPriorityQueue ; $ paths -> insert ( get_template_directory ( ) . '/app/views' , 200 ) ; $ paths -> insert ( dirname ( __DIR__ ) . '/views' , 100 ) ; self :: $ renderer = new BladeRenderer ( $ paths , array ( 'cache_path' => get_template_directory ( ) . '/public/views/' ) ) ; self :: $ renderer -> addCustomCompiler ( 'wp_head' , function ( $ expression ) { return '<?php wp_head(); ?>' ; } ) ; self :: $ renderer -> addCustomCompiler ( 'doquery' , function ( $ expression ) { return '<?php
                if (!isset($__posts)) { $posts = array(); }
                $__posts[] = $posts;
                
                $args = ' . $ expression . ';

                if (@!$args["paged"]) {
                   $args["paged"] = get_query_var( "paged", 1 );
                }
                $query = new WP_Query($args);
                $posts = array_map(function($post){
                    return new \Balise\AnchorFramework\PostWrapper($post, true);
                }, $query->posts);

                ?>
                ' ; } ) ; self :: $ renderer -> addCustomCompiler ( 'endquery' , function ( ) { return '<?php
                $posts = array_pop($__posts);

                ?>
                ' ; } ) ; self :: $ renderer -> addCustomCompiler ( 'wp_footer' , function ( $ expression ) { return '<?php wp_footer(); ?>' ; } ) ; } }
Initial function that hook into the functions.php file
- Make sure that custom templates are loaded
- Make sure the template_loader hierarchy gets saved
Initial function that hook into the functions . php file - Make sure that custom templates are loaded - Make sure the template_loader hierarchy gets saved