@@ -9,40 +9,40 @@ discard block |
||
| 9 | 9 | * @param string $TermClass |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm'){ |
|
| 13 | - if (is_string($maybe_args) && !strstr($maybe_args, '=')){ |
|
| 12 | + public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') { |
|
| 13 | + if ( is_string($maybe_args) && !strstr($maybe_args, '=') ) { |
|
| 14 | 14 | //the user is sending the $TermClass in the second argument |
| 15 | 15 | $TermClass = $maybe_args; |
| 16 | 16 | } |
| 17 | - if (is_string($maybe_args) && strstr($maybe_args, '=')){ |
|
| 17 | + if ( is_string($maybe_args) && strstr($maybe_args, '=') ) { |
|
| 18 | 18 | parse_str($maybe_args, $maybe_args); |
| 19 | 19 | } |
| 20 | - if (is_string($args) && strstr($args, '=')){ |
|
| 20 | + if ( is_string($args) && strstr($args, '=') ) { |
|
| 21 | 21 | //a string and a query string! |
| 22 | 22 | $parsed = TimberTermGetter::get_term_query_from_query_string($args); |
| 23 | - if (is_array($maybe_args)){ |
|
| 23 | + if ( is_array($maybe_args) ) { |
|
| 24 | 24 | $parsed->args = array_merge($parsed->args, $maybe_args); |
| 25 | 25 | } |
| 26 | 26 | return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass); |
| 27 | - } else if (is_string($args)){ |
|
| 27 | + } else if ( is_string($args) ) { |
|
| 28 | 28 | //its just a string with a single taxonomy |
| 29 | 29 | $parsed = TimberTermGetter::get_term_query_from_string($args); |
| 30 | - if (is_array($maybe_args)){ |
|
| 30 | + if ( is_array($maybe_args) ) { |
|
| 31 | 31 | $parsed->args = array_merge($parsed->args, $maybe_args); |
| 32 | 32 | } |
| 33 | 33 | return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass); |
| 34 | - } else if (is_array($args) && TimberHelper::is_array_assoc($args)){ |
|
| 34 | + } else if ( is_array($args) && TimberHelper::is_array_assoc($args) ) { |
|
| 35 | 35 | //its an associative array, like a good ole query |
| 36 | 36 | $parsed = TimberTermGetter::get_term_query_from_assoc_array($args); |
| 37 | 37 | return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass); |
| 38 | - } else if (is_array($args)){ |
|
| 38 | + } else if ( is_array($args) ) { |
|
| 39 | 39 | //its just an array of strings or IDs (hopefully) |
| 40 | 40 | $parsed = TimberTermGetter::get_term_query_from_array($args); |
| 41 | - if (is_array($maybe_args)){ |
|
| 41 | + if ( is_array($maybe_args) ) { |
|
| 42 | 42 | $parsed->args = array_merge($parsed->args, $maybe_args); |
| 43 | 43 | } |
| 44 | 44 | return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass); |
| 45 | - } else if (is_null($args)) { |
|
| 45 | + } else if ( is_null($args) ) { |
|
| 46 | 46 | return self::handle_term_query(get_taxonomies(), array(), $TermClass); |
| 47 | 47 | } |
| 48 | 48 | return null; |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | * @param string $TermClass |
| 55 | 55 | * @return mixed |
| 56 | 56 | */ |
| 57 | - public static function handle_term_query($taxonomies, $args, $TermClass){ |
|
| 58 | - if (!isset($args['hide_empty'])){ |
|
| 57 | + public static function handle_term_query($taxonomies, $args, $TermClass) { |
|
| 58 | + if ( !isset($args['hide_empty']) ) { |
|
| 59 | 59 | $args['hide_empty'] = false; |
| 60 | 60 | } |
| 61 | - if (isset($args['term_id']) && is_int($args['term_id'])){ |
|
| 61 | + if ( isset($args['term_id']) && is_int($args['term_id']) ) { |
|
| 62 | 62 | $args['term_id'] = array($args['term_id']); |
| 63 | 63 | } |
| 64 | - if (isset($args['term_id'])){ |
|
| 64 | + if ( isset($args['term_id']) ) { |
|
| 65 | 65 | $args['include'] = $args['term_id']; |
| 66 | 66 | } |
| 67 | 67 | $terms = get_terms($taxonomies, $args); |
| 68 | - foreach($terms as &$term){ |
|
| 68 | + foreach ($terms as &$term) { |
|
| 69 | 69 | $term = new $TermClass($term->term_id, $term->taxonomy); |
| 70 | 70 | } |
| 71 | 71 | return $terms; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | public static function get_term_query_from_string($taxs) { |
| 90 | 90 | $ret = new stdClass(); |
| 91 | 91 | $ret->args = array(); |
| 92 | - if (is_string($taxs)) { |
|
| 92 | + if ( is_string($taxs) ) { |
|
| 93 | 93 | $taxs = array($taxs); |
| 94 | 94 | } |
| 95 | 95 | $ret->taxonomies = self::correct_taxonomy_names($taxs); |
@@ -103,17 +103,17 @@ discard block |
||
| 103 | 103 | public static function get_term_query_from_assoc_array($args) { |
| 104 | 104 | $ret = new stdClass(); |
| 105 | 105 | $ret->args = $args; |
| 106 | - if (isset($ret->args['tax'])) { |
|
| 106 | + if ( isset($ret->args['tax']) ) { |
|
| 107 | 107 | $ret->taxonomies = $ret->args['tax']; |
| 108 | - } else if (isset($ret->args['taxonomies'])) { |
|
| 108 | + } else if ( isset($ret->args['taxonomies']) ) { |
|
| 109 | 109 | $ret->taxonomies = $ret->args['taxonomies']; |
| 110 | - } else if (isset($ret->args['taxs'])) { |
|
| 110 | + } else if ( isset($ret->args['taxs']) ) { |
|
| 111 | 111 | $ret->taxonomies = $ret->args['taxs']; |
| 112 | - } else if (isset($ret->args['taxonomy'])) { |
|
| 112 | + } else if ( isset($ret->args['taxonomy']) ) { |
|
| 113 | 113 | $ret->taxonomies = $ret->args['taxonomy']; |
| 114 | 114 | } |
| 115 | - if (isset($ret->taxonomies)) { |
|
| 116 | - if (is_string($ret->taxonomies)) { |
|
| 115 | + if ( isset($ret->taxonomies) ) { |
|
| 116 | + if ( is_string($ret->taxonomies) ) { |
|
| 117 | 117 | $ret->taxonomies = array($ret->taxonomies); |
| 118 | 118 | } |
| 119 | 119 | $ret->taxonomies = self::correct_taxonomy_names($ret->taxonomies); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | * @return stdClass |
| 129 | 129 | */ |
| 130 | 130 | public static function get_term_query_from_array($args) { |
| 131 | - if (is_array($args) && !empty($args)) { |
|
| 131 | + if ( is_array($args) && !empty($args) ) { |
|
| 132 | 132 | //okay its an array with content |
| 133 | - if (is_int($args[0])) { |
|
| 133 | + if ( is_int($args[0]) ) { |
|
| 134 | 134 | return self::get_term_query_from_array_of_ids($args); |
| 135 | - } else if (is_string($args[0])) { |
|
| 135 | + } else if ( is_string($args[0]) ) { |
|
| 136 | 136 | return self::get_term_query_from_array_of_strings($args); |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | * @return array |
| 167 | 167 | */ |
| 168 | 168 | private static function correct_taxonomy_names($taxs) { |
| 169 | - if (is_string($taxs)) { |
|
| 169 | + if ( is_string($taxs) ) { |
|
| 170 | 170 | $taxs = array($taxs); |
| 171 | 171 | } |
| 172 | 172 | foreach ($taxs as &$tax) { |
| 173 | - if ($tax == 'tags' || $tax == 'tag') { |
|
| 173 | + if ( $tax == 'tags' || $tax == 'tag' ) { |
|
| 174 | 174 | $tax = 'post_tag'; |
| 175 | - } else if ($tax == 'categories') { |
|
| 175 | + } else if ( $tax == 'categories' ) { |
|
| 176 | 176 | $tax = 'category'; |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | * @param int $tid |
| 55 | 55 | * @param string $tax |
| 56 | 56 | */ |
| 57 | - public function __construct( $tid = null, $tax = '' ) { |
|
| 58 | - if ($tid === null) { |
|
| 57 | + public function __construct($tid = null, $tax = '') { |
|
| 58 | + if ( $tid === null ) { |
|
| 59 | 59 | $tid = $this->get_term_from_query(); |
| 60 | 60 | } |
| 61 | - if (strlen($tax)) { |
|
| 61 | + if ( strlen($tax) ) { |
|
| 62 | 62 | $this->taxonomy = $tax; |
| 63 | 63 | } |
| 64 | 64 | $this->init($tid); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return static |
| 79 | 79 | */ |
| 80 | - public static function from( $tid, $taxonomy ) { |
|
| 80 | + public static function from($tid, $taxonomy) { |
|
| 81 | 81 | return new static($tid, $taxonomy); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | global $wp_query; |
| 94 | 94 | if ( isset($wp_query->queried_object) ) { |
| 95 | 95 | $qo = $wp_query->queried_object; |
| 96 | - if (isset($qo->term_id)) { |
|
| 96 | + if ( isset($qo->term_id) ) { |
|
| 97 | 97 | return $qo->term_id; |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @internal |
| 107 | 107 | * @param int $tid |
| 108 | 108 | */ |
| 109 | - protected function init( $tid ) { |
|
| 109 | + protected function init($tid) { |
|
| 110 | 110 | $term = $this->get_term($tid); |
| 111 | 111 | if ( isset($term->id) ) { |
| 112 | 112 | $term->ID = $term->id; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | //echo 'bad call using '.$tid; |
| 117 | 117 | //TimberHelper::error_log(debug_backtrace()); |
| 118 | 118 | } |
| 119 | - if ( isset($term->ID) ){ |
|
| 119 | + if ( isset($term->ID) ) { |
|
| 120 | 120 | $term->id = $term->ID; |
| 121 | 121 | $this->import($term); |
| 122 | 122 | if ( isset($term->term_id) ) { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param int $tid |
| 143 | 143 | * @return mixed |
| 144 | 144 | */ |
| 145 | - protected function get_term( $tid ) { |
|
| 145 | + protected function get_term($tid) { |
|
| 146 | 146 | if ( is_object($tid) || is_array($tid) ) { |
| 147 | 147 | return $tid; |
| 148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | global $wpdb; |
| 155 | 155 | $query = $wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $tid); |
| 156 | 156 | $tax = $wpdb->get_var($query); |
| 157 | - if (isset($tax) && strlen($tax)) { |
|
| 157 | + if ( isset($tax) && strlen($tax) ) { |
|
| 158 | 158 | $this->taxonomy = $tax; |
| 159 | 159 | return get_term($tid, $tax); |
| 160 | 160 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param int $tid |
| 168 | 168 | * @return int |
| 169 | 169 | */ |
| 170 | - protected function get_tid( $tid ) { |
|
| 170 | + protected function get_tid($tid) { |
|
| 171 | 171 | global $wpdb; |
| 172 | 172 | if ( is_numeric($tid) ) { |
| 173 | 173 | return $tid; |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | * @param string $field_name |
| 206 | 206 | * @return string |
| 207 | 207 | */ |
| 208 | - public function get_meta_field( $field_name ) { |
|
| 209 | - if (!isset($this->$field_name)) { |
|
| 208 | + public function get_meta_field($field_name) { |
|
| 209 | + if ( !isset($this->$field_name) ) { |
|
| 210 | 210 | $field_value = ''; |
| 211 | 211 | $field_value = apply_filters('timber_term_get_meta_field', $field_value, $this->ID, $field_name, $this); |
| 212 | 212 | $field_value = apply_filters('timber/term/meta/field', $field_value, $this->ID, $field_name, $this); |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | * @param string $PostClass |
| 245 | 245 | * @return array|bool|null |
| 246 | 246 | */ |
| 247 | - public function get_posts( $numberposts = 10, $post_type = 'any', $PostClass = '' ) { |
|
| 248 | - if (!strlen($PostClass)) { |
|
| 247 | + public function get_posts($numberposts = 10, $post_type = 'any', $PostClass = '') { |
|
| 248 | + if ( !strlen($PostClass) ) { |
|
| 249 | 249 | $PostClass = $this->PostClass; |
| 250 | 250 | } |
| 251 | 251 | $default_tax_query = array(array( |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | parse_str($args, $new_args); |
| 260 | 260 | $args = $new_args; |
| 261 | 261 | $args['tax_query'] = $default_tax_query; |
| 262 | - if (!isset($args['post_type'])) { |
|
| 262 | + if ( !isset($args['post_type']) ) { |
|
| 263 | 263 | $args['post_type'] = 'any'; |
| 264 | 264 | } |
| 265 | - if (class_exists($post_type)) { |
|
| 265 | + if ( class_exists($post_type) ) { |
|
| 266 | 266 | $PostClass = $post_type; |
| 267 | 267 | } |
| 268 | 268 | } else if ( is_array($numberposts) ) { |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | * @param string $key |
| 309 | 309 | * @param mixed $value |
| 310 | 310 | */ |
| 311 | - function update( $key, $value ) { |
|
| 312 | - $value = apply_filters( 'timber_term_set_meta', $value, $key, $this->ID, $this ); |
|
| 311 | + function update($key, $value) { |
|
| 312 | + $value = apply_filters('timber_term_set_meta', $value, $key, $this->ID, $this); |
|
| 313 | 313 | $this->$key = $value; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -331,11 +331,11 @@ discard block |
||
| 331 | 331 | public function description() { |
| 332 | 332 | $prefix = '<p>'; |
| 333 | 333 | $suffix = '</p>'; |
| 334 | - $desc = term_description( $this->ID, $this->taxonomy ); |
|
| 335 | - if (substr($desc, 0, strlen($prefix)) == $prefix) { |
|
| 334 | + $desc = term_description($this->ID, $this->taxonomy); |
|
| 335 | + if ( substr($desc, 0, strlen($prefix)) == $prefix ) { |
|
| 336 | 336 | $desc = substr($desc, strlen($prefix)); |
| 337 | 337 | } |
| 338 | - $desc = preg_replace('/'. preg_quote('</p>', '/') . '$/', '', $desc); |
|
| 338 | + $desc = preg_replace('/' . preg_quote('</p>', '/') . '$/', '', $desc); |
|
| 339 | 339 | return trim($desc); |
| 340 | 340 | } |
| 341 | 341 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * @param string $field_name |
| 370 | 370 | * @return string |
| 371 | 371 | */ |
| 372 | - public function meta( $field_name ) { |
|
| 372 | + public function meta($field_name) { |
|
| 373 | 373 | return $this->get_meta_field($field_name); |
| 374 | 374 | } |
| 375 | 375 | |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | * ``` |
| 398 | 398 | * @return array|bool|null |
| 399 | 399 | */ |
| 400 | - public function posts( $numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '' ) { |
|
| 400 | + public function posts($numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '') { |
|
| 401 | 401 | return $this->get_posts($numberposts_or_args, $post_type_or_class, $post_class); |
| 402 | 402 | } |
| 403 | 403 | |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * @param int $i |
| 423 | 423 | * @return string |
| 424 | 424 | */ |
| 425 | - function get_page( $i ) { |
|
| 425 | + function get_page($i) { |
|
| 426 | 426 | return $this->get_path() . '/page/' . $i; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $ss = $data->get_stylesheet(); |
| 77 | 77 | $this->slug = $ss; |
| 78 | 78 | |
| 79 | - if ( ! function_exists( 'get_home_path' ) ) { |
|
| 79 | + if ( !function_exists('get_home_path') ) { |
|
| 80 | 80 | require_once(ABSPATH . 'wp-admin/includes/file.php'); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @return string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`) |
| 104 | 104 | */ |
| 105 | 105 | public function path() { |
| 106 | - return TimberURLHelper::get_rel_url( $this->link() ); |
|
| 106 | + return TimberURLHelper::get_rel_url($this->link()); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | public static function get_current_url() { |
| 11 | 11 | $pageURL = "http://"; |
| 12 | - if ( isset( $_SERVER['HTTPS'] ) && $_SERVER["HTTPS"] == "on" ) { |
|
| 13 | - $pageURL = "https://";; |
|
| 12 | + if ( isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on" ) { |
|
| 13 | + $pageURL = "https://"; ; |
|
| 14 | 14 | } |
| 15 | 15 | if ( isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != "80" ) { |
| 16 | 16 | $pageURL .= self::get_host() . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | * @param string $url |
| 27 | 27 | * @return bool |
| 28 | 28 | */ |
| 29 | - public static function is_url( $url ) { |
|
| 30 | - if ( !is_string( $url ) ) { |
|
| 29 | + public static function is_url($url) { |
|
| 30 | + if ( !is_string($url) ) { |
|
| 31 | 31 | return false; |
| 32 | 32 | } |
| 33 | - $url = strtolower( $url ); |
|
| 34 | - if ( strstr( $url, '://' ) ) { |
|
| 33 | + $url = strtolower($url); |
|
| 34 | + if ( strstr($url, '://') ) { |
|
| 35 | 35 | return true; |
| 36 | 36 | } |
| 37 | 37 | return false; |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | 45 | public static function get_path_base() { |
| 46 | - $struc = get_option( 'permalink_structure' ); |
|
| 47 | - $struc = explode( '/', $struc ); |
|
| 46 | + $struc = get_option('permalink_structure'); |
|
| 47 | + $struc = explode('/', $struc); |
|
| 48 | 48 | $p = '/'; |
| 49 | - foreach ( $struc as $s ) { |
|
| 50 | - if ( !strstr( $s, '%' ) && strlen( $s ) ) { |
|
| 49 | + foreach ($struc as $s) { |
|
| 50 | + if ( !strstr($s, '%') && strlen($s) ) { |
|
| 51 | 51 | $p .= $s . '/'; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -61,22 +61,22 @@ discard block |
||
| 61 | 61 | * @param bool $force |
| 62 | 62 | * @return string |
| 63 | 63 | */ |
| 64 | - public static function get_rel_url( $url, $force = false ) { |
|
| 65 | - $url_info = parse_url( $url ); |
|
| 66 | - if ( isset( $url_info['host'] ) && $url_info['host'] != self::get_host() && !$force ) { |
|
| 64 | + public static function get_rel_url($url, $force = false) { |
|
| 65 | + $url_info = parse_url($url); |
|
| 66 | + if ( isset($url_info['host']) && $url_info['host'] != self::get_host() && !$force ) { |
|
| 67 | 67 | return $url; |
| 68 | 68 | } |
| 69 | 69 | $link = ''; |
| 70 | - if ( isset( $url_info['path'] ) ) { |
|
| 70 | + if ( isset($url_info['path']) ) { |
|
| 71 | 71 | $link = $url_info['path']; |
| 72 | 72 | } |
| 73 | - if ( isset( $url_info['query'] ) && strlen( $url_info['query'] ) ) { |
|
| 73 | + if ( isset($url_info['query']) && strlen($url_info['query']) ) { |
|
| 74 | 74 | $link .= '?' . $url_info['query']; |
| 75 | 75 | } |
| 76 | - if ( isset( $url_info['fragment'] ) && strlen( $url_info['fragment'] ) ) { |
|
| 76 | + if ( isset($url_info['fragment']) && strlen($url_info['fragment']) ) { |
|
| 77 | 77 | $link .= '#' . $url_info['fragment']; |
| 78 | 78 | } |
| 79 | - $link = TimberURLHelper::remove_double_slashes( $link ); |
|
| 79 | + $link = TimberURLHelper::remove_double_slashes($link); |
|
| 80 | 80 | return $link; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | * @return string the HTTP_HOST or SERVER_NAME |
| 87 | 87 | */ |
| 88 | 88 | public static function get_host() { |
| 89 | - if (isset($_SERVER['HTTP_HOST'])) { |
|
| 89 | + if ( isset($_SERVER['HTTP_HOST']) ) { |
|
| 90 | 90 | return $_SERVER['HTTP_HOST']; |
| 91 | 91 | } |
| 92 | - if (isset($_SERVER['SERVER_NAME'])) { |
|
| 92 | + if ( isset($_SERVER['SERVER_NAME']) ) { |
|
| 93 | 93 | return $_SERVER['SERVER_NAME']; |
| 94 | 94 | } |
| 95 | 95 | return ''; |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * @param string $url |
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | - public static function is_local( $url ) { |
|
| 105 | - if ( strstr( $url, self::get_host() ) ) { |
|
| 104 | + public static function is_local($url) { |
|
| 105 | + if ( strstr($url, self::get_host()) ) { |
|
| 106 | 106 | return true; |
| 107 | 107 | } |
| 108 | 108 | return false; |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | * @param string $src |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | - public static function get_full_path( $src ) { |
|
| 117 | + public static function get_full_path($src) { |
|
| 118 | 118 | $root = ABSPATH; |
| 119 | 119 | $old_root_path = $root . $src; |
| 120 | - $old_root_path = str_replace( '//', '/', $old_root_path ); |
|
| 120 | + $old_root_path = str_replace('//', '/', $old_root_path); |
|
| 121 | 121 | return $old_root_path; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -129,16 +129,16 @@ discard block |
||
| 129 | 129 | * @param string $url |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public static function url_to_file_system( $url ) { |
|
| 133 | - $url_parts = parse_url( $url ); |
|
| 132 | + public static function url_to_file_system($url) { |
|
| 133 | + $url_parts = parse_url($url); |
|
| 134 | 134 | $path = ABSPATH . $url_parts['path']; |
| 135 | - $path = str_replace( '//', '/', $path ); |
|
| 135 | + $path = str_replace('//', '/', $path); |
|
| 136 | 136 | return $path; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public static function file_system_to_url( $fs ) { |
|
| 140 | - $relative_path = self::get_rel_path( $fs ); |
|
| 141 | - $home = home_url( '/'.$relative_path ); |
|
| 139 | + public static function file_system_to_url($fs) { |
|
| 140 | + $relative_path = self::get_rel_path($fs); |
|
| 141 | + $home = home_url('/' . $relative_path); |
|
| 142 | 142 | return $home; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | * @param string $src |
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | - public static function get_rel_path( $src ) { |
|
| 152 | - if ( strstr( $src, ABSPATH ) ) { |
|
| 153 | - return str_replace( ABSPATH, '', $src ); |
|
| 151 | + public static function get_rel_path($src) { |
|
| 152 | + if ( strstr($src, ABSPATH) ) { |
|
| 153 | + return str_replace(ABSPATH, '', $src); |
|
| 154 | 154 | } |
| 155 | 155 | //its outside the wordpress directory, alternate setups: |
| 156 | - $src = str_replace( WP_CONTENT_DIR, '', $src ); |
|
| 156 | + $src = str_replace(WP_CONTENT_DIR, '', $src); |
|
| 157 | 157 | return WP_CONTENT_SUBDIR . $src; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | * @param string $url |
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | - public static function remove_double_slashes( $url ) { |
|
| 167 | - $url = str_replace( '//', '/', $url ); |
|
| 168 | - if ( strstr( $url, 'http:' ) && !strstr( $url, 'http://' ) ) { |
|
| 169 | - $url = str_replace( 'http:/', 'http://', $url ); |
|
| 166 | + public static function remove_double_slashes($url) { |
|
| 167 | + $url = str_replace('//', '/', $url); |
|
| 168 | + if ( strstr($url, 'http:') && !strstr($url, 'http://') ) { |
|
| 169 | + $url = str_replace('http:/', 'http://', $url); |
|
| 170 | 170 | } |
| 171 | 171 | return $url; |
| 172 | 172 | } |
@@ -178,20 +178,20 @@ discard block |
||
| 178 | 178 | * @param string $path |
| 179 | 179 | * @return string |
| 180 | 180 | */ |
| 181 | - public static function prepend_to_url( $url, $path ) { |
|
| 182 | - if ( strstr( strtolower( $url ), 'http' ) ) { |
|
| 183 | - $url_parts = parse_url( $url ); |
|
| 181 | + public static function prepend_to_url($url, $path) { |
|
| 182 | + if ( strstr(strtolower($url), 'http') ) { |
|
| 183 | + $url_parts = parse_url($url); |
|
| 184 | 184 | $url = $url_parts['scheme'] . '://' . $url_parts['host'] . $path . $url_parts['path']; |
| 185 | - if ( isset( $url_parts['query'] ) ) { |
|
| 185 | + if ( isset($url_parts['query']) ) { |
|
| 186 | 186 | $url .= $url_parts['query']; |
| 187 | 187 | } |
| 188 | - if ( isset( $url_parts['fragment'] ) ) { |
|
| 188 | + if ( isset($url_parts['fragment']) ) { |
|
| 189 | 189 | $url .= $url_parts['fragment']; |
| 190 | 190 | } |
| 191 | 191 | } else { |
| 192 | 192 | $url = $url . $path; |
| 193 | 193 | } |
| 194 | - return self::remove_double_slashes( $url ); |
|
| 194 | + return self::remove_double_slashes($url); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | * @param string $path |
| 201 | 201 | * @return string |
| 202 | 202 | */ |
| 203 | - public static function preslashit( $path ) { |
|
| 204 | - if ( strpos( $path, '/' ) != 0 ) { |
|
| 203 | + public static function preslashit($path) { |
|
| 204 | + if ( strpos($path, '/') != 0 ) { |
|
| 205 | 205 | $path = '/' . $path; |
| 206 | 206 | } |
| 207 | 207 | return $path; |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return boolean true if $path is an absolute url, false if relative. |
| 214 | 214 | */ |
| 215 | - public static function is_absolute( $path ) { |
|
| 216 | - return (boolean) ( strstr( $path, 'http' ) ); |
|
| 215 | + public static function is_absolute($path) { |
|
| 216 | + return (boolean) (strstr($path, 'http')); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | * @param string $url a URL to evaluate against |
| 225 | 225 | * @return boolean if $url points to an external location returns true |
| 226 | 226 | */ |
| 227 | - public static function is_external_content( $url ) { |
|
| 228 | - $is_external = TimberURLHelper::is_absolute( $url ) && ! TimberURLHelper::is_internal_content( $url ); |
|
| 227 | + public static function is_external_content($url) { |
|
| 228 | + $is_external = TimberURLHelper::is_absolute($url) && !TimberURLHelper::is_internal_content($url); |
|
| 229 | 229 | |
| 230 | 230 | return $is_external; |
| 231 | 231 | } |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | // otherwise you run into errors with sites that: |
| 236 | 236 | // 1. use WPML plugin |
| 237 | 237 | // 2. or redefine content directory |
| 238 | - $is_content_url = strstr( $url, content_url() ); |
|
| 238 | + $is_content_url = strstr($url, content_url()); |
|
| 239 | 239 | |
| 240 | 240 | // this case covers when the upload directory has been redefined |
| 241 | 241 | $upload_dir = wp_upload_dir(); |
| 242 | - $is_upload_url = strstr( $url, $upload_dir['baseurl'] ); |
|
| 242 | + $is_upload_url = strstr($url, $upload_dir['baseurl']); |
|
| 243 | 243 | |
| 244 | 244 | return $is_content_url || $is_upload_url; |
| 245 | 245 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | * @return bool true if $path is an external url, false if relative or local. |
| 252 | 252 | * true if it's a subdomain (http://cdn.example.org = true) |
| 253 | 253 | */ |
| 254 | - public static function is_external( $url ) { |
|
| 255 | - $has_http = strstr( strtolower( $url ), 'http' ); |
|
| 256 | - $on_domain = strstr( $url, self::get_host() ); |
|
| 254 | + public static function is_external($url) { |
|
| 255 | + $has_http = strstr(strtolower($url), 'http'); |
|
| 256 | + $on_domain = strstr($url, self::get_host()); |
|
| 257 | 257 | if ( $has_http && !$on_domain ) { |
| 258 | 258 | return true; |
| 259 | 259 | } |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | * @param string $link |
| 267 | 267 | * @return string |
| 268 | 268 | */ |
| 269 | - public static function remove_trailing_slash( $link ) { |
|
| 269 | + public static function remove_trailing_slash($link) { |
|
| 270 | 270 | if ( $link != "/" ) |
| 271 | - $link = untrailingslashit( $link ); |
|
| 271 | + $link = untrailingslashit($link); |
|
| 272 | 272 | return $link; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -280,25 +280,25 @@ discard block |
||
| 280 | 280 | * @return string|WP_Error the location of the temporay file name or an error |
| 281 | 281 | * @deprecated since 0.20.0 |
| 282 | 282 | */ |
| 283 | - static function download_url( $url, $timeout = 300 ) { |
|
| 283 | + static function download_url($url, $timeout = 300) { |
|
| 284 | 284 | if ( !$url ) { |
| 285 | - return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) ); |
|
| 285 | + return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $tmpfname = wp_tempnam( $url ); |
|
| 288 | + $tmpfname = wp_tempnam($url); |
|
| 289 | 289 | if ( !$tmpfname ) { |
| 290 | - return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.' ) ); |
|
| 290 | + return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) ); |
|
| 293 | + $response = wp_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname)); |
|
| 294 | 294 | |
| 295 | - if ( is_wp_error( $response ) ) { |
|
| 296 | - unlink( $tmpfname ); |
|
| 295 | + if ( is_wp_error($response) ) { |
|
| 296 | + unlink($tmpfname); |
|
| 297 | 297 | return $response; |
| 298 | 298 | } |
| 299 | - if ( 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
| 300 | - unlink( $tmpfname ); |
|
| 301 | - return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) ); |
|
| 299 | + if ( 200 != wp_remote_retrieve_response_code($response) ) { |
|
| 300 | + unlink($tmpfname); |
|
| 301 | + return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response))); |
|
| 302 | 302 | } |
| 303 | 303 | return $tmpfname; |
| 304 | 304 | } |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | * @param int $i the position of the parameter to grab. |
| 312 | 312 | * @return array|string |
| 313 | 313 | */ |
| 314 | - public static function get_params( $i = false ) { |
|
| 315 | - $args = explode( '/', trim( strtolower( $_SERVER['REQUEST_URI'] ) ) ); |
|
| 314 | + public static function get_params($i = false) { |
|
| 315 | + $args = explode('/', trim(strtolower($_SERVER['REQUEST_URI']))); |
|
| 316 | 316 | $newargs = array(); |
| 317 | - foreach ( $args as $arg ) { |
|
| 318 | - if ( strlen( $arg ) ) { |
|
| 317 | + foreach ($args as $arg) { |
|
| 318 | + if ( strlen($arg) ) { |
|
| 319 | 319 | $newargs[] = $arg; |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | if ( $i < 0 ) { |
| 326 | 326 | //count from end |
| 327 | - $i = count( $newargs ) + $i; |
|
| 327 | + $i = count($newargs) + $i; |
|
| 328 | 328 | } |
| 329 | - if ( isset( $newargs[$i] ) ) { |
|
| 329 | + if ( isset($newargs[$i]) ) { |
|
| 330 | 330 | return $newargs[$i]; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->init($cid); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - function __toString(){ |
|
| 47 | + function __toString() { |
|
| 48 | 48 | return $this->content(); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function init($cid) { |
| 56 | 56 | $comment_data = $cid; |
| 57 | - if (is_integer($cid)) { |
|
| 57 | + if ( is_integer($cid) ) { |
|
| 58 | 58 | $comment_data = get_comment($cid); |
| 59 | 59 | } |
| 60 | 60 | $this->import($comment_data); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | * @return TimberUser |
| 87 | 87 | */ |
| 88 | 88 | public function author() { |
| 89 | - if ($this->user_id) { |
|
| 89 | + if ( $this->user_id ) { |
|
| 90 | 90 | return new TimberUser($this->user_id); |
| 91 | 91 | } else { |
| 92 | 92 | $author = new TimberUser(0); |
| 93 | - if (isset($this->comment_author) && $this->comment_author) { |
|
| 93 | + if ( isset($this->comment_author) && $this->comment_author ) { |
|
| 94 | 94 | $author->name = $this->comment_author; |
| 95 | 95 | } else { |
| 96 | 96 | $author->name = 'Anonymous'; |
@@ -114,21 +114,21 @@ discard block |
||
| 114 | 114 | * @return bool|mixed|string |
| 115 | 115 | */ |
| 116 | 116 | public function avatar($size = 92, $default = '') { |
| 117 | - if (!get_option('show_avatars')) { |
|
| 117 | + if ( !get_option('show_avatars') ) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | - if (!is_numeric($size)) { |
|
| 120 | + if ( !is_numeric($size) ) { |
|
| 121 | 121 | $size = '92'; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $email = $this->avatar_email(); |
| 125 | 125 | $email_hash = ''; |
| 126 | - if (!empty($email)) { |
|
| 126 | + if ( !empty($email) ) { |
|
| 127 | 127 | $email_hash = md5(strtolower(trim($email))); |
| 128 | 128 | } |
| 129 | 129 | $host = $this->avatar_host($email_hash); |
| 130 | 130 | $default = $this->avatar_default($default, $email, $size, $host); |
| 131 | - if (!empty($email)) { |
|
| 131 | + if ( !empty($email) ) { |
|
| 132 | 132 | $avatar = $this->avatar_out($default, $host, $email_hash, $size); |
| 133 | 133 | } else { |
| 134 | 134 | $avatar = $default; |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | * ``` |
| 180 | 180 | * @return string |
| 181 | 181 | */ |
| 182 | - public function date( $date_format = '' ) { |
|
| 182 | + public function date($date_format = '') { |
|
| 183 | 183 | $df = $date_format ? $date_format : get_option('date_format'); |
| 184 | - $the_date = (string)mysql2date($df, $this->comment_date); |
|
| 184 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
| 185 | 185 | return apply_filters('get_comment_date ', $the_date, $df); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | * ``` |
| 205 | 205 | * @return string |
| 206 | 206 | */ |
| 207 | - public function time( $time_format = '' ) { |
|
| 207 | + public function time($time_format = '') { |
|
| 208 | 208 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 209 | - $the_time = (string)mysql2date($tf, $this->comment_date); |
|
| 209 | + $the_time = (string) mysql2date($tf, $this->comment_date); |
|
| 210 | 210 | return apply_filters('get_comment_time', $the_time, $tf); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -232,14 +232,14 @@ discard block |
||
| 232 | 232 | * @return mixed |
| 233 | 233 | */ |
| 234 | 234 | protected function get_meta_fields($comment_id = null) { |
| 235 | - if ($comment_id === null) { |
|
| 235 | + if ( $comment_id === null ) { |
|
| 236 | 236 | $comment_id = $this->ID; |
| 237 | 237 | } |
| 238 | 238 | //Could not find a WP function to fetch all comment meta data, so I made one. |
| 239 | 239 | apply_filters('timber_comment_get_meta_pre', array(), $comment_id); |
| 240 | 240 | $comment_metas = get_comment_meta($comment_id); |
| 241 | 241 | foreach ($comment_metas as &$cm) { |
| 242 | - if (is_array($cm) && count($cm) == 1) { |
|
| 242 | + if ( is_array($cm) && count($cm) == 1 ) { |
|
| 243 | 243 | $cm = $cm[0]; |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | protected function get_meta_field($field_name) { |
| 256 | 256 | $value = apply_filters('timber_comment_get_meta_field_pre', null, $this->ID, $field_name, $this); |
| 257 | - if ($value === null) { |
|
| 257 | + if ( $value === null ) { |
|
| 258 | 258 | $value = get_comment_meta($this->ID, $field_name, true); |
| 259 | 259 | } |
| 260 | 260 | $value = apply_filters('timber_comment_get_meta_field', $value, $this->ID, $field_name, $this); |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | * @param int $post_id |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | - public function reply_link( $reply_text = 'Reply' ) { |
|
| 272 | + public function reply_link($reply_text = 'Reply') { |
|
| 273 | 273 | if ( is_singular() && comments_open() && get_option('thread_comments') ) { |
| 274 | - wp_enqueue_script( 'comment-reply' ); |
|
| 274 | + wp_enqueue_script('comment-reply'); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | // Get the comments depth option from the admin panel |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | 'max_depth' => $max_depth, |
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | - return get_comment_reply_link( $args, $this->ID, $this->post_id ); |
|
| 289 | + return get_comment_reply_link($args, $this->ID, $this->post_id); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /* AVATAR Stuff |
@@ -297,9 +297,9 @@ discard block |
||
| 297 | 297 | * @return string |
| 298 | 298 | */ |
| 299 | 299 | protected function avatar_email() { |
| 300 | - $id = (int)$this->user_id; |
|
| 300 | + $id = (int) $this->user_id; |
|
| 301 | 301 | $user = get_userdata($id); |
| 302 | - if ($user) { |
|
| 302 | + if ( $user ) { |
|
| 303 | 303 | $email = $user->user_email; |
| 304 | 304 | } else { |
| 305 | 305 | $email = $this->comment_author_email; |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @return string |
| 314 | 314 | */ |
| 315 | 315 | protected function avatar_host($email_hash) { |
| 316 | - if (is_ssl()) { |
|
| 316 | + if ( is_ssl() ) { |
|
| 317 | 317 | $host = 'https://secure.gravatar.com'; |
| 318 | 318 | } else { |
| 319 | - if (!empty($email_hash)) { |
|
| 319 | + if ( !empty($email_hash) ) { |
|
| 320 | 320 | $host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2)); |
| 321 | 321 | } else { |
| 322 | 322 | $host = 'http://0.gravatar.com'; |
@@ -335,28 +335,28 @@ discard block |
||
| 335 | 335 | * @return string |
| 336 | 336 | */ |
| 337 | 337 | protected function avatar_default($default, $email, $size, $host) { |
| 338 | - if (substr($default, 0, 1) == '/') { |
|
| 338 | + if ( substr($default, 0, 1) == '/' ) { |
|
| 339 | 339 | $default = home_url() . $default; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if (empty($default)) { |
|
| 342 | + if ( empty($default) ) { |
|
| 343 | 343 | $avatar_default = get_option('avatar_default'); |
| 344 | - if (empty($avatar_default)) { |
|
| 344 | + if ( empty($avatar_default) ) { |
|
| 345 | 345 | $default = 'mystery'; |
| 346 | 346 | } else { |
| 347 | 347 | $default = $avatar_default; |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | - if ('mystery' == $default) { |
|
| 350 | + if ( 'mystery' == $default ) { |
|
| 351 | 351 | $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
| 352 | 352 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
| 353 | - } else if ('blank' == $default) { |
|
| 353 | + } else if ( 'blank' == $default ) { |
|
| 354 | 354 | $default = $email ? 'blank' : includes_url('images/blank.gif'); |
| 355 | - } else if (!empty($email) && 'gravatar_default' == $default) { |
|
| 355 | + } else if ( !empty($email) && 'gravatar_default' == $default ) { |
|
| 356 | 356 | $default = ''; |
| 357 | - } else if ('gravatar_default' == $default) { |
|
| 357 | + } else if ( 'gravatar_default' == $default ) { |
|
| 358 | 358 | $default = $host . '/avatar/?s=' . $size; |
| 359 | - } else if (empty($email) && !strstr($default, 'http://')) { |
|
| 359 | + } else if ( empty($email) && !strstr($default, 'http://') ) { |
|
| 360 | 360 | $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
| 361 | 361 | } |
| 362 | 362 | return $default; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | protected function avatar_out($default, $host, $email_hash, $size) { |
| 374 | 374 | $out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode($default); |
| 375 | 375 | $rating = get_option('avatar_rating'); |
| 376 | - if (!empty($rating)) { |
|
| 376 | + if ( !empty($rating) ) { |
|
| 377 | 377 | $out .= '&r=' . $rating; |
| 378 | 378 | } |
| 379 | 379 | return str_replace('&', '&', esc_url($out)); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function __construct() { |
| 15 | - add_action( 'timber/twig/filters', array( $this, 'add_timber_filters_deprecated' ) ); |
|
| 16 | - add_action( 'timber/twig/filters', array( $this, 'add_timber_filters' ) ); |
|
| 15 | + add_action('timber/twig/filters', array($this, 'add_timber_filters_deprecated')); |
|
| 16 | + add_action('timber/twig/filters', array($this, 'add_timber_filters')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | * @deprecated since 0.20.7 |
| 24 | 24 | * @return Twig_Environment |
| 25 | 25 | */ |
| 26 | - function add_timber_filters_deprecated( $twig ) { |
|
| 27 | - $twig->addFilter( new Twig_SimpleFilter( 'get_src_from_attachment_id', 'twig_get_src_from_attachment_id' ) ); |
|
| 28 | - $twig->addFilter( new Twig_SimpleFilter( 'wp_body_class', array( $this, 'body_class' ) ) ); |
|
| 29 | - $twig->addFilter( new Twig_SimpleFilter( 'twitterify', array( 'TimberHelper', 'twitterify' ) ) ); |
|
| 30 | - $twig->addFilter( new Twig_SimpleFilter( 'twitterfy', array( 'TimberHelper', 'twitterify' ) ) ); |
|
| 31 | - $twig->addFilter( new Twig_SimpleFilter( 'string', function($arr, $glue = ' '){ |
|
| 26 | + function add_timber_filters_deprecated($twig) { |
|
| 27 | + $twig->addFilter(new Twig_SimpleFilter('get_src_from_attachment_id', 'twig_get_src_from_attachment_id')); |
|
| 28 | + $twig->addFilter(new Twig_SimpleFilter('wp_body_class', array($this, 'body_class'))); |
|
| 29 | + $twig->addFilter(new Twig_SimpleFilter('twitterify', array('TimberHelper', 'twitterify'))); |
|
| 30 | + $twig->addFilter(new Twig_SimpleFilter('twitterfy', array('TimberHelper', 'twitterify'))); |
|
| 31 | + $twig->addFilter(new Twig_SimpleFilter('string', function($arr, $glue = ' ') { |
|
| 32 | 32 | return twig_join_filter($arr, $glue); |
| 33 | - } ) ); |
|
| 33 | + } )); |
|
| 34 | 34 | return $twig; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,151 +40,151 @@ discard block |
||
| 40 | 40 | * @param Twig_Environment $twig |
| 41 | 41 | * @return Twig_Environment |
| 42 | 42 | */ |
| 43 | - function add_timber_filters( $twig ) { |
|
| 43 | + function add_timber_filters($twig) { |
|
| 44 | 44 | /* image filters */ |
| 45 | - $twig->addFilter( new Twig_SimpleFilter( 'resize', array( 'TimberImageHelper', 'resize' ) ) ); |
|
| 46 | - $twig->addFilter( new Twig_SimpleFilter( 'retina', array( 'TimberImageHelper', 'retina_resize' ) ) ); |
|
| 47 | - $twig->addFilter( new Twig_SimpleFilter( 'letterbox', array( 'TimberImageHelper', 'letterbox' ) ) ); |
|
| 48 | - $twig->addFilter( new Twig_SimpleFilter( 'tojpg', array( 'TimberImageHelper', 'img_to_jpg' ) ) ); |
|
| 45 | + $twig->addFilter(new Twig_SimpleFilter('resize', array('TimberImageHelper', 'resize'))); |
|
| 46 | + $twig->addFilter(new Twig_SimpleFilter('retina', array('TimberImageHelper', 'retina_resize'))); |
|
| 47 | + $twig->addFilter(new Twig_SimpleFilter('letterbox', array('TimberImageHelper', 'letterbox'))); |
|
| 48 | + $twig->addFilter(new Twig_SimpleFilter('tojpg', array('TimberImageHelper', 'img_to_jpg'))); |
|
| 49 | 49 | |
| 50 | 50 | /* debugging filters */ |
| 51 | - $twig->addFilter( new Twig_SimpleFilter( 'docs', 'twig_object_docs' ) ); |
|
| 52 | - $twig->addFilter( new Twig_SimpleFilter( 'get_class', 'get_class' ) ); |
|
| 53 | - $twig->addFilter( new Twig_SimpleFilter( 'get_type', 'get_type' ) ); |
|
| 54 | - $twig->addFilter( new Twig_SimpleFilter( 'print_r', function( $arr ) { |
|
| 55 | - return print_r( $arr, true ); |
|
| 56 | - } ) ); |
|
| 57 | - $twig->addFilter( new Twig_SimpleFilter( 'print_a', function( $arr ) { |
|
| 58 | - return '<pre>' . self::object_docs( $arr, true ) . '</pre>'; |
|
| 59 | - } ) ); |
|
| 51 | + $twig->addFilter(new Twig_SimpleFilter('docs', 'twig_object_docs')); |
|
| 52 | + $twig->addFilter(new Twig_SimpleFilter('get_class', 'get_class')); |
|
| 53 | + $twig->addFilter(new Twig_SimpleFilter('get_type', 'get_type')); |
|
| 54 | + $twig->addFilter(new Twig_SimpleFilter('print_r', function($arr) { |
|
| 55 | + return print_r($arr, true); |
|
| 56 | + } )); |
|
| 57 | + $twig->addFilter(new Twig_SimpleFilter('print_a', function($arr) { |
|
| 58 | + return '<pre>' . self::object_docs($arr, true) . '</pre>'; |
|
| 59 | + } )); |
|
| 60 | 60 | |
| 61 | 61 | /* other filters */ |
| 62 | - $twig->addFilter( new Twig_SimpleFilter( 'stripshortcodes', 'strip_shortcodes' ) ); |
|
| 63 | - $twig->addFilter( new Twig_SimpleFilter( 'array', array( $this, 'to_array' ) ) ); |
|
| 64 | - $twig->addFilter( new Twig_SimpleFilter( 'excerpt', 'wp_trim_words' ) ); |
|
| 65 | - $twig->addFilter( new Twig_SimpleFilter( 'function', array( $this, 'exec_function' ) ) ); |
|
| 66 | - $twig->addFilter( new Twig_SimpleFilter( 'pretags', array( $this, 'twig_pretags' ) ) ); |
|
| 67 | - $twig->addFilter( new Twig_SimpleFilter( 'sanitize', 'sanitize_title' ) ); |
|
| 68 | - $twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) ); |
|
| 69 | - $twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) ); |
|
| 70 | - $twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) ); |
|
| 71 | - $twig->addFilter( new Twig_SimpleFilter( 'list', array( $this, 'add_list_separators' ) ) ); |
|
| 72 | - |
|
| 73 | - $twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) { |
|
| 74 | - return TimberURLHelper::get_rel_url( $link, true ); |
|
| 75 | - } ) ); |
|
| 76 | - |
|
| 77 | - $twig->addFilter( new Twig_SimpleFilter( 'date', array( $this, 'intl_date' ) ) ); |
|
| 78 | - |
|
| 79 | - $twig->addFilter( new Twig_SimpleFilter( 'truncate', function ( $text, $len ) { |
|
| 80 | - return TimberHelper::trim_words( $text, $len ); |
|
| 81 | - } ) ); |
|
| 62 | + $twig->addFilter(new Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes')); |
|
| 63 | + $twig->addFilter(new Twig_SimpleFilter('array', array($this, 'to_array'))); |
|
| 64 | + $twig->addFilter(new Twig_SimpleFilter('excerpt', 'wp_trim_words')); |
|
| 65 | + $twig->addFilter(new Twig_SimpleFilter('function', array($this, 'exec_function'))); |
|
| 66 | + $twig->addFilter(new Twig_SimpleFilter('pretags', array($this, 'twig_pretags'))); |
|
| 67 | + $twig->addFilter(new Twig_SimpleFilter('sanitize', 'sanitize_title')); |
|
| 68 | + $twig->addFilter(new Twig_SimpleFilter('shortcodes', 'do_shortcode')); |
|
| 69 | + $twig->addFilter(new Twig_SimpleFilter('time_ago', array($this, 'time_ago'))); |
|
| 70 | + $twig->addFilter(new Twig_SimpleFilter('wpautop', 'wpautop')); |
|
| 71 | + $twig->addFilter(new Twig_SimpleFilter('list', array($this, 'add_list_separators'))); |
|
| 72 | + |
|
| 73 | + $twig->addFilter(new Twig_SimpleFilter('relative', function($link) { |
|
| 74 | + return TimberURLHelper::get_rel_url($link, true); |
|
| 75 | + } )); |
|
| 76 | + |
|
| 77 | + $twig->addFilter(new Twig_SimpleFilter('date', array($this, 'intl_date'))); |
|
| 78 | + |
|
| 79 | + $twig->addFilter(new Twig_SimpleFilter('truncate', function($text, $len) { |
|
| 80 | + return TimberHelper::trim_words($text, $len); |
|
| 81 | + } )); |
|
| 82 | 82 | |
| 83 | 83 | /* actions and filters */ |
| 84 | - $twig->addFunction( new Twig_SimpleFunction( 'action', function ( $context ) { |
|
| 84 | + $twig->addFunction(new Twig_SimpleFunction('action', function($context) { |
|
| 85 | 85 | $args = func_get_args(); |
| 86 | - array_shift( $args ); |
|
| 86 | + array_shift($args); |
|
| 87 | 87 | $args[] = $context; |
| 88 | - call_user_func_array( 'do_action', $args ); |
|
| 89 | - }, array( 'needs_context' => true ) ) ); |
|
| 88 | + call_user_func_array('do_action', $args); |
|
| 89 | + }, array('needs_context' => true))); |
|
| 90 | 90 | |
| 91 | - $twig->addFilter( new Twig_SimpleFilter( 'apply_filters', function () { |
|
| 91 | + $twig->addFilter(new Twig_SimpleFilter('apply_filters', function() { |
|
| 92 | 92 | $args = func_get_args(); |
| 93 | - $tag = current( array_splice( $args, 1, 1 ) ); |
|
| 93 | + $tag = current(array_splice($args, 1, 1)); |
|
| 94 | 94 | |
| 95 | - return apply_filters_ref_array( $tag, $args ); |
|
| 96 | - } ) ); |
|
| 97 | - $twig->addFunction( new Twig_SimpleFunction( 'function', array( &$this, 'exec_function' ) ) ); |
|
| 98 | - $twig->addFunction( new Twig_SimpleFunction( 'fn', array( &$this, 'exec_function' ) ) ); |
|
| 95 | + return apply_filters_ref_array($tag, $args); |
|
| 96 | + } )); |
|
| 97 | + $twig->addFunction(new Twig_SimpleFunction('function', array(&$this, 'exec_function'))); |
|
| 98 | + $twig->addFunction(new Twig_SimpleFunction('fn', array(&$this, 'exec_function'))); |
|
| 99 | 99 | |
| 100 | - $twig->addFunction( new Twig_SimpleFunction( 'shortcode', 'do_shortcode' ) ); |
|
| 100 | + $twig->addFunction(new Twig_SimpleFunction('shortcode', 'do_shortcode')); |
|
| 101 | 101 | |
| 102 | 102 | /* TimberObjects */ |
| 103 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberPost', function ( $pid, $PostClass = 'TimberPost' ) { |
|
| 104 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 105 | - foreach ( $pid as &$p ) { |
|
| 106 | - $p = new $PostClass( $p ); |
|
| 103 | + $twig->addFunction(new Twig_SimpleFunction('TimberPost', function($pid, $PostClass = 'TimberPost') { |
|
| 104 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 105 | + foreach ($pid as &$p) { |
|
| 106 | + $p = new $PostClass($p); |
|
| 107 | 107 | } |
| 108 | 108 | return $pid; |
| 109 | 109 | } |
| 110 | - return new $PostClass( $pid ); |
|
| 111 | - } ) ); |
|
| 112 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberImage', function ( $pid, $ImageClass = 'TimberImage' ) { |
|
| 113 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 114 | - foreach ( $pid as &$p ) { |
|
| 115 | - $p = new $ImageClass( $p ); |
|
| 110 | + return new $PostClass($pid); |
|
| 111 | + } )); |
|
| 112 | + $twig->addFunction(new Twig_SimpleFunction('TimberImage', function($pid, $ImageClass = 'TimberImage') { |
|
| 113 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 114 | + foreach ($pid as &$p) { |
|
| 115 | + $p = new $ImageClass($p); |
|
| 116 | 116 | } |
| 117 | 117 | return $pid; |
| 118 | 118 | } |
| 119 | - return new $ImageClass( $pid ); |
|
| 120 | - } ) ); |
|
| 121 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberTerm', function ( $pid, $TermClass = 'TimberTerm' ) { |
|
| 122 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 123 | - foreach ( $pid as &$p ) { |
|
| 124 | - $p = new $TermClass( $p ); |
|
| 119 | + return new $ImageClass($pid); |
|
| 120 | + } )); |
|
| 121 | + $twig->addFunction(new Twig_SimpleFunction('TimberTerm', function($pid, $TermClass = 'TimberTerm') { |
|
| 122 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 123 | + foreach ($pid as &$p) { |
|
| 124 | + $p = new $TermClass($p); |
|
| 125 | 125 | } |
| 126 | 126 | return $pid; |
| 127 | 127 | } |
| 128 | - return new $TermClass( $pid ); |
|
| 129 | - } ) ); |
|
| 130 | - $twig->addFunction( new Twig_SimpleFunction( 'TimberUser', function ( $pid, $UserClass = 'TimberUser' ) { |
|
| 131 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 132 | - foreach ( $pid as &$p ) { |
|
| 133 | - $p = new $UserClass( $p ); |
|
| 128 | + return new $TermClass($pid); |
|
| 129 | + } )); |
|
| 130 | + $twig->addFunction(new Twig_SimpleFunction('TimberUser', function($pid, $UserClass = 'TimberUser') { |
|
| 131 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 132 | + foreach ($pid as &$p) { |
|
| 133 | + $p = new $UserClass($p); |
|
| 134 | 134 | } |
| 135 | 135 | return $pid; |
| 136 | 136 | } |
| 137 | - return new $UserClass( $pid ); |
|
| 138 | - } ) ); |
|
| 137 | + return new $UserClass($pid); |
|
| 138 | + } )); |
|
| 139 | 139 | |
| 140 | 140 | /* TimberObjects Alias */ |
| 141 | - $twig->addFunction( new Twig_SimpleFunction( 'Post', function ( $pid, $PostClass = 'TimberPost' ) { |
|
| 142 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 143 | - foreach ( $pid as &$p ) { |
|
| 144 | - $p = new $PostClass( $p ); |
|
| 141 | + $twig->addFunction(new Twig_SimpleFunction('Post', function($pid, $PostClass = 'TimberPost') { |
|
| 142 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 143 | + foreach ($pid as &$p) { |
|
| 144 | + $p = new $PostClass($p); |
|
| 145 | 145 | } |
| 146 | 146 | return $pid; |
| 147 | 147 | } |
| 148 | - return new $PostClass( $pid ); |
|
| 149 | - } ) ); |
|
| 150 | - $twig->addFunction( new Twig_SimpleFunction( 'Image', function ( $pid, $ImageClass = 'TimberImage' ) { |
|
| 151 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 152 | - foreach ( $pid as &$p ) { |
|
| 153 | - $p = new $ImageClass( $p ); |
|
| 148 | + return new $PostClass($pid); |
|
| 149 | + } )); |
|
| 150 | + $twig->addFunction(new Twig_SimpleFunction('Image', function($pid, $ImageClass = 'TimberImage') { |
|
| 151 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 152 | + foreach ($pid as &$p) { |
|
| 153 | + $p = new $ImageClass($p); |
|
| 154 | 154 | } |
| 155 | 155 | return $pid; |
| 156 | 156 | } |
| 157 | - return new $ImageClass( $pid ); |
|
| 158 | - } ) ); |
|
| 159 | - $twig->addFunction( new Twig_SimpleFunction( 'Term', function ( $pid, $TermClass = 'TimberTerm' ) { |
|
| 160 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 161 | - foreach ( $pid as &$p ) { |
|
| 162 | - $p = new $TermClass( $p ); |
|
| 157 | + return new $ImageClass($pid); |
|
| 158 | + } )); |
|
| 159 | + $twig->addFunction(new Twig_SimpleFunction('Term', function($pid, $TermClass = 'TimberTerm') { |
|
| 160 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 161 | + foreach ($pid as &$p) { |
|
| 162 | + $p = new $TermClass($p); |
|
| 163 | 163 | } |
| 164 | 164 | return $pid; |
| 165 | 165 | } |
| 166 | - return new $TermClass( $pid ); |
|
| 167 | - } ) ); |
|
| 168 | - $twig->addFunction( new Twig_SimpleFunction( 'User', function ( $pid, $UserClass = 'TimberUser' ) { |
|
| 169 | - if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) { |
|
| 170 | - foreach ( $pid as &$p ) { |
|
| 171 | - $p = new $UserClass( $p ); |
|
| 166 | + return new $TermClass($pid); |
|
| 167 | + } )); |
|
| 168 | + $twig->addFunction(new Twig_SimpleFunction('User', function($pid, $UserClass = 'TimberUser') { |
|
| 169 | + if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) { |
|
| 170 | + foreach ($pid as &$p) { |
|
| 171 | + $p = new $UserClass($p); |
|
| 172 | 172 | } |
| 173 | 173 | return $pid; |
| 174 | 174 | } |
| 175 | - return new $UserClass( $pid ); |
|
| 176 | - } ) ); |
|
| 175 | + return new $UserClass($pid); |
|
| 176 | + } )); |
|
| 177 | 177 | |
| 178 | 178 | /* bloginfo and translate */ |
| 179 | - $twig->addFunction( 'bloginfo', new Twig_SimpleFunction( 'bloginfo', function ( $show = '', $filter = 'raw' ) { |
|
| 180 | - return get_bloginfo( $show, $filter ); |
|
| 181 | - } ) ); |
|
| 182 | - $twig->addFunction( '__', new Twig_SimpleFunction( '__', function ( $text, $domain = 'default' ) { |
|
| 183 | - return __( $text, $domain ); |
|
| 184 | - } ) ); |
|
| 179 | + $twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function($show = '', $filter = 'raw') { |
|
| 180 | + return get_bloginfo($show, $filter); |
|
| 181 | + } )); |
|
| 182 | + $twig->addFunction('__', new Twig_SimpleFunction('__', function($text, $domain = 'default') { |
|
| 183 | + return __($text, $domain); |
|
| 184 | + } )); |
|
| 185 | 185 | /* get_twig is deprecated, use timber/twig */ |
| 186 | - $twig = apply_filters( 'get_twig', $twig ); |
|
| 187 | - $twig = apply_filters( 'timber/twig', $twig ); |
|
| 186 | + $twig = apply_filters('get_twig', $twig); |
|
| 187 | + $twig = apply_filters('timber/twig', $twig); |
|
| 188 | 188 | return $twig; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | * @param mixed $arr |
| 195 | 195 | * @return array |
| 196 | 196 | */ |
| 197 | - function to_array( $arr ) { |
|
| 198 | - if ( is_array( $arr ) ) { |
|
| 197 | + function to_array($arr) { |
|
| 198 | + if ( is_array($arr) ) { |
|
| 199 | 199 | return $arr; |
| 200 | 200 | } |
| 201 | - $arr = array( $arr ); |
|
| 201 | + $arr = array($arr); |
|
| 202 | 202 | return $arr; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | * @param string $function_name |
| 209 | 209 | * @return mixed |
| 210 | 210 | */ |
| 211 | - function exec_function( $function_name ) { |
|
| 211 | + function exec_function($function_name) { |
|
| 212 | 212 | $args = func_get_args(); |
| 213 | - array_shift( $args ); |
|
| 213 | + array_shift($args); |
|
| 214 | 214 | if ( is_string($function_name) ) { |
| 215 | - $function_name = trim( $function_name ); |
|
| 215 | + $function_name = trim($function_name); |
|
| 216 | 216 | } |
| 217 | - return call_user_func_array( $function_name, ( $args ) ); |
|
| 217 | + return call_user_func_array($function_name, ($args)); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | * @param string $content |
| 224 | 224 | * @return string |
| 225 | 225 | */ |
| 226 | - function twig_pretags( $content ) { |
|
| 227 | - return preg_replace_callback( '|<pre.*>(.*)</pre|isU', array( &$this, 'convert_pre_entities' ), $content ); |
|
| 226 | + function twig_pretags($content) { |
|
| 227 | + return preg_replace_callback('|<pre.*>(.*)</pre|isU', array(&$this, 'convert_pre_entities'), $content); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | * @param array $matches |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - function convert_pre_entities( $matches ) { |
|
| 237 | - return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] ); |
|
| 236 | + function convert_pre_entities($matches) { |
|
| 237 | + return str_replace($matches[1], htmlentities($matches[1]), $matches[0]); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | * @deprecated 0.20.7 |
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | - function body_class( $body_classes ) { |
|
| 245 | + function body_class($body_classes) { |
|
| 246 | 246 | ob_start(); |
| 247 | - if ( is_array( $body_classes ) ) { |
|
| 248 | - $body_classes = explode( ' ', $body_classes ); |
|
| 247 | + if ( is_array($body_classes) ) { |
|
| 248 | + $body_classes = explode(' ', $body_classes); |
|
| 249 | 249 | } |
| 250 | - body_class( $body_classes ); |
|
| 250 | + body_class($body_classes); |
|
| 251 | 251 | $return = ob_get_contents(); |
| 252 | 252 | ob_end_clean(); |
| 253 | 253 | return $return; |
@@ -260,20 +260,20 @@ discard block |
||
| 260 | 260 | * @param string $format (optional) |
| 261 | 261 | * @return string |
| 262 | 262 | */ |
| 263 | - function intl_date( $date, $format = null ) { |
|
| 263 | + function intl_date($date, $format = null) { |
|
| 264 | 264 | if ( $format === null ) { |
| 265 | - $format = get_option( 'date_format' ); |
|
| 265 | + $format = get_option('date_format'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | if ( $date instanceof DateTime ) { |
| 269 | 269 | $timestamp = $date->getTimestamp(); |
| 270 | - } else if (is_numeric( $date ) && strtotime( $date ) === false ) { |
|
| 271 | - $timestamp = intval( $date ); |
|
| 270 | + } else if ( is_numeric($date) && strtotime($date) === false ) { |
|
| 271 | + $timestamp = intval($date); |
|
| 272 | 272 | } else { |
| 273 | - $timestamp = strtotime( $date ); |
|
| 273 | + $timestamp = strtotime($date); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - return date_i18n( $format, $timestamp ); |
|
| 276 | + return date_i18n($format, $timestamp); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | //debug |
@@ -285,17 +285,17 @@ discard block |
||
| 285 | 285 | * @param bool $methods |
| 286 | 286 | * @return string |
| 287 | 287 | */ |
| 288 | - function object_docs( $obj, $methods = true ) { |
|
| 289 | - $class = get_class( $obj ); |
|
| 290 | - $properties = (array)$obj; |
|
| 288 | + function object_docs($obj, $methods = true) { |
|
| 289 | + $class = get_class($obj); |
|
| 290 | + $properties = (array) $obj; |
|
| 291 | 291 | if ( $methods ) { |
| 292 | 292 | /** @var array $methods */ |
| 293 | 293 | $methods = $obj->get_method_values(); |
| 294 | 294 | } |
| 295 | - $rets = array_merge( $properties, $methods ); |
|
| 296 | - ksort( $rets ); |
|
| 297 | - $str = print_r( $rets, true ); |
|
| 298 | - $str = str_replace( 'Array', $class . ' Object', $str ); |
|
| 295 | + $rets = array_merge($properties, $methods); |
|
| 296 | + ksort($rets); |
|
| 297 | + $str = print_r($rets, true); |
|
| 298 | + $str = str_replace('Array', $class . ' Object', $str); |
|
| 299 | 299 | return $str; |
| 300 | 300 | } |
| 301 | 301 | |
@@ -306,15 +306,15 @@ discard block |
||
| 306 | 306 | * @param string $format_future |
| 307 | 307 | * @return string |
| 308 | 308 | */ |
| 309 | - function time_ago( $from, $to = null, $format_past = '%s ago', $format_future = '%s from now' ) { |
|
| 309 | + function time_ago($from, $to = null, $format_past = '%s ago', $format_future = '%s from now') { |
|
| 310 | 310 | $to = $to === null ? time() : $to; |
| 311 | - $to = is_int( $to ) ? $to : strtotime( $to ); |
|
| 312 | - $from = is_int( $from ) ? $from : strtotime( $from ); |
|
| 311 | + $to = is_int($to) ? $to : strtotime($to); |
|
| 312 | + $from = is_int($from) ? $from : strtotime($from); |
|
| 313 | 313 | |
| 314 | 314 | if ( $from < $to ) { |
| 315 | - return sprintf( $format_past, human_time_diff( $from, $to ) ); |
|
| 315 | + return sprintf($format_past, human_time_diff($from, $to)); |
|
| 316 | 316 | } else { |
| 317 | - return sprintf( $format_future, human_time_diff( $to, $from ) ); |
|
| 317 | + return sprintf($format_future, human_time_diff($to, $from)); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | * @param string $second_delimiter |
| 325 | 325 | * @return string |
| 326 | 326 | */ |
| 327 | - function add_list_separators( $arr, $first_delimiter = ',', $second_delimiter = 'and' ) { |
|
| 328 | - $length = count( $arr ); |
|
| 327 | + function add_list_separators($arr, $first_delimiter = ',', $second_delimiter = 'and') { |
|
| 328 | + $length = count($arr); |
|
| 329 | 329 | $list = ''; |
| 330 | - foreach( $arr as $index => $item ) { |
|
| 330 | + foreach ($arr as $index => $item) { |
|
| 331 | 331 | if ( $index < $length - 2 ) { |
| 332 | - $delimiter = $first_delimiter.' '; |
|
| 332 | + $delimiter = $first_delimiter . ' '; |
|
| 333 | 333 | } elseif ( $index == $length - 2 ) { |
| 334 | - $delimiter = ' '.$second_delimiter.' '; |
|
| 334 | + $delimiter = ' ' . $second_delimiter . ' '; |
|
| 335 | 335 | } else { |
| 336 | 336 | $delimiter = ''; |
| 337 | 337 | } |
| 338 | - $list = $list.$item.$delimiter; |
|
| 338 | + $list = $list . $item . $delimiter; |
|
| 339 | 339 | } |
| 340 | 340 | return $list; |
| 341 | 341 | } |
@@ -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,35 +212,35 @@ 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), enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ |
| 226 | - if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
| 227 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
| 228 | - preg_match_all( '/./u', $text, $words_array ); |
|
| 229 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
| 226 | + if ( 'characters' == _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset')) ) { |
|
| 227 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
| 228 | + preg_match_all('/./u', $text, $words_array); |
|
| 229 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
| 230 | 230 | $sep = ''; |
| 231 | 231 | } else { |
| 232 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
| 232 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
| 233 | 233 | $sep = ' '; |
| 234 | 234 | } |
| 235 | - if ( count( $words_array ) > $num_words ) { |
|
| 236 | - array_pop( $words_array ); |
|
| 237 | - $text = implode( $sep, $words_array ); |
|
| 235 | + if ( count($words_array) > $num_words ) { |
|
| 236 | + array_pop($words_array); |
|
| 237 | + $text = implode($sep, $words_array); |
|
| 238 | 238 | $text = $text . $more; |
| 239 | 239 | } else { |
| 240 | - $text = implode( $sep, $words_array ); |
|
| 240 | + $text = implode($sep, $words_array); |
|
| 241 | 241 | } |
| 242 | - $text = self::close_tags( $text ); |
|
| 243 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
| 242 | + $text = self::close_tags($text); |
|
| 243 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -249,29 +249,29 @@ discard block |
||
| 249 | 249 | * @param string $html |
| 250 | 250 | * @return string |
| 251 | 251 | */ |
| 252 | - public static function close_tags( $html ) { |
|
| 252 | + public static function close_tags($html) { |
|
| 253 | 253 | //put all opened tags into an array |
| 254 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
| 254 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
| 255 | 255 | $openedtags = $result[1]; |
| 256 | 256 | //put all closed tags into an array |
| 257 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
| 257 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
| 258 | 258 | $closedtags = $result[1]; |
| 259 | - $len_opened = count( $openedtags ); |
|
| 259 | + $len_opened = count($openedtags); |
|
| 260 | 260 | // all tags are closed |
| 261 | - if ( count( $closedtags ) == $len_opened ) { |
|
| 261 | + if ( count($closedtags) == $len_opened ) { |
|
| 262 | 262 | return $html; |
| 263 | 263 | } |
| 264 | - $openedtags = array_reverse( $openedtags ); |
|
| 264 | + $openedtags = array_reverse($openedtags); |
|
| 265 | 265 | // close tags |
| 266 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
| 267 | - if ( !in_array( $openedtags[$i], $closedtags ) ) { |
|
| 266 | + for ($i = 0; $i < $len_opened; $i++) { |
|
| 267 | + if ( !in_array($openedtags[$i], $closedtags) ) { |
|
| 268 | 268 | $html .= '</' . $openedtags[$i] . '>'; |
| 269 | 269 | } else { |
| 270 | - unset( $closedtags[array_search( $openedtags[$i], $closedtags )] ); |
|
| 270 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | - $html = str_replace(array('</br>','</hr>','</wbr>'), '', $html); |
|
| 274 | - $html = str_replace(array('<br>','<hr>','<wbr>'), array('<br />','<hr />','<wbr />'), $html); |
|
| 273 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
| 274 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
| 275 | 275 | return $html; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -284,17 +284,17 @@ discard block |
||
| 284 | 284 | * @return array|int |
| 285 | 285 | * @deprecated 0.20.0 |
| 286 | 286 | */ |
| 287 | - public static function get_posts_by_meta( $key, $value ) { |
|
| 287 | + public static function get_posts_by_meta($key, $value) { |
|
| 288 | 288 | global $wpdb; |
| 289 | - $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value ); |
|
| 290 | - $results = $wpdb->get_col( $query ); |
|
| 289 | + $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value); |
|
| 290 | + $results = $wpdb->get_col($query); |
|
| 291 | 291 | $pids = array(); |
| 292 | - foreach ( $results as $result ) { |
|
| 293 | - if ( get_post( $result ) ) { |
|
| 292 | + foreach ($results as $result) { |
|
| 293 | + if ( get_post($result) ) { |
|
| 294 | 294 | $pids[] = $result; |
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | - if ( count( $pids ) ) { |
|
| 297 | + if ( count($pids) ) { |
|
| 298 | 298 | return $pids; |
| 299 | 299 | } |
| 300 | 300 | return 0; |
@@ -308,12 +308,12 @@ discard block |
||
| 308 | 308 | * @return int |
| 309 | 309 | * @deprecated 0.20.0 |
| 310 | 310 | */ |
| 311 | - public static function get_post_by_meta( $key, $value ) { |
|
| 311 | + public static function get_post_by_meta($key, $value) { |
|
| 312 | 312 | global $wpdb; |
| 313 | - $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value ); |
|
| 314 | - $results = $wpdb->get_col( $query ); |
|
| 315 | - foreach ( $results as $result ) { |
|
| 316 | - if ( $result && get_post( $result ) ) { |
|
| 313 | + $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value); |
|
| 314 | + $results = $wpdb->get_col($query); |
|
| 315 | + foreach ($results as $result) { |
|
| 316 | + if ( $result && get_post($result) ) { |
|
| 317 | 317 | return $result; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -326,10 +326,10 @@ discard block |
||
| 326 | 326 | * @param int $ttid |
| 327 | 327 | * @return mixed |
| 328 | 328 | */ |
| 329 | - public static function get_term_id_by_term_taxonomy_id( $ttid ) { |
|
| 329 | + public static function get_term_id_by_term_taxonomy_id($ttid) { |
|
| 330 | 330 | global $wpdb; |
| 331 | - $query = $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid ); |
|
| 332 | - return $wpdb->get_var( $query ); |
|
| 331 | + $query = $wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid); |
|
| 332 | + return $wpdb->get_var($query); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /* Object Utilities |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @param string $prop |
| 343 | 343 | * @return void |
| 344 | 344 | */ |
| 345 | - public static function osort( &$array, $prop ) { |
|
| 346 | - usort( $array, function ( $a, $b ) use ( $prop ) { |
|
| 345 | + public static function osort(&$array, $prop) { |
|
| 346 | + usort($array, function($a, $b) use ($prop) { |
|
| 347 | 347 | return $a->$prop > $b->$prop ? 1 : -1; |
| 348 | 348 | } ); |
| 349 | 349 | } |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | * @param array $arr |
| 355 | 355 | * @return bool |
| 356 | 356 | */ |
| 357 | - public static function is_array_assoc( $arr ) { |
|
| 358 | - if ( !is_array( $arr ) ) { |
|
| 357 | + public static function is_array_assoc($arr) { |
|
| 358 | + if ( !is_array($arr) ) { |
|
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | - return (bool)count( array_filter( array_keys( $arr ), 'is_string' ) ); |
|
| 361 | + return (bool) count(array_filter(array_keys($arr), 'is_string')); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -367,11 +367,11 @@ discard block |
||
| 367 | 367 | * @param array $array |
| 368 | 368 | * @return stdClass |
| 369 | 369 | */ |
| 370 | - public static function array_to_object( $array ) { |
|
| 370 | + public static function array_to_object($array) { |
|
| 371 | 371 | $obj = new stdClass; |
| 372 | - foreach ( $array as $k => $v ) { |
|
| 373 | - if ( is_array( $v ) ) { |
|
| 374 | - $obj->{$k} = self::array_to_object( $v ); //RECURSION |
|
| 372 | + foreach ($array as $k => $v) { |
|
| 373 | + if ( is_array($v) ) { |
|
| 374 | + $obj->{$k} = self::array_to_object($v); //RECURSION |
|
| 375 | 375 | } else { |
| 376 | 376 | $obj->{$k} = $v; |
| 377 | 377 | } |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | * @param mixed $value |
| 388 | 388 | * @return bool|int |
| 389 | 389 | */ |
| 390 | - public static function get_object_index_by_property( $array, $key, $value ) { |
|
| 391 | - if ( is_array( $array ) ) { |
|
| 390 | + public static function get_object_index_by_property($array, $key, $value) { |
|
| 391 | + if ( is_array($array) ) { |
|
| 392 | 392 | $i = 0; |
| 393 | - foreach ( $array as $arr ) { |
|
| 394 | - if ( is_array( $arr ) ) { |
|
| 393 | + foreach ($array as $arr) { |
|
| 394 | + if ( is_array($arr) ) { |
|
| 395 | 395 | if ( $arr[$key] == $value ) { |
| 396 | 396 | return $i; |
| 397 | 397 | } |
@@ -415,16 +415,16 @@ discard block |
||
| 415 | 415 | * @return array|null |
| 416 | 416 | * @throws Exception |
| 417 | 417 | */ |
| 418 | - public static function get_object_by_property( $array, $key, $value ) { |
|
| 419 | - if ( is_array( $array ) ) { |
|
| 420 | - foreach ( $array as $arr ) { |
|
| 418 | + public static function get_object_by_property($array, $key, $value) { |
|
| 419 | + if ( is_array($array) ) { |
|
| 420 | + foreach ($array as $arr) { |
|
| 421 | 421 | if ( $arr->$key == $value ) { |
| 422 | 422 | return $arr; |
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | } else { |
| 426 | - throw new InvalidArgumentException( '$array is not an array, got:' ); |
|
| 427 | - TimberHelper::error_log( $array ); |
|
| 426 | + throw new InvalidArgumentException('$array is not an array, got:'); |
|
| 427 | + TimberHelper::error_log($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,28 +512,28 @@ discard block |
||
| 512 | 512 | 'current' => 0, |
| 513 | 513 | 'show_all' => false, |
| 514 | 514 | 'prev_next' => false, |
| 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 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
| 536 | - $n_display = number_format_i18n( $n ); |
|
| 535 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
| 536 | + $n_display = number_format_i18n($n); |
|
| 537 | 537 | if ( $n == $args['current'] ) { |
| 538 | 538 | $page_links[] = array( |
| 539 | 539 | 'class' => 'page-number page-numbers current', |
@@ -544,18 +544,18 @@ discard block |
||
| 544 | 544 | ); |
| 545 | 545 | $dots = true; |
| 546 | 546 | } else { |
| 547 | - 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'] ) ) { |
|
| 548 | - $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); |
|
| 549 | - $link = str_replace( '%#%', $n, $link ); |
|
| 550 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
| 547 | + 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']) ) { |
|
| 548 | + $link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']); |
|
| 549 | + $link = str_replace('%#%', $n, $link); |
|
| 550 | + $link = trailingslashit($link) . ltrim($args['add_fragment'], '/'); |
|
| 551 | 551 | if ( $args['add_args'] ) { |
| 552 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
| 552 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
| 553 | 553 | } |
| 554 | 554 | $link = str_replace(' ', '+', $link); |
| 555 | - $link = untrailingslashit( $link ); |
|
| 555 | + $link = untrailingslashit($link); |
|
| 556 | 556 | $page_links[] = array( |
| 557 | 557 | 'class' => 'page-number page-numbers', |
| 558 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
| 558 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
| 559 | 559 | 'title' => $n_display, |
| 560 | 560 | 'name' => $n_display, |
| 561 | 561 | 'current' => $args['current'] == $n |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | } elseif ( $dots && !$args['show_all'] ) { |
| 565 | 565 | $page_links[] = array( |
| 566 | 566 | 'class' => 'dots', |
| 567 | - 'title' => __( '…' ) |
|
| 567 | + 'title' => __('…') |
|
| 568 | 568 | ); |
| 569 | 569 | $dots = false; |
| 570 | 570 | } |
@@ -583,8 +583,8 @@ discard block |
||
| 583 | 583 | /** |
| 584 | 584 | * @deprecated 0.18.0 |
| 585 | 585 | */ |
| 586 | - static function is_url( $url ) { |
|
| 587 | - return TimberURLHelper::is_url( $url ); |
|
| 586 | + static function is_url($url) { |
|
| 587 | + return TimberURLHelper::is_url($url); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -597,71 +597,71 @@ discard block |
||
| 597 | 597 | /** |
| 598 | 598 | * @deprecated 0.18.0 |
| 599 | 599 | */ |
| 600 | - static function get_rel_url( $url, $force = false ) { |
|
| 601 | - return TimberURLHelper::get_rel_url( $url, $force ); |
|
| 600 | + static function get_rel_url($url, $force = false) { |
|
| 601 | + return TimberURLHelper::get_rel_url($url, $force); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
| 605 | 605 | * @deprecated 0.18.0 |
| 606 | 606 | */ |
| 607 | - static function is_local( $url ) { |
|
| 608 | - return TimberURLHelper::is_local( $url ); |
|
| 607 | + static function is_local($url) { |
|
| 608 | + return TimberURLHelper::is_local($url); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | 612 | * @deprecated 0.18.0 |
| 613 | 613 | */ |
| 614 | - static function get_full_path( $src ) { |
|
| 615 | - return TimberURLHelper::get_full_path( $src ); |
|
| 614 | + static function get_full_path($src) { |
|
| 615 | + return TimberURLHelper::get_full_path($src); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
| 619 | 619 | * @deprecated 0.18.0 |
| 620 | 620 | */ |
| 621 | - static function get_rel_path( $src ) { |
|
| 622 | - return TimberURLHelper::get_rel_path( $src ); |
|
| 621 | + static function get_rel_path($src) { |
|
| 622 | + return TimberURLHelper::get_rel_path($src); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
| 626 | 626 | * @deprecated 0.18.0 |
| 627 | 627 | */ |
| 628 | - static function remove_double_slashes( $url ) { |
|
| 629 | - return TimberURLHelper::remove_double_slashes( $url ); |
|
| 628 | + static function remove_double_slashes($url) { |
|
| 629 | + return TimberURLHelper::remove_double_slashes($url); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | /** |
| 633 | 633 | * @deprecated 0.18.0 |
| 634 | 634 | */ |
| 635 | - static function prepend_to_url( $url, $path ) { |
|
| 636 | - return TimberURLHelper::prepend_to_url( $url, $path ); |
|
| 635 | + static function prepend_to_url($url, $path) { |
|
| 636 | + return TimberURLHelper::prepend_to_url($url, $path); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
| 640 | 640 | * @deprecated 0.18.0 |
| 641 | 641 | */ |
| 642 | - static function preslashit( $path ) { |
|
| 643 | - return TimberURLHelper::preslashit( $path ); |
|
| 642 | + static function preslashit($path) { |
|
| 643 | + return TimberURLHelper::preslashit($path); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | /** |
| 647 | 647 | * @deprecated 0.18.0 |
| 648 | 648 | */ |
| 649 | - static function is_external( $url ) { |
|
| 650 | - return TimberURLHelper::is_external( $url ); |
|
| 649 | + static function is_external($url) { |
|
| 650 | + return TimberURLHelper::is_external($url); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * @deprecated 0.18.0 |
| 655 | 655 | */ |
| 656 | - static function download_url( $url, $timeout = 300 ) { |
|
| 657 | - return TimberURLHelper::download_url( $url, $timeout ); |
|
| 656 | + static function download_url($url, $timeout = 300) { |
|
| 657 | + return TimberURLHelper::download_url($url, $timeout); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
| 661 | 661 | * @deprecated 0.18.0 |
| 662 | 662 | */ |
| 663 | - static function get_params( $i = -1 ) { |
|
| 664 | - return TimberURLHelper::get_params( $i ); |
|
| 663 | + static function get_params($i = -1) { |
|
| 664 | + return TimberURLHelper::get_params($i); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | } |
@@ -14,11 +14,11 @@ discard block |
||
| 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 | } |
@@ -71,16 +71,16 @@ discard block |
||
| 71 | 71 | if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) { |
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | - if ( version_compare( phpversion(), '5.3.0', '<' ) && !is_admin() ) { |
|
| 75 | - trigger_error( 'Timber requires PHP 5.3.0 or greater. You have '.phpversion(), E_USER_ERROR ); |
|
| 74 | + if ( version_compare(phpversion(), '5.3.0', '<') && !is_admin() ) { |
|
| 75 | + trigger_error('Timber requires PHP 5.3.0 or greater. You have ' . phpversion(), E_USER_ERROR); |
|
| 76 | 76 | } |
| 77 | - if ( !class_exists( 'Twig_Autoloader' ) ) { |
|
| 78 | - 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 ); |
|
| 77 | + if ( !class_exists('Twig_Autoloader') ) { |
|
| 78 | + 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); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | function init_constants() { |
| 83 | - defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( __DIR__ ) ); |
|
| 83 | + defined("TIMBER_LOC") or define("TIMBER_LOC", realpath(__DIR__)); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | protected function init() { |
| 90 | 90 | TimberTwig::init(); |
| 91 | - TimberRoutes::init( $this ); |
|
| 91 | + TimberRoutes::init($this); |
|
| 92 | 92 | TimberImageHelper::init(); |
| 93 | 93 | TimberAdmin::init(); |
| 94 | 94 | TimberIntegrations::init(); |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $PostClass |
| 105 | 105 | * @return array|bool|null |
| 106 | 106 | */ |
| 107 | - public static function get_post( $query = false, $PostClass = 'TimberPost' ) { |
|
| 108 | - return TimberPostGetter::get_post( $query, $PostClass ); |
|
| 107 | + public static function get_post($query = false, $PostClass = 'TimberPost') { |
|
| 108 | + return TimberPostGetter::get_post($query, $PostClass); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | * @param string $PostClass |
| 116 | 116 | * @return array|bool|null |
| 117 | 117 | */ |
| 118 | - public static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) { |
|
| 119 | - return TimberPostGetter::get_posts( $query, $PostClass, $return_collection ); |
|
| 118 | + public static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) { |
|
| 119 | + return TimberPostGetter::get_posts($query, $PostClass, $return_collection); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * @param string $PostClass |
| 127 | 127 | * @return array|bool|null |
| 128 | 128 | */ |
| 129 | - public static function query_post( $query = false, $PostClass = 'TimberPost' ) { |
|
| 130 | - return TimberPostGetter::query_post( $query, $PostClass ); |
|
| 129 | + public static function query_post($query = false, $PostClass = 'TimberPost') { |
|
| 130 | + return TimberPostGetter::query_post($query, $PostClass); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | * @param string $PostClass |
| 138 | 138 | * @return array|bool|null |
| 139 | 139 | */ |
| 140 | - public static function query_posts( $query = false, $PostClass = 'TimberPost' ) { |
|
| 141 | - return TimberPostGetter::query_posts( $query, $PostClass ); |
|
| 140 | + public static function query_posts($query = false, $PostClass = 'TimberPost') { |
|
| 141 | + return TimberPostGetter::query_posts($query, $PostClass); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | * @return array |
| 149 | 149 | * @deprecated since 0.20.0 |
| 150 | 150 | */ |
| 151 | - static function get_pids( $query = null ) { |
|
| 152 | - return TimberPostGetter::get_pids( $query ); |
|
| 151 | + static function get_pids($query = null) { |
|
| 152 | + return TimberPostGetter::get_pids($query); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | * @return array |
| 160 | 160 | * @deprecated since 0.20.0 |
| 161 | 161 | */ |
| 162 | - static function get_posts_from_loop( $PostClass ) { |
|
| 163 | - return TimberPostGetter::get_posts( $PostClass ); |
|
| 162 | + static function get_posts_from_loop($PostClass) { |
|
| 163 | + return TimberPostGetter::get_posts($PostClass); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @return array |
| 172 | 172 | * @deprecated since 0.20.0 |
| 173 | 173 | */ |
| 174 | - static function get_posts_from_slug( $slug, $PostClass = 'TimberPost' ) { |
|
| 175 | - return TimberPostGetter::get_posts( $slug, $PostClass ); |
|
| 174 | + static function get_posts_from_slug($slug, $PostClass = 'TimberPost') { |
|
| 175 | + return TimberPostGetter::get_posts($slug, $PostClass); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | * @return array |
| 184 | 184 | * @deprecated since 0.20.0 |
| 185 | 185 | */ |
| 186 | - static function get_posts_from_wp_query( $query = array(), $PostClass = 'TimberPost' ) { |
|
| 187 | - return TimberPostGetter::query_posts( $query, $PostClass ); |
|
| 186 | + static function get_posts_from_wp_query($query = array(), $PostClass = 'TimberPost') { |
|
| 187 | + return TimberPostGetter::query_posts($query, $PostClass); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | * @return array|null |
| 196 | 196 | * @deprecated since 0.20.0 |
| 197 | 197 | */ |
| 198 | - static function get_posts_from_array_of_ids( $query = array(), $PostClass = 'TimberPost' ) { |
|
| 199 | - return TimberPostGetter::get_posts( $query, $PostClass ); |
|
| 198 | + static function get_posts_from_array_of_ids($query = array(), $PostClass = 'TimberPost') { |
|
| 199 | + return TimberPostGetter::get_posts($query, $PostClass); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * @return int |
| 207 | 207 | * @deprecated since 0.20.0 |
| 208 | 208 | */ |
| 209 | - static function get_pid( $query ) { |
|
| 210 | - $pids = TimberPostGetter::get_pids( $query ); |
|
| 211 | - if ( is_array( $pids ) && count( $pids ) ) { |
|
| 209 | + static function get_pid($query) { |
|
| 210 | + $pids = TimberPostGetter::get_pids($query); |
|
| 211 | + if ( is_array($pids) && count($pids) ) { |
|
| 212 | 212 | return $pids[0]; |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | * @param string $TermClass |
| 235 | 235 | * @return mixed |
| 236 | 236 | */ |
| 237 | - public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) { |
|
| 238 | - return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass ); |
|
| 237 | + public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') { |
|
| 238 | + return TimberTermGetter::get_terms($args, $maybe_args, $TermClass); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /* Site Retrieval |
@@ -247,14 +247,14 @@ discard block |
||
| 247 | 247 | * @param array|bool $blog_ids |
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | - public static function get_sites( $blog_ids = false ) { |
|
| 251 | - if ( !is_array( $blog_ids ) ) { |
|
| 250 | + public static function get_sites($blog_ids = false) { |
|
| 251 | + if ( !is_array($blog_ids) ) { |
|
| 252 | 252 | global $wpdb; |
| 253 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC" ); |
|
| 253 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC"); |
|
| 254 | 254 | } |
| 255 | 255 | $return = array(); |
| 256 | - foreach ( $blog_ids as $blog_id ) { |
|
| 257 | - $return[] = new TimberSite( $blog_id ); |
|
| 256 | + foreach ($blog_ids as $blog_id) { |
|
| 257 | + $return[] = new TimberSite($blog_id); |
|
| 258 | 258 | } |
| 259 | 259 | return $return; |
| 260 | 260 | } |
@@ -272,29 +272,29 @@ discard block |
||
| 272 | 272 | $data = array(); |
| 273 | 273 | $data['http_host'] = 'http://' . TimberURLHelper::get_host(); |
| 274 | 274 | $data['wp_title'] = TimberHelper::get_wp_title(); |
| 275 | - $data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' ); |
|
| 276 | - $data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' ); |
|
| 277 | - $data['body_class'] = implode( ' ', get_body_class() ); |
|
| 275 | + $data['wp_head'] = TimberHelper::function_wrapper('wp_head'); |
|
| 276 | + $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer'); |
|
| 277 | + $data['body_class'] = implode(' ', get_body_class()); |
|
| 278 | 278 | |
| 279 | 279 | $data['site'] = new TimberSite(); |
| 280 | 280 | $data['theme'] = $data['site']->theme; |
| 281 | 281 | //deprecated, these should be fetched via TimberSite or TimberTheme |
| 282 | - $data['theme_dir'] = WP_CONTENT_SUBDIR.str_replace( WP_CONTENT_DIR, '', get_stylesheet_directory() ); |
|
| 283 | - $data['language_attributes'] = TimberHelper::function_wrapper( 'language_attributes' ); |
|
| 282 | + $data['theme_dir'] = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory()); |
|
| 283 | + $data['language_attributes'] = TimberHelper::function_wrapper('language_attributes'); |
|
| 284 | 284 | $data['stylesheet_uri'] = get_stylesheet_uri(); |
| 285 | 285 | $data['template_uri'] = get_template_directory_uri(); |
| 286 | 286 | |
| 287 | 287 | $data['posts'] = Timber::query_posts(); |
| 288 | 288 | |
| 289 | 289 | //deprecated, this should be fetched via TimberMenu |
| 290 | - if ( function_exists( 'wp_nav_menu' ) ) { |
|
| 290 | + if ( function_exists('wp_nav_menu') ) { |
|
| 291 | 291 | $locations = get_nav_menu_locations(); |
| 292 | - if ( count( $locations ) ) { |
|
| 293 | - $data['wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) ); |
|
| 292 | + if ( count($locations) ) { |
|
| 293 | + $data['wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu')); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | - $data = apply_filters( 'timber_context', $data ); |
|
| 297 | - $data = apply_filters( 'timber/context', $data ); |
|
| 296 | + $data = apply_filters('timber_context', $data); |
|
| 297 | + $data = apply_filters('timber/context', $data); |
|
| 298 | 298 | return $data; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -308,27 +308,27 @@ discard block |
||
| 308 | 308 | * @param bool $via_render |
| 309 | 309 | * @return bool|string |
| 310 | 310 | */ |
| 311 | - public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) { |
|
| 311 | + public static function compile($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false) { |
|
| 312 | 312 | $caller = self::get_calling_script_dir(); |
| 313 | 313 | $caller_file = self::get_calling_script_file(); |
| 314 | - $caller_file = apply_filters( 'timber_calling_php_file', $caller_file ); |
|
| 315 | - $loader = new TimberLoader( $caller ); |
|
| 316 | - $file = $loader->choose_template( $filenames ); |
|
| 314 | + $caller_file = apply_filters('timber_calling_php_file', $caller_file); |
|
| 315 | + $loader = new TimberLoader($caller); |
|
| 316 | + $file = $loader->choose_template($filenames); |
|
| 317 | 317 | $output = ''; |
| 318 | - if ( is_null( $data ) ) { |
|
| 318 | + if ( is_null($data) ) { |
|
| 319 | 319 | $data = array(); |
| 320 | 320 | } |
| 321 | - if ( strlen( $file ) ) { |
|
| 321 | + if ( strlen($file) ) { |
|
| 322 | 322 | if ( $via_render ) { |
| 323 | - $file = apply_filters( 'timber_render_file', $file ); |
|
| 324 | - $data = apply_filters( 'timber_render_data', $data ); |
|
| 323 | + $file = apply_filters('timber_render_file', $file); |
|
| 324 | + $data = apply_filters('timber_render_data', $data); |
|
| 325 | 325 | } else { |
| 326 | - $file = apply_filters( 'timber_compile_file', $file ); |
|
| 327 | - $data = apply_filters( 'timber_compile_data', $data ); |
|
| 326 | + $file = apply_filters('timber_compile_file', $file); |
|
| 327 | + $data = apply_filters('timber_compile_data', $data); |
|
| 328 | 328 | } |
| 329 | - $output = $loader->render( $file, $data, $expires, $cache_mode ); |
|
| 329 | + $output = $loader->render($file, $data, $expires, $cache_mode); |
|
| 330 | 330 | } |
| 331 | - do_action( 'timber_compile_done' ); |
|
| 331 | + do_action('timber_compile_done'); |
|
| 332 | 332 | return $output; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | * @param array $data an array with data in it. |
| 340 | 340 | * @return bool|string |
| 341 | 341 | */ |
| 342 | - public static function compile_string( $string, $data = array() ) { |
|
| 342 | + public static function compile_string($string, $data = array()) { |
|
| 343 | 343 | $dummy_loader = new TimberLoader(); |
| 344 | 344 | $dummy_loader->get_twig(); |
| 345 | 345 | $loader = new Twig_Loader_String(); |
| 346 | - $twig = new Twig_Environment( $loader ); |
|
| 347 | - $twig = apply_filters( 'timber/twig/filters', $twig ); |
|
| 348 | - $twig = apply_filters( 'twig_apply_filters', $twig ); |
|
| 349 | - return $twig->render( $string, $data ); |
|
| 346 | + $twig = new Twig_Environment($loader); |
|
| 347 | + $twig = apply_filters('timber/twig/filters', $twig); |
|
| 348 | + $twig = apply_filters('twig_apply_filters', $twig); |
|
| 349 | + return $twig->render($string, $data); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -358,15 +358,15 @@ discard block |
||
| 358 | 358 | * @param string $cache_mode |
| 359 | 359 | * @return bool|string |
| 360 | 360 | */ |
| 361 | - public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
|
| 361 | + public static function fetch($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) { |
|
| 362 | 362 | if ( $expires === true ) { |
| 363 | 363 | //if this is reading as true; the user probably is using the old $echo param |
| 364 | 364 | //so we should move all vars up by a spot |
| 365 | 365 | $expires = $cache_mode; |
| 366 | 366 | $cache_mode = TimberLoader::CACHE_USE_DEFAULT; |
| 367 | 367 | } |
| 368 | - $output = self::compile( $filenames, $data, $expires, $cache_mode, true ); |
|
| 369 | - $output = apply_filters( 'timber_compile_result', $output ); |
|
| 368 | + $output = self::compile($filenames, $data, $expires, $cache_mode, true); |
|
| 369 | + $output = apply_filters('timber_compile_result', $output); |
|
| 370 | 370 | return $output; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -379,8 +379,8 @@ discard block |
||
| 379 | 379 | * @param string $cache_mode |
| 380 | 380 | * @return bool|string |
| 381 | 381 | */ |
| 382 | - public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
|
| 383 | - $output = static::fetch( $filenames, $data, $expires, $cache_mode ); |
|
| 382 | + public static function render($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) { |
|
| 383 | + $output = static::fetch($filenames, $data, $expires, $cache_mode); |
|
| 384 | 384 | echo $output; |
| 385 | 385 | return $output; |
| 386 | 386 | } |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | * @param array $data an array with data in it. |
| 393 | 393 | * @return bool|string |
| 394 | 394 | */ |
| 395 | - public static function render_string( $string, $data = array() ) { |
|
| 396 | - $compiled = self::compile_string( $string, $data ); |
|
| 395 | + public static function render_string($string, $data = array()) { |
|
| 396 | + $compiled = self::compile_string($string, $data); |
|
| 397 | 397 | echo $compiled; |
| 398 | 398 | return $compiled; |
| 399 | 399 | } |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | * @param array $data |
| 410 | 410 | * @return bool|string |
| 411 | 411 | */ |
| 412 | - public static function get_sidebar( $sidebar = '', $data = array() ) { |
|
| 412 | + public static function get_sidebar($sidebar = '', $data = array()) { |
|
| 413 | 413 | if ( $sidebar == '' ) { |
| 414 | 414 | $sidebar = 'sidebar.php'; |
| 415 | 415 | } |
| 416 | - if ( strstr( strtolower( $sidebar ), '.php' ) ) { |
|
| 417 | - return self::get_sidebar_from_php( $sidebar, $data ); |
|
| 416 | + if ( strstr(strtolower($sidebar), '.php') ) { |
|
| 417 | + return self::get_sidebar_from_php($sidebar, $data); |
|
| 418 | 418 | } |
| 419 | - return self::compile( $sidebar, $data ); |
|
| 419 | + return self::compile($sidebar, $data); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
@@ -426,21 +426,21 @@ discard block |
||
| 426 | 426 | * @param array $data |
| 427 | 427 | * @return string |
| 428 | 428 | */ |
| 429 | - public static function get_sidebar_from_php( $sidebar = '', $data ) { |
|
| 429 | + public static function get_sidebar_from_php($sidebar = '', $data) { |
|
| 430 | 430 | $caller = self::get_calling_script_dir(); |
| 431 | 431 | $loader = new TimberLoader(); |
| 432 | - $uris = $loader->get_locations( $caller ); |
|
| 432 | + $uris = $loader->get_locations($caller); |
|
| 433 | 433 | ob_start(); |
| 434 | 434 | $found = false; |
| 435 | - foreach ( $uris as $uri ) { |
|
| 436 | - if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) { |
|
| 437 | - include trailingslashit( $uri ) . $sidebar; |
|
| 435 | + foreach ($uris as $uri) { |
|
| 436 | + if ( file_exists(trailingslashit($uri) . $sidebar) ) { |
|
| 437 | + include trailingslashit($uri) . $sidebar; |
|
| 438 | 438 | $found = true; |
| 439 | 439 | break; |
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | if ( !$found ) { |
| 443 | - TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' ); |
|
| 443 | + TimberHelper::error_log('error loading your sidebar, check to make sure the file exists'); |
|
| 444 | 444 | } |
| 445 | 445 | $ret = ob_get_contents(); |
| 446 | 446 | ob_end_clean(); |
@@ -456,8 +456,8 @@ discard block |
||
| 456 | 456 | * @param int $widget_id |
| 457 | 457 | * @return TimberFunctionWrapper |
| 458 | 458 | */ |
| 459 | - public static function get_widgets( $widget_id ) { |
|
| 460 | - return TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true ); |
|
| 459 | + public static function get_widgets($widget_id) { |
|
| 460 | + return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true); |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | |
@@ -472,15 +472,15 @@ discard block |
||
| 472 | 472 | * @param array $args |
| 473 | 473 | * @deprecated since 0.20.0 |
| 474 | 474 | */ |
| 475 | - public static function add_route( $route, $callback, $args = array() ) { |
|
| 476 | - Routes::map( $route, $callback, $args ); |
|
| 475 | + public static function add_route($route, $callback, $args = array()) { |
|
| 476 | + Routes::map($route, $callback, $args); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
| 480 | 480 | * @deprecated since 0.22.2 |
| 481 | 481 | */ |
| 482 | 482 | public function cancel_query() { |
| 483 | - add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) ); |
|
| 483 | + add_action('posts_request', array($this, 'cancel_query_posts_request')); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -497,8 +497,8 @@ discard block |
||
| 497 | 497 | * |
| 498 | 498 | * @deprecated since 0.20.0 |
| 499 | 499 | */ |
| 500 | - public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) { |
|
| 501 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
| 500 | + public static function load_template($template, $query = false, $status_code = 200, $tparams = false) { |
|
| 501 | + return Routes::load($template, $tparams, $query, $status_code); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
@@ -506,8 +506,8 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @deprecated since 0.20.2 |
| 508 | 508 | */ |
| 509 | - public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) { |
|
| 510 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
| 509 | + public static function load_view($template, $query = false, $status_code = 200, $tparams = false) { |
|
| 510 | + return Routes::load($template, $tparams, $query, $status_code); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | |
@@ -520,43 +520,43 @@ discard block |
||
| 520 | 520 | * @param array $prefs |
| 521 | 521 | * @return array mixed |
| 522 | 522 | */ |
| 523 | - public static function get_pagination( $prefs = array() ) { |
|
| 523 | + public static function get_pagination($prefs = array()) { |
|
| 524 | 524 | global $wp_query; |
| 525 | 525 | global $paged; |
| 526 | 526 | global $wp_rewrite; |
| 527 | 527 | $args = array(); |
| 528 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 528 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 529 | 529 | if ( $wp_rewrite->using_permalinks() ) { |
| 530 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 531 | - if ( isset( $url[1] ) ) { |
|
| 532 | - parse_str( $url[1], $query ); |
|
| 530 | + $url = explode('?', get_pagenum_link(0)); |
|
| 531 | + if ( isset($url[1]) ) { |
|
| 532 | + parse_str($url[1], $query); |
|
| 533 | 533 | $args['add_args'] = $query; |
| 534 | 534 | } |
| 535 | 535 | $args['format'] = 'page/%#%'; |
| 536 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 536 | + $args['base'] = trailingslashit($url[0]) . '%_%'; |
|
| 537 | 537 | } else { |
| 538 | 538 | $big = 999999999; |
| 539 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 539 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 540 | 540 | } |
| 541 | 541 | $args['type'] = 'array'; |
| 542 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 543 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 544 | - if ( is_int( $prefs ) ) { |
|
| 542 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 543 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 544 | + if ( is_int($prefs) ) { |
|
| 545 | 545 | $args['mid_size'] = $prefs - 2; |
| 546 | 546 | } else { |
| 547 | - $args = array_merge( $args, $prefs ); |
|
| 547 | + $args = array_merge($args, $prefs); |
|
| 548 | 548 | } |
| 549 | 549 | $data = array(); |
| 550 | 550 | $data['current'] = $args['current']; |
| 551 | 551 | $data['total'] = $args['total']; |
| 552 | - $data['pages'] = TimberHelper::paginate_links( $args ); |
|
| 553 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 552 | + $data['pages'] = TimberHelper::paginate_links($args); |
|
| 553 | + $next = get_next_posts_page_link($args['total']); |
|
| 554 | 554 | if ( $next ) { |
| 555 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 555 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 556 | 556 | } |
| 557 | - $prev = previous_posts( false ); |
|
| 557 | + $prev = previous_posts(false); |
|
| 558 | 558 | if ( $prev ) { |
| 559 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 559 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 560 | 560 | } |
| 561 | 561 | if ( $paged < 2 ) { |
| 562 | 562 | $data['prev'] = ''; |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | * @return string |
| 575 | 575 | * @deprecated since 0.20.0 |
| 576 | 576 | */ |
| 577 | - public static function get_calling_script_path( $offset = 0 ) { |
|
| 578 | - $dir = self::get_calling_script_dir( $offset ); |
|
| 579 | - return str_replace( ABSPATH, '', realpath( $dir ) ); |
|
| 577 | + public static function get_calling_script_path($offset = 0) { |
|
| 578 | + $dir = self::get_calling_script_dir($offset); |
|
| 579 | + return str_replace(ABSPATH, '', realpath($dir)); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -584,10 +584,10 @@ discard block |
||
| 584 | 584 | * |
| 585 | 585 | * @return string |
| 586 | 586 | */ |
| 587 | - public static function get_calling_script_dir( $offset = 0 ) { |
|
| 588 | - $caller = self::get_calling_script_file( $offset ); |
|
| 589 | - if ( !is_null( $caller ) ) { |
|
| 590 | - $pathinfo = pathinfo( $caller ); |
|
| 587 | + public static function get_calling_script_dir($offset = 0) { |
|
| 588 | + $caller = self::get_calling_script_file($offset); |
|
| 589 | + if ( !is_null($caller) ) { |
|
| 590 | + $pathinfo = pathinfo($caller); |
|
| 591 | 591 | $dir = $pathinfo['dirname']; |
| 592 | 592 | return $dir; |
| 593 | 593 | } |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | * @return string|null |
| 601 | 601 | * @deprecated since 0.20.0 |
| 602 | 602 | */ |
| 603 | - public static function get_calling_script_file( $offset = 0 ) { |
|
| 603 | + public static function get_calling_script_file($offset = 0) { |
|
| 604 | 604 | $caller = null; |
| 605 | 605 | $backtrace = debug_backtrace(); |
| 606 | 606 | $i = 0; |
| 607 | - foreach ( $backtrace as $trace ) { |
|
| 607 | + foreach ($backtrace as $trace) { |
|
| 608 | 608 | if ( $trace['file'] != __FILE__ ) { |
| 609 | 609 | $caller = $trace['file']; |
| 610 | 610 | break; |
@@ -624,8 +624,8 @@ discard block |
||
| 624 | 624 | * @return bool |
| 625 | 625 | * @deprecated since 0.20.0 |
| 626 | 626 | */ |
| 627 | - public static function is_post_class_or_class_map( $args ) { |
|
| 628 | - return TimberPostGetter::is_post_class_or_class_map( $args ); |
|
| 627 | + public static function is_post_class_or_class_map($args) { |
|
| 628 | + return TimberPostGetter::is_post_class_or_class_map($args); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param mixed $pid |
| 169 | 169 | */ |
| 170 | 170 | public function __construct($pid = null) { |
| 171 | - $pid = $this->determine_id( $pid ); |
|
| 171 | + $pid = $this->determine_id($pid); |
|
| 172 | 172 | $this->init($pid); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | && get_class($wp_query->queried_object) == 'WP_Post' |
| 189 | 189 | ) { |
| 190 | 190 | $pid = $wp_query->queried_object_id; |
| 191 | - } else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) { |
|
| 191 | + } else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) { |
|
| 192 | 192 | //hack for static page as home page |
| 193 | 193 | $pid = $wp_query->queried_object_id; |
| 194 | 194 | } else if ( $pid === null ) { |
| 195 | 195 | $gtid = false; |
| 196 | 196 | $maybe_post = get_post(); |
| 197 | - if ( isset($maybe_post->ID) ){ |
|
| 197 | + if ( isset($maybe_post->ID) ) { |
|
| 198 | 198 | $gtid = true; |
| 199 | 199 | } |
| 200 | 200 | if ( $gtid ) { |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param string $field |
| 261 | 261 | * @param mixed $value |
| 262 | 262 | */ |
| 263 | - public function update( $field, $value ) { |
|
| 263 | + public function update($field, $value) { |
|
| 264 | 264 | if ( isset($this->ID) ) { |
| 265 | 265 | update_post_meta($this->ID, $field, $value); |
| 266 | 266 | $this->$field = $value; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @param mixed $pid |
| 276 | 276 | * @return WP_Post on success |
| 277 | 277 | */ |
| 278 | - protected function prepare_post_info( $pid = 0 ) { |
|
| 278 | + protected function prepare_post_info($pid = 0) { |
|
| 279 | 279 | if ( is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0 ) { |
| 280 | 280 | $pid = self::check_post_id($pid); |
| 281 | 281 | $post = get_post($pid); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @internal |
| 298 | 298 | * @return integer ID number of a post |
| 299 | 299 | */ |
| 300 | - protected function check_post_id( $pid ) { |
|
| 300 | + protected function check_post_id($pid) { |
|
| 301 | 301 | if ( is_numeric($pid) && $pid === 0 ) { |
| 302 | 302 | $pid = get_the_ID(); |
| 303 | 303 | return $pid; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | global $wpdb; |
| 324 | 324 | $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $post_name); |
| 325 | 325 | $result = $wpdb->get_row($query); |
| 326 | - if (!$result) { |
|
| 326 | + if ( !$result ) { |
|
| 327 | 327 | return null; |
| 328 | 328 | } |
| 329 | 329 | return $result->ID; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $text = TimberHelper::trim_words($text, $len, false); |
| 363 | 363 | $trimmed = true; |
| 364 | 364 | } |
| 365 | - $text = do_shortcode( $text ); |
|
| 365 | + $text = do_shortcode($text); |
|
| 366 | 366 | } |
| 367 | 367 | if ( !strlen($text) ) { |
| 368 | 368 | $text = TimberHelper::trim_words($this->get_content(), $len, false); |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | $read_more_class = apply_filters('timber/post/get_preview/read_more_class', "read-more"); |
| 393 | 393 | if ( $readmore && isset($readmore_matches) && !empty($readmore_matches[1]) ) { |
| 394 | - $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore_matches[1]) . '</a>'; |
|
| 394 | + $text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore_matches[1]) . '</a>'; |
|
| 395 | 395 | } elseif ( $readmore ) { |
| 396 | - $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore) . '</a>'; |
|
| 396 | + $text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore) . '</a>'; |
|
| 397 | 397 | } |
| 398 | - if ( !$strip && $last_p_tag && ( strpos($text, '<p>') || strpos($text, '<p ') ) ) { |
|
| 398 | + if ( !$strip && $last_p_tag && (strpos($text, '<p>') || strpos($text, '<p ')) ) { |
|
| 399 | 399 | $text .= '</p>'; |
| 400 | 400 | } |
| 401 | 401 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @internal |
| 408 | 408 | * @param bool|int $pid a post ID number |
| 409 | 409 | */ |
| 410 | - function import_custom( $pid = false ) { |
|
| 410 | + function import_custom($pid = false) { |
|
| 411 | 411 | if ( !$pid ) { |
| 412 | 412 | $pid = $this->ID; |
| 413 | 413 | } |
@@ -422,13 +422,13 @@ discard block |
||
| 422 | 422 | * @param int $pid |
| 423 | 423 | * @return array |
| 424 | 424 | */ |
| 425 | - protected function get_post_custom( $pid ) { |
|
| 425 | + protected function get_post_custom($pid) { |
|
| 426 | 426 | apply_filters('timber_post_get_meta_pre', array(), $pid, $this); |
| 427 | 427 | $customs = get_post_custom($pid); |
| 428 | 428 | if ( !is_array($customs) || empty($customs) ) { |
| 429 | 429 | return array(); |
| 430 | 430 | } |
| 431 | - foreach ( $customs as $key => $value ) { |
|
| 431 | + foreach ($customs as $key => $value) { |
|
| 432 | 432 | if ( is_array($value) && count($value) == 1 && isset($value[0]) ) { |
| 433 | 433 | $value = $value[0]; |
| 434 | 434 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @param bool $taxonomy |
| 483 | 483 | * @return TimberPost|boolean |
| 484 | 484 | */ |
| 485 | - function get_next( $taxonomy = false ) { |
|
| 485 | + function get_next($taxonomy = false) { |
|
| 486 | 486 | if ( !isset($this->_next) || !isset($this->_next[$taxonomy]) ) { |
| 487 | 487 | global $post; |
| 488 | 488 | $this->_next = array(); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | $post = $this; |
| 514 | 514 | $ret = array(); |
| 515 | 515 | if ( $multipage ) { |
| 516 | - for ( $i = 1; $i <= $numpages; $i++ ) { |
|
| 516 | + for ($i = 1; $i <= $numpages; $i++) { |
|
| 517 | 517 | $link = self::get_wp_link_page($i); |
| 518 | 518 | $data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link); |
| 519 | 519 | if ( $i == $page ) { |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * @param bool $taxonomy |
| 566 | 566 | * @return TimberPost|boolean |
| 567 | 567 | */ |
| 568 | - function get_prev( $taxonomy = false ) { |
|
| 568 | + function get_prev($taxonomy = false) { |
|
| 569 | 569 | if ( isset($this->_prev) && isset($this->_prev[$taxonomy]) ) { |
| 570 | 570 | return $this->_prev[$taxonomy]; |
| 571 | 571 | } |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | $post->slug = $post->post_name; |
| 633 | 633 | $customs = $this->get_post_custom($post->ID); |
| 634 | 634 | $post->custom = $customs; |
| 635 | - $post = (object) array_merge((array)$customs, (array)$post); |
|
| 635 | + $post = (object) array_merge((array) $customs, (array) $post); |
|
| 636 | 636 | return $post; |
| 637 | 637 | } |
| 638 | 638 | |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | * @param string $use |
| 644 | 644 | * @return string |
| 645 | 645 | */ |
| 646 | - function get_display_date( $use = 'post_date' ) { |
|
| 646 | + function get_display_date($use = 'post_date') { |
|
| 647 | 647 | return date(get_option('date_format'), strtotime($this->$use)); |
| 648 | 648 | } |
| 649 | 649 | |
@@ -653,9 +653,9 @@ discard block |
||
| 653 | 653 | * @param string $date_format |
| 654 | 654 | * @return string |
| 655 | 655 | */ |
| 656 | - function get_date( $date_format = '' ) { |
|
| 656 | + function get_date($date_format = '') { |
|
| 657 | 657 | $df = $date_format ? $date_format : get_option('date_format'); |
| 658 | - $the_date = (string)mysql2date($df, $this->post_date); |
|
| 658 | + $the_date = (string) mysql2date($df, $this->post_date); |
|
| 659 | 659 | return apply_filters('get_the_date', $the_date, $df); |
| 660 | 660 | } |
| 661 | 661 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | * @param string $date_format |
| 665 | 665 | * @return string |
| 666 | 666 | */ |
| 667 | - function get_modified_date( $date_format = '' ) { |
|
| 667 | + function get_modified_date($date_format = '') { |
|
| 668 | 668 | $df = $date_format ? $date_format : get_option('date_format'); |
| 669 | 669 | $the_time = $this->get_modified_time($df); |
| 670 | 670 | return apply_filters('get_the_modified_date', $the_time, $date_format); |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * @param string $time_format |
| 676 | 676 | * @return string |
| 677 | 677 | */ |
| 678 | - function get_modified_time( $time_format = '' ) { |
|
| 678 | + function get_modified_time($time_format = '') { |
|
| 679 | 679 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 680 | 680 | $the_time = get_post_modified_time($tf, false, $this->ID, true); |
| 681 | 681 | return apply_filters('get_the_modified_time', $the_time, $time_format); |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | * @param bool|string $childPostClass |
| 689 | 689 | * @return array |
| 690 | 690 | */ |
| 691 | - function get_children( $post_type = 'any', $childPostClass = false ) { |
|
| 691 | + function get_children($post_type = 'any', $childPostClass = false) { |
|
| 692 | 692 | if ( $childPostClass === false ) { |
| 693 | 693 | $childPostClass = $this->PostClass; |
| 694 | 694 | } |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | $post_type = $this->post_type; |
| 697 | 697 | } |
| 698 | 698 | $children = get_children('post_parent=' . $this->ID . '&post_type=' . $post_type . '&numberposts=-1&orderby=menu_order title&order=ASC'); |
| 699 | - foreach ( $children as &$child ) { |
|
| 699 | + foreach ($children as &$child) { |
|
| 700 | 700 | $child = new $childPostClass($child->ID); |
| 701 | 701 | } |
| 702 | 702 | $children = array_values($children); |
@@ -732,20 +732,20 @@ discard block |
||
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | if ( $user_ID ) { |
| 735 | - $args['include_unapproved'] = array( $user_ID ); |
|
| 736 | - } elseif ( ! empty( $comment_author_email ) ) { |
|
| 737 | - $args['include_unapproved'] = array( $comment_author_email ); |
|
| 735 | + $args['include_unapproved'] = array($user_ID); |
|
| 736 | + } elseif ( !empty($comment_author_email) ) { |
|
| 737 | + $args['include_unapproved'] = array($comment_author_email); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | $comments = get_comments($args); |
| 741 | 741 | $timber_comments = array(); |
| 742 | 742 | |
| 743 | 743 | if ( '' == get_query_var('cpage') && get_option('page_comments') ) { |
| 744 | - set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
|
| 744 | + set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); |
|
| 745 | 745 | $overridden_cpage = true; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - foreach($comments as $key => &$comment) { |
|
| 748 | + foreach ($comments as $key => &$comment) { |
|
| 749 | 749 | $timber_comment = new $CommentClass($comment); |
| 750 | 750 | $timber_comment->reply_link = $this->TimberComment_reply_link($comment->comment_ID, $this->ID); |
| 751 | 751 | $timber_comments[$timber_comment->id] = $timber_comment; |
@@ -753,22 +753,22 @@ discard block |
||
| 753 | 753 | |
| 754 | 754 | // Build a flattened (depth=1) comment tree |
| 755 | 755 | $comments_tree = array(); |
| 756 | - foreach( $timber_comments as $key => $comment ) { |
|
| 757 | - if ( ! $comment->is_child() ) { |
|
| 756 | + foreach ($timber_comments as $key => $comment) { |
|
| 757 | + if ( !$comment->is_child() ) { |
|
| 758 | 758 | continue; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | $tree_element = $comment; |
| 762 | 762 | do { |
| 763 | 763 | $tree_element = $timber_comments[$tree_element->comment_parent]; |
| 764 | - } while( $tree_element->is_child() ); |
|
| 764 | + } while ($tree_element->is_child()); |
|
| 765 | 765 | |
| 766 | 766 | $comments_tree[$tree_element->id][] = $comment->id; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | // Add child comments to the relative "super parents" |
| 770 | - foreach($comments_tree as $comment_parent => $comment_children) { |
|
| 771 | - foreach($comment_children as $comment_child) { |
|
| 770 | + foreach ($comments_tree as $comment_parent => $comment_children) { |
|
| 771 | + foreach ($comment_children as $comment_child) { |
|
| 772 | 772 | $timber_comments[$comment_parent]->children[] = $timber_comments[$comment_child]; |
| 773 | 773 | unset($timber_comments[$comment_child]); |
| 774 | 774 | } |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | * @param string $TermClass |
| 809 | 809 | * @return array |
| 810 | 810 | */ |
| 811 | - function get_terms( $tax = '', $merge = true, $TermClass = '' ) { |
|
| 811 | + function get_terms($tax = '', $merge = true, $TermClass = '') { |
|
| 812 | 812 | |
| 813 | 813 | $TermClass = $TermClass ?: $this->TermClass; |
| 814 | 814 | |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | $taxonomies = $tax; |
| 820 | 820 | } |
| 821 | 821 | if ( is_string($tax) ) { |
| 822 | - if ( in_array($tax, array('all','any','')) ) { |
|
| 822 | + if ( in_array($tax, array('all', 'any', '')) ) { |
|
| 823 | 823 | $taxonomies = get_object_taxonomies($this->post_type); |
| 824 | 824 | } else { |
| 825 | 825 | $taxonomies = array($tax); |
@@ -828,8 +828,8 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | $term_class_objects = array(); |
| 830 | 830 | |
| 831 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 832 | - if ( in_array($taxonomy, array('tag','tags')) ) { |
|
| 831 | + foreach ($taxonomies as $taxonomy) { |
|
| 832 | + if ( in_array($taxonomy, array('tag', 'tags')) ) { |
|
| 833 | 833 | $taxonomy = 'post_tag'; |
| 834 | 834 | } |
| 835 | 835 | if ( $taxonomy == 'categories' ) { |
@@ -866,11 +866,11 @@ discard block |
||
| 866 | 866 | * @param string $taxonomy |
| 867 | 867 | * @return bool |
| 868 | 868 | */ |
| 869 | - function has_term( $term_name_or_id, $taxonomy = 'all' ) { |
|
| 869 | + function has_term($term_name_or_id, $taxonomy = 'all') { |
|
| 870 | 870 | if ( $taxonomy == 'all' || $taxonomy == 'any' ) { |
| 871 | 871 | $taxes = get_object_taxonomies($this->post_type, 'names'); |
| 872 | 872 | $ret = false; |
| 873 | - foreach ( $taxes as $tax ) { |
|
| 873 | + foreach ($taxes as $tax) { |
|
| 874 | 874 | if ( has_term($term_name_or_id, $tax, $this->ID) ) { |
| 875 | 875 | $ret = true; |
| 876 | 876 | break; |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | * @param string $field |
| 886 | 886 | * @return TimberImage |
| 887 | 887 | */ |
| 888 | - function get_image( $field ) { |
|
| 888 | + function get_image($field) { |
|
| 889 | 889 | return new $this->ImageClass($this->$field); |
| 890 | 890 | } |
| 891 | 891 | |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | * @param int $page |
| 936 | 936 | * @return string |
| 937 | 937 | */ |
| 938 | - function get_content( $len = 0, $page = 0 ) { |
|
| 938 | + function get_content($len = 0, $page = 0) { |
|
| 939 | 939 | if ( $len == 0 && $page == 0 && $this->_content ) { |
| 940 | 940 | return $this->_content; |
| 941 | 941 | } |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | * @param string $field_name |
| 993 | 993 | * @return mixed |
| 994 | 994 | */ |
| 995 | - public function get_field( $field_name ) { |
|
| 995 | + public function get_field($field_name) { |
|
| 996 | 996 | $value = apply_filters('timber_post_get_meta_field_pre', null, $this->ID, $field_name, $this); |
| 997 | 997 | if ( $value === null ) { |
| 998 | 998 | $value = get_post_meta($this->ID, $field_name); |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | /** |
| 1011 | 1011 | * @param string $field_name |
| 1012 | 1012 | */ |
| 1013 | - function import_field( $field_name ) { |
|
| 1013 | + function import_field($field_name) { |
|
| 1014 | 1014 | $this->$field_name = $this->get_field($field_name); |
| 1015 | 1015 | } |
| 1016 | 1016 | |
@@ -1041,13 +1041,13 @@ discard block |
||
| 1041 | 1041 | * ``` |
| 1042 | 1042 | * @return string a space-seperated list of classes |
| 1043 | 1043 | */ |
| 1044 | - public function post_class( $class='' ) { |
|
| 1044 | + public function post_class($class = '') { |
|
| 1045 | 1045 | global $post; |
| 1046 | 1046 | $old_global_post = $post; |
| 1047 | 1047 | $post = $this; |
| 1048 | 1048 | $class_array = get_post_class($class, $this->ID); |
| 1049 | 1049 | $post = $old_global_post; |
| 1050 | - if ( is_array($class_array) ){ |
|
| 1050 | + if ( is_array($class_array) ) { |
|
| 1051 | 1051 | return implode(' ', $class_array); |
| 1052 | 1052 | } |
| 1053 | 1053 | return $class_array; |
@@ -1149,8 +1149,8 @@ discard block |
||
| 1149 | 1149 | * @param string|bool $childPostClass _optional_ a custom post class (ex: 'MyTimberPost') to return the objects as. By default (false) it will use TimberPost::$post_class value. |
| 1150 | 1150 | * @return array |
| 1151 | 1151 | */ |
| 1152 | - public function children( $post_type = 'any', $childPostClass = false ) { |
|
| 1153 | - return $this->get_children( $post_type, $childPostClass ); |
|
| 1152 | + public function children($post_type = 'any', $childPostClass = false) { |
|
| 1153 | + return $this->get_children($post_type, $childPostClass); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /** |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | * ``` |
| 1175 | 1175 | * @return bool|array |
| 1176 | 1176 | */ |
| 1177 | - public function comments( $count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment' ) { |
|
| 1177 | + public function comments($count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') { |
|
| 1178 | 1178 | return $this->get_comments($count, $order, $type, $status, $CommentClass); |
| 1179 | 1179 | } |
| 1180 | 1180 | |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @param int $page |
| 1192 | 1192 | * @return string |
| 1193 | 1193 | */ |
| 1194 | - public function content( $page = 0 ) { |
|
| 1194 | + public function content($page = 0) { |
|
| 1195 | 1195 | return $this->get_content(0, $page); |
| 1196 | 1196 | } |
| 1197 | 1197 | |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | * @param string $date_format |
| 1221 | 1221 | * @return string |
| 1222 | 1222 | */ |
| 1223 | - public function date( $date_format = '' ) { |
|
| 1223 | + public function date($date_format = '') { |
|
| 1224 | 1224 | return $this->get_date($date_format); |
| 1225 | 1225 | } |
| 1226 | 1226 | |
@@ -1242,9 +1242,9 @@ discard block |
||
| 1242 | 1242 | * @param string $time_format |
| 1243 | 1243 | * @return string |
| 1244 | 1244 | */ |
| 1245 | - public function time( $time_format = '' ) { |
|
| 1245 | + public function time($time_format = '') { |
|
| 1246 | 1246 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 1247 | - $the_time = (string)mysql2date($tf, $this->post_date); |
|
| 1247 | + $the_time = (string) mysql2date($tf, $this->post_date); |
|
| 1248 | 1248 | return apply_filters('get_the_time', $the_time, $tf); |
| 1249 | 1249 | } |
| 1250 | 1250 | |
@@ -1280,7 +1280,7 @@ discard block |
||
| 1280 | 1280 | * @param string $field_name |
| 1281 | 1281 | * @return mixed |
| 1282 | 1282 | */ |
| 1283 | - public function meta( $field_name = null ) { |
|
| 1283 | + public function meta($field_name = null) { |
|
| 1284 | 1284 | if ( $field_name === null ) { |
| 1285 | 1285 | //on the off-chance the field is actually named meta |
| 1286 | 1286 | $field_name = 'meta'; |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | /** |
| 1292 | 1292 | * @return string |
| 1293 | 1293 | */ |
| 1294 | - public function name(){ |
|
| 1294 | + public function name() { |
|
| 1295 | 1295 | return $this->title(); |
| 1296 | 1296 | } |
| 1297 | 1297 | |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | * @param string $date_format |
| 1300 | 1300 | * @return string |
| 1301 | 1301 | */ |
| 1302 | - public function modified_date( $date_format = '' ) { |
|
| 1302 | + public function modified_date($date_format = '') { |
|
| 1303 | 1303 | return $this->get_modified_date($date_format); |
| 1304 | 1304 | } |
| 1305 | 1305 | |
@@ -1307,7 +1307,7 @@ discard block |
||
| 1307 | 1307 | * @param string $time_format |
| 1308 | 1308 | * @return string |
| 1309 | 1309 | */ |
| 1310 | - public function modified_time( $time_format = '' ) { |
|
| 1310 | + public function modified_time($time_format = '') { |
|
| 1311 | 1311 | return $this->get_modified_time($time_format); |
| 1312 | 1312 | } |
| 1313 | 1313 | |
@@ -1316,7 +1316,7 @@ discard block |
||
| 1316 | 1316 | * @param bool $in_same_cat |
| 1317 | 1317 | * @return mixed |
| 1318 | 1318 | */ |
| 1319 | - public function next( $in_same_cat = false ) { |
|
| 1319 | + public function next($in_same_cat = false) { |
|
| 1320 | 1320 | return $this->get_next($in_same_cat); |
| 1321 | 1321 | } |
| 1322 | 1322 | |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | * @param bool $in_same_cat |
| 1375 | 1375 | * @return mixed |
| 1376 | 1376 | */ |
| 1377 | - public function prev( $in_same_cat = false ) { |
|
| 1377 | + public function prev($in_same_cat = false) { |
|
| 1378 | 1378 | return $this->get_prev($in_same_cat); |
| 1379 | 1379 | } |
| 1380 | 1380 | |
@@ -1386,7 +1386,7 @@ discard block |
||
| 1386 | 1386 | * @param bool $merge Should the resulting array be one big one (true)? Or should it be an array of sub-arrays for each taxonomy (false)? |
| 1387 | 1387 | * @return array |
| 1388 | 1388 | */ |
| 1389 | - public function terms( $tax = '', $merge = true ) { |
|
| 1389 | + public function terms($tax = '', $merge = true) { |
|
| 1390 | 1390 | return $this->get_terms($tax, $merge); |
| 1391 | 1391 | } |
| 1392 | 1392 | |