public function create_route()
 {
     $route_string = $this->containing_post_type . "/:name/" . $this->contained_post_type;
     \Routes::map($route_string, function ($params) {
         $posts = get_posts(array('name' => $params['name'], 'post_type' => $this->containing_post_type));
         if ($posts) {
             $wp_post = $posts[0];
             $query = array('post_type' => $this->contained_post_type, 'connected_type' => $this->p2p_connection_type, 'connected_items' => $wp_post->ID);
         }
         $params += array('archive_title' => $this->get_archive_title_string($wp_post, $this->contained_post_type), 'containing_post_type' => $this->containing_post_type, 'contained_post_type' => $this->contained_post_type, 'p2p_connection_type' => $this->p2p_connection_type);
         \Routes::load($this->template, $params, $query, 200);
     });
     $paginated_route_string = $this->containing_post_type . "/:name/" . $this->contained_post_type . "/page/:pg";
     \Routes::map($paginated_route_string, function ($params) {
         $posts = get_posts(array('name' => $params['name'], 'post_type' => $this->containing_post_type));
         if ($posts) {
             $wp_post = $posts[0];
             $query = array('post_type' => $this->contained_post_type, 'connected_type' => $this->p2p_connection_type, 'connected_items' => $wp_post->ID, 'paged' => $params['pg']);
             $params += array('archive_title' => $this->get_archive_title_string($wp_post, $this->contained_post_type), 'containing_post_type' => $this->containing_post_type, 'contained_post_type' => $this->contained_post_type, 'p2p_connection_type' => $this->p2p_connection_type);
         }
         \Routes::load($this->template, $params, $query, 200);
     });
 }
Exemple #2
0
 /**
  * Load view.
  *
  * @deprecated since 0.20.2
  */
 public static function load_view($template, $query = false, $status_code = 200, $tparams = false)
 {
     return Routes::load($template, $tparams, $query, $status_code);
 }
Exemple #3
0
 function testFullPathRouteDoesntExist()
 {
     $hello = WP_CONTENT_DIR . '/plugins/hello-foo.php';
     $template = Routes::load($hello);
     $this->assertFalse($template);
 }