@@ -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 | /** |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * @return array |
| 123 | 123 | * @deprecated since 0.20.0 |
| 124 | 124 | */ |
| 125 | - static function get_pids( $query = null ) { |
|
| 126 | - return TimberPostGetter::get_pids( $query ); |
|
| 125 | + static function get_pids($query = null) { |
|
| 126 | + return TimberPostGetter::get_pids($query); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | * @return array |
| 134 | 134 | * @deprecated since 0.20.0 |
| 135 | 135 | */ |
| 136 | - static function get_posts_from_loop( $PostClass ) { |
|
| 137 | - return TimberPostGetter::get_posts( $PostClass ); |
|
| 136 | + static function get_posts_from_loop($PostClass) { |
|
| 137 | + return TimberPostGetter::get_posts($PostClass); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * @return array |
| 146 | 146 | * @deprecated since 0.20.0 |
| 147 | 147 | */ |
| 148 | - static function get_posts_from_slug( $slug, $PostClass = 'TimberPost' ) { |
|
| 149 | - return TimberPostGetter::get_posts( $slug, $PostClass ); |
|
| 148 | + static function get_posts_from_slug($slug, $PostClass = 'TimberPost') { |
|
| 149 | + return TimberPostGetter::get_posts($slug, $PostClass); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * @return array |
| 158 | 158 | * @deprecated since 0.20.0 |
| 159 | 159 | */ |
| 160 | - static function get_posts_from_wp_query( $query = array(), $PostClass = 'TimberPost' ) { |
|
| 161 | - return TimberPostGetter::query_posts( $query, $PostClass ); |
|
| 160 | + static function get_posts_from_wp_query($query = array(), $PostClass = 'TimberPost') { |
|
| 161 | + return TimberPostGetter::query_posts($query, $PostClass); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | * @return array|null |
| 170 | 170 | * @deprecated since 0.20.0 |
| 171 | 171 | */ |
| 172 | - static function get_posts_from_array_of_ids( $query = array(), $PostClass = 'TimberPost' ) { |
|
| 173 | - return TimberPostGetter::get_posts( $query, $PostClass ); |
|
| 172 | + static function get_posts_from_array_of_ids($query = array(), $PostClass = 'TimberPost') { |
|
| 173 | + return TimberPostGetter::get_posts($query, $PostClass); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * @return int |
| 181 | 181 | * @deprecated since 0.20.0 |
| 182 | 182 | */ |
| 183 | - static function get_pid( $query ) { |
|
| 184 | - $pids = TimberPostGetter::get_pids( $query ); |
|
| 185 | - if ( is_array( $pids ) && count( $pids ) ) { |
|
| 183 | + static function get_pid($query) { |
|
| 184 | + $pids = TimberPostGetter::get_pids($query); |
|
| 185 | + if ( is_array($pids) && count($pids) ) { |
|
| 186 | 186 | return $pids[0]; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * @param string $TermClass |
| 209 | 209 | * @return mixed |
| 210 | 210 | */ |
| 211 | - public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) { |
|
| 212 | - return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass ); |
|
| 211 | + public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') { |
|
| 212 | + return TimberTermGetter::get_terms($args, $maybe_args, $TermClass); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /* Site Retrieval |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | * @param array|bool $blog_ids |
| 222 | 222 | * @return array |
| 223 | 223 | */ |
| 224 | - public static function get_sites( $blog_ids = false ) { |
|
| 225 | - if ( !is_array( $blog_ids ) ) { |
|
| 224 | + public static function get_sites($blog_ids = false) { |
|
| 225 | + if ( !is_array($blog_ids) ) { |
|
| 226 | 226 | global $wpdb; |
| 227 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC" ); |
|
| 227 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC"); |
|
| 228 | 228 | } |
| 229 | 229 | $return = array(); |
| 230 | - foreach ( $blog_ids as $blog_id ) { |
|
| 231 | - $return[] = new TimberSite( $blog_id ); |
|
| 230 | + foreach ($blog_ids as $blog_id) { |
|
| 231 | + $return[] = new TimberSite($blog_id); |
|
| 232 | 232 | } |
| 233 | 233 | return $return; |
| 234 | 234 | } |
@@ -246,29 +246,29 @@ discard block |
||
| 246 | 246 | $data = array(); |
| 247 | 247 | $data['http_host'] = 'http://' . TimberURLHelper::get_host(); |
| 248 | 248 | $data['wp_title'] = TimberHelper::get_wp_title(); |
| 249 | - $data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' ); |
|
| 250 | - $data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' ); |
|
| 251 | - $data['body_class'] = implode( ' ', get_body_class() ); |
|
| 249 | + $data['wp_head'] = TimberHelper::function_wrapper('wp_head'); |
|
| 250 | + $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer'); |
|
| 251 | + $data['body_class'] = implode(' ', get_body_class()); |
|
| 252 | 252 | |
| 253 | 253 | $data['site'] = new TimberSite(); |
| 254 | 254 | $data['theme'] = $data['site']->theme; |
| 255 | 255 | //deprecated, these should be fetched via TimberSite or TimberTheme |
| 256 | - $data['theme_dir'] = WP_CONTENT_SUBDIR.str_replace( WP_CONTENT_DIR, '', get_stylesheet_directory() ); |
|
| 257 | - $data['language_attributes'] = TimberHelper::function_wrapper( 'language_attributes' ); |
|
| 256 | + $data['theme_dir'] = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory()); |
|
| 257 | + $data['language_attributes'] = TimberHelper::function_wrapper('language_attributes'); |
|
| 258 | 258 | $data['stylesheet_uri'] = get_stylesheet_uri(); |
| 259 | 259 | $data['template_uri'] = get_template_directory_uri(); |
| 260 | 260 | |
| 261 | 261 | $data['posts'] = Timber::query_posts(); |
| 262 | 262 | |
| 263 | 263 | //deprecated, this should be fetched via TimberMenu |
| 264 | - if ( function_exists( 'wp_nav_menu' ) ) { |
|
| 264 | + if ( function_exists('wp_nav_menu') ) { |
|
| 265 | 265 | $locations = get_nav_menu_locations(); |
| 266 | - if ( count( $locations ) ) { |
|
| 267 | - $data['wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) ); |
|
| 266 | + if ( count($locations) ) { |
|
| 267 | + $data['wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu')); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - $data = apply_filters( 'timber_context', $data ); |
|
| 271 | - $data = apply_filters( 'timber/context', $data ); |
|
| 270 | + $data = apply_filters('timber_context', $data); |
|
| 271 | + $data = apply_filters('timber/context', $data); |
|
| 272 | 272 | return $data; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -282,27 +282,27 @@ discard block |
||
| 282 | 282 | * @param bool $via_render |
| 283 | 283 | * @return bool|string |
| 284 | 284 | */ |
| 285 | - public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) { |
|
| 285 | + public static function compile($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false) { |
|
| 286 | 286 | $caller = self::get_calling_script_dir(); |
| 287 | 287 | $caller_file = self::get_calling_script_file(); |
| 288 | - $caller_file = apply_filters( 'timber_calling_php_file', $caller_file ); |
|
| 289 | - $loader = new TimberLoader( $caller ); |
|
| 290 | - $file = $loader->choose_template( $filenames ); |
|
| 288 | + $caller_file = apply_filters('timber_calling_php_file', $caller_file); |
|
| 289 | + $loader = new TimberLoader($caller); |
|
| 290 | + $file = $loader->choose_template($filenames); |
|
| 291 | 291 | $output = ''; |
| 292 | - if ( is_null( $data ) ) { |
|
| 292 | + if ( is_null($data) ) { |
|
| 293 | 293 | $data = array(); |
| 294 | 294 | } |
| 295 | - if ( strlen( $file ) ) { |
|
| 295 | + if ( strlen($file) ) { |
|
| 296 | 296 | if ( $via_render ) { |
| 297 | - $file = apply_filters( 'timber_render_file', $file ); |
|
| 298 | - $data = apply_filters( 'timber_render_data', $data ); |
|
| 297 | + $file = apply_filters('timber_render_file', $file); |
|
| 298 | + $data = apply_filters('timber_render_data', $data); |
|
| 299 | 299 | } else { |
| 300 | - $file = apply_filters( 'timber_compile_file', $file ); |
|
| 301 | - $data = apply_filters( 'timber_compile_data', $data ); |
|
| 300 | + $file = apply_filters('timber_compile_file', $file); |
|
| 301 | + $data = apply_filters('timber_compile_data', $data); |
|
| 302 | 302 | } |
| 303 | - $output = $loader->render( $file, $data, $expires, $cache_mode ); |
|
| 303 | + $output = $loader->render($file, $data, $expires, $cache_mode); |
|
| 304 | 304 | } |
| 305 | - do_action( 'timber_compile_done' ); |
|
| 305 | + do_action('timber_compile_done'); |
|
| 306 | 306 | return $output; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -313,14 +313,14 @@ discard block |
||
| 313 | 313 | * @param array $data an array with data in it. |
| 314 | 314 | * @return bool|string |
| 315 | 315 | */ |
| 316 | - public static function compile_string( $string, $data = array() ) { |
|
| 316 | + public static function compile_string($string, $data = array()) { |
|
| 317 | 317 | $dummy_loader = new TimberLoader(); |
| 318 | 318 | $dummy_loader->get_twig(); |
| 319 | 319 | $loader = new Twig_Loader_String(); |
| 320 | - $twig = new Twig_Environment( $loader ); |
|
| 321 | - $twig = apply_filters( 'timber/twig/filters', $twig ); |
|
| 322 | - $twig = apply_filters( 'twig_apply_filters', $twig ); |
|
| 323 | - return $twig->render( $string, $data ); |
|
| 320 | + $twig = new Twig_Environment($loader); |
|
| 321 | + $twig = apply_filters('timber/twig/filters', $twig); |
|
| 322 | + $twig = apply_filters('twig_apply_filters', $twig); |
|
| 323 | + return $twig->render($string, $data); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -332,15 +332,15 @@ discard block |
||
| 332 | 332 | * @param string $cache_mode |
| 333 | 333 | * @return bool|string |
| 334 | 334 | */ |
| 335 | - public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
|
| 335 | + public static function fetch($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) { |
|
| 336 | 336 | if ( $expires === true ) { |
| 337 | 337 | //if this is reading as true; the user probably is using the old $echo param |
| 338 | 338 | //so we should move all vars up by a spot |
| 339 | 339 | $expires = $cache_mode; |
| 340 | 340 | $cache_mode = TimberLoader::CACHE_USE_DEFAULT; |
| 341 | 341 | } |
| 342 | - $output = self::compile( $filenames, $data, $expires, $cache_mode, true ); |
|
| 343 | - $output = apply_filters( 'timber_compile_result', $output ); |
|
| 342 | + $output = self::compile($filenames, $data, $expires, $cache_mode, true); |
|
| 343 | + $output = apply_filters('timber_compile_result', $output); |
|
| 344 | 344 | return $output; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | * @param string $cache_mode |
| 354 | 354 | * @return bool|string |
| 355 | 355 | */ |
| 356 | - public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
|
| 357 | - $output = static::fetch( $filenames, $data, $expires, $cache_mode ); |
|
| 356 | + public static function render($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) { |
|
| 357 | + $output = static::fetch($filenames, $data, $expires, $cache_mode); |
|
| 358 | 358 | echo $output; |
| 359 | 359 | return $output; |
| 360 | 360 | } |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | * @param array $data an array with data in it. |
| 367 | 367 | * @return bool|string |
| 368 | 368 | */ |
| 369 | - public static function render_string( $string, $data = array() ) { |
|
| 370 | - $compiled = self::compile_string( $string, $data ); |
|
| 369 | + public static function render_string($string, $data = array()) { |
|
| 370 | + $compiled = self::compile_string($string, $data); |
|
| 371 | 371 | echo $compiled; |
| 372 | 372 | return $compiled; |
| 373 | 373 | } |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | * @param array $data |
| 384 | 384 | * @return bool|string |
| 385 | 385 | */ |
| 386 | - public static function get_sidebar( $sidebar = '', $data = array() ) { |
|
| 386 | + public static function get_sidebar($sidebar = '', $data = array()) { |
|
| 387 | 387 | if ( $sidebar == '' ) { |
| 388 | 388 | $sidebar = 'sidebar.php'; |
| 389 | 389 | } |
| 390 | - if ( strstr( strtolower( $sidebar ), '.php' ) ) { |
|
| 391 | - return self::get_sidebar_from_php( $sidebar, $data ); |
|
| 390 | + if ( strstr(strtolower($sidebar), '.php') ) { |
|
| 391 | + return self::get_sidebar_from_php($sidebar, $data); |
|
| 392 | 392 | } |
| 393 | - return self::compile( $sidebar, $data ); |
|
| 393 | + return self::compile($sidebar, $data); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
@@ -400,21 +400,21 @@ discard block |
||
| 400 | 400 | * @param array $data |
| 401 | 401 | * @return string |
| 402 | 402 | */ |
| 403 | - public static function get_sidebar_from_php( $sidebar = '', $data ) { |
|
| 403 | + public static function get_sidebar_from_php($sidebar = '', $data) { |
|
| 404 | 404 | $caller = self::get_calling_script_dir(); |
| 405 | 405 | $loader = new TimberLoader(); |
| 406 | - $uris = $loader->get_locations( $caller ); |
|
| 406 | + $uris = $loader->get_locations($caller); |
|
| 407 | 407 | ob_start(); |
| 408 | 408 | $found = false; |
| 409 | - foreach ( $uris as $uri ) { |
|
| 410 | - if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) { |
|
| 411 | - include trailingslashit( $uri ) . $sidebar; |
|
| 409 | + foreach ($uris as $uri) { |
|
| 410 | + if ( file_exists(trailingslashit($uri) . $sidebar) ) { |
|
| 411 | + include trailingslashit($uri) . $sidebar; |
|
| 412 | 412 | $found = true; |
| 413 | 413 | break; |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | if ( !$found ) { |
| 417 | - TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' ); |
|
| 417 | + TimberHelper::error_log('error loading your sidebar, check to make sure the file exists'); |
|
| 418 | 418 | } |
| 419 | 419 | $ret = ob_get_contents(); |
| 420 | 420 | ob_end_clean(); |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | * @param int $widget_id |
| 431 | 431 | * @return TimberFunctionWrapper |
| 432 | 432 | */ |
| 433 | - public static function get_widgets( $widget_id ) { |
|
| 434 | - return TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true ); |
|
| 433 | + public static function get_widgets($widget_id) { |
|
| 434 | + return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
@@ -446,15 +446,15 @@ discard block |
||
| 446 | 446 | * @param array $args |
| 447 | 447 | * @deprecated since 0.20.0 |
| 448 | 448 | */ |
| 449 | - public static function add_route( $route, $callback, $args = array() ) { |
|
| 450 | - Routes::map( $route, $callback, $args ); |
|
| 449 | + public static function add_route($route, $callback, $args = array()) { |
|
| 450 | + Routes::map($route, $callback, $args); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * @deprecated since 0.22.2 |
| 455 | 455 | */ |
| 456 | 456 | public function cancel_query() { |
| 457 | - add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) ); |
|
| 457 | + add_action('posts_request', array($this, 'cancel_query_posts_request')); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -471,8 +471,8 @@ discard block |
||
| 471 | 471 | * |
| 472 | 472 | * @deprecated since 0.20.0 |
| 473 | 473 | */ |
| 474 | - public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) { |
|
| 475 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
| 474 | + public static function load_template($template, $query = false, $status_code = 200, $tparams = false) { |
|
| 475 | + return Routes::load($template, $tparams, $query, $status_code); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @deprecated since 0.20.2 |
| 482 | 482 | */ |
| 483 | - public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) { |
|
| 484 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
| 483 | + public static function load_view($template, $query = false, $status_code = 200, $tparams = false) { |
|
| 484 | + return Routes::load($template, $tparams, $query, $status_code); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | |
@@ -494,43 +494,43 @@ discard block |
||
| 494 | 494 | * @param array $prefs |
| 495 | 495 | * @return array mixed |
| 496 | 496 | */ |
| 497 | - public static function get_pagination( $prefs = array() ) { |
|
| 497 | + public static function get_pagination($prefs = array()) { |
|
| 498 | 498 | global $wp_query; |
| 499 | 499 | global $paged; |
| 500 | 500 | global $wp_rewrite; |
| 501 | 501 | $args = array(); |
| 502 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 502 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 503 | 503 | if ( $wp_rewrite->using_permalinks() ) { |
| 504 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 505 | - if ( isset( $url[1] ) ) { |
|
| 506 | - parse_str( $url[1], $query ); |
|
| 504 | + $url = explode('?', get_pagenum_link(0)); |
|
| 505 | + if ( isset($url[1]) ) { |
|
| 506 | + parse_str($url[1], $query); |
|
| 507 | 507 | $args['add_args'] = $query; |
| 508 | 508 | } |
| 509 | 509 | $args['format'] = 'page/%#%'; |
| 510 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 510 | + $args['base'] = trailingslashit($url[0]) . '%_%'; |
|
| 511 | 511 | } else { |
| 512 | 512 | $big = 999999999; |
| 513 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 513 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 514 | 514 | } |
| 515 | 515 | $args['type'] = 'array'; |
| 516 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 517 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 518 | - if ( is_int( $prefs ) ) { |
|
| 516 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 517 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 518 | + if ( is_int($prefs) ) { |
|
| 519 | 519 | $args['mid_size'] = $prefs - 2; |
| 520 | 520 | } else { |
| 521 | - $args = array_merge( $args, $prefs ); |
|
| 521 | + $args = array_merge($args, $prefs); |
|
| 522 | 522 | } |
| 523 | 523 | $data = array(); |
| 524 | 524 | $data['current'] = $args['current']; |
| 525 | 525 | $data['total'] = $args['total']; |
| 526 | - $data['pages'] = TimberHelper::paginate_links( $args ); |
|
| 527 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 526 | + $data['pages'] = TimberHelper::paginate_links($args); |
|
| 527 | + $next = get_next_posts_page_link($args['total']); |
|
| 528 | 528 | if ( $next ) { |
| 529 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 529 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 530 | 530 | } |
| 531 | - $prev = previous_posts( false ); |
|
| 531 | + $prev = previous_posts(false); |
|
| 532 | 532 | if ( $prev ) { |
| 533 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 533 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 534 | 534 | } |
| 535 | 535 | if ( $paged < 2 ) { |
| 536 | 536 | $data['prev'] = ''; |
@@ -548,9 +548,9 @@ discard block |
||
| 548 | 548 | * @return string |
| 549 | 549 | * @deprecated since 0.20.0 |
| 550 | 550 | */ |
| 551 | - public static function get_calling_script_path( $offset = 0 ) { |
|
| 552 | - $dir = self::get_calling_script_dir( $offset ); |
|
| 553 | - return str_replace( ABSPATH, '', realpath( $dir ) ); |
|
| 551 | + public static function get_calling_script_path($offset = 0) { |
|
| 552 | + $dir = self::get_calling_script_dir($offset); |
|
| 553 | + return str_replace(ABSPATH, '', realpath($dir)); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
@@ -558,10 +558,10 @@ discard block |
||
| 558 | 558 | * |
| 559 | 559 | * @return string |
| 560 | 560 | */ |
| 561 | - public static function get_calling_script_dir( $offset = 0 ) { |
|
| 562 | - $caller = self::get_calling_script_file( $offset ); |
|
| 563 | - if ( !is_null( $caller ) ) { |
|
| 564 | - $pathinfo = pathinfo( $caller ); |
|
| 561 | + public static function get_calling_script_dir($offset = 0) { |
|
| 562 | + $caller = self::get_calling_script_file($offset); |
|
| 563 | + if ( !is_null($caller) ) { |
|
| 564 | + $pathinfo = pathinfo($caller); |
|
| 565 | 565 | $dir = $pathinfo['dirname']; |
| 566 | 566 | return $dir; |
| 567 | 567 | } |
@@ -574,11 +574,11 @@ discard block |
||
| 574 | 574 | * @return string|null |
| 575 | 575 | * @deprecated since 0.20.0 |
| 576 | 576 | */ |
| 577 | - public static function get_calling_script_file( $offset = 0 ) { |
|
| 577 | + public static function get_calling_script_file($offset = 0) { |
|
| 578 | 578 | $caller = null; |
| 579 | 579 | $backtrace = debug_backtrace(); |
| 580 | 580 | $i = 0; |
| 581 | - foreach ( $backtrace as $trace ) { |
|
| 581 | + foreach ($backtrace as $trace) { |
|
| 582 | 582 | if ( array_key_exists('file', $trace) && $trace['file'] != __FILE__ ) { |
| 583 | 583 | $caller = $trace['file']; |
| 584 | 584 | break; |
@@ -598,8 +598,8 @@ discard block |
||
| 598 | 598 | * @return bool |
| 599 | 599 | * @deprecated since 0.20.0 |
| 600 | 600 | */ |
| 601 | - public static function is_post_class_or_class_map( $args ) { |
|
| 602 | - return TimberPostGetter::is_post_class_or_class_map( $args ); |
|
| 601 | + public static function is_post_class_or_class_map($args) { |
|
| 602 | + return TimberPostGetter::is_post_class_or_class_map($args); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | } |