Timber - Version 1.9.2

Version Description

Changes for Theme Developers - You can use Timber::context() as an alias for Timber::get_context(). It's prettier, it also will prep you for Timber 2.0 where Timber::get_context() is deprecated #1938

Fixes and improvements - Integration of newest version of Upstatement/Routes which uses (newest) version 1.2.0 of AltoRouter #1946 (thanks @seanstickle)

Download this release

Release Info

Developer jarednova
Plugin Icon 128x128 Timber
Version 1.9.2
Comparing to
See all releases

Code changes from version 1.9.1 to 1.9.2

lib/Timber.php CHANGED
@@ -35,7 +35,7 @@ use Timber\Loader;
35
  */
36
  class Timber {
37
 
38
- public static $version = '1.9.1';
39
  public static $locations;
40
  public static $dirname = 'views';
41
  public static $twig_cache = false;
@@ -225,6 +225,21 @@ class Timber {
225
  /* Template Setup and Display
226
  ================================ */
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  /**
229
  * Get context.
230
  * @api
35
  */
36
  class Timber {
37
 
38
+ public static $version = '1.9.2';
39
  public static $locations;
40
  public static $dirname = 'views';
41
  public static $twig_cache = false;
225
  /* Template Setup and Display
226
  ================================ */
227
 
228
+ /**
229
+ * Alias for Timber::get_context() which is deprecated in 2.0.
230
+ *
231
+ * This will allow us to update the starter theme to use the ::context() method and better
232
+ * prepare users for the upgrade (even if the details of what the method returns differs
233
+ * slightly).
234
+ *
235
+ * @see \Timber\Timber::get_context()
236
+ * @api
237
+ * @return array
238
+ */
239
+ public static function context() {
240
+ return self::get_context();
241
+ }
242
+
243
  /**
244
  * Get context.
245
  * @api
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Timber ===
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
- Requires at least: 4.7.9
5
- Tested up to: 5.0.3
6
- Stable tag: 1.9.1
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -36,12 +36,21 @@ _Twig is the template language powering Timber; if you need a little background
36
  **Changes for Theme Developers**
37
  - Please add bullet points here with your PR. The heading for this section will get the correct version number once released.
38
 
 
 
 
 
 
 
 
 
39
  = 1.9.1 =
40
 
41
  **Changes for Theme Developers**
42
  - You can now pass params to `{{ user.avatar }}` such as `{{ user.avatar({size: 128}) }}` #1730 (thanks @palmiak)
43
 
44
  **Fixes and improvements**
 
45
  - Fix for URLHelper::is_external for URLs without protocol #1924 (thanks @hacknug)
46
 
47
  = 1.9.0 =
1
  === Timber ===
2
  Contributors: jarednova, connorjburton, lggorman
3
  Tags: template engine, templates, twig
4
+ Requires at least: 4.7.12
5
+ Tested up to: 5.1
6
+ Stable tag: 1.9.2
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
36
  **Changes for Theme Developers**
37
  - Please add bullet points here with your PR. The heading for this section will get the correct version number once released.
38
 
39
+ = 1.9.2 =
40
+
41
+ **Changes for Theme Developers**
42
+ - You can use `Timber::context()` as an alias for `Timber::get_context()`. It's prettier, it also will prep you for Timber 2.0 where `Timber::get_context()` is deprecated #1938
43
+
44
+ **Fixes and improvements**
45
+ - Integration of newest version of Upstatement/Routes which uses (newest) version 1.2.0 of AltoRouter #1946 (thanks @seanstickle)
46
+
47
  = 1.9.1 =
48
 
49
  **Changes for Theme Developers**
50
  - You can now pass params to `{{ user.avatar }}` such as `{{ user.avatar({size: 128}) }}` #1730 (thanks @palmiak)
51
 
52
  **Fixes and improvements**
53
+ - Fix for PHP 7.3 compatibility #1915 (thanks @palmiak)
54
  - Fix for URLHelper::is_external for URLs without protocol #1924 (thanks @hacknug)
55
 
56
  = 1.9.0 =
timber-starter-theme/functions.php CHANGED
@@ -40,8 +40,8 @@ class StarterSite extends Timber\Site {
40
  /** Add timber support. */
41
  public function __construct() {
42
  add_action( 'after_setup_theme', array( $this, 'theme_supports' ) );
43
- add_filter( 'timber_context', array( $this, 'add_to_context' ) );
44
- add_filter( 'get_twig', array( $this, 'add_to_twig' ) );
45
  add_action( 'init', array( $this, 'register_post_types' ) );
46
  add_action( 'init', array( $this, 'register_taxonomies' ) );
47
  parent::__construct();
40
  /** Add timber support. */
41
  public function __construct() {
42
  add_action( 'after_setup_theme', array( $this, 'theme_supports' ) );
43
+ add_filter( 'timber/context', array( $this, 'add_to_context' ) );
44
+ add_filter( 'timber/twig', array( $this, 'add_to_twig' ) );
45
  add_action( 'init', array( $this, 'register_post_types' ) );
46
  add_action( 'init', array( $this, 'register_taxonomies' ) );
47
  parent::__construct();
timber-starter-theme/page.php CHANGED
@@ -22,6 +22,7 @@
22
  */
23
 
24
  $context = Timber::get_context();
25
- $post = new TimberPost();
26
- $context['post'] = $post;
27
- Timber::render( array( 'page-' . $post->post_name . '.twig', 'page.twig' ), $context );
 
22
  */
23
 
24
  $context = Timber::get_context();
25
+
26
+ $timber_post = new Timber\Post();
27
+ $context['post'] = $timber_post;
28
+ Timber::render( array( 'page-' . $timber_post->post_name . '.twig', 'page.twig' ), $context );
timber-starter-theme/single.php CHANGED
@@ -10,11 +10,11 @@
10
  */
11
 
12
  $context = Timber::get_context();
13
- $post = Timber::query_post();
14
- $context['post'] = $post;
15
 
16
- if ( post_password_required( $post->ID ) ) {
17
  Timber::render( 'single-password.twig', $context );
18
  } else {
19
- Timber::render( array( 'single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig' ), $context );
20
  }
10
  */
11
 
12
  $context = Timber::get_context();
13
+ $timber_post = Timber::query_post();
14
+ $context['post'] = $timber_post;
15
 
16
+ if ( post_password_required( $timber_post->ID ) ) {
17
  Timber::render( 'single-password.twig', $context );
18
  } else {
19
+ Timber::render( array( 'single-' . $timber_post->ID . '.twig', 'single-' . $timber_post->post_type . '.twig', 'single.twig' ), $context );
20
  }
timber-starter-theme/templates/html-header.twig CHANGED
@@ -1,8 +1,7 @@
1
  <!doctype html>
2
- <!--[if lt IE 7]><html class="no-js no-svg ie ie6 lt-ie9 lt-ie8 lt-ie7" {{ site.language_attributes }}> <![endif]-->
3
- <!--[if IE 7]><html class="no-js no-svg ie ie7 lt-ie9 lt-ie8" {{ site.language_attributes }}> <![endif]-->
4
- <!--[if IE 8]><html class="no-js no-svg ie ie8 lt-ie9" {{ site.language_attributes }}> <![endif]-->
5
- <!--[if gt IE 8]><!--><html class="no-js no-svg" {{ site.language_attributes }}> <!--<![endif]-->
6
  <head>
7
  <meta charset="{{ site.charset }}" />
8
  <meta name="description" content="{{ site.description }}">
1
  <!doctype html>
2
+ <!--[if lt IE 9]><html class="no-js no-svg ie lt-ie9 lt-ie8 lt-ie7" {{ site.language_attributes }}> <![endif]-->
3
+ <!--[if IE 9]><html class="no-js no-svg ie ie9 lt-ie9 lt-ie8" {{ site.language_attributes }}> <![endif]-->
4
+ <!--[if gt IE 9]><!--><html class="no-js no-svg" {{ site.language_attributes }}> <!--<![endif]-->
 
5
  <head>
6
  <meta charset="{{ site.charset }}" />
7
  <meta name="description" content="{{ site.description }}">
timber-starter-theme/templates/menu.twig CHANGED
@@ -3,7 +3,7 @@
3
  {% for item in menu %}
4
  <li class="{{ item.classes | join(' ') }}">
5
  <a target="{{ item.target }}" href="{{ item.link }}">{{ item.title }}</a>
6
- {% include "menu.twig" with {'menu': item.get_children} %}
7
  </li>
8
  {% endfor %}
9
  </ul>
3
  {% for item in menu %}
4
  <li class="{{ item.classes | join(' ') }}">
5
  <a target="{{ item.target }}" href="{{ item.link }}">{{ item.title }}</a>
6
+ {% include "menu.twig" with {'menu': item.children} %}
7
  </li>
8
  {% endfor %}
9
  </ul>
timber.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
4
  Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
- Version: 1.9.1
8
  Author URI: http://upstatement.com/
9
  */
10
  // we look for Composer files first in the plugins dir.
4
  Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
5
  Plugin URI: http://timber.upstatement.com
6
  Author: Jared Novack + Upstatement
7
+ Version: 1.9.2
8
  Author URI: http://upstatement.com/
9
  */
10
  // we look for Composer files first in the plugins dir.
vendor/altorouter/altorouter/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: php
2
- php:
3
- - 5.3
4
- - 5.4
5
- - 5.5
6
-
7
- script: phpunit --coverage-text ./
 
 
 
 
 
 
 
vendor/altorouter/altorouter/AltoRouter.php CHANGED
@@ -2,9 +2,24 @@
2
 
3
  class AltoRouter {
4
 
 
 
 
5
  protected $routes = array();
 
 
 
 
6
  protected $namedRoutes = array();
 
 
 
 
7
  protected $basePath = '';
 
 
 
 
8
  protected $matchTypes = array(
9
  'i' => '[0-9]++',
10
  'a' => '[0-9A-Za-z]++',
@@ -26,6 +41,15 @@ class AltoRouter {
26
  $this->setBasePath($basePath);
27
  $this->addMatchTypes($matchTypes);
28
  }
 
 
 
 
 
 
 
 
 
29
 
30
  /**
31
  * Add multiple routes at once from array in the following format:
@@ -37,6 +61,7 @@ class AltoRouter {
37
  * @param array $routes
38
  * @return void
39
  * @author Koen Punt
 
40
  */
41
  public function addRoutes($routes){
42
  if(!is_array($routes) && !$routes instanceof Traversable) {
@@ -67,10 +92,11 @@ class AltoRouter {
67
  /**
68
  * Map a route to a target
69
  *
70
- * @param string $method One of 4 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PUT|DELETE)
71
  * @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
72
  * @param mixed $target The target where this route should point to. Can be anything.
73
  * @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
 
74
  */
75
  public function map($method, $route, $target, $name = null) {
76
 
@@ -96,6 +122,7 @@ class AltoRouter {
96
  * @param string $routeName The name of the route.
97
  * @param array @params Associative array of parameters to replace placeholders with.
98
  * @return string The URL of the route with named parameters in place.
 
99
  */
100
  public function generate($routeName, array $params = array()) {
101
 
@@ -161,10 +188,6 @@ class AltoRouter {
161
  $requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
162
  }
163
 
164
- // Force request_order to be GP
165
- // http://www.mail-archive.com/internals@lists.php.net/msg33119.html
166
- $_REQUEST = array_merge($_GET, $_POST);
167
-
168
  foreach($this->routes as $handler) {
169
  list($method, $_route, $target, $name) = $handler;
170
 
@@ -186,7 +209,8 @@ class AltoRouter {
186
  if ($_route === '*') {
187
  $match = true;
188
  } elseif (isset($_route[0]) && $_route[0] === '@') {
189
- $match = preg_match('`' . substr($_route, 1) . '`u', $requestUrl, $params);
 
190
  } else {
191
  $route = null;
192
  $regex = false;
2
 
3
  class AltoRouter {
4
 
5
+ /**
6
+ * @var array Array of all routes (incl. named routes).
7
+ */
8
  protected $routes = array();
9
+
10
+ /**
11
+ * @var array Array of all named routes.
12
+ */
13
  protected $namedRoutes = array();
14
+
15
+ /**
16
+ * @var string Can be used to ignore leading part of the Request URL (if main file lives in subdirectory of host)
17
+ */
18
  protected $basePath = '';
19
+
20
+ /**
21
+ * @var array Array of default match types (regex helpers)
22
+ */
23
  protected $matchTypes = array(
24
  'i' => '[0-9]++',
25
  'a' => '[0-9A-Za-z]++',
41
  $this->setBasePath($basePath);
42
  $this->addMatchTypes($matchTypes);
43
  }
44
+
45
+ /**
46
+ * Retrieves all routes.
47
+ * Useful if you want to process or display routes.
48
+ * @return array All routes.
49
+ */
50
+ public function getRoutes() {
51
+ return $this->routes;
52
+ }
53
 
54
  /**
55
  * Add multiple routes at once from array in the following format:
61
  * @param array $routes
62
  * @return void
63
  * @author Koen Punt
64
+ * @throws Exception
65
  */
66
  public function addRoutes($routes){
67
  if(!is_array($routes) && !$routes instanceof Traversable) {
92
  /**
93
  * Map a route to a target
94
  *
95
+ * @param string $method One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)
96
  * @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
97
  * @param mixed $target The target where this route should point to. Can be anything.
98
  * @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
99
+ * @throws Exception
100
  */
101
  public function map($method, $route, $target, $name = null) {
102
 
122
  * @param string $routeName The name of the route.
123
  * @param array @params Associative array of parameters to replace placeholders with.
124
  * @return string The URL of the route with named parameters in place.
125
+ * @throws Exception
126
  */
127
  public function generate($routeName, array $params = array()) {
128
 
188
  $requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
189
  }
190
 
 
 
 
 
191
  foreach($this->routes as $handler) {
192
  list($method, $_route, $target, $name) = $handler;
193
 
209
  if ($_route === '*') {
210
  $match = true;
211
  } elseif (isset($_route[0]) && $_route[0] === '@') {
212
+ $pattern = '`' . substr($_route, 1) . '`u';
213
+ $match = preg_match($pattern, $requestUrl, $params);
214
  } else {
215
  $route = null;
216
  $regex = false;
vendor/altorouter/altorouter/AltoRouterTest.php DELETED
@@ -1,423 +0,0 @@
1
- <?php
2
-
3
- require 'AltoRouter.php';
4
-
5
- class AltoRouterDebug extends AltoRouter{
6
-
7
- public function getNamedRoutes(){
8
- return $this->namedRoutes;
9
- }
10
-
11
- public function getRoutes(){
12
- return $this->routes;
13
- }
14
-
15
- public function getBasePath(){
16
- return $this->basePath;
17
- }
18
-
19
- }
20
-
21
- class SimpleTraversable implements Iterator{
22
-
23
- protected $_position = 0;
24
-
25
- protected $_data = array(
26
- array('GET', '/foo', 'foo_action', null),
27
- array('POST', '/bar', 'bar_action', 'second_route')
28
- );
29
-
30
- public function current(){
31
- return $this->_data[$this->_position];
32
- }
33
- public function key(){
34
- return $this->_position;
35
- }
36
- public function next(){
37
- ++$this->_position;
38
- }
39
- public function rewind(){
40
- $this->_position = 0;
41
- }
42
- public function valid(){
43
- return isset($this->_data[$this->_position]);
44
- }
45
-
46
- }
47
-
48
- /**
49
- * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-07-14 at 17:47:46.
50
- */
51
- class AltoRouterTest extends PHPUnit_Framework_TestCase
52
- {
53
- /**
54
- * @var AltoRouter
55
- */
56
- protected $router;
57
-
58
- /**
59
- * Sets up the fixture, for example, opens a network connection.
60
- * This method is called before a test is executed.
61
- */
62
- protected function setUp()
63
- {
64
- $this->router = new AltoRouterDebug;
65
- }
66
-
67
- /**
68
- * Tears down the fixture, for example, closes a network connection.
69
- * This method is called after a test is executed.
70
- */
71
- protected function tearDown()
72
- {
73
- }
74
-
75
- /**
76
- * @covers AltoRouter::addRoutes
77
- */
78
- public function testAddRoutes()
79
- {
80
- $method = 'POST';
81
- $route = '/[:controller]/[:action]';
82
- $target = function(){};
83
-
84
- $this->router->addRoutes(array(
85
- array($method, $route, $target),
86
- array($method, $route, $target, 'second_route')
87
- ));
88
-
89
- $routes = $this->router->getRoutes();
90
-
91
- $this->assertEquals(array($method, $route, $target, null), $routes[0]);
92
- $this->assertEquals(array($method, $route, $target, 'second_route'), $routes[1]);
93
- }
94
-
95
- /**
96
- * @covers AltoRouter::addRoutes
97
- */
98
- public function testAddRoutesAcceptsTraverable()
99
- {
100
- $traversable = new SimpleTraversable();
101
- $this->router->addRoutes($traversable);
102
-
103
- $traversable->rewind();
104
-
105
- $first = $traversable->current();
106
- $traversable->next();
107
- $second = $traversable->current();
108
-
109
- $routes = $this->router->getRoutes();
110
-
111
- $this->assertEquals($first, $routes[0]);
112
- $this->assertEquals($second, $routes[1]);
113
- }
114
-
115
- /**
116
- * @covers AltoRouter::addRoutes
117
- * @expectedException Exception
118
- */
119
- public function testAddRoutesThrowsExceptionOnInvalidArgument()
120
- {
121
- $this->router->addRoutes(new stdClass);
122
- }
123
-
124
- /**
125
- * @covers AltoRouter::setBasePath
126
- */
127
- public function testSetBasePath()
128
- {
129
- $basePath = $this->router->setBasePath('/some/path');
130
- $this->assertEquals('/some/path', $this->router->getBasePath());
131
-
132
- $basePath = $this->router->setBasePath('/some/path');
133
- $this->assertEquals('/some/path', $this->router->getBasePath());
134
- }
135
-
136
- /**
137
- * @covers AltoRouter::map
138
- */
139
- public function testMap()
140
- {
141
- $method = 'POST';
142
- $route = '/[:controller]/[:action]';
143
- $target = function(){};
144
-
145
- $this->router->map($method, $route, $target);
146
-
147
- $routes = $this->router->getRoutes();
148
-
149
- $this->assertEquals(array($method, $route, $target, null), $routes[0]);
150
- }
151
-
152
- /**
153
- * @covers AltoRouter::map
154
- */
155
- public function testMapWithName()
156
- {
157
- $method = 'POST';
158
- $route = '/[:controller]/[:action]';
159
- $target = function(){};
160
- $name = 'myroute';
161
-
162
- $this->router->map($method, $route, $target, $name);
163
-
164
- $routes = $this->router->getRoutes();
165
- $this->assertEquals(array($method, $route, $target, $name), $routes[0]);
166
-
167
- $named_routes = $this->router->getNamedRoutes();
168
- $this->assertEquals($route, $named_routes[$name]);
169
-
170
- try{
171
- $this->router->map($method, $route, $target, $name);
172
- $this->fail('Should not be able to add existing named route');
173
- }catch(Exception $e){
174
- $this->assertEquals("Can not redeclare route '{$name}'", $e->getMessage());
175
- }
176
- }
177
-
178
-
179
- /**
180
- * @covers AltoRouter::generate
181
- */
182
- public function testGenerate()
183
- {
184
- $params = array(
185
- 'controller' => 'test',
186
- 'action' => 'someaction'
187
- );
188
-
189
- $this->router->map('GET', '/[:controller]/[:action]', function(){}, 'foo_route');
190
-
191
- $this->assertEquals('/test/someaction',
192
- $this->router->generate('foo_route', $params));
193
-
194
- $params = array(
195
- 'controller' => 'test',
196
- 'action' => 'someaction',
197
- 'type' => 'json'
198
- );
199
-
200
- $this->assertEquals('/test/someaction',
201
- $this->router->generate('foo_route', $params));
202
-
203
- }
204
-
205
- public function testGenerateWithOptionalUrlParts()
206
- {
207
- $this->router->map('GET', '/[:controller]/[:action].[:type]?', function(){}, 'bar_route');
208
-
209
- $params = array(
210
- 'controller' => 'test',
211
- 'action' => 'someaction'
212
- );
213
-
214
- $this->assertEquals('/test/someaction',
215
- $this->router->generate('bar_route', $params));
216
-
217
- $params = array(
218
- 'controller' => 'test',
219
- 'action' => 'someaction',
220
- 'type' => 'json'
221
- );
222
-
223
- $this->assertEquals('/test/someaction.json',
224
- $this->router->generate('bar_route', $params));
225
- }
226
-
227
- public function testGenerateWithNonexistingRoute()
228
- {
229
- try{
230
- $this->router->generate('nonexisting_route');
231
- $this->fail('Should trigger an exception on nonexisting named route');
232
- }catch(Exception $e){
233
- $this->assertEquals("Route 'nonexisting_route' does not exist.", $e->getMessage());
234
- }
235
- }
236
-
237
- /**
238
- * @covers AltoRouter::match
239
- * @covers AltoRouter::compileRoute
240
- */
241
- public function testMatch()
242
- {
243
- $this->router->map('GET', '/foo/[:controller]/[:action]', 'foo_action', 'foo_route');
244
-
245
- $this->assertEquals(array(
246
- 'target' => 'foo_action',
247
- 'params' => array(
248
- 'controller' => 'test',
249
- 'action' => 'do'
250
- ),
251
- 'name' => 'foo_route'
252
- ), $this->router->match('/foo/test/do', 'GET'));
253
-
254
- $this->assertFalse($this->router->match('/foo/test/do', 'POST'));
255
-
256
- $this->assertEquals(array(
257
- 'target' => 'foo_action',
258
- 'params' => array(
259
- 'controller' => 'test',
260
- 'action' => 'do'
261
- ),
262
- 'name' => 'foo_route'
263
- ), $this->router->match('/foo/test/do?param=value', 'GET'));
264
-
265
- }
266
-
267
- public function testMatchWithFixedParamValues()
268
- {
269
- $this->router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');
270
-
271
- $this->assertEquals(array(
272
- 'target' => 'usersController#doAction',
273
- 'params' => array(
274
- 'id' => 1,
275
- 'action' => 'delete'
276
- ),
277
- 'name' => 'users_do'
278
- ), $this->router->match('/users/1/delete', 'POST'));
279
-
280
- $this->assertFalse($this->router->match('/users/1/delete', 'GET'));
281
- $this->assertFalse($this->router->match('/users/abc/delete', 'POST'));
282
- $this->assertFalse($this->router->match('/users/1/create', 'GET'));
283
- }
284
-
285
- public function testMatchWithServerVars()
286
- {
287
- $this->router->map('GET', '/foo/[:controller]/[:action]', 'foo_action', 'foo_route');
288
-
289
- $_SERVER['REQUEST_URI'] = '/foo/test/do';
290
- $_SERVER['REQUEST_METHOD'] = 'GET';
291
-
292
- $this->assertEquals(array(
293
- 'target' => 'foo_action',
294
- 'params' => array(
295
- 'controller' => 'test',
296
- 'action' => 'do'
297
- ),
298
- 'name' => 'foo_route'
299
- ), $this->router->match());
300
- }
301
-
302
- public function testMatchWithOptionalUrlParts()
303
- {
304
- $this->router->map('GET', '/bar/[:controller]/[:action].[:type]?', 'bar_action', 'bar_route');
305
-
306
- $this->assertEquals(array(
307
- 'target' => 'bar_action',
308
- 'params' => array(
309
- 'controller' => 'test',
310
- 'action' => 'do',
311
- 'type' => 'json'
312
- ),
313
- 'name' => 'bar_route'
314
- ), $this->router->match('/bar/test/do.json', 'GET'));
315
-
316
- }
317
-
318
- public function testMatchWithWildcard()
319
- {
320
- $this->router->map('GET', '/a', 'foo_action', 'foo_route');
321
- $this->router->map('GET', '*', 'bar_action', 'bar_route');
322
-
323
- $this->assertEquals(array(
324
- 'target' => 'bar_action',
325
- 'params' => array(),
326
- 'name' => 'bar_route'
327
- ), $this->router->match('/everything', 'GET'));
328
-
329
- }
330
-
331
- public function testMatchWithCustomRegexp()
332
- {
333
- $this->router->map('GET', '@^/[a-z]*$', 'bar_action', 'bar_route');
334
-
335
- $this->assertEquals(array(
336
- 'target' => 'bar_action',
337
- 'params' => array(),
338
- 'name' => 'bar_route'
339
- ), $this->router->match('/everything', 'GET'));
340
-
341
- $this->assertFalse($this->router->match('/some-other-thing', 'GET'));
342
-
343
- }
344
-
345
- public function testMatchWithUnicodeRegex()
346
- {
347
- $pattern = '/(?<path>[^';
348
- // Arabic characters
349
- $pattern .= '\x{0600}-\x{06FF}';
350
- $pattern .= '\x{FB50}-\x{FDFD}';
351
- $pattern .= '\x{FE70}-\x{FEFF}';
352
- $pattern .= '\x{0750}-\x{077F}';
353
- // Alphanumeric, /, _, - and space characters
354
- $pattern .= 'a-zA-Z0-9\/_-\s';
355
- // 'ZERO WIDTH NON-JOINER'
356
- $pattern .= '\x{200C}';
357
- $pattern .= ']+)';
358
-
359
- $this->router->map('GET', '@' . $pattern, 'unicode_action', 'unicode_route');
360
-
361
- $this->assertEquals(array(
362
- 'target' => 'unicode_action',
363
- 'name' => 'unicode_route',
364
- 'params' => array(
365
- 'path' => '大家好'
366
- )
367
- ), $this->router->match('/大家好', 'GET'));
368
-
369
- $this->assertFalse($this->router->match('/﷽‎', 'GET'));
370
- }
371
-
372
- /**
373
- * @covers AltoRouter::addMatchTypes
374
- */
375
- public function testMatchWithCustomNamedRegex()
376
- {
377
- $this->router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?'));
378
- $this->router->map('GET', '/bar/[cId:customId]', 'bar_action', 'bar_route');
379
-
380
- $this->assertEquals(array(
381
- 'target' => 'bar_action',
382
- 'params' => array(
383
- 'customId' => 'AB1',
384
- ),
385
- 'name' => 'bar_route'
386
- ), $this->router->match('/bar/AB1', 'GET'));
387
-
388
- $this->assertEquals(array(
389
- 'target' => 'bar_action',
390
- 'params' => array(
391
- 'customId' => 'AB1_0123456789',
392
- ),
393
- 'name' => 'bar_route'
394
- ), $this->router->match('/bar/AB1_0123456789', 'GET'));
395
-
396
- $this->assertFalse($this->router->match('/some-other-thing', 'GET'));
397
-
398
- }
399
-
400
- public function testMatchWithCustomNamedUnicodeRegex()
401
- {
402
- $pattern = '[^';
403
- // Arabic characters
404
- $pattern .= '\x{0600}-\x{06FF}';
405
- $pattern .= '\x{FB50}-\x{FDFD}';
406
- $pattern .= '\x{FE70}-\x{FEFF}';
407
- $pattern .= '\x{0750}-\x{077F}';
408
- $pattern .= ']+';
409
-
410
- $this->router->addMatchTypes(array('nonArabic' => $pattern));
411
- $this->router->map('GET', '/bar/[nonArabic:string]', 'non_arabic_action', 'non_arabic_route');
412
-
413
- $this->assertEquals(array(
414
- 'target' => 'non_arabic_action',
415
- 'name' => 'non_arabic_route',
416
- 'params' => array(
417
- 'string' => 'some-path'
418
- )
419
- ), $this->router->match('/bar/some-path', 'GET'));
420
-
421
- $this->assertFalse($this->router->match('/﷽‎', 'GET'));
422
- }
423
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/altorouter/altorouter/README.md CHANGED
@@ -1,77 +1,38 @@
1
- # AltoRouter [![Build Status](https://api.travis-ci.org/dannyvankooten/AltoRouter.png)](http://travis-ci.org/dannyvankooten/AltoRouter)
2
  AltoRouter is a small but powerful routing class for PHP 5.3+, heavily inspired by [klein.php](https://github.com/chriso/klein.php/).
3
 
4
- * Dynamic routing with named parameters
5
- * Reversed routing
6
- * Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/))
7
- * Custom regexes
8
-
9
- ## Getting started
10
-
11
- 1. PHP 5.3.x is required
12
- 2. Install AltoRouter using Composer or manually
13
- 2. Setup URL rewriting so that all requests are handled by **index.php**
14
- 3. Create an instance of AltoRouter, map your routes and match a request.
15
- 4. Have a look at the basic example in the `examples` directory for a better understanding on how to use AltoRouter.
16
-
17
- ## Routing
18
  ```php
19
  $router = new AltoRouter();
20
- $router->setBasePath('/AltoRouter'); // (optional) the subdir AltoRouter lives in
21
-
22
- // mapping routes
23
- $router->map('GET|POST','/', 'home#index', 'home');
24
- $router->map('GET','/users', array('c' => 'UserController', 'a' => 'ListAction'));
25
- $router->map('GET','/users/[i:id]', 'users#show', 'users_show');
26
- $router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');
27
-
28
- // reversed routing
29
- $router->generate('users_show', array('id' => 5));
30
-
31
- ```
32
-
33
- **You can use the following limits on your named parameters. AltoRouter will create the correct regexes for you.**
34
 
35
- ```php
36
- * // Match all request URIs
37
- [i] // Match an integer
38
- [i:id] // Match an integer as 'id'
39
- [a:action] // Match alphanumeric characters as 'action'
40
- [h:key] // Match hexadecimal characters as 'key'
41
- [:action] // Match anything up to the next / or end of the URI as 'action'
42
- [create|edit:action] // Match either 'create' or 'edit' as 'action'
43
- [*] // Catch all (lazy, stops at the next trailing slash)
44
- [*:trailing] // Catch all as 'trailing' (lazy)
45
- [**:trailing] // Catch all (possessive - will match the rest of the URI)
46
- .[:format]? // Match an optional parameter 'format' - a / or . before the block is also optional
47
- ```
48
-
49
- **Some more complicated examples**
50
 
51
- ```php
52
- @/(?[A-Za-z]{2}_[A-Za-z]{2})$ // custom regex, matches language codes like "en_us" etc.
53
- /posts/[*:title][i:id] // Matches "/posts/this-is-a-title-123"
54
- /output.[xml|json:format]? // Matches "/output", "output.xml", "output.json"
55
- /[:controller]?/[:action]? // Matches the typical /controller/action format
56
  ```
57
 
58
- **The character before the colon (the 'match type') is a shortcut for one of the following regular expressions**
59
 
60
- ```php
61
- 'i' => '[0-9]++'
62
- 'a' => '[0-9A-Za-z]++'
63
- 'h' => '[0-9A-Fa-f]++'
64
- '*' => '.+?'
65
- '**' => '.++'
66
- '' => '[^/\.]++'
67
- ```
68
 
69
- **New match types can be added using the `addMatchTypes()` method**
70
 
71
- ```php
72
- $router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?'));
73
- ```
74
 
 
 
 
 
 
75
 
76
  ## Contributors
77
  - [Danny van Kooten](https://github.com/dannyvankooten)
@@ -83,7 +44,7 @@ $router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?'));
83
 
84
  (MIT License)
85
 
86
- Copyright (c) 2012-2013 Danny van Kooten <hi@dannyvankooten.com>
87
 
88
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
89
 
1
+ # AltoRouter [![Build Status](https://api.travis-ci.org/dannyvankooten/AltoRouter.png)](http://travis-ci.org/dannyvankooten/AltoRouter) [![Latest Stable Version](https://poser.pugx.org/altorouter/altorouter/v/stable.svg)](https://packagist.org/packages/altorouter/altorouter) [![License](https://poser.pugx.org/altorouter/altorouter/license.svg)](https://packagist.org/packages/altorouter/altorouter) [![Code Climate](https://codeclimate.com/github/dannyvankooten/AltoRouter/badges/gpa.svg)](https://codeclimate.com/github/dannyvankooten/AltoRouter) [![Test Coverage](https://codeclimate.com/github/dannyvankooten/AltoRouter/badges/coverage.svg)](https://codeclimate.com/github/dannyvankooten/AltoRouter)
2
  AltoRouter is a small but powerful routing class for PHP 5.3+, heavily inspired by [klein.php](https://github.com/chriso/klein.php/).
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ```php
5
  $router = new AltoRouter();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ // map homepage
8
+ $router->map( 'GET', '/', function() {
9
+ require __DIR__ . '/views/home.php';
10
+ });
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ // map users details page
13
+ $router->map( 'GET|POST', '/users/[i:id]/', function( $id ) {
14
+ $user = .....
15
+ require __DIR__ . '/views/user/details.php';
16
+ });
17
  ```
18
 
19
+ ## Features
20
 
21
+ * Can be used with all HTTP Methods
22
+ * Dynamic routing with named route parameters
23
+ * Reversed routing
24
+ * Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/))
25
+ * Custom regexes
 
 
 
26
 
27
+ ## Getting started
28
 
29
+ You need PHP >= 5.3 to use AltoRouter.
 
 
30
 
31
+ - [Install AltoRouter](http://altorouter.com/usage/install.html)
32
+ - [Rewrite all requests to AltoRouter](http://altorouter.com/usage/rewrite-requests.html)
33
+ - [Map your routes](http://altorouter.com/usage/mapping-routes.html)
34
+ - [Match requests](http://altorouter.com/usage/matching-requests.html)
35
+ - [Process the request your preferred way](http://altorouter.com/usage/processing-requests.html)
36
 
37
  ## Contributors
38
  - [Danny van Kooten](https://github.com/dannyvankooten)
44
 
45
  (MIT License)
46
 
47
+ Copyright (c) 2012-2015 Danny van Kooten <hi@dannyvankooten.com>
48
 
49
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
50
 
vendor/altorouter/altorouter/composer.json CHANGED
@@ -22,7 +22,14 @@
22
  "require": {
23
  "php": ">=5.3.0"
24
  },
 
 
 
 
25
  "autoload": {
26
  "classmap": ["AltoRouter.php"]
 
 
 
27
  }
28
  }
22
  "require": {
23
  "php": ">=5.3.0"
24
  },
25
+ "require-dev": {
26
+ "phpunit/phpunit": "4.5.*",
27
+ "codeclimate/php-test-reporter": "dev-master"
28
+ },
29
  "autoload": {
30
  "classmap": ["AltoRouter.php"]
31
+ },
32
+ "scripts": {
33
+ "test": "vendor/bin/phpunit"
34
  }
35
  }
vendor/altorouter/altorouter/examples/basic/.htaccess DELETED
@@ -1,3 +0,0 @@
1
- RewriteEngine On
2
- RewriteCond %{REQUEST_FILENAME} !-f
3
- RewriteRule . index.php [L]
 
 
 
vendor/altorouter/altorouter/examples/basic/index.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- require '../../AltoRouter.php';
4
-
5
- $router = new AltoRouter();
6
- $router->setBasePath('/AltoRouter/examples/basic');
7
- $router->map('GET|POST','/', 'home#index', 'home');
8
- $router->map('GET','/users/', array('c' => 'UserController', 'a' => 'ListAction'));
9
- $router->map('GET','/users/[i:id]', 'users#show', 'users_show');
10
- $router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');
11
-
12
- // match current request
13
- $match = $router->match();
14
- ?>
15
- <h1>AltoRouter</h1>
16
-
17
- <h3>Current request: </h3>
18
- <pre>
19
- Target: <?php var_dump($match['target']); ?>
20
- Params: <?php var_dump($match['params']); ?>
21
- Name: <?php var_dump($match['name']); ?>
22
- </pre>
23
-
24
- <h3>Try these requests: </h3>
25
- <p><a href="<?php echo $router->generate('home'); ?>">GET <?php echo $router->generate('home'); ?></a></p>
26
- <p><a href="<?php echo $router->generate('users_show', array('id' => 5)); ?>">GET <?php echo $router->generate('users_show', array('id' => 5)); ?></a></p>
27
- <p><form action="<?php echo $router->generate('users_do', array('id' => 10, 'action' => 'update')); ?>" method="post"><button type="submit"><?php echo $router->generate('users_do', array('id' => 10, 'action' => 'update')); ?></button></form></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit299ac90e7e60969457d3d264c8b850ff::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit67a1de83cd78fdba34c58ae2f6651dfe::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit299ac90e7e60969457d3d264c8b850ff
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit299ac90e7e60969457d3d264c8b850ff
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit299ac90e7e60969457d3d264c8b850ff', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit299ac90e7e60969457d3d264c8b850ff', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit67a1de83cd78fdba34c58ae2f6651dfe
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit67a1de83cd78fdba34c58ae2f6651dfe', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit67a1de83cd78fdba34c58ae2f6651dfe', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
vendor/composer/installed.json CHANGED
@@ -123,23 +123,27 @@
123
  },
124
  {
125
  "name": "altorouter/altorouter",
126
- "version": "v1.1.0",
127
- "version_normalized": "1.1.0.0",
128
  "source": {
129
  "type": "git",
130
  "url": "https://github.com/dannyvankooten/AltoRouter.git",
131
- "reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4"
132
  },
133
  "dist": {
134
  "type": "zip",
135
- "url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/09d9d946c546bae6d22a7654cdb3b825ffda54b4",
136
- "reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4",
137
  "shasum": ""
138
  },
139
  "require": {
140
  "php": ">=5.3.0"
141
  },
142
- "time": "2014-04-16 09:44:40",
 
 
 
 
143
  "type": "library",
144
  "installation-source": "dist",
145
  "autoload": {
@@ -176,21 +180,21 @@
176
  },
177
  {
178
  "name": "upstatement/routes",
179
- "version": "0.4",
180
- "version_normalized": "0.4.0.0",
181
  "source": {
182
  "type": "git",
183
  "url": "https://github.com/Upstatement/routes.git",
184
- "reference": "fae7d46f56e8b5775f072774941a5f0a25cb86f3"
185
  },
186
  "dist": {
187
  "type": "zip",
188
- "url": "https://api.github.com/repos/Upstatement/routes/zipball/fae7d46f56e8b5775f072774941a5f0a25cb86f3",
189
- "reference": "fae7d46f56e8b5775f072774941a5f0a25cb86f3",
190
  "shasum": ""
191
  },
192
  "require": {
193
- "altorouter/altorouter": "1.1.0",
194
  "composer/installers": "~1.0",
195
  "php": ">=5.3.0"
196
  },
@@ -199,7 +203,7 @@
199
  "satooshi/php-coveralls": "dev-master",
200
  "wp-cli/wp-cli": "*"
201
  },
202
- "time": "2016-07-06 12:53:24",
203
  "type": "library",
204
  "installation-source": "dist",
205
  "autoload": {
123
  },
124
  {
125
  "name": "altorouter/altorouter",
126
+ "version": "v1.2.0",
127
+ "version_normalized": "1.2.0.0",
128
  "source": {
129
  "type": "git",
130
  "url": "https://github.com/dannyvankooten/AltoRouter.git",
131
+ "reference": "39c50092470128c12284d332bb57f306bb5b58e4"
132
  },
133
  "dist": {
134
  "type": "zip",
135
+ "url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/39c50092470128c12284d332bb57f306bb5b58e4",
136
+ "reference": "39c50092470128c12284d332bb57f306bb5b58e4",
137
  "shasum": ""
138
  },
139
  "require": {
140
  "php": ">=5.3.0"
141
  },
142
+ "require-dev": {
143
+ "codeclimate/php-test-reporter": "dev-master",
144
+ "phpunit/phpunit": "4.5.*"
145
+ },
146
+ "time": "2015-11-30 00:47:43",
147
  "type": "library",
148
  "installation-source": "dist",
149
  "autoload": {
180
  },
181
  {
182
  "name": "upstatement/routes",
183
+ "version": "0.5",
184
+ "version_normalized": "0.5.0.0",
185
  "source": {
186
  "type": "git",
187
  "url": "https://github.com/Upstatement/routes.git",
188
+ "reference": "3267d28be0a73f197087d58384e1a358d85671b6"
189
  },
190
  "dist": {
191
  "type": "zip",
192
+ "url": "https://api.github.com/repos/Upstatement/routes/zipball/3267d28be0a73f197087d58384e1a358d85671b6",
193
+ "reference": "3267d28be0a73f197087d58384e1a358d85671b6",
194
  "shasum": ""
195
  },
196
  "require": {
197
+ "altorouter/altorouter": "^1.1.0",
198
  "composer/installers": "~1.0",
199
  "php": ">=5.3.0"
200
  },
203
  "satooshi/php-coveralls": "dev-master",
204
  "wp-cli/wp-cli": "*"
205
  },
206
+ "time": "2018-12-04 01:13:41",
207
  "type": "library",
208
  "installation-source": "dist",
209
  "autoload": {
vendor/upstatement/routes/.travis.yml CHANGED
@@ -1,19 +1,14 @@
1
  language: php
2
 
3
  php:
4
- - 5.3
5
- - 5.4
6
- - hhvm
7
 
8
  env:
9
  - WP_VERSION=latest WP_MULTISITE=0
10
  - WP_VERSION=latest WP_MULTISITE=1
11
- - WP_VERSION=3.9 WP_MULTISITE=0
12
- - WP_VERSION=3.9 WP_MULTISITE=1
13
- - WP_VERSION=3.8.3 WP_MULTISITE=0
14
- - WP_VERSION=3.8.3 WP_MULTISITE=1
15
- - WP_VERSION=3.7.3 WP_MULTISITE=0
16
- - WP_VERSION=3.7.3 WP_MULTISITE=1
17
 
18
  before_script:
19
  - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
1
  language: php
2
 
3
  php:
4
+ - 5.6.30
5
+ - 7.1
 
6
 
7
  env:
8
  - WP_VERSION=latest WP_MULTISITE=0
9
  - WP_VERSION=latest WP_MULTISITE=1
10
+ - WP_VERSION=4.7.3 WP_MULTISITE=0
11
+ - WP_VERSION=4.7.3 WP_MULTISITE=1
 
 
 
 
12
 
13
  before_script:
14
  - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
vendor/upstatement/routes/README.md CHANGED
@@ -1,12 +1,12 @@
1
  # Routes
2
- Simple routing for WordPress.
3
 
4
  [![Build Status](https://img.shields.io/travis/Upstatement/routes/master.svg?style=flat-square)](https://travis-ci.org/Upstatement/routes)
5
  [![Coverage Status](https://img.shields.io/coveralls/Upstatement/routes.svg?style=flat-square)](https://coveralls.io/r/Upstatement/routes?branch=master)
6
  [![Packagist Downloads](https://img.shields.io/packagist/dt/Upstatement/routes.svg?style=flat-square)]()
7
 
8
 
9
- ### Usage
10
  ```php
11
  /* functions.php */
12
  Routes::map('myfoo/bar', 'my_callback_function');
@@ -17,3 +17,112 @@ Routes::map('my-events/:event', function($params) {
17
  Routes::load('single.php', array('event' => $event), $query, 200);
18
  });
19
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Routes
2
+ Simple routing for WordPress. Designed for usage with [Timber](https://github.com/timber/timber)
3
 
4
  [![Build Status](https://img.shields.io/travis/Upstatement/routes/master.svg?style=flat-square)](https://travis-ci.org/Upstatement/routes)
5
  [![Coverage Status](https://img.shields.io/coveralls/Upstatement/routes.svg?style=flat-square)](https://coveralls.io/r/Upstatement/routes?branch=master)
6
  [![Packagist Downloads](https://img.shields.io/packagist/dt/Upstatement/routes.svg?style=flat-square)]()
7
 
8
 
9
+ ### Basic Usage
10
  ```php
11
  /* functions.php */
12
  Routes::map('myfoo/bar', 'my_callback_function');
17
  Routes::load('single.php', array('event' => $event), $query, 200);
18
  });
19
  ```
20
+
21
+ Using routes makes it easy for you to implement custom pagination — and anything else you might imagine in your wildest dreams of URLs and parameters. OMG so easy!
22
+
23
+ ## Some examples
24
+ In your functions.php file, this can be called anywhere (don't hook it to init or another action or it might be called too late)
25
+
26
+ ```php
27
+ <?php
28
+ Routes::map('blog/:name', function($params){
29
+ $query = 'posts_per_page=3&post_type='.$params['name'];
30
+ Routes::load('archive.php', null, $query, 200);
31
+ });
32
+
33
+ Routes::map('blog/:name/page/:pg', function($params){
34
+ $query = 'posts_per_page=3&post_type='.$params['name'].'&paged='.$params['pg'];
35
+ $params = array('thing' => 'foo', 'bar' => 'I dont even know');
36
+ Routes::load('archive.php', $params, $query);
37
+ });
38
+ ```
39
+
40
+ ## map
41
+
42
+ `Routes::map($pattern, $callback)`
43
+
44
+ ### Usage
45
+
46
+ A `functions.php` where I want to display custom paginated content:
47
+
48
+ ```php
49
+ <?php
50
+ Routes::map('info/:name/page/:pg', function($params){
51
+ //make a custom query based on incoming path and run it...
52
+ $query = 'posts_per_page=3&post_type='.$params['name'].'&paged='.intval($params['pg']);
53
+
54
+ //load up a template which will use that query
55
+ Routes::load('archive.php', null, $query);
56
+ });
57
+ ```
58
+
59
+ ### Arguments
60
+
61
+ `$pattern` (required)
62
+ Set a pattern for Routes to match on, by default everything is handled as a string. Any segment that begins with a `:` is handled as a variable, for example:
63
+
64
+ **To paginate:**
65
+
66
+ ```
67
+ page/:pagenum
68
+ ```
69
+
70
+ **To edit a user:**
71
+
72
+ ```
73
+ my-users/:userid/edit
74
+ ```
75
+
76
+ `$callback`
77
+ A function that should fire when the pattern matches the request. Callback takes one argument which is an array of the parameters passed in the URL.
78
+
79
+ So in this example: `'info/:name/page/:pg'`, $params would have data for:
80
+ * `$data['name']`
81
+ * `$data['pg']`
82
+
83
+ ... which you can use in the callback function as a part of your query
84
+
85
+ * * *
86
+
87
+ ## load
88
+
89
+ `Routes::load($php_file, $args, $query = null, $status_code = 200)`
90
+
91
+ ### Arguments
92
+
93
+ `$php_file` (required)
94
+ A PHP file to load, in my experience this is usually your archive.php or a generic listing page (but don't worry it can be anything!)
95
+
96
+ `$template_params`
97
+ Any data you want to send to the resulting view. Example:
98
+
99
+ ```php
100
+ <?php
101
+ /* functions.php */
102
+
103
+ Routes::map('info/:name/page/:pg', function($params){
104
+ //make a custom query based on incoming path and run it...
105
+ $query = 'posts_per_page=3&post_type='.$params['name'].'&paged='.intval($params['pg']);
106
+
107
+ //load up a template which will use that query
108
+ $params = array();
109
+ $params['my_title'] = 'This is my custom title';
110
+ Routes::load('archive.php', $params, $query, 200);
111
+ });
112
+ ```
113
+
114
+ ```php
115
+ <?php
116
+ /* archive.php */
117
+
118
+ global $params;
119
+ $context['wp_title'] = $params['my_title']; // "This is my custom title"
120
+ /* the rest as normal... */
121
+ Timber::render('archive.twig', $context);
122
+ ```
123
+
124
+ `$query`
125
+ The query you want to use, it can accept a string or array just like `Timber::get_posts` -- use the standard WP_Query syntax (or a WP_Query object too)
126
+
127
+ `$status_code`
128
+ Send an optional status code. Defaults to 200 for 'Success/OK'
vendor/upstatement/routes/Routes.php CHANGED
@@ -97,9 +97,10 @@ class Routes {
97
  * @param int $status_code A code for the status (ex: 200)
98
  * @param WP_Query $query Use a WP_Query object in the template file instead of
99
  * the default query
 
100
  * @return bool
101
  */
102
- public static function load($template, $tparams = false, $query = false, $status_code = 200) {
103
  $fullPath = is_readable($template);
104
  if (!$fullPath) {
105
  $template = locate_template($template);
@@ -146,7 +147,7 @@ class Routes {
146
  if ($template) {
147
  add_filter('template_include', function($t) use ($template) {
148
  return $template;
149
- });
150
  return true;
151
  }
152
  return false;
97
  * @param int $status_code A code for the status (ex: 200)
98
  * @param WP_Query $query Use a WP_Query object in the template file instead of
99
  * the default query
100
+ * @param int $priority The priority used by the "template_include" filter
101
  * @return bool
102
  */
103
+ public static function load($template, $tparams = false, $query = false, $status_code = 200, $priority = 10) {
104
  $fullPath = is_readable($template);
105
  if (!$fullPath) {
106
  $template = locate_template($template);
147
  if ($template) {
148
  add_filter('template_include', function($t) use ($template) {
149
  return $template;
150
+ }, $priority);
151
  return true;
152
  }
153
  return false;
vendor/upstatement/routes/composer.json CHANGED
@@ -18,7 +18,7 @@
18
  },
19
  "require" : {
20
  "php" : ">=5.3.0",
21
- "altorouter/altorouter" : "1.1.0",
22
  "composer/installers" : "~1.0"
23
  },
24
  "require-dev": {
18
  },
19
  "require" : {
20
  "php" : ">=5.3.0",
21
+ "altorouter/altorouter" : "^1.1.0",
22
  "composer/installers" : "~1.0"
23
  },
24
  "require-dev": {