@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * } |
| 55 | 55 | * @param string $base any additional paths that need to be prepended to the URLs that are generated, for example: "tags" |
| 56 | 56 | */ |
| 57 | - function __construct( $args = null, $base = '' ) { |
|
| 57 | + function __construct($args = null, $base = '') { |
|
| 58 | 58 | $this->init($args, $base); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param array|string $args |
| 64 | 64 | * @param string $base |
| 65 | 65 | */ |
| 66 | - function init( $args = null, $base = '' ) { |
|
| 66 | + function init($args = null, $base = '') { |
|
| 67 | 67 | $this->base = $base; |
| 68 | 68 | $this->items = $this->get_items($args); |
| 69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param string $text |
| 75 | 75 | * @return mixed |
| 76 | 76 | */ |
| 77 | - protected function get_archives_link( $url, $text ) { |
|
| 77 | + protected function get_archives_link($url, $text) { |
|
| 78 | 78 | $ret = array(); |
| 79 | 79 | $ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text); |
| 80 | 80 | $ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base)); |
@@ -91,18 +91,18 @@ discard block |
||
| 91 | 91 | * @param string $limit |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - protected function get_items_yearly( $args, $last_changed, $join, $where, $order, $limit ) { |
|
| 94 | + protected function get_items_yearly($args, $last_changed, $join, $where, $order, $limit) { |
|
| 95 | 95 | global $wpdb; |
| 96 | 96 | $output = array(); |
| 97 | 97 | $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; |
| 98 | 98 | $key = md5($query); |
| 99 | 99 | $key = "wp_get_archives:$key:$last_changed"; |
| 100 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 100 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 101 | 101 | $results = $wpdb->get_results($query); |
| 102 | 102 | wp_cache_set($key, $results, 'posts'); |
| 103 | 103 | } |
| 104 | - if ($results) { |
|
| 105 | - foreach ((array)$results as $result) { |
|
| 104 | + if ( $results ) { |
|
| 105 | + foreach ((array) $results as $result) { |
|
| 106 | 106 | $url = get_year_link($result->year); |
| 107 | 107 | $text = sprintf('%d', $result->year); |
| 108 | 108 | $output[] = $this->get_archives_link($url, $text); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param bool $nested |
| 123 | 123 | * @return array |
| 124 | 124 | */ |
| 125 | - protected function get_items_monthly( $args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true ) { |
|
| 125 | + protected function get_items_monthly($args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true) { |
|
| 126 | 126 | global $wpdb, $wp_locale; |
| 127 | 127 | $output = array(); |
| 128 | 128 | $defaults = array( |
@@ -137,26 +137,26 @@ discard block |
||
| 137 | 137 | . "ORDER BY post_date $order $limit"; |
| 138 | 138 | $key = md5($query); |
| 139 | 139 | $key = "wp_get_archives:$key:$last_changed"; |
| 140 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 140 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 141 | 141 | $results = $wpdb->get_results($query); |
| 142 | 142 | wp_cache_set($key, $results, 'posts'); |
| 143 | 143 | } |
| 144 | - if ($results) { |
|
| 145 | - foreach ((array)$results as $result) { |
|
| 144 | + if ( $results ) { |
|
| 145 | + foreach ((array) $results as $result) { |
|
| 146 | 146 | $url = get_month_link($result->year, $result->month); |
| 147 | - if ($show_year && !$nested) { |
|
| 147 | + if ( $show_year && !$nested ) { |
|
| 148 | 148 | $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year); |
| 149 | 149 | } else { |
| 150 | 150 | $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month)); |
| 151 | 151 | } |
| 152 | - if ($nested) { |
|
| 152 | + if ( $nested ) { |
|
| 153 | 153 | $output[$result->year][] = $this->get_archives_link($url, $text); |
| 154 | 154 | } else { |
| 155 | 155 | $output[] = $this->get_archives_link($url, $text); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - if ($nested) { |
|
| 159 | + if ( $nested ) { |
|
| 160 | 160 | $out2 = array(); |
| 161 | 161 | foreach ($output as $year => $months) { |
| 162 | 162 | $out2[] = array('name' => $year, 'children' => $months); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param array|string $args |
| 172 | 172 | * @return array|string |
| 173 | 173 | */ |
| 174 | - function get_items( $args = null ) { |
|
| 174 | + function get_items($args = null) { |
|
| 175 | 175 | global $wpdb; |
| 176 | 176 | |
| 177 | 177 | $defaults = array( |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $archive_week_start_date_format = 'Y/m/d'; |
| 221 | 221 | $archive_week_end_date_format = 'Y/m/d'; |
| 222 | 222 | |
| 223 | - if (!$archive_date_format_over_ride) { |
|
| 223 | + if ( !$archive_date_format_over_ride ) { |
|
| 224 | 224 | $archive_day_date_format = get_option('date_format'); |
| 225 | 225 | $archive_week_start_date_format = get_option('date_format'); |
| 226 | 226 | $archive_week_end_date_format = get_option('date_format'); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $output = array(); |
| 234 | 234 | $last_changed = wp_cache_get('last_changed', 'posts'); |
| 235 | - if (!$last_changed) { |
|
| 235 | + if ( !$last_changed ) { |
|
| 236 | 236 | $last_changed = microtime(); |
| 237 | 237 | wp_cache_set('last_changed', $last_changed, 'posts'); |
| 238 | 238 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit); |
| 243 | 243 | } elseif ( 'monthly-nested' == $type ) { |
| 244 | 244 | $years = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit); |
| 245 | - foreach ( $years as &$year ) { |
|
| 245 | + foreach ($years as &$year) { |
|
| 246 | 246 | $args = array('show_year' => false); |
| 247 | 247 | $year['children'] = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit); |
| 248 | 248 | } |
@@ -251,14 +251,14 @@ discard block |
||
| 251 | 251 | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; |
| 252 | 252 | $key = md5($query); |
| 253 | 253 | $key = "wp_get_archives:$key:$last_changed"; |
| 254 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 254 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 255 | 255 | $results = $wpdb->get_results($query); |
| 256 | 256 | $cache = array(); |
| 257 | 257 | $cache[$key] = $results; |
| 258 | 258 | wp_cache_set($key, $results, 'posts'); |
| 259 | 259 | } |
| 260 | 260 | if ( $results ) { |
| 261 | - foreach ( (array)$results as $result ) { |
|
| 261 | + foreach ((array) $results as $result) { |
|
| 262 | 262 | $url = get_day_link($result->year, $result->month, $result->dayofmonth); |
| 263 | 263 | $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth); |
| 264 | 264 | $text = mysql2date($archive_day_date_format, $date); |
@@ -271,13 +271,13 @@ discard block |
||
| 271 | 271 | . "count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; |
| 272 | 272 | $key = md5($query); |
| 273 | 273 | $key = "wp_get_archives:$key:$last_changed"; |
| 274 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 274 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 275 | 275 | $results = $wpdb->get_results($query); |
| 276 | 276 | wp_cache_set($key, $results, 'posts'); |
| 277 | 277 | } |
| 278 | 278 | $arc_w_last = ''; |
| 279 | 279 | if ( $results ) { |
| 280 | - foreach ( (array)$results as $result ) { |
|
| 280 | + foreach ((array) $results as $result) { |
|
| 281 | 281 | if ( $result->week != $arc_w_last ) { |
| 282 | 282 | $arc_year = $result->yr; |
| 283 | 283 | $arc_w_last = $result->week; |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | wp_cache_set($key, $results, 'posts'); |
| 301 | 301 | } |
| 302 | 302 | if ( $results ) { |
| 303 | - foreach ( (array)$results as $result ) { |
|
| 304 | - if ($result->post_date != '0000-00-00 00:00:00') { |
|
| 303 | + foreach ((array) $results as $result) { |
|
| 304 | + if ( $result->post_date != '0000-00-00 00:00:00' ) { |
|
| 305 | 305 | $url = get_permalink($result); |
| 306 | - if ($result->post_title) { |
|
| 306 | + if ( $result->post_title ) { |
|
| 307 | 307 | /** This filter is documented in wp-includes/post-template.php */ |
| 308 | 308 | $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID)); |
| 309 | 309 | } else { |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | interface TimberCoreInterface { |
| 4 | 4 | |
| 5 | - public function __call( $field, $args ); |
|
| 5 | + public function __call($field, $args); |
|
| 6 | 6 | |
| 7 | - public function __get( $field ); |
|
| 7 | + public function __get($field); |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @return boolean |
| 11 | 11 | */ |
| 12 | - public function __isset( $field ); |
|
| 12 | + public function __isset($field); |
|
| 13 | 13 | |
| 14 | - public function meta( $key ); |
|
| 14 | + public function meta($key); |
|
| 15 | 15 | |
| 16 | 16 | } |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @return boolean |
| 13 | 13 | */ |
| 14 | - function __isset( $field ) { |
|
| 15 | - if ( isset( $this->$field ) ) { |
|
| 14 | + function __isset($field) { |
|
| 15 | + if ( isset($this->$field) ) { |
|
| 16 | 16 | return $this->$field; |
| 17 | 17 | } |
| 18 | 18 | return false; |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2 |
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | - function __call( $field, $args ) { |
|
| 26 | - return $this->__get( $field ); |
|
| 25 | + function __call($field, $args) { |
|
| 26 | + return $this->__get($field); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return mixed |
| 33 | 33 | */ |
| 34 | - function __get( $field ) { |
|
| 34 | + function __get($field) { |
|
| 35 | 35 | if ( property_exists($this, $field) ) { |
| 36 | 36 | return $this->$field; |
| 37 | 37 | } |
| 38 | - if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) { |
|
| 38 | + if ( method_exists($this, 'meta') && $meta_value = $this->meta($field) ) { |
|
| 39 | 39 | return $this->$field = $meta_value; |
| 40 | 40 | } |
| 41 | 41 | if ( method_exists($this, $field) ) { |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | * ``` |
| 56 | 56 | * @param array|object $info an object or array you want to grab data from to attach to the Timber object |
| 57 | 57 | */ |
| 58 | - function import( $info, $force = false ) { |
|
| 59 | - if ( is_object( $info ) ) { |
|
| 60 | - $info = get_object_vars( $info ); |
|
| 58 | + function import($info, $force = false) { |
|
| 59 | + if ( is_object($info) ) { |
|
| 60 | + $info = get_object_vars($info); |
|
| 61 | 61 | } |
| 62 | - if ( is_array( $info ) ) { |
|
| 63 | - foreach ( $info as $key => $value ) { |
|
| 64 | - if ( !empty( $key ) && $force ) { |
|
| 62 | + if ( is_array($info) ) { |
|
| 63 | + foreach ($info as $key => $value) { |
|
| 64 | + if ( !empty($key) && $force ) { |
|
| 65 | 65 | $this->$key = $value; |
| 66 | - } else if ( !empty( $key ) && !method_exists($this, $key) ){ |
|
| 66 | + } else if ( !empty($key) && !method_exists($this, $key) ) { |
|
| 67 | 67 | $this->$key = $value; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * @param string $key |
| 77 | 77 | * @param mixed $value |
| 78 | 78 | */ |
| 79 | - function update( $key, $value ) { |
|
| 80 | - update_metadata( $this->object_type, $this->ID, $key, $value ); |
|
| 79 | + function update($key, $value) { |
|
| 80 | + update_metadata($this->object_type, $this->ID, $key, $value); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * @return bool |
| 95 | 95 | */ |
| 96 | 96 | function can_edit() { |
| 97 | - if ( !function_exists( 'current_user_can' ) ) { |
|
| 97 | + if ( !function_exists('current_user_can') ) { |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
| 100 | + if ( current_user_can('edit_post', $this->ID) ) { |
|
| 101 | 101 | return true; |
| 102 | 102 | } |
| 103 | 103 | return false; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | private $_use_ob; |
| 8 | 8 | |
| 9 | 9 | public function __toString() { |
| 10 | - return (string)$this->call(); |
|
| 10 | + return (string) $this->call(); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | * @param array $args |
| 18 | 18 | * @param bool $return_output_buffer |
| 19 | 19 | */ |
| 20 | - public function __construct( $function, $args = array(), $return_output_buffer = false ) { |
|
| 20 | + public function __construct($function, $args = array(), $return_output_buffer = false) { |
|
| 21 | 21 | $this->_function = $function; |
| 22 | 22 | $this->_args = $args; |
| 23 | 23 | $this->_use_ob = $return_output_buffer; |
| 24 | 24 | |
| 25 | - add_filter( 'get_twig', array( &$this, 'add_to_twig' ) ); |
|
| 25 | + add_filter('get_twig', array(&$this, 'add_to_twig')); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | * @param Twig_Environment $twig |
| 32 | 32 | * @return Twig_Environment |
| 33 | 33 | */ |
| 34 | - public function add_to_twig( $twig ) { |
|
| 34 | + public function add_to_twig($twig) { |
|
| 35 | 35 | $wrapper = $this; |
| 36 | 36 | |
| 37 | - $twig->addFunction( new Twig_SimpleFunction( $this->_function, function () use ( $wrapper ) { |
|
| 38 | - return call_user_func_array( array( $wrapper, 'call' ), func_get_args() ); |
|
| 39 | - } ) ); |
|
| 37 | + $twig->addFunction(new Twig_SimpleFunction($this->_function, function() use ($wrapper) { |
|
| 38 | + return call_user_func_array(array($wrapper, 'call'), func_get_args()); |
|
| 39 | + } )); |
|
| 40 | 40 | |
| 41 | 41 | return $twig; |
| 42 | 42 | } |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | 49 | public function call() { |
| 50 | - $args = $this->_parse_args( func_get_args(), $this->_args ); |
|
| 50 | + $args = $this->_parse_args(func_get_args(), $this->_args); |
|
| 51 | 51 | |
| 52 | 52 | if ( $this->_use_ob ) { |
| 53 | - return TimberHelper::ob_function( $this->_function, $args ); |
|
| 53 | + return TimberHelper::ob_function($this->_function, $args); |
|
| 54 | 54 | } else { |
| 55 | - return call_user_func_array( $this->_function, $args ); |
|
| 55 | + return call_user_func_array($this->_function, $args); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | * @param array $defaults |
| 64 | 64 | * @return array |
| 65 | 65 | */ |
| 66 | - private function _parse_args( $args, $defaults ) { |
|
| 67 | - $_arg = reset( $defaults ); |
|
| 66 | + private function _parse_args($args, $defaults) { |
|
| 67 | + $_arg = reset($defaults); |
|
| 68 | 68 | |
| 69 | - foreach ( $args as $index => $arg ) { |
|
| 70 | - $defaults[$index] = is_null( $arg ) ? $_arg : $arg; |
|
| 71 | - $_arg = next( $defaults ); |
|
| 69 | + foreach ($args as $index => $arg) { |
|
| 70 | + $defaults[$index] = is_null($arg) ? $_arg : $arg; |
|
| 71 | + $_arg = next($defaults); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $defaults; |
@@ -25,17 +25,17 @@ discard block |
||
| 25 | 25 | * @param bool $force (optional) Force callback to be executed when transient is locked |
| 26 | 26 | * @return mixed |
| 27 | 27 | */ |
| 28 | - public static function transient( $slug, $callback, $transient_time = 0, $lock_timeout = 5, $force = false ) { |
|
| 28 | + public static function transient($slug, $callback, $transient_time = 0, $lock_timeout = 5, $force = false) { |
|
| 29 | 29 | |
| 30 | - $enable_transients = ( $transient_time === false || ( defined( 'WP_DISABLE_TRANSIENTS' ) && WP_DISABLE_TRANSIENTS ) ) ? false : true; |
|
| 31 | - $data = $enable_transients ? get_transient( $slug ) : false; |
|
| 30 | + $enable_transients = ($transient_time === false || (defined('WP_DISABLE_TRANSIENTS') && WP_DISABLE_TRANSIENTS)) ? false : true; |
|
| 31 | + $data = $enable_transients ? get_transient($slug) : false; |
|
| 32 | 32 | |
| 33 | 33 | if ( false === $data ) { |
| 34 | 34 | |
| 35 | - if ( $enable_transients && self::_is_transient_locked( $slug ) ) { |
|
| 35 | + if ( $enable_transients && self::_is_transient_locked($slug) ) { |
|
| 36 | 36 | |
| 37 | - $force = apply_filters( 'timber_force_transients', $force ); |
|
| 38 | - $force = apply_filters( 'timber_force_transient_' . $slug, $force ); |
|
| 37 | + $force = apply_filters('timber_force_transients', $force); |
|
| 38 | + $force = apply_filters('timber_force_transient_' . $slug, $force); |
|
| 39 | 39 | |
| 40 | 40 | if ( !$force ) { |
| 41 | 41 | //the server is currently executing the process. |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | // lock timeout shouldn't be higher than 5 seconds, unless |
| 50 | 50 | // remote calls with high timeouts are made here |
| 51 | 51 | if ( $enable_transients ) |
| 52 | - self::_lock_transient( $slug, $lock_timeout ); |
|
| 52 | + self::_lock_transient($slug, $lock_timeout); |
|
| 53 | 53 | |
| 54 | 54 | $data = $callback(); |
| 55 | 55 | |
| 56 | 56 | if ( $enable_transients ) { |
| 57 | - set_transient( $slug, $data, $transient_time ); |
|
| 58 | - self::_unlock_transient( $slug ); |
|
| 57 | + set_transient($slug, $data, $transient_time); |
|
| 58 | + self::_unlock_transient($slug); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | } |
@@ -69,24 +69,24 @@ discard block |
||
| 69 | 69 | * @param string $slug |
| 70 | 70 | * @param integer $lock_timeout |
| 71 | 71 | */ |
| 72 | - static function _lock_transient( $slug, $lock_timeout ) { |
|
| 73 | - set_transient( $slug . '_lock', true, $lock_timeout ); |
|
| 72 | + static function _lock_transient($slug, $lock_timeout) { |
|
| 73 | + set_transient($slug . '_lock', true, $lock_timeout); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @internal |
| 78 | 78 | * @param string $slug |
| 79 | 79 | */ |
| 80 | - static function _unlock_transient( $slug ) { |
|
| 81 | - delete_transient( $slug . '_lock', true ); |
|
| 80 | + static function _unlock_transient($slug) { |
|
| 81 | + delete_transient($slug . '_lock', true); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * @internal |
| 86 | 86 | * @param string $slug |
| 87 | 87 | */ |
| 88 | - static function _is_transient_locked( $slug ) { |
|
| 89 | - return (bool)get_transient( $slug . '_lock' ); |
|
| 88 | + static function _is_transient_locked($slug) { |
|
| 89 | + return (bool) get_transient($slug . '_lock'); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /* These are for measuring page render time */ |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public static function start_timer() { |
| 100 | 100 | $time = microtime(); |
| 101 | - $time = explode( ' ', $time ); |
|
| 101 | + $time = explode(' ', $time); |
|
| 102 | 102 | $time = $time[1] + $time[0]; |
| 103 | 103 | return $time; |
| 104 | 104 | } |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | * @param int $start |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | - public static function stop_timer( $start ) { |
|
| 117 | + public static function stop_timer($start) { |
|
| 118 | 118 | $time = microtime(); |
| 119 | - $time = explode( ' ', $time ); |
|
| 119 | + $time = explode(' ', $time); |
|
| 120 | 120 | $time = $time[1] + $time[0]; |
| 121 | 121 | $finish = $time; |
| 122 | - $total_time = round( ( $finish - $start ), 4 ); |
|
| 122 | + $total_time = round(($finish - $start), 4); |
|
| 123 | 123 | return $total_time . ' seconds.'; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @param array $args |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - public static function ob_function( $function, $args = array( null ) ) { |
|
| 155 | + public static function ob_function($function, $args = array(null)) { |
|
| 156 | 156 | ob_start(); |
| 157 | - call_user_func_array( $function, $args ); |
|
| 157 | + call_user_func_array($function, $args); |
|
| 158 | 158 | $data = ob_get_contents(); |
| 159 | 159 | ob_end_clean(); |
| 160 | 160 | return $data; |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | * @param bool $return_output_buffer |
| 169 | 169 | * @return TimberFunctionWrapper |
| 170 | 170 | */ |
| 171 | - public static function function_wrapper( $function_name, $defaults = array(), $return_output_buffer = false ) { |
|
| 172 | - return new TimberFunctionWrapper( $function_name, $defaults, $return_output_buffer ); |
|
| 171 | + public static function function_wrapper($function_name, $defaults = array(), $return_output_buffer = false) { |
|
| 172 | + return new TimberFunctionWrapper($function_name, $defaults, $return_output_buffer); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | * @param mixed $arg that you want to error_log |
| 179 | 179 | * @return void |
| 180 | 180 | */ |
| 181 | - public static function error_log( $arg ) { |
|
| 181 | + public static function error_log($arg) { |
|
| 182 | 182 | if ( !WP_DEBUG ) { |
| 183 | 183 | return; |
| 184 | 184 | } |
| 185 | - if ( is_object( $arg ) || is_array( $arg ) ) { |
|
| 186 | - $arg = print_r( $arg, true ); |
|
| 185 | + if ( is_object($arg) || is_array($arg) ) { |
|
| 186 | + $arg = print_r($arg, true); |
|
| 187 | 187 | } |
| 188 | - return error_log( $arg ); |
|
| 188 | + return error_log($arg); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | * @param string $seplocation |
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | - public static function get_wp_title( $separator = ' ', $seplocation = 'left' ) { |
|
| 199 | - $separator = apply_filters( 'timber_wp_title_seperator', $separator ); |
|
| 200 | - return trim( wp_title( $separator, false, $seplocation ) ); |
|
| 198 | + public static function get_wp_title($separator = ' ', $seplocation = 'left') { |
|
| 199 | + $separator = apply_filters('timber_wp_title_seperator', $separator); |
|
| 200 | + return trim(wp_title($separator, false, $seplocation)); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /* Text Utilities |
@@ -212,36 +212,36 @@ discard block |
||
| 212 | 212 | * @param string $allowed_tags |
| 213 | 213 | * @return string |
| 214 | 214 | */ |
| 215 | - public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { |
|
| 215 | + public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { |
|
| 216 | 216 | if ( null === $more ) { |
| 217 | - $more = __( '…' ); |
|
| 217 | + $more = __('…'); |
|
| 218 | 218 | } |
| 219 | 219 | $original_text = $text; |
| 220 | 220 | $allowed_tag_string = ''; |
| 221 | - foreach ( explode( ' ', apply_filters( 'timber/trim_words/allowed_tags', $allowed_tags ) ) as $tag ) { |
|
| 221 | + foreach (explode(' ', apply_filters('timber/trim_words/allowed_tags', $allowed_tags)) as $tag) { |
|
| 222 | 222 | $allowed_tag_string .= '<' . $tag . '>'; |
| 223 | 223 | } |
| 224 | - $text = strip_tags( $text, $allowed_tag_string ); |
|
| 224 | + $text = strip_tags($text, $allowed_tag_string); |
|
| 225 | 225 | /* translators: If your word count is based on single characters (East Asian characters), |
| 226 | 226 | enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ |
| 227 | - if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
| 228 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
| 229 | - preg_match_all( '/./u', $text, $words_array ); |
|
| 230 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
| 227 | + if ( 'characters' == _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset')) ) { |
|
| 228 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
| 229 | + preg_match_all('/./u', $text, $words_array); |
|
| 230 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
| 231 | 231 | $sep = ''; |
| 232 | 232 | } else { |
| 233 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
| 233 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
| 234 | 234 | $sep = ' '; |
| 235 | 235 | } |
| 236 | - if ( count( $words_array ) > $num_words ) { |
|
| 237 | - array_pop( $words_array ); |
|
| 238 | - $text = implode( $sep, $words_array ); |
|
| 236 | + if ( count($words_array) > $num_words ) { |
|
| 237 | + array_pop($words_array); |
|
| 238 | + $text = implode($sep, $words_array); |
|
| 239 | 239 | $text = $text . $more; |
| 240 | 240 | } else { |
| 241 | - $text = implode( $sep, $words_array ); |
|
| 241 | + $text = implode($sep, $words_array); |
|
| 242 | 242 | } |
| 243 | - $text = self::close_tags( $text ); |
|
| 244 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
| 243 | + $text = self::close_tags($text); |
|
| 244 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -250,29 +250,29 @@ discard block |
||
| 250 | 250 | * @param string $html |
| 251 | 251 | * @return string |
| 252 | 252 | */ |
| 253 | - public static function close_tags( $html ) { |
|
| 253 | + public static function close_tags($html) { |
|
| 254 | 254 | //put all opened tags into an array |
| 255 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
| 255 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
| 256 | 256 | $openedtags = $result[1]; |
| 257 | 257 | //put all closed tags into an array |
| 258 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
| 258 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
| 259 | 259 | $closedtags = $result[1]; |
| 260 | - $len_opened = count( $openedtags ); |
|
| 260 | + $len_opened = count($openedtags); |
|
| 261 | 261 | // all tags are closed |
| 262 | - if ( count( $closedtags ) == $len_opened ) { |
|
| 262 | + if ( count($closedtags) == $len_opened ) { |
|
| 263 | 263 | return $html; |
| 264 | 264 | } |
| 265 | - $openedtags = array_reverse( $openedtags ); |
|
| 265 | + $openedtags = array_reverse($openedtags); |
|
| 266 | 266 | // close tags |
| 267 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
| 268 | - if ( !in_array( $openedtags[$i], $closedtags ) ) { |
|
| 267 | + for ($i = 0; $i < $len_opened; $i++) { |
|
| 268 | + if ( !in_array($openedtags[$i], $closedtags) ) { |
|
| 269 | 269 | $html .= '</' . $openedtags[$i] . '>'; |
| 270 | 270 | } else { |
| 271 | - unset( $closedtags[array_search( $openedtags[$i], $closedtags )] ); |
|
| 271 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | - $html = str_replace(array('</br>','</hr>','</wbr>'), '', $html); |
|
| 275 | - $html = str_replace(array('<br>','<hr>','<wbr>'), array('<br />','<hr />','<wbr />'), $html); |
|
| 274 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
| 275 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
| 276 | 276 | return $html; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -285,17 +285,17 @@ discard block |
||
| 285 | 285 | * @return array|int |
| 286 | 286 | * @deprecated 0.20.0 |
| 287 | 287 | */ |
| 288 | - public static function get_posts_by_meta( $key, $value ) { |
|
| 288 | + public static function get_posts_by_meta($key, $value) { |
|
| 289 | 289 | global $wpdb; |
| 290 | - $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value ); |
|
| 291 | - $results = $wpdb->get_col( $query ); |
|
| 290 | + $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value); |
|
| 291 | + $results = $wpdb->get_col($query); |
|
| 292 | 292 | $pids = array(); |
| 293 | - foreach ( $results as $result ) { |
|
| 294 | - if ( get_post( $result ) ) { |
|
| 293 | + foreach ($results as $result) { |
|
| 294 | + if ( get_post($result) ) { |
|
| 295 | 295 | $pids[] = $result; |
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | - if ( count( $pids ) ) { |
|
| 298 | + if ( count($pids) ) { |
|
| 299 | 299 | return $pids; |
| 300 | 300 | } |
| 301 | 301 | return 0; |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | * @return int |
| 310 | 310 | * @deprecated 0.20.0 |
| 311 | 311 | */ |
| 312 | - public static function get_post_by_meta( $key, $value ) { |
|
| 312 | + public static function get_post_by_meta($key, $value) { |
|
| 313 | 313 | global $wpdb; |
| 314 | - $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value ); |
|
| 315 | - $results = $wpdb->get_col( $query ); |
|
| 316 | - foreach ( $results as $result ) { |
|
| 317 | - if ( $result && get_post( $result ) ) { |
|
| 314 | + $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value); |
|
| 315 | + $results = $wpdb->get_col($query); |
|
| 316 | + foreach ($results as $result) { |
|
| 317 | + if ( $result && get_post($result) ) { |
|
| 318 | 318 | return $result; |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -327,10 +327,10 @@ discard block |
||
| 327 | 327 | * @param int $ttid |
| 328 | 328 | * @return mixed |
| 329 | 329 | */ |
| 330 | - public static function get_term_id_by_term_taxonomy_id( $ttid ) { |
|
| 330 | + public static function get_term_id_by_term_taxonomy_id($ttid) { |
|
| 331 | 331 | global $wpdb; |
| 332 | - $query = $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid ); |
|
| 333 | - return $wpdb->get_var( $query ); |
|
| 332 | + $query = $wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid); |
|
| 333 | + return $wpdb->get_var($query); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /* Object Utilities |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | * @param string $prop |
| 344 | 344 | * @return void |
| 345 | 345 | */ |
| 346 | - public static function osort( &$array, $prop ) { |
|
| 347 | - usort( $array, function ( $a, $b ) use ( $prop ) { |
|
| 346 | + public static function osort(&$array, $prop) { |
|
| 347 | + usort($array, function($a, $b) use ($prop) { |
|
| 348 | 348 | return $a->$prop > $b->$prop ? 1 : -1; |
| 349 | 349 | } ); |
| 350 | 350 | } |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | * @param array $arr |
| 356 | 356 | * @return bool |
| 357 | 357 | */ |
| 358 | - public static function is_array_assoc( $arr ) { |
|
| 359 | - if ( !is_array( $arr ) ) { |
|
| 358 | + public static function is_array_assoc($arr) { |
|
| 359 | + if ( !is_array($arr) ) { |
|
| 360 | 360 | return false; |
| 361 | 361 | } |
| 362 | - return (bool)count( array_filter( array_keys( $arr ), 'is_string' ) ); |
|
| 362 | + return (bool) count(array_filter(array_keys($arr), 'is_string')); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -368,11 +368,11 @@ discard block |
||
| 368 | 368 | * @param array $array |
| 369 | 369 | * @return stdClass |
| 370 | 370 | */ |
| 371 | - public static function array_to_object( $array ) { |
|
| 371 | + public static function array_to_object($array) { |
|
| 372 | 372 | $obj = new stdClass; |
| 373 | - foreach ( $array as $k => $v ) { |
|
| 374 | - if ( is_array( $v ) ) { |
|
| 375 | - $obj->{$k} = self::array_to_object( $v ); //RECURSION |
|
| 373 | + foreach ($array as $k => $v) { |
|
| 374 | + if ( is_array($v) ) { |
|
| 375 | + $obj->{$k} = self::array_to_object($v); //RECURSION |
|
| 376 | 376 | } else { |
| 377 | 377 | $obj->{$k} = $v; |
| 378 | 378 | } |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | * @param mixed $value |
| 389 | 389 | * @return bool|int |
| 390 | 390 | */ |
| 391 | - public static function get_object_index_by_property( $array, $key, $value ) { |
|
| 392 | - if ( is_array( $array ) ) { |
|
| 391 | + public static function get_object_index_by_property($array, $key, $value) { |
|
| 392 | + if ( is_array($array) ) { |
|
| 393 | 393 | $i = 0; |
| 394 | - foreach ( $array as $arr ) { |
|
| 395 | - if ( is_array( $arr ) ) { |
|
| 394 | + foreach ($array as $arr) { |
|
| 395 | + if ( is_array($arr) ) { |
|
| 396 | 396 | if ( $arr[$key] == $value ) { |
| 397 | 397 | return $i; |
| 398 | 398 | } |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | * @return array|null |
| 417 | 417 | * @throws Exception |
| 418 | 418 | */ |
| 419 | - public static function get_object_by_property( $array, $key, $value ) { |
|
| 420 | - if ( is_array( $array ) ) { |
|
| 421 | - foreach ( $array as $arr ) { |
|
| 419 | + public static function get_object_by_property($array, $key, $value) { |
|
| 420 | + if ( is_array($array) ) { |
|
| 421 | + foreach ($array as $arr) { |
|
| 422 | 422 | if ( $arr->$key == $value ) { |
| 423 | 423 | return $arr; |
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | } else { |
| 427 | - throw new Exception( '$array is not an array, given value: ' . $array ); |
|
| 427 | + throw new Exception('$array is not an array, given value: ' . $array); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
@@ -435,9 +435,9 @@ discard block |
||
| 435 | 435 | * @param int $len |
| 436 | 436 | * @return array |
| 437 | 437 | */ |
| 438 | - public static function array_truncate( $array, $len ) { |
|
| 439 | - if ( sizeof( $array ) > $len ) { |
|
| 440 | - $array = array_splice( $array, 0, $len ); |
|
| 438 | + public static function array_truncate($array, $len) { |
|
| 439 | + if ( sizeof($array) > $len ) { |
|
| 440 | + $array = array_splice($array, 0, $len); |
|
| 441 | 441 | } |
| 442 | 442 | return $array; |
| 443 | 443 | } |
@@ -451,12 +451,12 @@ discard block |
||
| 451 | 451 | * @param mixed $value |
| 452 | 452 | * @return bool |
| 453 | 453 | */ |
| 454 | - public static function is_true( $value ) { |
|
| 455 | - if ( isset( $value ) ) { |
|
| 456 | - if (is_string($value)) { |
|
| 454 | + public static function is_true($value) { |
|
| 455 | + if ( isset($value) ) { |
|
| 456 | + if ( is_string($value) ) { |
|
| 457 | 457 | $value = strtolower($value); |
| 458 | 458 | } |
| 459 | - if ( ($value == 'true' || $value === 1 || $value === '1' || $value == true) && $value !== false && $value !== 'false') { |
|
| 459 | + if ( ($value == 'true' || $value === 1 || $value === '1' || $value == true) && $value !== false && $value !== 'false' ) { |
|
| 460 | 460 | return true; |
| 461 | 461 | } |
| 462 | 462 | } |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | * @param int $i |
| 470 | 470 | * @return bool |
| 471 | 471 | */ |
| 472 | - public static function iseven( $i ) { |
|
| 473 | - return ( $i % 2 ) == 0; |
|
| 472 | + public static function iseven($i) { |
|
| 473 | + return ($i % 2) == 0; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | * @param int $i |
| 480 | 480 | * @return bool |
| 481 | 481 | */ |
| 482 | - public static function isodd( $i ) { |
|
| 483 | - return ( $i % 2 ) != 0; |
|
| 482 | + public static function isodd($i) { |
|
| 483 | + return ($i % 2) != 0; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /* Links, Forms, Etc. Utilities |
@@ -494,8 +494,8 @@ discard block |
||
| 494 | 494 | * @param array $args this $args thing is a fucking mess, [fix at some point](http://codex.wordpress.org/Function_Reference/comment_form) |
| 495 | 495 | * @return string |
| 496 | 496 | */ |
| 497 | - public static function get_comment_form( $post_id = null, $args = array() ) { |
|
| 498 | - return self::ob_function( 'comment_form', array( $args, $post_id ) ); |
|
| 497 | + public static function get_comment_form($post_id = null, $args = array()) { |
|
| 498 | + return self::ob_function('comment_form', array($args, $post_id)); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | /** |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | * @param string $args |
| 505 | 505 | * @return array |
| 506 | 506 | */ |
| 507 | - public static function paginate_links( $args = '' ) { |
|
| 507 | + public static function paginate_links($args = '') { |
|
| 508 | 508 | $defaults = array( |
| 509 | 509 | 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) |
| 510 | 510 | 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number |
@@ -512,42 +512,42 @@ discard block |
||
| 512 | 512 | 'current' => 0, |
| 513 | 513 | 'show_all' => false, |
| 514 | 514 | 'prev_next' => true, |
| 515 | - 'prev_text' => __( '« Previous' ), |
|
| 516 | - 'next_text' => __( 'Next »' ), |
|
| 515 | + 'prev_text' => __('« Previous'), |
|
| 516 | + 'next_text' => __('Next »'), |
|
| 517 | 517 | 'end_size' => 1, |
| 518 | 518 | 'mid_size' => 2, |
| 519 | 519 | 'type' => 'array', |
| 520 | 520 | 'add_args' => false, // array of query args to add |
| 521 | 521 | 'add_fragment' => '' |
| 522 | 522 | ); |
| 523 | - $args = wp_parse_args( $args, $defaults ); |
|
| 523 | + $args = wp_parse_args($args, $defaults); |
|
| 524 | 524 | // Who knows what else people pass in $args |
| 525 | - $args['total'] = intval( (int)$args['total'] ); |
|
| 525 | + $args['total'] = intval((int) $args['total']); |
|
| 526 | 526 | if ( $args['total'] < 2 ) { |
| 527 | 527 | return array(); |
| 528 | 528 | } |
| 529 | - $args['current'] = (int)$args['current']; |
|
| 530 | - $args['end_size'] = 0 < (int)$args['end_size'] ? (int)$args['end_size'] : 1; // Out of bounds? Make it the default. |
|
| 531 | - $args['mid_size'] = 0 <= (int)$args['mid_size'] ? (int)$args['mid_size'] : 2; |
|
| 532 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; |
|
| 529 | + $args['current'] = (int) $args['current']; |
|
| 530 | + $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. |
|
| 531 | + $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; |
|
| 532 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; |
|
| 533 | 533 | $page_links = array(); |
| 534 | 534 | $dots = false; |
| 535 | 535 | if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) { |
| 536 | - $link = str_replace( '%_%', 2 == $args['current'] ? '' : $args['format'], $args['base'] ); |
|
| 537 | - $link = str_replace( '%#%', $args['current'] - 1, $link ); |
|
| 536 | + $link = str_replace('%_%', 2 == $args['current'] ? '' : $args['format'], $args['base']); |
|
| 537 | + $link = str_replace('%#%', $args['current'] - 1, $link); |
|
| 538 | 538 | if ( $args['add_args'] ) { |
| 539 | - $link = add_query_arg( $args['add_args'], $link ); |
|
| 539 | + $link = add_query_arg($args['add_args'], $link); |
|
| 540 | 540 | } |
| 541 | 541 | $link .= $args['add_fragment']; |
| 542 | - $link = untrailingslashit( $link ); |
|
| 542 | + $link = untrailingslashit($link); |
|
| 543 | 543 | $page_links[] = array( |
| 544 | 544 | 'class' => 'prev page-numbers', |
| 545 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 545 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 546 | 546 | 'title' => $args['prev_text'] |
| 547 | 547 | ); |
| 548 | 548 | } |
| 549 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
| 550 | - $n_display = number_format_i18n( $n ); |
|
| 549 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
| 550 | + $n_display = number_format_i18n($n); |
|
| 551 | 551 | if ( $n == $args['current'] ) { |
| 552 | 552 | $page_links[] = array( |
| 553 | 553 | 'class' => 'page-number page-numbers current', |
@@ -558,18 +558,18 @@ discard block |
||
| 558 | 558 | ); |
| 559 | 559 | $dots = true; |
| 560 | 560 | } else { |
| 561 | - if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) { |
|
| 562 | - $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); |
|
| 563 | - $link = str_replace( '%#%', $n, $link ); |
|
| 564 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
| 561 | + if ( $args['show_all'] || ($n <= $args['end_size'] || ($args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size']) || $n > $args['total'] - $args['end_size']) ) { |
|
| 562 | + $link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']); |
|
| 563 | + $link = str_replace('%#%', $n, $link); |
|
| 564 | + $link = trailingslashit($link) . ltrim($args['add_fragment'], '/'); |
|
| 565 | 565 | if ( $args['add_args'] ) { |
| 566 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
| 566 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
| 567 | 567 | } |
| 568 | 568 | $link = str_replace(' ', '+', $link); |
| 569 | - $link = untrailingslashit( $link ); |
|
| 569 | + $link = untrailingslashit($link); |
|
| 570 | 570 | $page_links[] = array( |
| 571 | 571 | 'class' => 'page-number page-numbers', |
| 572 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 572 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 573 | 573 | 'title' => $n_display, |
| 574 | 574 | 'name' => $n_display, |
| 575 | 575 | 'current' => $args['current'] == $n |
@@ -578,22 +578,22 @@ discard block |
||
| 578 | 578 | } elseif ( $dots && !$args['show_all'] ) { |
| 579 | 579 | $page_links[] = array( |
| 580 | 580 | 'class' => 'dots', |
| 581 | - 'title' => __( '…' ) |
|
| 581 | + 'title' => __('…') |
|
| 582 | 582 | ); |
| 583 | 583 | $dots = false; |
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | - if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 == $args['total'] ) ) { |
|
| 588 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
| 589 | - $link = str_replace( '%#%', $args['current'] + 1, $link ); |
|
| 587 | + if ( $args['prev_next'] && $args['current'] && ($args['current'] < $args['total'] || -1 == $args['total']) ) { |
|
| 588 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
| 589 | + $link = str_replace('%#%', $args['current'] + 1, $link); |
|
| 590 | 590 | if ( $args['add_args'] ) { |
| 591 | - $link = add_query_arg( $args['add_args'], $link ); |
|
| 591 | + $link = add_query_arg($args['add_args'], $link); |
|
| 592 | 592 | } |
| 593 | - $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] ); |
|
| 593 | + $link = untrailingslashit(trailingslashit($link) . $args['add_fragment']); |
|
| 594 | 594 | $page_links[] = array( |
| 595 | 595 | 'class' => 'next page-numbers', |
| 596 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 596 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 597 | 597 | 'title' => $args['next_text'] |
| 598 | 598 | ); |
| 599 | 599 | } |
@@ -610,8 +610,8 @@ discard block |
||
| 610 | 610 | /** |
| 611 | 611 | * @deprecated 0.18.0 |
| 612 | 612 | */ |
| 613 | - static function is_url( $url ) { |
|
| 614 | - return TimberURLHelper::is_url( $url ); |
|
| 613 | + static function is_url($url) { |
|
| 614 | + return TimberURLHelper::is_url($url); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | /** |
@@ -624,71 +624,71 @@ discard block |
||
| 624 | 624 | /** |
| 625 | 625 | * @deprecated 0.18.0 |
| 626 | 626 | */ |
| 627 | - static function get_rel_url( $url, $force = false ) { |
|
| 628 | - return TimberURLHelper::get_rel_url( $url, $force ); |
|
| 627 | + static function get_rel_url($url, $force = false) { |
|
| 628 | + return TimberURLHelper::get_rel_url($url, $force); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
| 632 | 632 | * @deprecated 0.18.0 |
| 633 | 633 | */ |
| 634 | - static function is_local( $url ) { |
|
| 635 | - return TimberURLHelper::is_local( $url ); |
|
| 634 | + static function is_local($url) { |
|
| 635 | + return TimberURLHelper::is_local($url); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * @deprecated 0.18.0 |
| 640 | 640 | */ |
| 641 | - static function get_full_path( $src ) { |
|
| 642 | - return TimberURLHelper::get_full_path( $src ); |
|
| 641 | + static function get_full_path($src) { |
|
| 642 | + return TimberURLHelper::get_full_path($src); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
| 646 | 646 | * @deprecated 0.18.0 |
| 647 | 647 | */ |
| 648 | - static function get_rel_path( $src ) { |
|
| 649 | - return TimberURLHelper::get_rel_path( $src ); |
|
| 648 | + static function get_rel_path($src) { |
|
| 649 | + return TimberURLHelper::get_rel_path($src); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | 653 | * @deprecated 0.18.0 |
| 654 | 654 | */ |
| 655 | - static function remove_double_slashes( $url ) { |
|
| 656 | - return TimberURLHelper::remove_double_slashes( $url ); |
|
| 655 | + static function remove_double_slashes($url) { |
|
| 656 | + return TimberURLHelper::remove_double_slashes($url); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
| 660 | 660 | * @deprecated 0.18.0 |
| 661 | 661 | */ |
| 662 | - static function prepend_to_url( $url, $path ) { |
|
| 663 | - return TimberURLHelper::prepend_to_url( $url, $path ); |
|
| 662 | + static function prepend_to_url($url, $path) { |
|
| 663 | + return TimberURLHelper::prepend_to_url($url, $path); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /** |
| 667 | 667 | * @deprecated 0.18.0 |
| 668 | 668 | */ |
| 669 | - static function preslashit( $path ) { |
|
| 670 | - return TimberURLHelper::preslashit( $path ); |
|
| 669 | + static function preslashit($path) { |
|
| 670 | + return TimberURLHelper::preslashit($path); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | /** |
| 674 | 674 | * @deprecated 0.18.0 |
| 675 | 675 | */ |
| 676 | - static function is_external( $url ) { |
|
| 677 | - return TimberURLHelper::is_external( $url ); |
|
| 676 | + static function is_external($url) { |
|
| 677 | + return TimberURLHelper::is_external($url); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
| 681 | 681 | * @deprecated 0.18.0 |
| 682 | 682 | */ |
| 683 | - static function download_url( $url, $timeout = 300 ) { |
|
| 684 | - return TimberURLHelper::download_url( $url, $timeout ); |
|
| 683 | + static function download_url($url, $timeout = 300) { |
|
| 684 | + return TimberURLHelper::download_url($url, $timeout); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
| 688 | 688 | * @deprecated 0.18.0 |
| 689 | 689 | */ |
| 690 | - static function get_params( $i = -1 ) { |
|
| 691 | - return TimberURLHelper::get_params( $i ); |
|
| 690 | + static function get_params($i = -1) { |
|
| 691 | + return TimberURLHelper::get_params($i); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @return string the src of the file |
| 88 | 88 | */ |
| 89 | 89 | public function __toString() { |
| 90 | - if ($this->get_src()) { |
|
| 90 | + if ( $this->get_src() ) { |
|
| 91 | 91 | return $this->get_src(); |
| 92 | 92 | } |
| 93 | 93 | return ''; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @return array|int |
| 108 | 108 | */ |
| 109 | 109 | protected function get_dimensions($dim = null) { |
| 110 | - if (isset($this->_dimensions)) { |
|
| 110 | + if ( isset($this->_dimensions) ) { |
|
| 111 | 111 | return $this->get_dimensions_loaded($dim); |
| 112 | 112 | } |
| 113 | 113 | if ( file_exists($this->file_loc) && filesize($this->file_loc) ) { |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | * @return array|int |
| 126 | 126 | */ |
| 127 | 127 | protected function get_dimensions_loaded($dim) { |
| 128 | - if ($dim === null) { |
|
| 128 | + if ( $dim === null ) { |
|
| 129 | 129 | return $this->_dimensions; |
| 130 | 130 | } |
| 131 | - if ($dim == 'w' || $dim == 'width') { |
|
| 131 | + if ( $dim == 'w' || $dim == 'width' ) { |
|
| 132 | 132 | return $this->_dimensions[0]; |
| 133 | 133 | } |
| 134 | - if ($dim == 'h' || $dim == 'height') { |
|
| 134 | + if ( $dim == 'h' || $dim == 'height' ) { |
|
| 135 | 135 | return $this->_dimensions[1]; |
| 136 | 136 | } |
| 137 | 137 | return null; |
@@ -141,27 +141,27 @@ discard block |
||
| 141 | 141 | * @internal |
| 142 | 142 | * @param int $iid the id number of the image in the WP database |
| 143 | 143 | */ |
| 144 | - protected function get_image_info( $iid ) { |
|
| 144 | + protected function get_image_info($iid) { |
|
| 145 | 145 | $image_info = $iid; |
| 146 | - if (is_numeric($iid)) { |
|
| 146 | + if ( is_numeric($iid) ) { |
|
| 147 | 147 | $image_info = wp_get_attachment_metadata($iid); |
| 148 | - if (!is_array($image_info)) { |
|
| 148 | + if ( !is_array($image_info) ) { |
|
| 149 | 149 | $image_info = array(); |
| 150 | 150 | } |
| 151 | 151 | $image_custom = get_post_custom($iid); |
| 152 | 152 | $basic = get_post($iid); |
| 153 | - if ($basic) { |
|
| 154 | - if (isset($basic->post_excerpt)) { |
|
| 153 | + if ( $basic ) { |
|
| 154 | + if ( isset($basic->post_excerpt) ) { |
|
| 155 | 155 | $this->caption = $basic->post_excerpt; |
| 156 | 156 | } |
| 157 | 157 | $image_custom = array_merge($image_custom, get_object_vars($basic)); |
| 158 | 158 | } |
| 159 | 159 | return array_merge($image_info, $image_custom); |
| 160 | 160 | } |
| 161 | - if (is_array($image_info) && isset($image_info['image'])) { |
|
| 161 | + if ( is_array($image_info) && isset($image_info['image']) ) { |
|
| 162 | 162 | return $image_info['image']; |
| 163 | 163 | } |
| 164 | - if (is_object($image_info)) { |
|
| 164 | + if ( is_object($image_info) ) { |
|
| 165 | 165 | return get_object_vars($image_info); |
| 166 | 166 | } |
| 167 | 167 | return $iid; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return string with http/https corrected depending on what's appropriate for server |
| 174 | 174 | */ |
| 175 | 175 | protected static function _maybe_secure_url($url) { |
| 176 | - if (is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0) { |
|
| 176 | + if ( is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0 ) { |
|
| 177 | 177 | $url = 'https' . substr($url, strlen('http')); |
| 178 | 178 | } |
| 179 | 179 | return $url; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | public static function wp_upload_dir() { |
| 183 | 183 | static $wp_upload_dir = false; |
| 184 | 184 | |
| 185 | - if (!$wp_upload_dir) { |
|
| 185 | + if ( !$wp_upload_dir ) { |
|
| 186 | 186 | $wp_upload_dir = wp_upload_dir(); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | * @internal |
| 194 | 194 | * @param int $iid |
| 195 | 195 | */ |
| 196 | - function init( $iid = false ) { |
|
| 197 | - if ( !is_numeric( $iid ) && is_string( $iid ) ) { |
|
| 198 | - if (strstr($iid, '://')) { |
|
| 196 | + function init($iid = false) { |
|
| 197 | + if ( !is_numeric($iid) && is_string($iid) ) { |
|
| 198 | + if ( strstr($iid, '://') ) { |
|
| 199 | 199 | $this->init_with_url($iid); |
| 200 | 200 | return; |
| 201 | 201 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $this->init_with_file_path($iid); |
| 204 | 204 | return; |
| 205 | 205 | } |
| 206 | - if (strstr(strtolower($iid), '.jpg')) { |
|
| 206 | + if ( strstr(strtolower($iid), '.jpg') ) { |
|
| 207 | 207 | $this->init_with_relative_path($iid); |
| 208 | 208 | return; |
| 209 | 209 | } |
@@ -214,24 +214,24 @@ discard block |
||
| 214 | 214 | $this->import($image_info); |
| 215 | 215 | $basedir = self::wp_upload_dir(); |
| 216 | 216 | $basedir = $basedir['basedir']; |
| 217 | - if (isset($this->file)) { |
|
| 217 | + if ( isset($this->file) ) { |
|
| 218 | 218 | $this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file; |
| 219 | - } else if (isset($this->_wp_attached_file)) { |
|
| 219 | + } else if ( isset($this->_wp_attached_file) ) { |
|
| 220 | 220 | $this->file = reset($this->_wp_attached_file); |
| 221 | 221 | $this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file; |
| 222 | 222 | } |
| 223 | - if (isset($image_info['id'])) { |
|
| 223 | + if ( isset($image_info['id']) ) { |
|
| 224 | 224 | $this->ID = $image_info['id']; |
| 225 | - } else if (is_numeric($iid)) { |
|
| 225 | + } else if ( is_numeric($iid) ) { |
|
| 226 | 226 | $this->ID = $iid; |
| 227 | 227 | } |
| 228 | - if (isset($this->ID)) { |
|
| 228 | + if ( isset($this->ID) ) { |
|
| 229 | 229 | $custom = get_post_custom($this->ID); |
| 230 | 230 | foreach ($custom as $key => $value) { |
| 231 | 231 | $this->$key = $value[0]; |
| 232 | 232 | } |
| 233 | 233 | } else { |
| 234 | - if (is_array($iid) || is_object($iid)) { |
|
| 234 | + if ( is_array($iid) || is_object($iid) ) { |
|
| 235 | 235 | TimberHelper::error_log('Not able to init in TimberImage with iid='); |
| 236 | 236 | TimberHelper::error_log($iid); |
| 237 | 237 | } else { |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | * @internal |
| 245 | 245 | * @param string $relative_path |
| 246 | 246 | */ |
| 247 | - protected function init_with_relative_path( $relative_path ) { |
|
| 248 | - $this->abs_url = home_url( $relative_path ); |
|
| 249 | - $file_path = TimberURLHelper::get_full_path( $relative_path ); |
|
| 247 | + protected function init_with_relative_path($relative_path) { |
|
| 248 | + $this->abs_url = home_url($relative_path); |
|
| 249 | + $file_path = TimberURLHelper::get_full_path($relative_path); |
|
| 250 | 250 | $this->file_loc = $file_path; |
| 251 | 251 | $this->file = $file_path; |
| 252 | 252 | } |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | * @internal |
| 256 | 256 | * @param string $file_path |
| 257 | 257 | */ |
| 258 | - protected function init_with_file_path( $file_path ) { |
|
| 259 | - $url = TimberURLHelper::file_system_to_url( $file_path ); |
|
| 258 | + protected function init_with_file_path($file_path) { |
|
| 259 | + $url = TimberURLHelper::file_system_to_url($file_path); |
|
| 260 | 260 | $this->abs_url = $url; |
| 261 | 261 | $this->file_loc = $file_path; |
| 262 | 262 | $this->file = $file_path; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | protected function init_with_url($url) { |
| 270 | 270 | $this->abs_url = $url; |
| 271 | - if (TimberURLHelper::is_local($url)) { |
|
| 271 | + if ( TimberURLHelper::is_local($url) ) { |
|
| 272 | 272 | $this->file = ABSPATH . TimberURLHelper::get_rel_url($url); |
| 273 | 273 | $this->file_loc = ABSPATH . TimberURLHelper::get_rel_url($url); |
| 274 | 274 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * ``` |
| 337 | 337 | */ |
| 338 | 338 | public function link() { |
| 339 | - if (strlen($this->abs_url)) { |
|
| 339 | + if ( strlen($this->abs_url) ) { |
|
| 340 | 340 | return $this->abs_url; |
| 341 | 341 | } |
| 342 | 342 | return get_permalink($this->ID); |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @return bool|TimberPost |
| 348 | 348 | */ |
| 349 | 349 | public function parent() { |
| 350 | - if (!$this->post_parent) { |
|
| 350 | + if ( !$this->post_parent ) { |
|
| 351 | 351 | return false; |
| 352 | 352 | } |
| 353 | 353 | return new $this->PostClass($this->post_parent); |
@@ -455,8 +455,8 @@ discard block |
||
| 455 | 455 | * @param string $size |
| 456 | 456 | * @return bool|string |
| 457 | 457 | */ |
| 458 | - function get_src( $size = '' ) { |
|
| 459 | - return $this->src( $size ); |
|
| 458 | + function get_src($size = '') { |
|
| 459 | + return $this->src($size); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -7,16 +7,16 @@ |
||
| 7 | 7 | class TimberIntegrations { |
| 8 | 8 | public static function init() { |
| 9 | 9 | |
| 10 | - add_action( 'init', array( __CLASS__, 'maybe_init_acftimber' ) ); |
|
| 10 | + add_action('init', array(__CLASS__, 'maybe_init_acftimber')); |
|
| 11 | 11 | |
| 12 | - if ( class_exists( 'WP_CLI_Command' ) ) { |
|
| 13 | - WP_CLI::add_command( 'timber', 'Timber_WP_CLI_Command' ); |
|
| 12 | + if ( class_exists('WP_CLI_Command') ) { |
|
| 13 | + WP_CLI::add_command('timber', 'Timber_WP_CLI_Command'); |
|
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public static function maybe_init_acftimber() { |
| 18 | 18 | |
| 19 | - if ( class_exists( 'ACF' ) ) { |
|
| 19 | + if ( class_exists('ACF') ) { |
|
| 20 | 20 | new ACFTimber(); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function render($file, $data = null, $expires = false, $cache_mode = self::CACHE_USE_DEFAULT) { |
| 43 | 43 | // Different $expires if user is anonymous or logged in |
| 44 | - if (is_array($expires)) { |
|
| 45 | - if (is_user_logged_in() && isset($expires[1])) { |
|
| 44 | + if ( is_array($expires) ) { |
|
| 45 | + if ( is_user_logged_in() && isset($expires[1]) ) { |
|
| 46 | 46 | $expires = $expires[1]; |
| 47 | 47 | } else { |
| 48 | 48 | $expires = $expires[0]; |
@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $key = null; |
| 53 | 53 | $output = false; |
| 54 | - if (false !== $expires) { |
|
| 54 | + if ( false !== $expires ) { |
|
| 55 | 55 | ksort($data); |
| 56 | 56 | $key = md5($file . json_encode($data)); |
| 57 | 57 | $output = $this->get_cache($key, self::CACHEGROUP, $cache_mode); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if (false === $output || null === $output) { |
|
| 60 | + if ( false === $output || null === $output ) { |
|
| 61 | 61 | $twig = $this->get_twig(); |
| 62 | - if (strlen($file)) { |
|
| 62 | + if ( strlen($file) ) { |
|
| 63 | 63 | $loader = $this->get_loader(); |
| 64 | 64 | $result = $loader->getCacheKey($file); |
| 65 | 65 | do_action('timber_loader_render_file', $result); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $output = $twig->render($file, $data); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if (false !== $output && false !== $expires && null !== $key) { |
|
| 72 | + if ( false !== $output && false !== $expires && null !== $key ) { |
|
| 73 | 73 | $this->set_cache($key, $output, self::CACHEGROUP, $expires, $cache_mode); |
| 74 | 74 | } |
| 75 | 75 | $output = apply_filters('timber_output', $output); |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | * @return bool |
| 82 | 82 | */ |
| 83 | 83 | function choose_template($filenames) { |
| 84 | - if (is_array($filenames)) { |
|
| 84 | + if ( is_array($filenames) ) { |
|
| 85 | 85 | /* its an array so we have to figure out which one the dev wants */ |
| 86 | 86 | foreach ($filenames as $filename) { |
| 87 | - if ($this->template_exists($filename)) { |
|
| 87 | + if ( $this->template_exists($filename) ) { |
|
| 88 | 88 | return $filename; |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | function template_exists($file) { |
| 101 | 101 | foreach ($this->locations as $dir) { |
| 102 | 102 | $look_for = trailingslashit($dir) . $file; |
| 103 | - if (file_exists($look_for)) { |
|
| 103 | + if ( file_exists($look_for) ) { |
|
| 104 | 104 | return true; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $theme_locs = array(); |
| 115 | 115 | $child_loc = get_stylesheet_directory(); |
| 116 | 116 | $parent_loc = get_template_directory(); |
| 117 | - if (DIRECTORY_SEPARATOR == '\\') { |
|
| 117 | + if ( DIRECTORY_SEPARATOR == '\\' ) { |
|
| 118 | 118 | $child_loc = str_replace('/', '\\', $child_loc); |
| 119 | 119 | $parent_loc = str_replace('/', '\\', $parent_loc); |
| 120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | foreach ($this->get_locations_theme_dir() as $dirname) { |
| 123 | 123 | $theme_locs[] = trailingslashit($child_loc) . trailingslashit($dirname); |
| 124 | 124 | } |
| 125 | - if ($child_loc != $parent_loc) { |
|
| 125 | + if ( $child_loc != $parent_loc ) { |
|
| 126 | 126 | $theme_locs[] = $parent_loc; |
| 127 | 127 | foreach ($this->get_locations_theme_dir() as $dirname) { |
| 128 | 128 | $theme_locs[] = trailingslashit($parent_loc) . trailingslashit($dirname); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return string[] the names of directores, ie: array('templats', 'views'); |
| 139 | 139 | */ |
| 140 | 140 | private function get_locations_theme_dir() { |
| 141 | - if (is_string(Timber::$dirname)) { |
|
| 141 | + if ( is_string(Timber::$dirname) ) { |
|
| 142 | 142 | return array(Timber::$dirname); |
| 143 | 143 | } |
| 144 | 144 | return Timber::$dirname; |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | function get_locations_user() { |
| 151 | 151 | $locs = array(); |
| 152 | - if (isset(Timber::$locations)) { |
|
| 153 | - if (is_string(Timber::$locations)) { |
|
| 152 | + if ( isset(Timber::$locations) ) { |
|
| 153 | + if ( is_string(Timber::$locations) ) { |
|
| 154 | 154 | Timber::$locations = array(Timber::$locations); |
| 155 | 155 | } |
| 156 | 156 | foreach (Timber::$locations as $tloc) { |
| 157 | 157 | $tloc = realpath($tloc); |
| 158 | - if (is_dir($tloc)) { |
|
| 158 | + if ( is_dir($tloc) ) { |
|
| 159 | 159 | $locs[] = $tloc; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -169,14 +169,14 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | function get_locations_caller($caller = false) { |
| 171 | 171 | $locs = array(); |
| 172 | - if ($caller && is_string($caller)) { |
|
| 172 | + if ( $caller && is_string($caller) ) { |
|
| 173 | 173 | $caller = trailingslashit($caller); |
| 174 | - if (is_dir($caller)) { |
|
| 174 | + if ( is_dir($caller) ) { |
|
| 175 | 175 | $locs[] = $caller; |
| 176 | 176 | } |
| 177 | 177 | foreach ($this->get_locations_theme_dir() as $dirname) { |
| 178 | 178 | $caller_sub = $caller . trailingslashit($dirname); |
| 179 | - if (is_dir($caller_sub)) { |
|
| 179 | + if ( is_dir($caller_sub) ) { |
|
| 180 | 180 | $locs[] = $caller_sub; |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | $paths = array(); |
| 211 | 211 | foreach ($this->locations as $loc) { |
| 212 | 212 | $loc = realpath($loc); |
| 213 | - if (is_dir($loc)) { |
|
| 213 | + if ( is_dir($loc) ) { |
|
| 214 | 214 | $loc = realpath($loc); |
| 215 | 215 | $paths[] = $loc; |
| 216 | 216 | } else { |
| 217 | 217 | //error_log($loc.' is not a directory'); |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - if (!ini_get('open_basedir')) { |
|
| 220 | + if ( !ini_get('open_basedir') ) { |
|
| 221 | 221 | $paths[] = '/'; |
| 222 | 222 | } else { |
| 223 | 223 | $paths[] = ABSPATH; |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | function get_twig() { |
| 234 | 234 | $loader = $this->get_loader(); |
| 235 | 235 | $params = array('debug' => WP_DEBUG, 'autoescape' => false); |
| 236 | - if (isset(Timber::$autoescape)) { |
|
| 236 | + if ( isset(Timber::$autoescape) ) { |
|
| 237 | 237 | $params['autoescape'] = Timber::$autoescape; |
| 238 | 238 | } |
| 239 | - if (Timber::$cache === true) { |
|
| 239 | + if ( Timber::$cache === true ) { |
|
| 240 | 240 | Timber::$twig_cache = true; |
| 241 | 241 | } |
| 242 | - if (Timber::$twig_cache) { |
|
| 243 | - $twig_cache_loc = apply_filters( 'timber/cache/location', TIMBER_LOC . '/cache/twig' ); |
|
| 244 | - if (!file_exists($twig_cache_loc)) { |
|
| 242 | + if ( Timber::$twig_cache ) { |
|
| 243 | + $twig_cache_loc = apply_filters('timber/cache/location', TIMBER_LOC . '/cache/twig'); |
|
| 244 | + if ( !file_exists($twig_cache_loc) ) { |
|
| 245 | 245 | mkdir($twig_cache_loc, 0777, true); |
| 246 | 246 | } |
| 247 | 247 | $params['cache'] = $twig_cache_loc; |
@@ -258,26 +258,26 @@ discard block |
||
| 258 | 258 | return $twig; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT){ |
|
| 261 | + public function clear_cache_timber($cache_mode = self::CACHE_USE_DEFAULT) { |
|
| 262 | 262 | //_transient_timberloader |
| 263 | 263 | $object_cache = false; |
| 264 | - if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) { |
|
| 264 | + if ( isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache']) ) { |
|
| 265 | 265 | $object_cache = true; |
| 266 | 266 | } |
| 267 | 267 | $cache_mode = $this->_get_cache_mode($cache_mode); |
| 268 | - if (self::CACHE_TRANSIENT === $cache_mode) { |
|
| 268 | + if ( self::CACHE_TRANSIENT === $cache_mode ) { |
|
| 269 | 269 | global $wpdb; |
| 270 | 270 | $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%'); |
| 271 | - $wpdb->query( $query ); |
|
| 271 | + $wpdb->query($query); |
|
| 272 | 272 | return true; |
| 273 | - } else if (self::CACHE_SITE_TRANSIENT === $cache_mode) { |
|
| 273 | + } else if ( self::CACHE_SITE_TRANSIENT === $cache_mode ) { |
|
| 274 | 274 | global $wpdb; |
| 275 | 275 | $query = $wpdb->prepare("DELETE FROM $wpdb->options WHERE option_name LIKE '%s'", '_transient_timberloader_%'); |
| 276 | - $wpdb->query( $query ); |
|
| 276 | + $wpdb->query($query); |
|
| 277 | 277 | return true; |
| 278 | - } else if (self::CACHE_OBJECT === $cache_mode && $object_cache) { |
|
| 278 | + } else if ( self::CACHE_OBJECT === $cache_mode && $object_cache ) { |
|
| 279 | 279 | global $wp_object_cache; |
| 280 | - if (isset($wp_object_cache->cache[self::CACHEGROUP])){ |
|
| 280 | + if ( isset($wp_object_cache->cache[self::CACHEGROUP]) ) { |
|
| 281 | 281 | unset($wp_object_cache->cache[self::CACHEGROUP]); |
| 282 | 282 | return true; |
| 283 | 283 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $twig = $this->get_twig(); |
| 290 | 290 | $twig->clearCacheFiles(); |
| 291 | 291 | $cache = $twig->getCache(); |
| 292 | - if ($cache){ |
|
| 292 | + if ( $cache ) { |
|
| 293 | 293 | self::rrmdir($twig->getCache()); |
| 294 | 294 | return true; |
| 295 | 295 | } |
@@ -300,15 +300,15 @@ discard block |
||
| 300 | 300 | * @param string|false $dirPath |
| 301 | 301 | */ |
| 302 | 302 | public static function rrmdir($dirPath) { |
| 303 | - if (! is_dir($dirPath)) { |
|
| 303 | + if ( !is_dir($dirPath) ) { |
|
| 304 | 304 | throw new InvalidArgumentException("$dirPath must be a directory"); |
| 305 | 305 | } |
| 306 | - if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { |
|
| 306 | + if ( substr($dirPath, strlen($dirPath) - 1, 1) != '/' ) { |
|
| 307 | 307 | $dirPath .= '/'; |
| 308 | 308 | } |
| 309 | 309 | $files = glob($dirPath . '*', GLOB_MARK); |
| 310 | 310 | foreach ($files as $file) { |
| 311 | - if (is_dir($file)) { |
|
| 311 | + if ( is_dir($file) ) { |
|
| 312 | 312 | self::rrmdir($file); |
| 313 | 313 | } else { |
| 314 | 314 | unlink($file); |
@@ -323,9 +323,9 @@ discard block |
||
| 323 | 323 | private function _get_cache_extension() { |
| 324 | 324 | |
| 325 | 325 | $key_generator = new \Timber\Cache\KeyGenerator(); |
| 326 | - $cache_provider = new \Timber\Cache\WPObjectCacheAdapter( $this ); |
|
| 327 | - $cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy( $cache_provider, $key_generator ); |
|
| 328 | - $cache_extension = new \Asm89\Twig\CacheExtension\Extension( $cache_strategy ); |
|
| 326 | + $cache_provider = new \Timber\Cache\WPObjectCacheAdapter($this); |
|
| 327 | + $cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy($cache_provider, $key_generator); |
|
| 328 | + $cache_extension = new \Asm89\Twig\CacheExtension\Extension($cache_strategy); |
|
| 329 | 329 | |
| 330 | 330 | return $cache_extension; |
| 331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | public function get_cache($key, $group = self::CACHEGROUP, $cache_mode = self::CACHE_USE_DEFAULT) { |
| 340 | 340 | $object_cache = false; |
| 341 | 341 | |
| 342 | - if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) { |
|
| 342 | + if ( isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache']) ) { |
|
| 343 | 343 | $object_cache = true; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | $value = false; |
| 349 | 349 | |
| 350 | 350 | $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN); |
| 351 | - if (self::CACHE_TRANSIENT === $cache_mode) |
|
| 351 | + if ( self::CACHE_TRANSIENT === $cache_mode ) |
|
| 352 | 352 | $value = get_transient($trans_key); |
| 353 | 353 | |
| 354 | - elseif (self::CACHE_SITE_TRANSIENT === $cache_mode) |
|
| 354 | + elseif ( self::CACHE_SITE_TRANSIENT === $cache_mode ) |
|
| 355 | 355 | $value = get_site_transient($trans_key); |
| 356 | 356 | |
| 357 | - elseif (self::CACHE_OBJECT === $cache_mode && $object_cache) |
|
| 357 | + elseif ( self::CACHE_OBJECT === $cache_mode && $object_cache ) |
|
| 358 | 358 | $value = wp_cache_get($key, $group); |
| 359 | 359 | |
| 360 | 360 | return $value; |
@@ -371,23 +371,23 @@ discard block |
||
| 371 | 371 | public function set_cache($key, $value, $group = self::CACHEGROUP, $expires = 0, $cache_mode = self::CACHE_USE_DEFAULT) { |
| 372 | 372 | $object_cache = false; |
| 373 | 373 | |
| 374 | - if (isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache'])) { |
|
| 374 | + if ( isset($GLOBALS['wp_object_cache']) && is_object($GLOBALS['wp_object_cache']) ) { |
|
| 375 | 375 | $object_cache = true; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ((int)$expires < 1) |
|
| 378 | + if ( (int) $expires < 1 ) |
|
| 379 | 379 | $expires = 0; |
| 380 | 380 | |
| 381 | 381 | $cache_mode = self::_get_cache_mode($cache_mode); |
| 382 | 382 | $trans_key = substr($group . '_' . $key, 0, self::TRANS_KEY_LEN); |
| 383 | 383 | |
| 384 | - if (self::CACHE_TRANSIENT === $cache_mode) |
|
| 384 | + if ( self::CACHE_TRANSIENT === $cache_mode ) |
|
| 385 | 385 | set_transient($trans_key, $value, $expires); |
| 386 | 386 | |
| 387 | - elseif (self::CACHE_SITE_TRANSIENT === $cache_mode) |
|
| 387 | + elseif ( self::CACHE_SITE_TRANSIENT === $cache_mode ) |
|
| 388 | 388 | set_site_transient($trans_key, $value, $expires); |
| 389 | 389 | |
| 390 | - elseif (self::CACHE_OBJECT === $cache_mode && $object_cache) |
|
| 390 | + elseif ( self::CACHE_OBJECT === $cache_mode && $object_cache ) |
|
| 391 | 391 | wp_cache_set($key, $value, $group, $expires); |
| 392 | 392 | |
| 393 | 393 | return $value; |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | * @return string |
| 399 | 399 | */ |
| 400 | 400 | private function _get_cache_mode($cache_mode) { |
| 401 | - if (empty($cache_mode) || self::CACHE_USE_DEFAULT === $cache_mode) { |
|
| 401 | + if ( empty($cache_mode) || self::CACHE_USE_DEFAULT === $cache_mode ) { |
|
| 402 | 402 | $cache_mode = $this->cache_mode; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | // Fallback if self::$cache_mode did not get a valid value |
| 406 | - if (!in_array($cache_mode, self::$cache_modes)) { |
|
| 406 | + if ( !in_array($cache_mode, self::$cache_modes) ) { |
|
| 407 | 407 | $cache_mode = self::CACHE_OBJECT; |
| 408 | 408 | } |
| 409 | 409 | |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param array|object $data |
| 26 | 26 | */ |
| 27 | - public function __construct( $data ) { |
|
| 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 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * add a class the menu item should have |
| 48 | 48 | * @param string $class_name to be added |
| 49 | 49 | */ |
| 50 | - public function add_class( $class_name ) { |
|
| 50 | + public function add_class($class_name) { |
|
| 51 | 51 | $this->classes[] = $class_name; |
| 52 | 52 | $this->class .= ' ' . $class_name; |
| 53 | 53 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | /** |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @param TimberMenuItem $item |
| 133 | 133 | */ |
| 134 | - function add_child( $item ) { |
|
| 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 |
||
| 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 | } |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | * @internal |
| 167 | 167 | * @param array|object $data |
| 168 | 168 | */ |
| 169 | - function import_classes( $data ) { |
|
| 169 | + function import_classes($data) { |
|
| 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 |
||
| 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,18 +201,18 @@ discard block |
||
| 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 | /** |
| 208 | 208 | * @param string $key lookup key |
| 209 | 209 | * @return mixed whatever value is storied in the database |
| 210 | 210 | */ |
| 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 ); |
|
| 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); |
|
| 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 |
||
| 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 | } |