예제 #1
0
 /**
  * Method: action_wp_loaded
  * =========================================================================
  * At this point we setup the laravel router and completely take over
  * the frontend routing. I hate all the wordpress template hierarchy
  * and the wordpress rewrite rules, etc. A simple HTTP router is so
  * much easier to follow.
  *
  * Parameters:
  * -------------------------------------------------------------------------
  * n/a
  *
  * Returns:
  * -------------------------------------------------------------------------
  * void
  */
 public function action_wp_loaded()
 {
     // We only want the router to run for requests that get
     // funneled through index.php by the .htaccess rewrite rules.
     // wp-admin, wp-cron, wp-login, xmlrpc, etc should run as expected.
     if ($_SERVER['SCRIPT_NAME'] == '/index.php') {
         // Are we being run from a child theme?
         if (Paths::currentTheme() != Paths::parentTheme()) {
             try {
                 \Gears\Router::install(Paths::currentTheme() . '/routes', false);
             } catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e) {
                 // do nothing for now
             }
         }
         // Check to see if we have a 404 view
         if (\View::exists('errors.404')) {
             $notfound = \View::make('errors.404');
         } else {
             $notfound = null;
         }
         /*
          * If the execution gets to here it means either there is no child
          * theme. Or that the child theme router returned a 404. Either way
          * we will now run a second router, pointing to our route files.
          */
         \Gears\Router::install(Paths::parentTheme() . '/routes', $notfound);
         // The router by default exits php after it has done it's thing.
         // Statements after here are pointless...
     }
 }