@@ -64,7 +64,7 @@ |
||
| 64 | 64 | |
| 65 | 65 | /** @api |
| 66 | 66 | * @var string for people who like trackback spam |
| 67 | - */ |
|
| 67 | + */ |
|
| 68 | 68 | public $pingback_url; |
| 69 | 69 | public $siteurl; |
| 70 | 70 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | function __construct( $site_name_or_id = null ) { |
| 105 | 105 | $this->init(); |
| 106 | 106 | if ( is_multisite() ) { |
| 107 | - $this->init_as_multisite( $site_name_or_id ); |
|
| 107 | + $this->init_as_multisite($site_name_or_id); |
|
| 108 | 108 | } else { |
| 109 | 109 | $this->init_as_singlesite(); |
| 110 | 110 | } |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | $site_name_or_id = get_current_blog_id(); |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | - $info = get_blog_details( $site_name_or_id ); |
|
| 126 | - $this->import( $info ); |
|
| 125 | + $info = get_blog_details($site_name_or_id); |
|
| 126 | + $this->import($info); |
|
| 127 | 127 | $this->ID = $info->blog_id; |
| 128 | 128 | $this->id = $this->ID; |
| 129 | 129 | $this->name = $this->blogname; |
| 130 | 130 | $this->title = $this->blogname; |
| 131 | 131 | $this->url = $this->siteurl; |
| 132 | - $theme_slug = get_blog_option( $info->blog_id, 'stylesheet' ); |
|
| 133 | - $this->theme = new TimberTheme( $theme_slug ); |
|
| 134 | - $this->description = get_blog_option( $info->blog_id, 'blogdescription' ); |
|
| 135 | - $this->admin_email = get_blog_option( $info->blog_id, 'admin_email' ); |
|
| 132 | + $theme_slug = get_blog_option($info->blog_id, 'stylesheet'); |
|
| 133 | + $this->theme = new TimberTheme($theme_slug); |
|
| 134 | + $this->description = get_blog_option($info->blog_id, 'blogdescription'); |
|
| 135 | + $this->admin_email = get_blog_option($info->blog_id, 'admin_email'); |
|
| 136 | 136 | $this->multisite = true; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | * @internal |
| 142 | 142 | */ |
| 143 | 143 | protected function init_as_singlesite() { |
| 144 | - $this->admin_email = get_bloginfo( 'admin_email' ); |
|
| 145 | - $this->name = get_bloginfo( 'name' ); |
|
| 144 | + $this->admin_email = get_bloginfo('admin_email'); |
|
| 145 | + $this->name = get_bloginfo('name'); |
|
| 146 | 146 | $this->title = $this->name; |
| 147 | - $this->description = get_bloginfo( 'description' ); |
|
| 148 | - $this->url = get_bloginfo( 'url' ); |
|
| 147 | + $this->description = get_bloginfo('description'); |
|
| 148 | + $this->url = get_bloginfo('url'); |
|
| 149 | 149 | $this->theme = new TimberTheme(); |
| 150 | - $this->language_attributes = TimberHelper::function_wrapper( 'language_attributes' ); |
|
| 150 | + $this->language_attributes = TimberHelper::function_wrapper('language_attributes'); |
|
| 151 | 151 | $this->multisite = false; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | * @internal |
| 157 | 157 | */ |
| 158 | 158 | protected function init() { |
| 159 | - $this->rdf = get_bloginfo( 'rdf_url' ); |
|
| 160 | - $this->rss = get_bloginfo( 'rss_url' ); |
|
| 161 | - $this->rss2 = get_bloginfo( 'rss2_url' ); |
|
| 162 | - $this->atom = get_bloginfo( 'atom_url' ); |
|
| 163 | - $this->language = get_bloginfo( 'language' ); |
|
| 164 | - $this->charset = get_bloginfo( 'charset' ); |
|
| 165 | - $this->pingback = get_bloginfo( 'pingback_url' ); |
|
| 166 | - $this->language_attributes = TimberHelper::function_wrapper( 'language_attributes' ); |
|
| 159 | + $this->rdf = get_bloginfo('rdf_url'); |
|
| 160 | + $this->rss = get_bloginfo('rss_url'); |
|
| 161 | + $this->rss2 = get_bloginfo('rss2_url'); |
|
| 162 | + $this->atom = get_bloginfo('atom_url'); |
|
| 163 | + $this->language = get_bloginfo('language'); |
|
| 164 | + $this->charset = get_bloginfo('charset'); |
|
| 165 | + $this->pingback = get_bloginfo('pingback_url'); |
|
| 166 | + $this->language_attributes = TimberHelper::function_wrapper('language_attributes'); |
|
| 167 | 167 | /* deprecated benath this comment */ |
| 168 | - $this->pingback_url = get_bloginfo( 'pingback_url' ); |
|
| 168 | + $this->pingback_url = get_bloginfo('pingback_url'); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | * @return mixed |
| 176 | 176 | */ |
| 177 | 177 | function __get( $field ) { |
| 178 | - if ( !isset( $this->$field ) ) { |
|
| 178 | + if ( !isset($this->$field) ) { |
|
| 179 | 179 | if ( is_multisite() ) { |
| 180 | - $this->$field = get_blog_option( $this->ID, $field ); |
|
| 180 | + $this->$field = get_blog_option($this->ID, $field); |
|
| 181 | 181 | } else { |
| 182 | - $this->$field = get_option( $field ); |
|
| 182 | + $this->$field = get_option($field); |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | return $this->$field; |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @ignore |
| 228 | 228 | */ |
| 229 | 229 | public function meta( $field ) { |
| 230 | - return $this->__get( $field ); |
|
| 230 | + return $this->__get($field); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | * @param mixed $value |
| 238 | 238 | */ |
| 239 | 239 | public function update( $key, $value ) { |
| 240 | - $value = apply_filters( 'timber_site_set_meta', $value, $key, $this->ID, $this ); |
|
| 240 | + $value = apply_filters('timber_site_set_meta', $value, $key, $this->ID, $this); |
|
| 241 | 241 | if ( is_multisite() ) { |
| 242 | - update_blog_option( $this->ID, $key, $value ); |
|
| 242 | + update_blog_option($this->ID, $key, $value); |
|
| 243 | 243 | } else { |
| 244 | - update_option( $key, $value ); |
|
| 244 | + update_option($key, $value); |
|
| 245 | 245 | } |
| 246 | 246 | $this->$key = $value; |
| 247 | 247 | } |
@@ -333,7 +333,7 @@ |
||
| 333 | 333 | $suffix = '</p>'; |
| 334 | 334 | $desc = term_description( $this->ID, $this->taxonomy ); |
| 335 | 335 | if (substr($desc, 0, strlen($prefix)) == $prefix) { |
| 336 | - $desc = substr($desc, strlen($prefix)); |
|
| 336 | + $desc = substr($desc, strlen($prefix)); |
|
| 337 | 337 | } |
| 338 | 338 | $desc = preg_replace('/'. preg_quote('</p>', '/') . '$/', '', $desc); |
| 339 | 339 | return trim($desc); |
@@ -116,7 +116,7 @@ |
||
| 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) ) { |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | * @param string $tax |
| 56 | 56 | */ |
| 57 | 57 | public function __construct( $tid = null, $tax = '' ) { |
| 58 | - if ($tid === null) { |
|
| 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); |
@@ -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 | } |
@@ -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) ) { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param int $tid |
| 132 | 132 | * @return array |
| 133 | 133 | */ |
| 134 | - protected function get_term_meta($tid) { |
|
| 134 | + protected function get_term_meta( $tid ) { |
|
| 135 | 135 | $customs = array(); |
| 136 | 136 | $customs = apply_filters('timber_term_get_meta', $customs, $tid, $this); |
| 137 | 137 | return apply_filters('timber/term/meta', $customs, $tid, $this); |
@@ -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 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @return string |
| 207 | 207 | */ |
| 208 | 208 | public function get_meta_field( $field_name ) { |
| 209 | - if (!isset($this->$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); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @return array|bool|null |
| 246 | 246 | */ |
| 247 | 247 | public function get_posts( $numberposts = 10, $post_type = 'any', $PostClass = '' ) { |
| 248 | - if (!strlen($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) ) { |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | public function get_children() { |
| 295 | 295 | if ( !isset($this->_children) ) { |
| 296 | 296 | $children = get_term_children($this->ID, $this->taxonomy); |
| 297 | - foreach ($children as &$child) { |
|
| 297 | + foreach ( $children as &$child ) { |
|
| 298 | 298 | $child = new TimberTerm($child); |
| 299 | 299 | } |
| 300 | 300 | $this->_children = $children; |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @param mixed $value |
| 310 | 310 | */ |
| 311 | 311 | function update( $key, $value ) { |
| 312 | - $value = apply_filters( 'timber_term_set_meta', $value, $key, $this->ID, $this ); |
|
| 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 | |
@@ -75,6 +75,9 @@ discard block |
||
| 75 | 75 | return $image->writeImages($save_filename, true); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | + /** |
|
| 79 | + * @param string $load_filename |
|
| 80 | + */ |
|
| 78 | 81 | protected function get_target_sizes( $load_filename ) { |
| 79 | 82 | $image = wp_get_image_editor( $load_filename ); |
| 80 | 83 | $w = $this->w; |
@@ -142,7 +145,7 @@ discard block |
||
| 142 | 145 | * (ex: /src/var/www/wp-content/uploads/my-pic.jpg) |
| 143 | 146 | * @param string $save_filename filepath (not URL) where result file should be saved |
| 144 | 147 | * (ex: /src/var/www/wp-content/uploads/my-pic-300x200-c-default.jpg) |
| 145 | - * @return bool true if everything went fine, false otherwise |
|
| 148 | + * @return boolean|null true if everything went fine, false otherwise |
|
| 146 | 149 | */ |
| 147 | 150 | public function run($load_filename, $save_filename) { |
| 148 | 151 | //should be resized by gif resizer |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | * @param int $h height of new image |
| 18 | 18 | * @param string $crop cropping method, one of: 'default', 'center', 'top', 'bottom', 'left', 'right', 'top-center', 'bottom-center'. |
| 19 | 19 | */ |
| 20 | - function __construct($w, $h, $crop) { |
|
| 20 | + function __construct( $w, $h, $crop ) { |
|
| 21 | 21 | $this->w = $w; |
| 22 | 22 | $this->h = $h; |
| 23 | 23 | // Sanitize crop position |
| 24 | - $allowed_crop_positions = array( 'default', 'center', 'top', 'bottom', 'left', 'right', 'top-center', 'bottom-center' ); |
|
| 25 | - if ( $crop !== false && !in_array( $crop, $allowed_crop_positions ) ) { |
|
| 24 | + $allowed_crop_positions = array('default', 'center', 'top', 'bottom', 'left', 'right', 'top-center', 'bottom-center'); |
|
| 25 | + if ( $crop !== false && !in_array($crop, $allowed_crop_positions) ) { |
|
| 26 | 26 | $crop = $allowed_crop_positions[0]; |
| 27 | 27 | } |
| 28 | 28 | $this->crop = $crop; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param string $src_extension the extension (ex: .jpg) |
| 34 | 34 | * @return string the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg) |
| 35 | 35 | */ |
| 36 | - public function filename($src_filename, $src_extension) { |
|
| 36 | + public function filename( $src_filename, $src_extension ) { |
|
| 37 | 37 | $w = 0; |
| 38 | 38 | $h = 0; |
| 39 | 39 | if ( $this->w ) { |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | if ( $this->h ) { |
| 43 | 43 | $h = $this->h; |
| 44 | 44 | } |
| 45 | - $result = $src_filename . '-' . $w . 'x' . $h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false) |
|
| 46 | - if($src_extension) { |
|
| 47 | - $result .= '.'.$src_extension; |
|
| 45 | + $result = $src_filename . '-' . $w . 'x' . $h . '-c-' . ($this->crop ? $this->crop : 'f'); // Crop will be either user named or f (false) |
|
| 46 | + if ( $src_extension ) { |
|
| 47 | + $result .= '.' . $src_extension; |
|
| 48 | 48 | } |
| 49 | 49 | return $result; |
| 50 | 50 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param string $save_filename |
| 55 | 55 | */ |
| 56 | 56 | protected function run_animated_gif( $load_filename, $save_filename ) { |
| 57 | - $image = wp_get_image_editor( $load_filename ); |
|
| 57 | + $image = wp_get_image_editor($load_filename); |
|
| 58 | 58 | $current_size = $image->get_size(); |
| 59 | 59 | $src_w = $current_size['width']; |
| 60 | 60 | $src_h = $current_size['height']; |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | $image = new Imagick($load_filename); |
| 67 | 67 | $image = $image->coalesceImages(); |
| 68 | - $crop = self::get_target_sizes( $load_filename ); |
|
| 69 | - foreach ($image as $frame) { |
|
| 68 | + $crop = self::get_target_sizes($load_filename); |
|
| 69 | + foreach ( $image as $frame ) { |
|
| 70 | 70 | $frame->cropImage($crop['src_w'], $crop['src_h'], $crop['x'], $crop['y']); |
| 71 | 71 | $frame->thumbnailImage($w, $h); |
| 72 | 72 | $frame->setImagePage($w, $h, 0, 0); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | protected function get_target_sizes( $load_filename ) { |
| 79 | - $image = wp_get_image_editor( $load_filename ); |
|
| 79 | + $image = wp_get_image_editor($load_filename); |
|
| 80 | 80 | $w = $this->w; |
| 81 | 81 | $h = $this->h; |
| 82 | 82 | $crop = $this->crop; |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | $src_h = $current_size['height']; |
| 87 | 87 | $src_ratio = $src_w / $src_h; |
| 88 | 88 | if ( !$h ) { |
| 89 | - $h = round( $w / $src_ratio ); |
|
| 89 | + $h = round($w / $src_ratio); |
|
| 90 | 90 | } |
| 91 | 91 | if ( !$w ) { |
| 92 | 92 | //the user wants to resize based on constant height |
| 93 | - $w = round( $h * $src_ratio ); |
|
| 93 | + $w = round($h * $src_ratio); |
|
| 94 | 94 | } |
| 95 | 95 | if ( !$crop ) { |
| 96 | 96 | return array( |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | $src_wt = $src_h * $dest_ratio; |
| 105 | 105 | $src_ht = $src_w / $dest_ratio; |
| 106 | 106 | $src_x = $src_w / 2 - $src_wt / 2; |
| 107 | - $src_y = ( $src_h - $src_ht ) / 6; |
|
| 107 | + $src_y = ($src_h - $src_ht) / 6; |
|
| 108 | 108 | //now specific overrides based on options: |
| 109 | 109 | switch ( $crop ) { |
| 110 | 110 | case 'center': |
| 111 | 111 | // Get source x and y |
| 112 | - $src_x = round( ( $src_w - $src_wt ) / 2 ); |
|
| 113 | - $src_y = round( ( $src_h - $src_ht ) / 2 ); |
|
| 112 | + $src_x = round(($src_w - $src_wt) / 2); |
|
| 113 | + $src_y = round(($src_h - $src_ht) / 2); |
|
| 114 | 114 | break; |
| 115 | 115 | |
| 116 | 116 | case 'top': |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | break; |
| 123 | 123 | |
| 124 | 124 | case 'top-center': |
| 125 | - $src_y = round( ( $src_h - $src_ht ) / 4 ); |
|
| 125 | + $src_y = round(($src_h - $src_ht) / 4); |
|
| 126 | 126 | break; |
| 127 | 127 | |
| 128 | 128 | case 'bottom-center': |
| 129 | - $src_y = $src_h - $src_ht - round( ( $src_h - $src_ht ) / 4 ); |
|
| 129 | + $src_y = $src_h - $src_ht - round(($src_h - $src_ht) / 4); |
|
| 130 | 130 | break; |
| 131 | 131 | |
| 132 | 132 | case 'left': |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | break; |
| 139 | 139 | } |
| 140 | 140 | // Crop the image |
| 141 | - return ( $dest_ratio > $src_ratio ) |
|
| 141 | + return ($dest_ratio > $src_ratio) |
|
| 142 | 142 | ? array( |
| 143 | 143 | 'x' => 0, 'y' => $src_y, |
| 144 | 144 | 'src_w' => $src_w, 'src_h' => $src_ht, |
@@ -161,42 +161,42 @@ discard block |
||
| 161 | 161 | * (ex: /src/var/www/wp-content/uploads/my-pic-300x200-c-default.jpg) |
| 162 | 162 | * @return bool true if everything went fine, false otherwise |
| 163 | 163 | */ |
| 164 | - public function run($load_filename, $save_filename) { |
|
| 164 | + public function run( $load_filename, $save_filename ) { |
|
| 165 | 165 | //should be resized by gif resizer |
| 166 | 166 | if ( TimberImageHelper::is_animated_gif($load_filename) ) { |
| 167 | 167 | //attempt to resize |
| 168 | 168 | //return if successful |
| 169 | 169 | //proceed if not |
| 170 | 170 | $gif = self::run_animated_gif($load_filename, $save_filename); |
| 171 | - if ($gif) { |
|
| 171 | + if ( $gif ) { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | - $image = wp_get_image_editor( $load_filename ); |
|
| 176 | - if ( !is_wp_error( $image ) ) { |
|
| 177 | - $crop = self::get_target_sizes( $load_filename ); |
|
| 178 | - $image->crop( $crop['x'], |
|
| 175 | + $image = wp_get_image_editor($load_filename); |
|
| 176 | + if ( !is_wp_error($image) ) { |
|
| 177 | + $crop = self::get_target_sizes($load_filename); |
|
| 178 | + $image->crop($crop['x'], |
|
| 179 | 179 | $crop['y'], |
| 180 | 180 | $crop['src_w'], |
| 181 | 181 | $crop['src_h'], |
| 182 | 182 | $crop['target_w'], |
| 183 | 183 | $crop['target_h'] |
| 184 | 184 | ); |
| 185 | - $result = $image->save( $save_filename ); |
|
| 186 | - if ( is_wp_error( $result ) ) { |
|
| 185 | + $result = $image->save($save_filename); |
|
| 186 | + if ( is_wp_error($result) ) { |
|
| 187 | 187 | // @codeCoverageIgnoreStart |
| 188 | - TimberHelper::error_log( 'Error resizing image' ); |
|
| 189 | - TimberHelper::error_log( $result ); |
|
| 188 | + TimberHelper::error_log('Error resizing image'); |
|
| 189 | + TimberHelper::error_log($result); |
|
| 190 | 190 | return false; |
| 191 | 191 | // @codeCoverageIgnoreEnd |
| 192 | 192 | } else { |
| 193 | 193 | return true; |
| 194 | 194 | } |
| 195 | - } else if ( isset( $image->error_data['error_loading_image'] ) ) { |
|
| 195 | + } else if ( isset($image->error_data['error_loading_image']) ) { |
|
| 196 | 196 | // @codeCoverageIgnoreStart |
| 197 | - TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] ); |
|
| 197 | + TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']); |
|
| 198 | 198 | } else { |
| 199 | - TimberHelper::error_log( $image ); |
|
| 199 | + TimberHelper::error_log($image); |
|
| 200 | 200 | // @codeCoverageIgnoreEnd |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -15,12 +15,12 @@ |
||
| 15 | 15 | // then in the wp-content dir (site install). |
| 16 | 16 | // and finally in the current themes directories. |
| 17 | 17 | if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */ |
| 18 | - || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
| 19 | - || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
| 20 | - || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
| 21 | - || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
| 18 | + || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
| 19 | + || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
| 20 | + || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
| 21 | + || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
| 22 | 22 | ) { |
| 23 | - require_once $composer_autoload; |
|
| 23 | + require_once $composer_autoload; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $timber = new Timber(); |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | // we look for Composer files first in the plugins dir. |
| 15 | 15 | // then in the wp-content dir (site install). |
| 16 | 16 | // and finally in the current themes directories. |
| 17 | -if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */ |
|
| 18 | - || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
| 19 | - || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
| 20 | - || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
| 21 | - || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
| 17 | +if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php') /* check in self */ |
|
| 18 | + || file_exists($composer_autoload = WP_CONTENT_DIR . '/vendor/autoload.php') /* check in wp-content */ |
|
| 19 | + || file_exists($composer_autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php') /* check in plugin directory */ |
|
| 20 | + || file_exists($composer_autoload = get_stylesheet_directory() . '/vendor/autoload.php') /* check in child theme */ |
|
| 21 | + || file_exists($composer_autoload = get_template_directory() . '/vendor/autoload.php') /* check in parent theme */ |
|
| 22 | 22 | ) { |
| 23 | 23 | require_once $composer_autoload; |
| 24 | 24 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function __get( $field ) {} |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * @return boolean |
|
| 29 | + * @return boolean|null |
|
| 30 | 30 | */ |
| 31 | 31 | public function __isset( $field ) {} |
| 32 | 32 | |
@@ -28,7 +28,9 @@ |
||
| 28 | 28 | $this->_class = $function[0]; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if( is_string( $function[1] ) ) $this->_function = $function[1]; |
|
| 31 | + if( is_string( $function[1] ) ) { |
|
| 32 | + $this->_function = $function[1]; |
|
| 33 | + } |
|
| 32 | 34 | } else { |
| 33 | 35 | $this->_function = $function; |
| 34 | 36 | } |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | public function __toString() { |
| 11 | 11 | try { |
| 12 | - return (string)$this->call(); |
|
| 13 | - } catch (Exception $e) { |
|
| 12 | + return (string) $this->call(); |
|
| 13 | + } catch ( Exception $e ) { |
|
| 14 | 14 | return 'Caught exception: ' . $e->getMessage() . "\n"; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | * @param bool $return_output_buffer |
| 24 | 24 | */ |
| 25 | 25 | public function __construct( $function, $args = array(), $return_output_buffer = false ) { |
| 26 | - if( is_array( $function ) ) { |
|
| 27 | - if( (is_string( $function[0] ) && class_exists( $function[0] ) ) || gettype( $function[0] ) === 'object' ) { |
|
| 26 | + if ( is_array($function) ) { |
|
| 27 | + if ( (is_string($function[0]) && class_exists($function[0])) || gettype($function[0]) === 'object' ) { |
|
| 28 | 28 | $this->_class = $function[0]; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if( is_string( $function[1] ) ) $this->_function = $function[1]; |
|
| 31 | + if ( is_string($function[1]) ) $this->_function = $function[1]; |
|
| 32 | 32 | } else { |
| 33 | 33 | $this->_function = $function; |
| 34 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $this->_args = $args; |
| 37 | 37 | $this->_use_ob = $return_output_buffer; |
| 38 | 38 | |
| 39 | - add_filter( 'get_twig', array( &$this, 'add_to_twig' ) ); |
|
| 39 | + add_filter('get_twig', array(&$this, 'add_to_twig')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | public function add_to_twig( $twig ) { |
| 49 | 49 | $wrapper = $this; |
| 50 | 50 | |
| 51 | - $twig->addFunction( new Twig_SimpleFunction( $this->_function, function () use ( $wrapper ) { |
|
| 52 | - return call_user_func_array( array( $wrapper, 'call' ), func_get_args() ); |
|
| 53 | - } ) ); |
|
| 51 | + $twig->addFunction(new Twig_SimpleFunction($this->_function, function() use ($wrapper) { |
|
| 52 | + return call_user_func_array(array($wrapper, 'call'), func_get_args()); |
|
| 53 | + } )); |
|
| 54 | 54 | |
| 55 | 55 | return $twig; |
| 56 | 56 | } |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | 63 | public function call() { |
| 64 | - $args = $this->_parse_args( func_get_args(), $this->_args ); |
|
| 65 | - $callable = ( isset( $this->_class ) ) ? array( $this->_class, $this->_function ) : $this->_function; |
|
| 64 | + $args = $this->_parse_args(func_get_args(), $this->_args); |
|
| 65 | + $callable = (isset($this->_class)) ? array($this->_class, $this->_function) : $this->_function; |
|
| 66 | 66 | |
| 67 | 67 | if ( $this->_use_ob ) { |
| 68 | - return TimberHelper::ob_function( $callable, $args ); |
|
| 68 | + return TimberHelper::ob_function($callable, $args); |
|
| 69 | 69 | } else { |
| 70 | - return call_user_func_array( $callable, $args ); |
|
| 70 | + return call_user_func_array($callable, $args); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | 81 | private function _parse_args( $args, $defaults ) { |
| 82 | - $_arg = reset( $defaults ); |
|
| 82 | + $_arg = reset($defaults); |
|
| 83 | 83 | |
| 84 | 84 | foreach ( $args as $index => $arg ) { |
| 85 | - $defaults[$index] = is_null( $arg ) ? $_arg : $arg; |
|
| 86 | - $_arg = next( $defaults ); |
|
| 85 | + $defaults[$index] = is_null($arg) ? $_arg : $arg; |
|
| 86 | + $_arg = next($defaults); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | return $defaults; |
@@ -345,7 +345,7 @@ |
||
| 345 | 345 | * Get widgets. |
| 346 | 346 | * |
| 347 | 347 | * @param int $widget_id |
| 348 | - * @return TimberFunctionWrapper |
|
| 348 | + * @return string |
|
| 349 | 349 | */ |
| 350 | 350 | public static function get_widgets( $widget_id ) { |
| 351 | 351 | return trim( TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true ) ); |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) { |
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | - if ( version_compare( phpversion(), '5.3.0', '<' ) && !is_admin() ) { |
|
| 49 | - trigger_error( 'Timber requires PHP 5.3.0 or greater. You have '.phpversion(), E_USER_ERROR ); |
|
| 48 | + if ( version_compare(phpversion(), '5.3.0', '<') && !is_admin() ) { |
|
| 49 | + trigger_error('Timber requires PHP 5.3.0 or greater. You have ' . phpversion(), E_USER_ERROR); |
|
| 50 | 50 | } |
| 51 | - if ( !class_exists( 'Twig_Autoloader' ) ) { |
|
| 52 | - trigger_error( 'You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR ); |
|
| 51 | + if ( !class_exists('Twig_Autoloader') ) { |
|
| 52 | + trigger_error('You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | function init_constants() { |
| 57 | - defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( dirname(__DIR__) ) ); |
|
| 57 | + defined("TIMBER_LOC") or define("TIMBER_LOC", realpath(dirname(__DIR__))); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function init() { |
| 64 | 64 | TimberTwig::init(); |
| 65 | - TimberRoutes::init( $this ); |
|
| 65 | + TimberRoutes::init($this); |
|
| 66 | 66 | TimberImageHelper::init(); |
| 67 | 67 | TimberAdmin::init(); |
| 68 | 68 | TimberIntegrations::init(); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @return array|bool|null |
| 80 | 80 | */ |
| 81 | 81 | public static function get_post( $query = false, $PostClass = 'TimberPost' ) { |
| 82 | - return TimberPostGetter::get_post( $query, $PostClass ); |
|
| 82 | + return TimberPostGetter::get_post($query, $PostClass); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return array|bool|null |
| 91 | 91 | */ |
| 92 | 92 | public static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) { |
| 93 | - return TimberPostGetter::get_posts( $query, $PostClass, $return_collection ); |
|
| 93 | + return TimberPostGetter::get_posts($query, $PostClass, $return_collection); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return array|bool|null |
| 102 | 102 | */ |
| 103 | 103 | public static function query_post( $query = false, $PostClass = 'TimberPost' ) { |
| 104 | - return TimberPostGetter::query_post( $query, $PostClass ); |
|
| 104 | + return TimberPostGetter::query_post($query, $PostClass); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @return array|bool|null |
| 113 | 113 | */ |
| 114 | 114 | public static function query_posts( $query = false, $PostClass = 'TimberPost' ) { |
| 115 | - return TimberPostGetter::query_posts( $query, $PostClass ); |
|
| 115 | + return TimberPostGetter::query_posts($query, $PostClass); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @return mixed |
| 138 | 138 | */ |
| 139 | 139 | public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) { |
| 140 | - return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass ); |
|
| 140 | + return TimberTermGetter::get_terms($args, $maybe_args, $TermClass); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /* Site Retrieval |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | 152 | public static function get_sites( $blog_ids = false ) { |
| 153 | - if ( !is_array( $blog_ids ) ) { |
|
| 153 | + if ( !is_array($blog_ids) ) { |
|
| 154 | 154 | global $wpdb; |
| 155 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC" ); |
|
| 155 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC"); |
|
| 156 | 156 | } |
| 157 | 157 | $return = array(); |
| 158 | 158 | foreach ( $blog_ids as $blog_id ) { |
| 159 | - $return[] = new TimberSite( $blog_id ); |
|
| 159 | + $return[] = new TimberSite($blog_id); |
|
| 160 | 160 | } |
| 161 | 161 | return $return; |
| 162 | 162 | } |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | $data = array(); |
| 175 | 175 | $data['http_host'] = 'http://' . TimberURLHelper::get_host(); |
| 176 | 176 | $data['wp_title'] = TimberHelper::get_wp_title(); |
| 177 | - $data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' ); |
|
| 178 | - $data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' ); |
|
| 179 | - $data['body_class'] = implode( ' ', get_body_class() ); |
|
| 177 | + $data['wp_head'] = TimberHelper::function_wrapper('wp_head'); |
|
| 178 | + $data['wp_footer'] = TimberHelper::function_wrapper('wp_footer'); |
|
| 179 | + $data['body_class'] = implode(' ', get_body_class()); |
|
| 180 | 180 | |
| 181 | 181 | $data['site'] = new TimberSite(); |
| 182 | 182 | $data['request'] = new TimberRequest(); |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $data['posts'] = Timber::query_posts(); |
| 186 | 186 | |
| 187 | - $data = apply_filters( 'timber_context', $data ); |
|
| 188 | - $data = apply_filters( 'timber/context', $data ); |
|
| 187 | + $data = apply_filters('timber_context', $data); |
|
| 188 | + $data = apply_filters('timber/context', $data); |
|
| 189 | 189 | return $data; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -202,24 +202,24 @@ discard block |
||
| 202 | 202 | public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) { |
| 203 | 203 | $caller = self::get_calling_script_dir(); |
| 204 | 204 | $caller_file = self::get_calling_script_file(); |
| 205 | - $caller_file = apply_filters( 'timber_calling_php_file', $caller_file ); |
|
| 206 | - $loader = new TimberLoader( $caller ); |
|
| 207 | - $file = $loader->choose_template( $filenames ); |
|
| 205 | + $caller_file = apply_filters('timber_calling_php_file', $caller_file); |
|
| 206 | + $loader = new TimberLoader($caller); |
|
| 207 | + $file = $loader->choose_template($filenames); |
|
| 208 | 208 | $output = ''; |
| 209 | - if ( is_null( $data ) ) { |
|
| 209 | + if ( is_null($data) ) { |
|
| 210 | 210 | $data = array(); |
| 211 | 211 | } |
| 212 | - if ( strlen( $file ) ) { |
|
| 212 | + if ( strlen($file) ) { |
|
| 213 | 213 | if ( $via_render ) { |
| 214 | - $file = apply_filters( 'timber_render_file', $file ); |
|
| 215 | - $data = apply_filters( 'timber_render_data', $data ); |
|
| 214 | + $file = apply_filters('timber_render_file', $file); |
|
| 215 | + $data = apply_filters('timber_render_data', $data); |
|
| 216 | 216 | } else { |
| 217 | - $file = apply_filters( 'timber_compile_file', $file ); |
|
| 218 | - $data = apply_filters( 'timber_compile_data', $data ); |
|
| 217 | + $file = apply_filters('timber_compile_file', $file); |
|
| 218 | + $data = apply_filters('timber_compile_data', $data); |
|
| 219 | 219 | } |
| 220 | - $output = $loader->render( $file, $data, $expires, $cache_mode ); |
|
| 220 | + $output = $loader->render($file, $data, $expires, $cache_mode); |
|
| 221 | 221 | } |
| 222 | - do_action( 'timber_compile_done' ); |
|
| 222 | + do_action('timber_compile_done'); |
|
| 223 | 223 | return $output; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | $dummy_loader = new TimberLoader(); |
| 235 | 235 | $dummy_loader->get_twig(); |
| 236 | 236 | $loader = new Twig_Loader_String(); |
| 237 | - $twig = new Twig_Environment( $loader ); |
|
| 238 | - $twig = apply_filters( 'timber/twig/filters', $twig ); |
|
| 239 | - $twig = apply_filters( 'twig_apply_filters', $twig ); |
|
| 240 | - return $twig->render( $string, $data ); |
|
| 237 | + $twig = new Twig_Environment($loader); |
|
| 238 | + $twig = apply_filters('timber/twig/filters', $twig); |
|
| 239 | + $twig = apply_filters('twig_apply_filters', $twig); |
|
| 240 | + return $twig->render($string, $data); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | $expires = $cache_mode; |
| 257 | 257 | $cache_mode = TimberLoader::CACHE_USE_DEFAULT; |
| 258 | 258 | } |
| 259 | - $output = self::compile( $filenames, $data, $expires, $cache_mode, true ); |
|
| 260 | - $output = apply_filters( 'timber_compile_result', $output ); |
|
| 259 | + $output = self::compile($filenames, $data, $expires, $cache_mode, true); |
|
| 260 | + $output = apply_filters('timber_compile_result', $output); |
|
| 261 | 261 | return $output; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @return bool|string |
| 272 | 272 | */ |
| 273 | 273 | public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) { |
| 274 | - $output = static::fetch( $filenames, $data, $expires, $cache_mode ); |
|
| 274 | + $output = static::fetch($filenames, $data, $expires, $cache_mode); |
|
| 275 | 275 | echo $output; |
| 276 | 276 | return $output; |
| 277 | 277 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @return bool|string |
| 285 | 285 | */ |
| 286 | 286 | public static function render_string( $string, $data = array() ) { |
| 287 | - $compiled = self::compile_string( $string, $data ); |
|
| 287 | + $compiled = self::compile_string($string, $data); |
|
| 288 | 288 | echo $compiled; |
| 289 | 289 | return $compiled; |
| 290 | 290 | } |
@@ -304,10 +304,10 @@ discard block |
||
| 304 | 304 | if ( $sidebar == '' ) { |
| 305 | 305 | $sidebar = 'sidebar.php'; |
| 306 | 306 | } |
| 307 | - if ( strstr( strtolower( $sidebar ), '.php' ) ) { |
|
| 308 | - return self::get_sidebar_from_php( $sidebar, $data ); |
|
| 307 | + if ( strstr(strtolower($sidebar), '.php') ) { |
|
| 308 | + return self::get_sidebar_from_php($sidebar, $data); |
|
| 309 | 309 | } |
| 310 | - return self::compile( $sidebar, $data ); |
|
| 310 | + return self::compile($sidebar, $data); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -320,18 +320,18 @@ discard block |
||
| 320 | 320 | public static function get_sidebar_from_php( $sidebar = '', $data ) { |
| 321 | 321 | $caller = self::get_calling_script_dir(); |
| 322 | 322 | $loader = new TimberLoader(); |
| 323 | - $uris = $loader->get_locations( $caller ); |
|
| 323 | + $uris = $loader->get_locations($caller); |
|
| 324 | 324 | ob_start(); |
| 325 | 325 | $found = false; |
| 326 | 326 | foreach ( $uris as $uri ) { |
| 327 | - if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) { |
|
| 328 | - include trailingslashit( $uri ) . $sidebar; |
|
| 327 | + if ( file_exists(trailingslashit($uri) . $sidebar) ) { |
|
| 328 | + include trailingslashit($uri) . $sidebar; |
|
| 329 | 329 | $found = true; |
| 330 | 330 | break; |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | if ( !$found ) { |
| 334 | - TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' ); |
|
| 334 | + TimberHelper::error_log('error loading your sidebar, check to make sure the file exists'); |
|
| 335 | 335 | } |
| 336 | 336 | $ret = ob_get_contents(); |
| 337 | 337 | ob_end_clean(); |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * @return TimberFunctionWrapper |
| 349 | 349 | */ |
| 350 | 350 | public static function get_widgets( $widget_id ) { |
| 351 | - return trim( TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true ) ); |
|
| 351 | + return trim(TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true)); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @deprecated since 0.20.0 |
| 365 | 365 | */ |
| 366 | 366 | public static function add_route( $route, $callback, $args = array() ) { |
| 367 | - Routes::map( $route, $callback, $args ); |
|
| 367 | + Routes::map($route, $callback, $args); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * @deprecated since 0.20.0 |
| 374 | 374 | */ |
| 375 | 375 | public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) { |
| 376 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
| 376 | + return Routes::load($template, $tparams, $query, $status_code); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * @deprecated since 0.20.2 |
| 383 | 383 | */ |
| 384 | 384 | public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) { |
| 385 | - return Routes::load( $template, $tparams, $query, $status_code ); |
|
| 385 | + return Routes::load($template, $tparams, $query, $status_code); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | |
@@ -400,43 +400,43 @@ discard block |
||
| 400 | 400 | global $paged; |
| 401 | 401 | global $wp_rewrite; |
| 402 | 402 | $args = array(); |
| 403 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 403 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 404 | 404 | if ( $wp_rewrite->using_permalinks() ) { |
| 405 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 406 | - if ( isset( $url[1] ) ) { |
|
| 407 | - parse_str( $url[1], $query ); |
|
| 405 | + $url = explode('?', get_pagenum_link(0)); |
|
| 406 | + if ( isset($url[1]) ) { |
|
| 407 | + parse_str($url[1], $query); |
|
| 408 | 408 | $args['add_args'] = $query; |
| 409 | 409 | } |
| 410 | 410 | $args['format'] = 'page/%#%'; |
| 411 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 411 | + $args['base'] = trailingslashit($url[0]) . '%_%'; |
|
| 412 | 412 | } else { |
| 413 | 413 | $big = 999999999; |
| 414 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 414 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 415 | 415 | } |
| 416 | 416 | $args['type'] = 'array'; |
| 417 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 418 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 419 | - if ( is_int( $prefs ) ) { |
|
| 417 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 418 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 419 | + if ( is_int($prefs) ) { |
|
| 420 | 420 | $args['mid_size'] = $prefs - 2; |
| 421 | 421 | } else { |
| 422 | - $args = array_merge( $args, $prefs ); |
|
| 422 | + $args = array_merge($args, $prefs); |
|
| 423 | 423 | } |
| 424 | 424 | $data = array(); |
| 425 | 425 | $data['current'] = $args['current']; |
| 426 | 426 | $data['total'] = $args['total']; |
| 427 | - $data['pages'] = TimberHelper::paginate_links( $args ); |
|
| 428 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 427 | + $data['pages'] = TimberHelper::paginate_links($args); |
|
| 428 | + $next = get_next_posts_page_link($args['total']); |
|
| 429 | 429 | if ( $next ) { |
| 430 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 430 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 431 | 431 | } |
| 432 | - $prev = previous_posts( false ); |
|
| 432 | + $prev = previous_posts(false); |
|
| 433 | 433 | if ( $prev ) { |
| 434 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 434 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 435 | 435 | } |
| 436 | 436 | if ( $paged < 2 ) { |
| 437 | 437 | $data['prev'] = ''; |
| 438 | 438 | } |
| 439 | - if ( $data['total'] === ( double ) 0 ) { |
|
| 439 | + if ( $data['total'] === (double) 0 ) { |
|
| 440 | 440 | $data['next'] = ''; |
| 441 | 441 | } |
| 442 | 442 | return $data; |
@@ -451,9 +451,9 @@ discard block |
||
| 451 | 451 | * @return string |
| 452 | 452 | */ |
| 453 | 453 | public static function get_calling_script_dir( $offset = 0 ) { |
| 454 | - $caller = self::get_calling_script_file( $offset ); |
|
| 455 | - if ( !is_null( $caller ) ) { |
|
| 456 | - $pathinfo = pathinfo( $caller ); |
|
| 454 | + $caller = self::get_calling_script_file($offset); |
|
| 455 | + if ( !is_null($caller) ) { |
|
| 456 | + $pathinfo = pathinfo($caller); |
|
| 457 | 457 | $dir = $pathinfo['dirname']; |
| 458 | 458 | return $dir; |
| 459 | 459 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param int $h height |
| 18 | 18 | * @param string $color hex string, for color of padding bands |
| 19 | 19 | */ |
| 20 | - function __construct($w, $h, $color) { |
|
| 20 | + function __construct( $w, $h, $color ) { |
|
| 21 | 21 | $this->w = $w; |
| 22 | 22 | $this->h = $h; |
| 23 | 23 | $this->color = $color; |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * @return string the final filename to be used |
| 30 | 30 | * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg) |
| 31 | 31 | */ |
| 32 | - public function filename($src_filename, $src_extension) { |
|
| 33 | - $color = str_replace( '#', '', $this->color ); |
|
| 32 | + public function filename( $src_filename, $src_extension ) { |
|
| 33 | + $color = str_replace('#', '', $this->color); |
|
| 34 | 34 | $newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color; |
| 35 | 35 | $new_name = $newbase . '.' . $src_extension; |
| 36 | 36 | return $new_name; |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | * (ex: /src/var/www/wp-content/uploads/my-pic-lbox-300x200-FF3366.jpg) |
| 47 | 47 | * @return bool true if everything went fine, false otherwise |
| 48 | 48 | */ |
| 49 | - public function run($load_filename, $save_filename) { |
|
| 49 | + public function run( $load_filename, $save_filename ) { |
|
| 50 | 50 | $w = $this->w; |
| 51 | 51 | $h = $this->h; |
| 52 | 52 | |
| 53 | - $bg = imagecreatetruecolor( $w, $h ); |
|
| 54 | - $c = self::hexrgb( $this->color ); |
|
| 55 | - $bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] ); |
|
| 56 | - imagefill( $bg, 0, 0, $bgColor ); |
|
| 57 | - $image = wp_get_image_editor( $load_filename ); |
|
| 58 | - if ( !is_wp_error( $image ) ) { |
|
| 53 | + $bg = imagecreatetruecolor($w, $h); |
|
| 54 | + $c = self::hexrgb($this->color); |
|
| 55 | + $bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']); |
|
| 56 | + imagefill($bg, 0, 0, $bgColor); |
|
| 57 | + $image = wp_get_image_editor($load_filename); |
|
| 58 | + if ( !is_wp_error($image) ) { |
|
| 59 | 59 | $current_size = $image->get_size(); |
| 60 | 60 | $quality = $image->get_quality(); |
| 61 | 61 | $ow = $current_size['width']; |
@@ -69,38 +69,38 @@ discard block |
||
| 69 | 69 | $y = 0; |
| 70 | 70 | $x = $w / 2 - $owt / 2; |
| 71 | 71 | $oht = $h; |
| 72 | - $image->crop( 0, 0, $ow, $oh, $owt, $oht ); |
|
| 72 | + $image->crop(0, 0, $ow, $oh, $owt, $oht); |
|
| 73 | 73 | } else { |
| 74 | 74 | $w_scale = $w / $ow; |
| 75 | 75 | $oht = $oh * $w_scale; |
| 76 | 76 | $x = 0; |
| 77 | 77 | $y = $h / 2 - $oht / 2; |
| 78 | 78 | $owt = $w; |
| 79 | - $image->crop( 0, 0, $ow, $oh, $owt, $oht ); |
|
| 79 | + $image->crop(0, 0, $ow, $oh, $owt, $oht); |
|
| 80 | 80 | } |
| 81 | - $result = $image->save( $save_filename ); |
|
| 81 | + $result = $image->save($save_filename); |
|
| 82 | 82 | $func = 'imagecreatefromjpeg'; |
| 83 | 83 | $save_func = 'imagejpeg'; |
| 84 | - $ext = pathinfo( $save_filename, PATHINFO_EXTENSION ); |
|
| 84 | + $ext = pathinfo($save_filename, PATHINFO_EXTENSION); |
|
| 85 | 85 | if ( $ext == 'gif' ) { |
| 86 | 86 | $func = 'imagecreatefromgif'; |
| 87 | 87 | $save_func = 'imagegif'; |
| 88 | 88 | } else if ( $ext == 'png' ) { |
| 89 | 89 | $func = 'imagecreatefrompng'; |
| 90 | 90 | $save_func = 'imagepng'; |
| 91 | - if ($quality > 9) { |
|
| 92 | - $quality = $quality/10; |
|
| 91 | + if ( $quality > 9 ) { |
|
| 92 | + $quality = $quality / 10; |
|
| 93 | 93 | $quality = round(10 - $quality); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | - $image = $func( $save_filename ); |
|
| 97 | - imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht ); |
|
| 98 | - if ($save_func === 'imagegif') { |
|
| 99 | - return $save_func( $bg, $save_filename ); |
|
| 96 | + $image = $func($save_filename); |
|
| 97 | + imagecopy($bg, $image, $x, $y, 0, 0, $owt, $oht); |
|
| 98 | + if ( $save_func === 'imagegif' ) { |
|
| 99 | + return $save_func($bg, $save_filename); |
|
| 100 | 100 | } |
| 101 | - return $save_func( $bg, $save_filename, $quality ); |
|
| 101 | + return $save_func($bg, $save_filename, $quality); |
|
| 102 | 102 | } else { |
| 103 | - TimberHelper::error_log( $image ); |
|
| 103 | + TimberHelper::error_log($image); |
|
| 104 | 104 | } |
| 105 | 105 | return false; |
| 106 | 106 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @param string $color hex string of color to use for transparent zones |
| 14 | 14 | */ |
| 15 | - function __construct($color) { |
|
| 15 | + function __construct( $color ) { |
|
| 16 | 16 | $this->color = $color; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $src_extension ignored |
| 22 | 22 | * @return string the final filename to be used (ex: my-awesome-pic.jpg) |
| 23 | 23 | */ |
| 24 | - function filename($src_filename, $src_extension = 'jpg') { |
|
| 24 | + function filename( $src_filename, $src_extension = 'jpg' ) { |
|
| 25 | 25 | $new_name = $src_filename . '.jpg'; |
| 26 | 26 | return $new_name; |
| 27 | 27 | } |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | * (ex: /src/var/www/wp-content/uploads/my-pic.png) |
| 36 | 36 | * @return bool true if everything went fine, false otherwise |
| 37 | 37 | */ |
| 38 | - function run($load_filename, $save_filename) { |
|
| 39 | - $input = self::image_create( $load_filename ); |
|
| 40 | - list( $width, $height ) = getimagesize( $load_filename ); |
|
| 41 | - $output = imagecreatetruecolor( $width, $height ); |
|
| 42 | - $c = self::hexrgb( $this->color ); |
|
| 43 | - $color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] ); |
|
| 44 | - imagefilledrectangle( $output, 0, 0, $width, $height, $color ); |
|
| 45 | - imagecopy( $output, $input, 0, 0, 0, 0, $width, $height ); |
|
| 46 | - imagejpeg( $output, $save_filename ); |
|
| 38 | + function run( $load_filename, $save_filename ) { |
|
| 39 | + $input = self::image_create($load_filename); |
|
| 40 | + list($width, $height) = getimagesize($load_filename); |
|
| 41 | + $output = imagecreatetruecolor($width, $height); |
|
| 42 | + $c = self::hexrgb($this->color); |
|
| 43 | + $color = imagecolorallocate($output, $c['red'], $c['green'], $c['blue']); |
|
| 44 | + imagefilledrectangle($output, 0, 0, $width, $height, $color); |
|
| 45 | + imagecopy($output, $input, 0, 0, 0, 0, $width, $height); |
|
| 46 | + imagejpeg($output, $save_filename); |
|
| 47 | 47 | return true; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | function image_create( $filename, $ext = 'auto' ) { |
| 56 | 56 | if ( $ext == 'auto' ) { |
| 57 | 57 | $ext = wp_check_filetype($filename); |
| 58 | - if (isset($ext['ext'])) { |
|
| 58 | + if ( isset($ext['ext']) ) { |
|
| 59 | 59 | $ext = $ext['ext']; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -69,6 +69,6 @@ discard block |
||
| 69 | 69 | if ( $ext == 'jpg' || $ext == 'jpeg' ) { |
| 70 | 70 | return imagecreatefromjpeg($filename); |
| 71 | 71 | } |
| 72 | - throw new InvalidArgumentException( 'image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext ); |
|
| 72 | + throw new InvalidArgumentException('image_create only accepts PNG, GIF and JPGs. File extension was: ' . $ext); |
|
| 73 | 73 | } |
| 74 | 74 | } |