Completed
Pull Request — master (#895)
by
unknown
02:49
created
lib/cache/WPObjectCacheAdapter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 	 */
13 13
 	private $timberloader;
14 14
 
15
-	public function __construct(TimberLoader $timberloader, $cache_group = 'timber') {
15
+	public function __construct( TimberLoader $timberloader, $cache_group = 'timber' ) {
16 16
 		$this->cache_group = $cache_group;
17 17
 		$this->timberloader = $timberloader;
18 18
 	}
19 19
 
20
-	public function fetch($key) {
20
+	public function fetch( $key ) {
21 21
 		return $this->timberloader->get_cache($key, $this->cache_group, TimberLoader::CACHE_USE_DEFAULT);
22 22
 	}
23 23
 
24
-	public function save($key, $value, $expire = 0) {
24
+	public function save( $key, $value, $expire = 0 ) {
25 25
 		return $this->timberloader->set_cache($key, $value, $this->cache_group, $expire, TimberLoader::CACHE_USE_DEFAULT);
26 26
 	}
27 27
 
Please login to merge, or discard this patch.
lib/cache/KeyGenerator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
 	 * @param mixed $value
11 11
 	 * @return string
12 12
 	 */
13
-	public function generateKey($value) {
14
-		if (is_a($value, 'TimberKeyGeneratorInterface')) {
13
+	public function generateKey( $value ) {
14
+		if ( is_a($value, 'TimberKeyGeneratorInterface') ) {
15 15
 			return $value->_get_cache_key();
16 16
 		}
17 17
 
18
-		if (is_array($value) && isset($value['_cache_key'])) {
18
+		if ( is_array($value) && isset($value['_cache_key']) ) {
19 19
 			return $value['_cache_key'];
20 20
 		}
21 21
 
22 22
 		$key = md5(json_encode($value));
23
-		if (is_object($value)) {
23
+		if ( is_object($value) ) {
24 24
 			$key = get_class($value) . '|' . $key;
25 25
 		}
26 26
 
Please login to merge, or discard this patch.
lib/timber-menu-item.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function __construct( $data ) {
28 28
 		$data = (object) $data;
29
-		$this->import( $data );
30
-		$this->import_classes( $data );
31
-		if ( isset( $this->name ) ) {
29
+		$this->import($data);
30
+		$this->import_classes($data);
31
+		if ( isset($this->name) ) {
32 32
 			$this->_name = $this->name;
33 33
 		}
34 34
 		$this->name = $this->name();
35
-		$this->add_class( 'menu-item-' . $this->ID );
35
+		$this->add_class('menu-item-' . $this->ID);
36 36
 		$this->menu_object = $data;
37 37
 	}
38 38
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		if ( $title = $this->title() ) {
62 62
 			return $title;
63 63
 		}
64
-		if ( isset( $this->_name ) ) {
64
+		if ( isset($this->_name) ) {
65 65
 			return $this->_name;
66 66
 		}
67 67
 		return '';
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * @return string the slug of the menu item kinda-like-this
83 83
 	 */
84 84
 	public function slug() {
85
-		if ( !isset( $this->master_object ) ) {
85
+		if ( !isset($this->master_object) ) {
86 86
 			$this->master_object = $this->get_master_object();
87 87
 		}
88
-		if ( isset( $this->master_object->post_name ) && $this->master_object->post_name ) {
88
+		if ( isset($this->master_object->post_name) && $this->master_object->post_name ) {
89 89
 			return $this->master_object->post_name;
90 90
 		}
91 91
 		return $this->post_name;
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @return mixed whatever object (Post, Term, etc.) the menu item represents
97 97
 	 */
98 98
 	protected function get_master_object() {
99
-		if ( isset( $this->_menu_item_object_id ) ) {
100
-			return new $this->PostClass( $this->_menu_item_object_id );
99
+		if ( isset($this->_menu_item_object_id) ) {
100
+			return new $this->PostClass($this->_menu_item_object_id);
101 101
 		}
102 102
 	}
103 103
 
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	 * @return string an absolute URL http://example.org/my-page
108 108
 	 */
109 109
 	function get_link() {
110
-		if ( !isset( $this->url ) || !$this->url ) {
111
-			if ( isset( $this->_menu_item_type ) && $this->_menu_item_type == 'custom' ) {
110
+		if ( !isset($this->url) || !$this->url ) {
111
+			if ( isset($this->_menu_item_type) && $this->_menu_item_type == 'custom' ) {
112 112
 				$this->url = $this->_menu_item_url;
113
-			} else if ( isset( $this->menu_object ) && method_exists( $this->menu_object, 'get_link' ) ) {
113
+			} else if ( isset($this->menu_object) && method_exists($this->menu_object, 'get_link') ) {
114 114
 					$this->url = $this->menu_object->get_link();
115 115
 				}
116 116
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @return string a relative url /my-page
124 124
 	 */
125 125
 	function get_path() {
126
-		return TimberURLHelper::get_rel_url( $this->get_link() );
126
+		return TimberURLHelper::get_rel_url($this->get_link());
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	function add_child( $item ) {
135 135
 		if ( !$this->has_child_class ) {
136
-			$this->add_class( 'menu-item-has-children' );
136
+			$this->add_class('menu-item-has-children');
137 137
 			$this->has_child_class = true;
138 138
 		}
139
-		if ( !isset( $this->children ) ) {
139
+		if ( !isset($this->children) ) {
140 140
 			$this->children = array();
141 141
 		}
142 142
 		$this->children[] = $item;
143 143
 		$item->level = $this->level + 1;
144
-		if ($item->children) {
144
+		if ( $item->children ) {
145 145
 			$this->update_child_levels();
146 146
 		}
147 147
 	}
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @return bool 
153 153
 	 */
154 154
 	function update_child_levels() {
155
-		if (is_array($this->children)) {
156
-			foreach( $this->children as $child ) {
155
+		if ( is_array($this->children) ) {
156
+			foreach ( $this->children as $child ) {
157 157
 				$child->level = $this->level + 1;
158 158
 				$child->update_child_levels();
159 159
 			}
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 		if ( is_array($data) ) {
171 171
 			$data = (object) $data;
172 172
 		}
173
-		$this->classes = array_merge( $this->classes, $data->classes );
174
-		$this->classes = array_unique( $this->classes );
175
-		$this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this );
176
-		$this->class = trim( implode( ' ', $this->classes ) );
173
+		$this->classes = array_merge($this->classes, $data->classes);
174
+		$this->classes = array_unique($this->classes);
175
+		$this->classes = apply_filters('nav_menu_css_class', $this->classes, $this);
176
+		$this->class = trim(implode(' ', $this->classes));
177 177
 	}
178 178
 
179 179
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @return array|bool
183 183
 	 */
184 184
 	function get_children() {
185
-		if ( isset( $this->children ) ) {
185
+		if ( isset($this->children) ) {
186 186
 			return $this->children;
187 187
 		}
188 188
 		return false;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		if ( $this->type != 'custom' ) {
202 202
 			return false;
203 203
 		}
204
-		return TimberURLHelper::is_external( $this->url );
204
+		return TimberURLHelper::is_external($this->url);
205 205
 	}
206 206
 
207 207
 	/**
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 	 * @return mixed whatever value is storied in the database
210 210
 	 */
211 211
 	public function meta( $key ) {
212
-		if ( is_object( $this->menu_object ) && method_exists( $this->menu_object, 'meta' ) ) {
213
-			return $this->menu_object->meta( $key );
212
+		if ( is_object($this->menu_object) && method_exists($this->menu_object, 'meta') ) {
213
+			return $this->menu_object->meta($key);
214 214
 		}
215
-		if ( isset( $this->$key ) ) {
215
+		if ( isset($this->$key) ) {
216 216
 			return $this->$key;
217 217
 		}
218 218
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return string the public label like Foo
300 300
 	 */
301 301
 	public function title() {
302
-		if ( isset( $this->__title ) ) {
302
+		if ( isset($this->__title) ) {
303 303
 			return $this->__title;
304 304
 		}
305 305
 	}
Please login to merge, or discard this patch.
lib/timber-theme.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * We are currently using the My Theme theme.
63 63
 	 * ```
64 64
 	 */
65
-	function __construct($slug = null) {
65
+	function __construct( $slug = null ) {
66 66
 		$this->init($slug);
67 67
 	}
68 68
 
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 * @internal
71 71
 	 * @param string $slug
72 72
 	 */
73
-	protected function init($slug = null) {
73
+	protected function init( $slug = null ) {
74 74
 		$data = wp_get_theme($slug);
75 75
 		$this->name = $data->get('Name');
76 76
 		$ss = $data->get_stylesheet();
77 77
 		$this->slug = $ss;
78 78
 
79
-		if ( ! function_exists( 'get_home_path' ) ) {
79
+		if ( !function_exists('get_home_path') ) {
80 80
 			require_once(ABSPATH . 'wp-admin/includes/file.php');
81 81
 		}
82 82
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return  string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`)
104 104
 	 */
105 105
 	public function path() {
106
-		return TimberURLHelper::get_rel_url( $this->link() );
106
+		return TimberURLHelper::get_rel_url($this->link());
107 107
 	}
108 108
 
109 109
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param bool $default
112 112
 	 * @return string
113 113
 	 */
114
-	public function theme_mod($name, $default = false) {
114
+	public function theme_mod( $name, $default = false ) {
115 115
 		return get_theme_mod($name, $default);
116 116
 	}
117 117
 
Please login to merge, or discard this patch.
lib/timber-query-iterator.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( !defined( 'ABSPATH' ) )
3
+if ( !defined('ABSPATH') )
4 4
     exit;
5 5
 
6 6
 class TimberQueryIterator implements Iterator {
@@ -14,37 +14,37 @@  discard block
 block discarded – undo
14 14
     private $_posts_class = 'TimberPost';
15 15
 
16 16
     public function __construct( $query = false, $posts_class = 'TimberPost' ) {
17
-        add_action( 'pre_get_posts', array($this, 'fix_number_posts_wp_quirk' ));
17
+        add_action('pre_get_posts', array($this, 'fix_number_posts_wp_quirk'));
18 18
         if ( $posts_class )
19 19
             $this->_posts_class = $posts_class;
20 20
 
21
-        if ( is_a( $query, 'WP_Query' ) ) {
21
+        if ( is_a($query, 'WP_Query') ) {
22 22
             // We got a full-fledged WP Query, look no further!
23 23
             $the_query = $query;
24 24
 
25 25
         } elseif ( false === $query ) {
26 26
             // If query is explicitly set to false, use the main loop
27 27
             global $wp_query;
28
-            $the_query =& $wp_query;
28
+            $the_query = & $wp_query;
29 29
             //if we're on a custom posts page?
30 30
             $the_query = self::handle_maybe_custom_posts_page($the_query);
31
-        } elseif ( TimberHelper::is_array_assoc( $query ) || ( is_string( $query ) && strstr( $query, '=' ) ) ) {
31
+        } elseif ( TimberHelper::is_array_assoc($query) || (is_string($query) && strstr($query, '=')) ) {
32 32
             // We have a regularly formed WP query string or array to use
33
-            $the_query = new WP_Query( $query );
33
+            $the_query = new WP_Query($query);
34 34
 
35
-        } elseif ( is_numeric( $query ) || is_string( $query ) ) {
35
+        } elseif ( is_numeric($query) || is_string($query) ) {
36 36
             // We have what could be a post name or post ID to pull out
37
-            $the_query = self::get_query_from_string( $query );
37
+            $the_query = self::get_query_from_string($query);
38 38
 
39
-        } elseif ( is_array( $query ) && count( $query ) && ( is_integer( $query[0] ) || is_string( $query[0] ) ) ) {
39
+        } elseif ( is_array($query) && count($query) && (is_integer($query[0]) || is_string($query[0])) ) {
40 40
             // We have a list of pids (post IDs) to extract from
41
-            $the_query = self::get_query_from_array_of_ids( $query );
42
-        } elseif ( is_array($query) && empty($query)) {
41
+            $the_query = self::get_query_from_array_of_ids($query);
42
+        } elseif ( is_array($query) && empty($query) ) {
43 43
             // it's an empty array
44 44
             $the_query = array();
45 45
         } else {
46
-            TimberHelper::error_log( 'I have failed you! in ' . basename( __FILE__ ) . '::' . __LINE__ );
47
-            TimberHelper::error_log( $query );
46
+            TimberHelper::error_log('I have failed you! in ' . basename(__FILE__) . '::' . __LINE__);
47
+            TimberHelper::error_log($query);
48 48
 
49 49
             // We have failed hard, at least let get something.
50 50
             $the_query = new WP_Query();
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
     }
56 56
 
57 57
     public function get_posts( $return_collection = false ) {
58
-        if (isset($this->_query->posts)){
59
-            $posts = new TimberPostsCollection( $this->_query->posts, $this->_posts_class );
60
-            return ( $return_collection ) ? $posts : $posts->get_posts();
58
+        if ( isset($this->_query->posts) ) {
59
+            $posts = new TimberPostsCollection($this->_query->posts, $this->_posts_class);
60
+            return ($return_collection) ? $posts : $posts->get_posts();
61 61
         }
62 62
     }
63 63
 
@@ -65,38 +65,38 @@  discard block
 block discarded – undo
65 65
     // GET POSTS
66 66
     //
67 67
     public static function get_query_from_array_of_ids( $query = array() ) {
68
-        if ( !is_array( $query ) || !count( $query ) )
68
+        if ( !is_array($query) || !count($query) )
69 69
             return null;
70 70
 
71
-        return new WP_Query( array(
71
+        return new WP_Query(array(
72 72
                 'post_type'=> 'any',
73 73
                 'ignore_sticky_posts' => true,
74 74
                 'post__in' => $query,
75 75
                 'orderby'  => 'post__in',
76 76
                 'nopaging' => true
77
-            ) );
77
+            ));
78 78
     }
79 79
 
80 80
     public static function get_query_from_string( $string = '' ) {
81 81
         $post_type = false;
82 82
 
83
-        if ( is_string( $string ) && strstr( $string, '#' ) ) {
83
+        if ( is_string($string) && strstr($string, '#') ) {
84 84
             //we have a post_type directive here
85
-            list( $post_type, $string ) = explode( '#', $string );
85
+            list($post_type, $string) = explode('#', $string);
86 86
         }
87 87
 
88 88
         $query = array(
89
-            'post_type' => ( $post_type ) ? $post_type : 'any'
89
+            'post_type' => ($post_type) ? $post_type : 'any'
90 90
         );
91 91
 
92
-        if ( is_numeric( $string ) ) {
92
+        if ( is_numeric($string) ) {
93 93
             $query['p'] = $string;
94 94
 
95 95
         } else {
96 96
             $query['name'] = $string;
97 97
         }
98 98
 
99
-        return new WP_Query( $query );
99
+        return new WP_Query($query);
100 100
     }
101 101
 
102 102
     //
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
         // Sets up the global post, but also return the post, for use in Twig template
116 116
         $posts_class = $this->_posts_class;
117
-        return new $posts_class( $post );
117
+        return new $posts_class($post);
118 118
     }
119 119
 
120 120
     /**
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 
133 133
     //get_posts users numberposts
134 134
     static function fix_number_posts_wp_quirk( $query ) {
135
-        if (isset($query->query) && isset($query->query['numberposts'])
136
-                && !isset($query->query['posts_per_page'])) {
137
-            $query->set( 'posts_per_page', $query->query['numberposts'] );
135
+        if ( isset($query->query) && isset($query->query['numberposts'])
136
+                && !isset($query->query['posts_per_page']) ) {
137
+            $query->set('posts_per_page', $query->query['numberposts']);
138 138
         }
139 139
         return $query;
140 140
     }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @return WP_Query
146 146
      */
147 147
     static function handle_maybe_custom_posts_page( $query ) {
148
-    	if ($custom_posts_page = get_option('page_for_posts')) {
148
+    	if ( $custom_posts_page = get_option('page_for_posts') ) {
149 149
         	if ( isset($query->query['p']) && $query->query['p'] == $custom_posts_page ) {
150 150
         		return new WP_Query(array('post_type' => 'post'));
151 151
         	}
Please login to merge, or discard this patch.