示例#1
0
 public function test_load()
 {
     global $twig, $apps;
     // Register and load test_app
     \mtv\register_app('test_app', dirname(__FILE__) . '/test_app');
     $apps = array('test_app');
     \mtv\load($apps);
     // Make sure test_app home view function is loaded
     $this->assertTrue(function_exists('test_app\\views\\home'));
     // Make sure test_app TestModel class is loaded
     $this->assertTrue(class_exists('test_app\\models\\TestModel'));
     // Make sure Twig was reinitialized
     $this->assertTrue(!empty($twig));
 }
示例#2
0
    if (is_admin() && defined('DOING_AJAX') && DOING_AJAX == true) {
        if (!empty($GLOBALS['apps'])) {
            mtv\load($GLOBALS['apps']);
        }
    }
    /**
     * Is our chosen theme an MTV theme?
     * Here we check to see if there is a urls.php file in the theme, then
     * we load the full MTV stack. If not, we don't want to hijack rewrite
     * rules and template selection.
     **/
    if (!file_exists(get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'urls.php') && !file_exists(get_template_directory() . DIRECTORY_SEPARATOR . 'urls.php')) {
        // if we're not loading the full stack, just load the basics, if we
        // have apps defined
        if (!is_admin() && !empty($GLOBALS['apps'])) {
            mtv\load($GLOBALS['apps']);
        }
        return;
    }
}, 999);
/*
 * If we have urls.php files in our theme, then we have an mtv theme, so we 
 * hijack urls and templates
 */
if (file_exists(get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'urls.php') && file_exists(get_template_directory() . DIRECTORY_SEPARATOR . 'urls.php')) {
    /**
     * *_rewrite_rules
     * Extra "permastruct" rules are run through this filter. Extra "permastruct" rules are added
     * to $wp_rewrite->extra_rules_top and include rewrite rules for tags, categories, and post_formats.
     * This only happens while generate_rewrite_rules runs. $wp_rewrite->extra_rules_top looks like
     * it's typically used for 3rd party stuff, just not always.