Esempio n. 1
0
 /**
  * The static method that will actually call WP Router to generate the routes.
  *
  * This is the method that will be called by the 'wp_router_generate_routes' action.
  *
  * @param  WP_router $router A WP Router instance.
  * @param  tad_FunctionsAdapterInterface $f An optionally injected functions adapter.
  *
  * @return void
  */
 public static function generateRoutes(WP_Router $router, tad_FunctionsAdapterInterface $f = null)
 {
     if (is_null($f)) {
         $f = new tad_FunctionsAdapter();
     }
     // action hook for plugins and themes to act on the route
     $f->do_action('route_before_adding_routes', self::$routes);
     foreach (self::$routes as $routeId => $args) {
         $router->add_route($routeId, $args);
         /**
          * Allow for extending classes to act on the route and circumvent PHP 5.2 lack
          * of late static binding.
          * Extending classes should:
          *  - register as classes extending the WPRouting_Route one using the tad_Static::setClassExtending method
          *  - implement the `actOnRoute` method
          */
         $class = tad_Static::getClassExtending(__CLASS__);
         if ($class and $class != __CLASS__) {
             if (method_exists($class, 'actOnRoute')) {
                 call_user_func(array($class, 'actOnRoute'), $routeId, $args);
             }
         }
     }
     // action hook for plugins and themes to act on the route
     $f->do_action('route_after_adding_routes', self::$routes);
 }
Esempio n. 2
0
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 3
0
 public static function generate_routes(WP_Router $router)
 {
     $router->add_route('wp-router-sample', array('path' => '^wp_router/(.*?)$', 'query_vars' => array('sample_argument' => 1), 'page_callback' => array(get_class(), 'sample_callback'), 'page_arguments' => array('sample_argument'), 'access_callback' => TRUE, 'title' => 'WP Router Sample Page'));
 }
 /**
  * @param WP_Router $router
  */
 public function register_page($router)
 {
     $issue_post_type = get_post_type_object('issue');
     $path = self::get_path();
     $router->add_route('buggypress_new_issue', array('path' => '((.+?)/)?' . $path . '/?$', 'query_vars' => array('project_slug' => 2), 'title' => $issue_post_type->labels->add_new_item, 'title_callback' => NULL, 'page_callback' => array('default' => array($this, 'render_page'), 'POST' => array($this, 'process_form')), 'page_arguments' => array('project_slug')));
 }
 /**
  * Calls the next Middleware.
  *
  * @param  WP_Request
  * @return void
  */
 public function next(WP_Request $request)
 {
     $this->router->next($request, $this->router, $this->store);
 }