@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg) |
31 | 31 | */ |
32 | 32 | public function filename($src_filename, $src_extension) { |
33 | - $color = str_replace( '#', '', $this->color ); |
|
33 | + $color = str_replace('#', '', $this->color); |
|
34 | 34 | $newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color; |
35 | 35 | $new_name = $newbase . '.' . $src_extension; |
36 | 36 | return $new_name; |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | $w = $this->w; |
51 | 51 | $h = $this->h; |
52 | 52 | |
53 | - $bg = imagecreatetruecolor( $w, $h ); |
|
54 | - $c = self::hexrgb( $this->color ); |
|
55 | - $bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] ); |
|
56 | - imagefill( $bg, 0, 0, $bgColor ); |
|
57 | - $image = wp_get_image_editor( $load_filename ); |
|
58 | - if ( !is_wp_error( $image ) ) { |
|
53 | + $bg = imagecreatetruecolor($w, $h); |
|
54 | + $c = self::hexrgb($this->color); |
|
55 | + $bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']); |
|
56 | + imagefill($bg, 0, 0, $bgColor); |
|
57 | + $image = wp_get_image_editor($load_filename); |
|
58 | + if ( !is_wp_error($image) ) { |
|
59 | 59 | $current_size = $image->get_size(); |
60 | 60 | $quality = $image->get_quality(); |
61 | 61 | $ow = $current_size['width']; |
@@ -69,38 +69,38 @@ discard block |
||
69 | 69 | $y = 0; |
70 | 70 | $x = $w / 2 - $owt / 2; |
71 | 71 | $oht = $h; |
72 | - $image->crop( 0, 0, $ow, $oh, $owt, $oht ); |
|
72 | + $image->crop(0, 0, $ow, $oh, $owt, $oht); |
|
73 | 73 | } else { |
74 | 74 | $w_scale = $w / $ow; |
75 | 75 | $oht = $oh * $w_scale; |
76 | 76 | $x = 0; |
77 | 77 | $y = $h / 2 - $oht / 2; |
78 | 78 | $owt = $w; |
79 | - $image->crop( 0, 0, $ow, $oh, $owt, $oht ); |
|
79 | + $image->crop(0, 0, $ow, $oh, $owt, $oht); |
|
80 | 80 | } |
81 | - $result = $image->save( $save_filename ); |
|
81 | + $result = $image->save($save_filename); |
|
82 | 82 | $func = 'imagecreatefromjpeg'; |
83 | 83 | $save_func = 'imagejpeg'; |
84 | - $ext = pathinfo( $save_filename, PATHINFO_EXTENSION ); |
|
84 | + $ext = pathinfo($save_filename, PATHINFO_EXTENSION); |
|
85 | 85 | if ( $ext == 'gif' ) { |
86 | 86 | $func = 'imagecreatefromgif'; |
87 | 87 | $save_func = 'imagegif'; |
88 | 88 | } else if ( $ext == 'png' ) { |
89 | 89 | $func = 'imagecreatefrompng'; |
90 | 90 | $save_func = 'imagepng'; |
91 | - if ($quality > 9) { |
|
92 | - $quality = $quality/10; |
|
91 | + if ( $quality > 9 ) { |
|
92 | + $quality = $quality / 10; |
|
93 | 93 | $quality = round(10 - $quality); |
94 | 94 | } |
95 | 95 | } |
96 | - $image = $func( $save_filename ); |
|
97 | - imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht ); |
|
98 | - if ($save_func === 'imagegif') { |
|
99 | - return $save_func( $bg, $save_filename ); |
|
96 | + $image = $func($save_filename); |
|
97 | + imagecopy($bg, $image, $x, $y, 0, 0, $owt, $oht); |
|
98 | + if ( $save_func === 'imagegif' ) { |
|
99 | + return $save_func($bg, $save_filename); |
|
100 | 100 | } |
101 | - return $save_func( $bg, $save_filename, $quality ); |
|
101 | + return $save_func($bg, $save_filename, $quality); |
|
102 | 102 | } else { |
103 | - TimberHelper::error_log( $image ); |
|
103 | + TimberHelper::error_log($image); |
|
104 | 104 | } |
105 | 105 | return false; |
106 | 106 | } |
@@ -15,12 +15,12 @@ |
||
15 | 15 | // then in the wp-content dir (site install). |
16 | 16 | // and finally in the current themes directories. |
17 | 17 | if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */ |
18 | - || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
19 | - || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
20 | - || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
21 | - || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
18 | + || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
19 | + || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
20 | + || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
21 | + || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
22 | 22 | ) { |
23 | - require_once $composer_autoload; |
|
23 | + require_once $composer_autoload; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $timber = new Timber(); |
@@ -14,11 +14,11 @@ |
||
14 | 14 | // we look for Composer files first in the plugins dir. |
15 | 15 | // then in the wp-content dir (site install). |
16 | 16 | // and finally in the current themes directories. |
17 | -if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */ |
|
18 | - || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
19 | - || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
20 | - || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
21 | - || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
17 | +if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php') /* check in self */ |
|
18 | + || file_exists($composer_autoload = WP_CONTENT_DIR . '/vendor/autoload.php') /* check in wp-content */ |
|
19 | + || file_exists($composer_autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php') /* check in plugin directory */ |
|
20 | + || file_exists($composer_autoload = get_stylesheet_directory() . '/vendor/autoload.php') /* check in child theme */ |
|
21 | + || file_exists($composer_autoload = get_template_directory() . '/vendor/autoload.php') /* check in parent theme */ |
|
22 | 22 | ) { |
23 | 23 | require_once $composer_autoload; |
24 | 24 | } |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) { |
46 | 46 | return; |
47 | 47 | } |
48 | - if ( version_compare( phpversion(), '5.3.0', '<' ) && !is_admin() ) { |
|
49 | - trigger_error( 'Timber requires PHP 5.3.0 or greater. You have '.phpversion(), E_USER_ERROR ); |
|
48 | + if ( version_compare(phpversion(), '5.3.0', '<') && !is_admin() ) { |
|
49 | + trigger_error('Timber requires PHP 5.3.0 or greater. You have ' . phpversion(), E_USER_ERROR); |
|
50 | 50 | } |
51 | - if ( !class_exists( 'Twig_Autoloader' ) ) { |
|
52 | - trigger_error( 'You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR ); |
|
51 | + if ( !class_exists('Twig_Autoloader') ) { |
|
52 | + trigger_error('You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | 56 | function init_constants() { |
57 | - defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( dirname(__DIR__) ) ); |
|
57 | + defined("TIMBER_LOC") or define("TIMBER_LOC", realpath(dirname(__DIR__))); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function init() { |
64 | 64 | TimberTwig::init(); |
65 | - TimberRoutes::init( $this ); |
|
65 | + TimberRoutes::init($this); |
|
66 | 66 | TimberImageHelper::init(); |
67 | 67 | TimberAdmin::init(); |
68 | 68 | TimberIntegrations::init(); |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param string $PostClass |
79 | 79 | * @return array|bool|null |
80 | 80 | */ |
81 | - public static function get_post( $query = false, $PostClass = 'TimberPost' ) { |
|
82 | - return TimberPostGetter::get_post( $query, $PostClass ); |
|
81 | + public static function get_post($query = false, $PostClass = 'TimberPost') { |
|
82 | + return TimberPostGetter::get_post($query, $PostClass); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param string $PostClass |
90 | 90 | * @return array|bool|null |
91 | 91 | */ |
92 | - public static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) { |
|
93 | - return TimberPostGetter::get_posts( $query, $PostClass, $return_collection ); |
|
92 | + public static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) { |
|
93 | + return TimberPostGetter::get_posts($query, $PostClass, $return_collection); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param string $PostClass |
101 | 101 | * @return array|bool|null |
102 | 102 | */ |
103 | - public static function query_post( $query = false, $PostClass = 'TimberPost' ) { |
|
104 | - return TimberPostGetter::query_post( $query, $PostClass ); |
|
103 | + public static function query_post($query = false, $PostClass = 'TimberPost') { |
|
104 | + return TimberPostGetter::query_post($query, $PostClass); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param string $PostClass |
112 | 112 | * @return array|bool|null |
113 | 113 | */ |
114 | - public static function query_posts( $query = false, $PostClass = 'TimberPost' ) { |
|
115 | - return TimberPostGetter::query_posts( $query, $PostClass ); |
|
114 | + public static function query_posts($query = false, $PostClass = 'TimberPost') { |
|
115 | + return TimberPostGetter::query_posts($query, $PostClass); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param string $TermClass |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) { |
|
140 | - return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass ); |
|
139 | + public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') { |
|
140 | + return TimberTermGetter::get_terms($args, $maybe_args, $TermClass); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /* Site Retrieval |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | * @param array|bool $blog_ids |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - public static function get_sites( $blog_ids = false ) { |
|
153 | - if ( !is_array( $blog_ids ) ) { |
|
152 | + public static function get_sites($blog_ids = false) { |
|
153 | + if ( !is_array($blog_ids) ) { |
|
154 | 154 | global $wpdb; |
155 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC" ); |
|
155 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC"); |
|
156 | 156 | } |
157 | 157 | $return = array(); |
158 | - foreach ( $blog_ids as $blog_id ) { |
|
159 | - $return[] = new TimberSite( $blog_id ); |
|
158 | + foreach ($blog_ids as $blog_id) { |
|
159 | + $return[] = new TimberSite($blog_id); |
|
160 | 160 | } |
161 | 161 | return $return; |
162 | 162 | } |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | $data = array(); |
175 | 175 | $data['http_host'] = 'http://' . TimberURLHelper::get_host(); |
176 | 176 | $data['wp_title'] = TimberHelper::get_wp_title(); |
177 | - $data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' ); |
|
178 | - $data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' ); |
|
179 | - $data['body_class'] = implode( ' ', get_body_class() ); |
|
177 | + $data['wp_head'] = TimberHelper::function_wrapper('wp_head'); |
|
178 | + $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer'); |
|
179 | + $data['body_class'] = implode(' ', get_body_class()); |
|
180 | 180 | |
181 | 181 | $data['site'] = new TimberSite(); |
182 | 182 | $data['theme'] = $data['site']->theme; |
183 | 183 | |
184 | 184 | $data['posts'] = Timber::query_posts(); |
185 | 185 | |
186 | - $data = apply_filters( 'timber_context', $data ); |
|
187 | - $data = apply_filters( 'timber/context', $data ); |
|
186 | + $data = apply_filters('timber_context', $data); |
|
187 | + $data = apply_filters('timber/context', $data); |
|
188 | 188 | return $data; |
189 | 189 | } |
190 | 190 | |
@@ -198,27 +198,27 @@ discard block |
||
198 | 198 | * @param bool $via_render |
199 | 199 | * @return bool|string |
200 | 200 | */ |
201 | - public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) { |
|
201 | + public static function compile($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false) { |
|
202 | 202 | $caller = self::get_calling_script_dir(); |
203 | 203 | $caller_file = self::get_calling_script_file(); |
204 | - $caller_file = apply_filters( 'timber_calling_php_file', $caller_file ); |
|
205 | - $loader = new TimberLoader( $caller ); |
|
206 | - $file = $loader->choose_template( $filenames ); |
|
204 | + $caller_file = apply_filters('timber_calling_php_file', $caller_file); |
|
205 | + $loader = new TimberLoader($caller); |
|
206 | + $file = $loader->choose_template($filenames); |
|
207 | 207 | $output = ''; |
208 | - if ( is_null( $data ) ) { |
|
208 | + if ( is_null($data) ) { |
|
209 | 209 | $data = array(); |
210 | 210 | } |
211 | - if ( strlen( $file ) ) { |
|
211 | + if ( strlen($file) ) { |
|
212 | 212 | if ( $via_render ) { |
213 | - $file = apply_filters( 'timber_render_file', $file ); |
|
214 | - $data = apply_filters( 'timber_render_data', $data ); |
|
213 | + $file = apply_filters('timber_render_file', $file); |
|
214 | + $data = apply_filters('timber_render_data', $data); |
|
215 | 215 | } else { |
216 | - $file = apply_filters( 'timber_compile_file', $file ); |
|
217 | - $data = apply_filters( 'timber_compile_data', $data ); |
|
216 | + $file = apply_filters('timber_compile_file', $file); |
|
217 | + $data = apply_filters('timber_compile_data', $data); |
|
218 | 218 | } |
219 | - $output = $loader->render( $file, $data, $expires, $cache_mode ); |
|
219 | + $output = $loader->render($file, $data, $expires, $cache_mode); |
|
220 | 220 | } |
221 | - do_action( 'timber_compile_done' ); |
|
221 | + do_action('timber_compile_done'); |
|
222 | 222 | return $output; |
223 | 223 | } |
224 | 224 | |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | * @param array $data an array with data in it. |
230 | 230 | * @return bool|string |
231 | 231 | */ |
232 | - public static function compile_string( $string, $data = array() ) { |
|
232 | + public static function compile_string($string, $data = array()) { |
|
233 | 233 | $dummy_loader = new TimberLoader(); |
234 | 234 | $dummy_loader->get_twig(); |
235 | 235 | $loader = new Twig_Loader_String(); |
236 | - $twig = new Twig_Environment( $loader ); |
|
237 | - $twig = apply_filters( 'timber/twig/filters', $twig ); |
|
238 | - $twig = apply_filters( 'twig_apply_filters', $twig ); |
|
239 | - return $twig->render( $string, $data ); |
|
236 | + $twig = new Twig_Environment($loader); |
|
237 | + $twig = apply_filters('timber/twig/filters', $twig); |
|
238 | + $twig = apply_filters('twig_apply_filters', $twig); |
|
239 | + return $twig->render($string, $data); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -248,15 +248,15 @@ discard block |
||
248 | 248 | * @param string $cache_mode |
249 | 249 | * @return bool|string |
250 | 250 | */ |
251 | - public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
|
251 | + public static function fetch($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) { |
|
252 | 252 | if ( $expires === true ) { |
253 | 253 | //if this is reading as true; the user probably is using the old $echo param |
254 | 254 | //so we should move all vars up by a spot |
255 | 255 | $expires = $cache_mode; |
256 | 256 | $cache_mode = TimberLoader::CACHE_USE_DEFAULT; |
257 | 257 | } |
258 | - $output = self::compile( $filenames, $data, $expires, $cache_mode, true ); |
|
259 | - $output = apply_filters( 'timber_compile_result', $output ); |
|
258 | + $output = self::compile($filenames, $data, $expires, $cache_mode, true); |
|
259 | + $output = apply_filters('timber_compile_result', $output); |
|
260 | 260 | return $output; |
261 | 261 | } |
262 | 262 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $cache_mode |
270 | 270 | * @return bool|string |
271 | 271 | */ |
272 | - public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
|
273 | - $output = static::fetch( $filenames, $data, $expires, $cache_mode ); |
|
272 | + public static function render($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) { |
|
273 | + $output = static::fetch($filenames, $data, $expires, $cache_mode); |
|
274 | 274 | echo $output; |
275 | 275 | return $output; |
276 | 276 | } |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * @param array $data an array with data in it. |
283 | 283 | * @return bool|string |
284 | 284 | */ |
285 | - public static function render_string( $string, $data = array() ) { |
|
286 | - $compiled = self::compile_string( $string, $data ); |
|
285 | + public static function render_string($string, $data = array()) { |
|
286 | + $compiled = self::compile_string($string, $data); |
|
287 | 287 | echo $compiled; |
288 | 288 | return $compiled; |
289 | 289 | } |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | * @param array $data |
300 | 300 | * @return bool|string |
301 | 301 | */ |
302 | - public static function get_sidebar( $sidebar = '', $data = array() ) { |
|
302 | + public static function get_sidebar($sidebar = '', $data = array()) { |
|
303 | 303 | if ( $sidebar == '' ) { |
304 | 304 | $sidebar = 'sidebar.php'; |
305 | 305 | } |
306 | - if ( strstr( strtolower( $sidebar ), '.php' ) ) { |
|
307 | - return self::get_sidebar_from_php( $sidebar, $data ); |
|
306 | + if ( strstr(strtolower($sidebar), '.php') ) { |
|
307 | + return self::get_sidebar_from_php($sidebar, $data); |
|
308 | 308 | } |
309 | - return self::compile( $sidebar, $data ); |
|
309 | + return self::compile($sidebar, $data); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -316,21 +316,21 @@ discard block |
||
316 | 316 | * @param array $data |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function get_sidebar_from_php( $sidebar = '', $data ) { |
|
319 | + public static function get_sidebar_from_php($sidebar = '', $data) { |
|
320 | 320 | $caller = self::get_calling_script_dir(); |
321 | 321 | $loader = new TimberLoader(); |
322 | - $uris = $loader->get_locations( $caller ); |
|
322 | + $uris = $loader->get_locations($caller); |
|
323 | 323 | ob_start(); |
324 | 324 | $found = false; |
325 | - foreach ( $uris as $uri ) { |
|
326 | - if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) { |
|
327 | - include trailingslashit( $uri ) . $sidebar; |
|
325 | + foreach ($uris as $uri) { |
|
326 | + if ( file_exists(trailingslashit($uri) . $sidebar) ) { |
|
327 | + include trailingslashit($uri) . $sidebar; |
|
328 | 328 | $found = true; |
329 | 329 | break; |
330 | 330 | } |
331 | 331 | } |
332 | 332 | if ( !$found ) { |
333 | - TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' ); |
|
333 | + TimberHelper::error_log('error loading your sidebar, check to make sure the file exists'); |
|
334 | 334 | } |
335 | 335 | $ret = ob_get_contents(); |
336 | 336 | ob_end_clean(); |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | * @param int $widget_id |
347 | 347 | * @return TimberFunctionWrapper |
348 | 348 | */ |
349 | - public static function get_widgets( $widget_id ) { |
|
350 | - return TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true ); |
|
349 | + public static function get_widgets($widget_id) { |
|
350 | + return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | * @param array $args |
363 | 363 | * @deprecated since 0.20.0 |
364 | 364 | */ |
365 | - public static function add_route( $route, $callback, $args = array() ) { |
|
366 | - Routes::map( $route, $callback, $args ); |
|
365 | + public static function add_route($route, $callback, $args = array()) { |
|
366 | + Routes::map($route, $callback, $args); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @deprecated since 0.20.0 |
373 | 373 | */ |
374 | - public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) { |
|
375 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
374 | + public static function load_template($template, $query = false, $status_code = 200, $tparams = false) { |
|
375 | + return Routes::load($template, $tparams, $query, $status_code); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @deprecated since 0.20.2 |
382 | 382 | */ |
383 | - public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) { |
|
384 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
383 | + public static function load_view($template, $query = false, $status_code = 200, $tparams = false) { |
|
384 | + return Routes::load($template, $tparams, $query, $status_code); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -394,43 +394,43 @@ discard block |
||
394 | 394 | * @param array $prefs |
395 | 395 | * @return array mixed |
396 | 396 | */ |
397 | - public static function get_pagination( $prefs = array() ) { |
|
397 | + public static function get_pagination($prefs = array()) { |
|
398 | 398 | global $wp_query; |
399 | 399 | global $paged; |
400 | 400 | global $wp_rewrite; |
401 | 401 | $args = array(); |
402 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
402 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
403 | 403 | if ( $wp_rewrite->using_permalinks() ) { |
404 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
405 | - if ( isset( $url[1] ) ) { |
|
406 | - parse_str( $url[1], $query ); |
|
404 | + $url = explode('?', get_pagenum_link(0)); |
|
405 | + if ( isset($url[1]) ) { |
|
406 | + parse_str($url[1], $query); |
|
407 | 407 | $args['add_args'] = $query; |
408 | 408 | } |
409 | 409 | $args['format'] = 'page/%#%'; |
410 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
410 | + $args['base'] = trailingslashit($url[0]) . '%_%'; |
|
411 | 411 | } else { |
412 | 412 | $big = 999999999; |
413 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
413 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
414 | 414 | } |
415 | 415 | $args['type'] = 'array'; |
416 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
417 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
418 | - if ( is_int( $prefs ) ) { |
|
416 | + $args['current'] = max(1, get_query_var('paged')); |
|
417 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
418 | + if ( is_int($prefs) ) { |
|
419 | 419 | $args['mid_size'] = $prefs - 2; |
420 | 420 | } else { |
421 | - $args = array_merge( $args, $prefs ); |
|
421 | + $args = array_merge($args, $prefs); |
|
422 | 422 | } |
423 | 423 | $data = array(); |
424 | 424 | $data['current'] = $args['current']; |
425 | 425 | $data['total'] = $args['total']; |
426 | - $data['pages'] = TimberHelper::paginate_links( $args ); |
|
427 | - $next = get_next_posts_page_link( $args['total'] ); |
|
426 | + $data['pages'] = TimberHelper::paginate_links($args); |
|
427 | + $next = get_next_posts_page_link($args['total']); |
|
428 | 428 | if ( $next ) { |
429 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
429 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
430 | 430 | } |
431 | - $prev = previous_posts( false ); |
|
431 | + $prev = previous_posts(false); |
|
432 | 432 | if ( $prev ) { |
433 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
433 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
434 | 434 | } |
435 | 435 | if ( $paged < 2 ) { |
436 | 436 | $data['prev'] = ''; |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return string |
448 | 448 | */ |
449 | - public static function get_calling_script_dir( $offset = 0 ) { |
|
450 | - $caller = self::get_calling_script_file( $offset ); |
|
451 | - if ( !is_null( $caller ) ) { |
|
452 | - $pathinfo = pathinfo( $caller ); |
|
449 | + public static function get_calling_script_dir($offset = 0) { |
|
450 | + $caller = self::get_calling_script_file($offset); |
|
451 | + if ( !is_null($caller) ) { |
|
452 | + $pathinfo = pathinfo($caller); |
|
453 | 453 | $dir = $pathinfo['dirname']; |
454 | 454 | return $dir; |
455 | 455 | } |
@@ -462,11 +462,11 @@ discard block |
||
462 | 462 | * @return string|null |
463 | 463 | * @deprecated since 0.20.0 |
464 | 464 | */ |
465 | - public static function get_calling_script_file( $offset = 0 ) { |
|
465 | + public static function get_calling_script_file($offset = 0) { |
|
466 | 466 | $caller = null; |
467 | 467 | $backtrace = debug_backtrace(); |
468 | 468 | $i = 0; |
469 | - foreach ( $backtrace as $trace ) { |
|
469 | + foreach ($backtrace as $trace) { |
|
470 | 470 | if ( array_key_exists('file', $trace) && $trace['file'] != __FILE__ ) { |
471 | 471 | $caller = $trace['file']; |
472 | 472 | break; |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function __get( $field ) {} |
27 | 27 | |
28 | 28 | /** |
29 | - * @return boolean |
|
29 | + * @return boolean|null |
|
30 | 30 | */ |
31 | 31 | public function __isset( $field ) {} |
32 | 32 |
@@ -21,14 +21,14 @@ |
||
21 | 21 | $this->get = $_GET; |
22 | 22 | } |
23 | 23 | |
24 | - public function __call( $field, $args ) {} |
|
24 | + public function __call($field, $args) {} |
|
25 | 25 | |
26 | - public function __get( $field ) {} |
|
26 | + public function __get($field) {} |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @return boolean |
30 | 30 | */ |
31 | - public function __isset( $field ) {} |
|
31 | + public function __isset($field) {} |
|
32 | 32 | |
33 | - public function meta( $key ) {} |
|
33 | + public function meta($key) {} |
|
34 | 34 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | public function __toString() { |
11 | 11 | try { |
12 | - return (string)$this->call(); |
|
12 | + return (string) $this->call(); |
|
13 | 13 | } catch (Exception $e) { |
14 | 14 | return 'Caught exception: ' . $e->getMessage() . "\n"; |
15 | 15 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @param array $args |
23 | 23 | * @param bool $return_output_buffer |
24 | 24 | */ |
25 | - public function __construct( $function, $args = array(), $return_output_buffer = false ) { |
|
26 | - if( is_array( $function ) ) { |
|
27 | - if( (is_string( $function[0] ) && class_exists( $function[0] ) ) || gettype( $function[0] ) === 'object' ) { |
|
25 | + public function __construct($function, $args = array(), $return_output_buffer = false) { |
|
26 | + if ( is_array($function) ) { |
|
27 | + if ( (is_string($function[0]) && class_exists($function[0])) || gettype($function[0]) === 'object' ) { |
|
28 | 28 | $this->_class = $function[0]; |
29 | 29 | } |
30 | 30 | |
31 | - if( is_string( $function[1] ) ) $this->_function = $function[1]; |
|
31 | + if ( is_string($function[1]) ) $this->_function = $function[1]; |
|
32 | 32 | } else { |
33 | 33 | $this->_function = $function; |
34 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->_args = $args; |
37 | 37 | $this->_use_ob = $return_output_buffer; |
38 | 38 | |
39 | - add_filter( 'get_twig', array( &$this, 'add_to_twig' ) ); |
|
39 | + add_filter('get_twig', array(&$this, 'add_to_twig')); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @param Twig_Environment $twig |
46 | 46 | * @return Twig_Environment |
47 | 47 | */ |
48 | - public function add_to_twig( $twig ) { |
|
48 | + public function add_to_twig($twig) { |
|
49 | 49 | $wrapper = $this; |
50 | 50 | |
51 | - $twig->addFunction( new Twig_SimpleFunction( $this->_function, function () use ( $wrapper ) { |
|
52 | - return call_user_func_array( array( $wrapper, 'call' ), func_get_args() ); |
|
53 | - } ) ); |
|
51 | + $twig->addFunction(new Twig_SimpleFunction($this->_function, function() use ($wrapper) { |
|
52 | + return call_user_func_array(array($wrapper, 'call'), func_get_args()); |
|
53 | + } )); |
|
54 | 54 | |
55 | 55 | return $twig; |
56 | 56 | } |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | public function call() { |
64 | - $args = $this->_parse_args( func_get_args(), $this->_args ); |
|
65 | - $callable = ( isset( $this->_class ) ) ? array( $this->_class, $this->_function ) : $this->_function; |
|
64 | + $args = $this->_parse_args(func_get_args(), $this->_args); |
|
65 | + $callable = (isset($this->_class)) ? array($this->_class, $this->_function) : $this->_function; |
|
66 | 66 | |
67 | 67 | if ( $this->_use_ob ) { |
68 | - return TimberHelper::ob_function( $callable, $args ); |
|
68 | + return TimberHelper::ob_function($callable, $args); |
|
69 | 69 | } else { |
70 | - return call_user_func_array( $callable, $args ); |
|
70 | + return call_user_func_array($callable, $args); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | * @param array $defaults |
79 | 79 | * @return array |
80 | 80 | */ |
81 | - private function _parse_args( $args, $defaults ) { |
|
82 | - $_arg = reset( $defaults ); |
|
81 | + private function _parse_args($args, $defaults) { |
|
82 | + $_arg = reset($defaults); |
|
83 | 83 | |
84 | - foreach ( $args as $index => $arg ) { |
|
85 | - $defaults[$index] = is_null( $arg ) ? $_arg : $arg; |
|
86 | - $_arg = next( $defaults ); |
|
84 | + foreach ($args as $index => $arg) { |
|
85 | + $defaults[$index] = is_null($arg) ? $_arg : $arg; |
|
86 | + $_arg = next($defaults); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $defaults; |
@@ -28,7 +28,9 @@ |
||
28 | 28 | $this->_class = $function[0]; |
29 | 29 | } |
30 | 30 | |
31 | - if( is_string( $function[1] ) ) $this->_function = $function[1]; |
|
31 | + if( is_string( $function[1] ) ) { |
|
32 | + $this->_function = $function[1]; |
|
33 | + } |
|
32 | 34 | } else { |
33 | 35 | $this->_function = $function; |
34 | 36 | } |