Completed
Push — master ( 608c6b...fdd09c )
by Jared
03:03
created
lib/cache/KeyGenerator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
 	 * @return string
12 12
 	 */
13 13
 	public function generateKey($value) {
14
-		if (is_a($value, 'TimberKeyGeneratorInterface')) {
14
+		if ( is_a($value, 'TimberKeyGeneratorInterface') ) {
15 15
 			return $value->_get_cache_key();
16 16
 		}
17 17
 
18
-		if (is_array($value) && isset($value['_cache_key'])) {
18
+		if ( is_array($value) && isset($value['_cache_key']) ) {
19 19
 			return $value['_cache_key'];
20 20
 		}
21 21
 
22 22
 		$key = md5(json_encode($value));
23
-		if (is_object($value)) {
23
+		if ( is_object($value) ) {
24 24
 			$key = get_class($value) . '|' . $key;
25 25
 		}
26 26
 
Please login to merge, or discard this patch.
lib/image/timber-image-operation-letterbox.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *                    (ex: my-awesome-pic-lbox-300x200-FF3366.jpg) 
31 31
 	 */
32 32
 	public function filename($src_filename, $src_extension) {
33
-		$color = str_replace( '#', '', $this->color );
33
+		$color = str_replace('#', '', $this->color);
34 34
 		$newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color;
35 35
 		$new_name = $newbase . '.' . $src_extension;
36 36
 		return $new_name;
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
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,29 +69,29 @@  discard block
 block discarded – undo
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
-			$image->save( $save_filename );
81
+			$image->save($save_filename);
82 82
 			$func = 'imagecreatefromjpeg';
83
-			$ext = pathinfo( $save_filename, PATHINFO_EXTENSION );
83
+			$ext = pathinfo($save_filename, PATHINFO_EXTENSION);
84 84
 			if ( $ext == 'gif' ) {
85 85
 				$func = 'imagecreatefromgif';
86 86
 			} else if ( $ext == 'png' ) {
87 87
 				$func = 'imagecreatefrompng';
88 88
 			}
89
-			$image = $func( $save_filename );
90
-			imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
91
-			imagejpeg( $bg, $save_filename, $quality );
89
+			$image = $func($save_filename);
90
+			imagecopy($bg, $image, $x, $y, 0, 0, $owt, $oht);
91
+			imagejpeg($bg, $save_filename, $quality);
92 92
 			return true;
93 93
 		} else {
94
-			TimberHelper::error_log( $image );
94
+			TimberHelper::error_log($image);
95 95
 		}
96 96
 		return false;
97 97
 	}
Please login to merge, or discard this patch.
lib/image/timber-image-operation-resize.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
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' );
25
-		if ( $crop !== false && !in_array( $crop, $allowed_crop_positions ) ) {
24
+		$allowed_crop_positions = array('default', 'center', 'top', 'bottom', 'left', 'right');
25
+		if ( $crop !== false && !in_array($crop, $allowed_crop_positions) ) {
26 26
 			$crop = $allowed_crop_positions[0];
27 27
 		}
28 28
 		$this->crop = $crop;
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 	 * @return  string    the final filename to be used (ex: my-awesome-pic-300x200-c-default.jpg)
35 35
 	 */
36 36
 	public function filename($src_filename, $src_extension) {
37
-		$result = $src_filename . '-' . $this->w . 'x' . $this->h . '-c-' . ( $this->crop ? $this->crop : 'f' ); // Crop will be either user named or f (false)
38
-		if($src_extension) {
39
-			$result .= '.'.$src_extension;
37
+		$result = $src_filename . '-' . $this->w . 'x' . $this->h . '-c-' . ($this->crop ? $this->crop : 'f'); // Crop will be either user named or f (false)
38
+		if ( $src_extension ) {
39
+			$result .= '.' . $src_extension;
40 40
 		}
41 41
 		return $result;
42 42
 	}
43 43
 
44
-	protected function run_animated_gif( $load_filename, $save_filename ) {
45
-		$image = wp_get_image_editor( $load_filename );
44
+	protected function run_animated_gif($load_filename, $save_filename) {
45
+		$image = wp_get_image_editor($load_filename);
46 46
 		$current_size = $image->get_size();
47 47
 		$src_w = $current_size['width'];
48 48
 		$src_h = $current_size['height'];
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		}
54 54
 		$image = new Imagick($load_filename);
55 55
 		$image = $image->coalesceImages();
56
-		$crop = self::get_target_sizes( $load_filename );
56
+		$crop = self::get_target_sizes($load_filename);
57 57
 		foreach ($image as $frame) {
58 58
 			$frame->cropImage($crop['src_w'], $crop['src_h'], $crop['x'], $crop['y']);
59 59
 			$frame->thumbnailImage($w, $h);
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		return $image->writeImages($save_filename, true);
64 64
 	}
65 65
 
66
-	protected function get_target_sizes( $load_filename ) {
67
-		$image = wp_get_image_editor( $load_filename );
66
+	protected function get_target_sizes($load_filename) {
67
+		$image = wp_get_image_editor($load_filename);
68 68
 		$w = $this->w;
69 69
 		$h = $this->h;
70 70
 		$crop = $this->crop;
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 		$src_h = $current_size['height'];
75 75
 		$src_ratio = $src_w / $src_h;
76 76
 		if ( !$h ) {
77
-			$h = round( $w / $src_ratio );
77
+			$h = round($w / $src_ratio);
78 78
 		}
79 79
 		if ( !$w ) {
80 80
 			//the user wants to resize based on constant height
81
-			$w = round( $h * $src_ratio );
81
+			$w = round($h * $src_ratio);
82 82
 		}
83 83
 		if ( !$crop ) {
84 84
 			return array(
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 		$src_wt = $src_h * $dest_ratio;
93 93
 		$src_ht = $src_w / $dest_ratio;
94 94
 		$src_x = $src_w / 2 - $src_wt / 2;
95
-		$src_y = ( $src_h - $src_ht ) / 6;
95
+		$src_y = ($src_h - $src_ht) / 6;
96 96
 		//now specific overrides based on options:
97 97
 		if ( $crop == 'center' ) {
98 98
 			// Get source x and y
99
-			$src_x = round( ( $src_w - $src_wt ) / 2 );
100
-			$src_y = round( ( $src_h - $src_ht ) / 2 );
99
+			$src_x = round(($src_w - $src_wt) / 2);
100
+			$src_y = round(($src_h - $src_ht) / 2);
101 101
 		} else if ( $crop == 'top' ) {
102 102
 			$src_y = 0;
103 103
 		} else if ( $crop == 'bottom' ) {
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 			//return if successful
140 140
 			//proceed if not
141 141
 			$gif = self::run_animated_gif($load_filename, $save_filename);
142
-			if ($gif) {
142
+			if ( $gif ) {
143 143
 				return true;
144 144
 			}
145 145
 		}
146
-		$image = wp_get_image_editor( $load_filename );
147
-		if ( !is_wp_error( $image ) ) {
148
-			$crop = self::get_target_sizes( $load_filename );
149
-			$image->crop( 	$crop['x'],
146
+		$image = wp_get_image_editor($load_filename);
147
+		if ( !is_wp_error($image) ) {
148
+			$crop = self::get_target_sizes($load_filename);
149
+			$image->crop($crop['x'],
150 150
 							$crop['y'],
151 151
 							$crop['src_w'],
152 152
 							$crop['src_h'],
153 153
 							$crop['target_w'],
154 154
 							$crop['target_h']
155 155
 			);
156
-			$result = $image->save( $save_filename );
157
-			if ( is_wp_error( $result ) ) {
158
-				error_log( 'Error resizing image' );
159
-				error_log( print_r( $result, true ) );
156
+			$result = $image->save($save_filename);
157
+			if ( is_wp_error($result) ) {
158
+				error_log('Error resizing image');
159
+				error_log(print_r($result, true));
160 160
 				return false;
161 161
 			} else {
162 162
 				return true;
163 163
 			}
164
-		} else if ( isset( $image->error_data['error_loading_image'] ) ) {
165
-			TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
164
+		} else if ( isset($image->error_data['error_loading_image']) ) {
165
+			TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']);
166 166
 		} else {
167
-			TimberHelper::error_log( $image );
167
+			TimberHelper::error_log($image);
168 168
 		}
169 169
 	}
170 170
 }
Please login to merge, or discard this patch.
lib/image/timber-image-operation-retina.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Contains the class for running image retina-izing operations
4
- */
3
+	 * Contains the class for running image retina-izing operations
4
+	 */
5 5
 
6 6
 /**
7 7
  * Increases image size by a given factor
@@ -11,62 +11,62 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class TimberImageOperationRetina extends TimberImageOperation {
13 13
 
14
-    private $factor;
14
+	private $factor;
15 15
 
16
-    /**
17
-     * Construct our operation
18
-     * @param float   $factor to multiply original dimensions by
19
-     */
20
-    function __construct($factor) {
21
-        $this->factor = $factor;
22
-    }
16
+	/**
17
+	 * Construct our operation
18
+	 * @param float   $factor to multiply original dimensions by
19
+	 */
20
+	function __construct($factor) {
21
+		$this->factor = $factor;
22
+	}
23 23
 
24
-    /**
25
-     * Generates the final filename based on the source's name and extension
26
-     *
27
-     * @param   string    $src_filename     the basename of the file (ex: my-awesome-pic)
28
-     * @param   string    $src_extension    the extension (ex: .jpg)
29
-     * @return  string    the final filename to be used (ex: [email protected])
30
-     */
31
-    function filename($src_filename, $src_extension) {
32
-        $newbase = $src_filename . '@' . $this->factor . 'x'; // add @2x, @3x, @1.5x, etc.
33
-        $new_name = $newbase . '.' . $src_extension;
34
-        return $new_name;
35
-    }
24
+	/**
25
+	 * Generates the final filename based on the source's name and extension
26
+	 *
27
+	 * @param   string    $src_filename     the basename of the file (ex: my-awesome-pic)
28
+	 * @param   string    $src_extension    the extension (ex: .jpg)
29
+	 * @return  string    the final filename to be used (ex: [email protected])
30
+	 */
31
+	function filename($src_filename, $src_extension) {
32
+		$newbase = $src_filename . '@' . $this->factor . 'x'; // add @2x, @3x, @1.5x, etc.
33
+		$new_name = $newbase . '.' . $src_extension;
34
+		return $new_name;
35
+	}
36 36
 
37
-    /**
38
-     * Performs the actual image manipulation,
39
-     * including saving the target file.
40
-     *
41
-     * @param  string $load_filename filepath (not URL) to source file
42
-     *                               (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
43
-     * @param  string $save_filename filepath (not URL) where result file should be saved
44
-     *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45
-     * @return bool                  true if everything went fine, false otherwise
46
-     */
47
-    function run($load_filename, $save_filename){
48
-        $image = wp_get_image_editor( $load_filename );
49
-        if ( !is_wp_error( $image ) ) {
50
-            $current_size = $image->get_size();
51
-            $src_w = $current_size['width'];
52
-            $src_h = $current_size['height'];
53
-            // Get ratios
54
-            $w = $src_w * $this->factor;
55
-            $h = $src_h * $this->factor;
56
-            $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
-            $result = $image->save( $save_filename );
58
-            if ( is_wp_error( $result ) ) {
59
-                error_log( 'Error resizing image' );
60
-                error_log( print_r( $result, true ) );
61
-                return false;
62
-            } else {
63
-                return true;
64
-            }
65
-        } else if ( isset( $image->error_data['error_loading_image'] ) ) {
66
-            TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
67
-        } else {
68
-            TimberHelper::error_log( $image );
69
-        }
70
-        return false;
71
-    }
37
+	/**
38
+	 * Performs the actual image manipulation,
39
+	 * including saving the target file.
40
+	 *
41
+	 * @param  string $load_filename filepath (not URL) to source file
42
+	 *                               (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
43
+	 * @param  string $save_filename filepath (not URL) where result file should be saved
44
+	 *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45
+	 * @return bool                  true if everything went fine, false otherwise
46
+	 */
47
+	function run($load_filename, $save_filename){
48
+		$image = wp_get_image_editor( $load_filename );
49
+		if ( !is_wp_error( $image ) ) {
50
+			$current_size = $image->get_size();
51
+			$src_w = $current_size['width'];
52
+			$src_h = $current_size['height'];
53
+			// Get ratios
54
+			$w = $src_w * $this->factor;
55
+			$h = $src_h * $this->factor;
56
+			$image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
+			$result = $image->save( $save_filename );
58
+			if ( is_wp_error( $result ) ) {
59
+				error_log( 'Error resizing image' );
60
+				error_log( print_r( $result, true ) );
61
+				return false;
62
+			} else {
63
+				return true;
64
+			}
65
+		} else if ( isset( $image->error_data['error_loading_image'] ) ) {
66
+			TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
67
+		} else {
68
+			TimberHelper::error_log( $image );
69
+		}
70
+		return false;
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,28 +44,28 @@
 block discarded – undo
44 44
      *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45 45
      * @return bool                  true if everything went fine, false otherwise
46 46
      */
47
-    function run($load_filename, $save_filename){
48
-        $image = wp_get_image_editor( $load_filename );
49
-        if ( !is_wp_error( $image ) ) {
47
+    function run($load_filename, $save_filename) {
48
+        $image = wp_get_image_editor($load_filename);
49
+        if ( !is_wp_error($image) ) {
50 50
             $current_size = $image->get_size();
51 51
             $src_w = $current_size['width'];
52 52
             $src_h = $current_size['height'];
53 53
             // Get ratios
54 54
             $w = $src_w * $this->factor;
55 55
             $h = $src_h * $this->factor;
56
-            $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
-            $result = $image->save( $save_filename );
58
-            if ( is_wp_error( $result ) ) {
59
-                error_log( 'Error resizing image' );
60
-                error_log( print_r( $result, true ) );
56
+            $image->crop(0, 0, $src_w, $src_h, $w, $h);
57
+            $result = $image->save($save_filename);
58
+            if ( is_wp_error($result) ) {
59
+                error_log('Error resizing image');
60
+                error_log(print_r($result, true));
61 61
                 return false;
62 62
             } else {
63 63
                 return true;
64 64
             }
65
-        } else if ( isset( $image->error_data['error_loading_image'] ) ) {
66
-            TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
65
+        } else if ( isset($image->error_data['error_loading_image']) ) {
66
+            TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']);
67 67
         } else {
68
-            TimberHelper::error_log( $image );
68
+            TimberHelper::error_log($image);
69 69
         }
70 70
         return false;
71 71
     }
Please login to merge, or discard this patch.
lib/image/timber-image-operation-tojpg.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
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
 
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 * @return resource an image identifier representing the image obtained from the given filename
52 52
 	 *                  will return the same data type regardless of whether the source is gif or png
53 53
 	 */
54
-	function image_create( $filename, $ext = 'auto' ) {
54
+	function image_create($filename, $ext = 'auto') {
55 55
 		if ( $ext == 'auto' ) {
56 56
 			$ext = wp_check_filetype($filename);
57
-			if (isset($ext['ext'])) {
57
+			if ( isset($ext['ext']) ) {
58 58
 				$ext = $ext['ext'];
59 59
 			}
60 60
 		}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		if ( $ext == 'png' ) {
66 66
 			return imagecreatefrompng($filename);
67 67
 		}
68
-		if ( $ext == 'jpg' || $ext == 'jpeg') {
68
+		if ( $ext == 'jpg' || $ext == 'jpeg' ) {
69 69
 			return imagecreatefromjpeg($filename);
70 70
 		}
71 71
 	}
Please login to merge, or discard this patch.
lib/image/timber-image-operation.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Each image filter is represented by a subclass of this class,m
4
- * and each filter call is a new instance, with call arguments as properties.
5
- * 
6
- * Only 3 methods need to be implemented:
7
- * - constructor, storing all filter arguments
8
- * - filename
9
- * - run
10
- */
3
+	 * Each image filter is represented by a subclass of this class,m
4
+	 * and each filter call is a new instance, with call arguments as properties.
5
+	 * 
6
+	 * Only 3 methods need to be implemented:
7
+	 * - constructor, storing all filter arguments
8
+	 * - filename
9
+	 * - run
10
+	 */
11 11
 abstract class TimberImageOperation {
12 12
 	/**
13 13
 	 * Builds the result filename, based on source filename and extension
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@
 block discarded – undo
36 36
 	 * @return array          array('red', 'green', 'blue') to int
37 37
 	 *                        ex: array('red' => 255, 'green' => 20, 'blue' => 85);
38 38
 	 */
39
-	public static function hexrgb( $hexstr ) {
40
-		if ( !strstr( $hexstr, '#' ) ) {
39
+	public static function hexrgb($hexstr) {
40
+		if ( !strstr($hexstr, '#') ) {
41 41
 			$hexstr = '#' . $hexstr;
42 42
 		}
43
-		if ( strlen( $hexstr ) == 4 ) {
43
+		if ( strlen($hexstr) == 4 ) {
44 44
 			$hexstr = '#' . $hexstr[1] . $hexstr[1] . $hexstr[2] . $hexstr[2] . $hexstr[3] . $hexstr[3];
45 45
 		}
46
-		$int = hexdec( $hexstr );
47
-		return array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int );
46
+		$int = hexdec($hexstr);
47
+		return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($int >> 0x8), "blue" => 0xFF & $int);
48 48
 	}
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
lib/integrations/acf-timber.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -2,57 +2,57 @@
 block discarded – undo
2 2
 
3 3
 class ACFTimber {
4 4
 
5
-    function __construct() {
6
-        add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
-        add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
-        add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
-        add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
-        add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
-        add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
12
-    }
13
-
14
-    function post_get_meta( $customs, $post_id ) {
15
-        return $customs;
16
-    }
17
-
18
-    function post_get_meta_field( $value, $post_id, $field_name ) {
19
-        return get_field( $field_name, $post_id );
20
-    }
21
-
22
-    function term_get_meta_field( $value, $term_id, $field_name, $term ) {
23
-        $searcher = $term->taxonomy . "_" . $term->ID;
24
-        return get_field( $field_name, $searcher );
25
-    }
26
-
27
-    function term_set_meta( $value, $field, $term_id, $term ) {
28
-        $searcher = $term->taxonomy . "_" . $term->ID;
29
-        update_field( $field, $value, $searcher );
30
-        return $value;
31
-    }
32
-
33
-    function term_get_meta( $fields, $term_id, $term ) {
34
-        $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
-        $fds = get_fields( $searcher );
36
-        if ( is_array( $fds ) ) {
37
-            foreach ( $fds as $key => $value ) {
38
-                $key = preg_replace( '/_/', '', $key, 1 );
39
-                $key = str_replace( $searcher, '', $key );
40
-                $key = preg_replace( '/_/', '', $key, 1 );
41
-                $field = get_field( $key, $searcher );
42
-                $fields[$key] = $field;
43
-            }
44
-            $fields = array_merge( $fields, $fds );
45
-        }
46
-        return $fields;
47
-    }
48
-
49
-    function user_get_meta( $fields, $user_id ) {
50
-        return $fields;
51
-    }
52
-
53
-    function user_get_meta_field( $value, $uid, $field ) {
54
-        return get_field( $field, 'user_' . $uid );
55
-    }
5
+	function __construct() {
6
+		add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
+		add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
+		add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
+		add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
+		add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
+		add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
12
+	}
13
+
14
+	function post_get_meta( $customs, $post_id ) {
15
+		return $customs;
16
+	}
17
+
18
+	function post_get_meta_field( $value, $post_id, $field_name ) {
19
+		return get_field( $field_name, $post_id );
20
+	}
21
+
22
+	function term_get_meta_field( $value, $term_id, $field_name, $term ) {
23
+		$searcher = $term->taxonomy . "_" . $term->ID;
24
+		return get_field( $field_name, $searcher );
25
+	}
26
+
27
+	function term_set_meta( $value, $field, $term_id, $term ) {
28
+		$searcher = $term->taxonomy . "_" . $term->ID;
29
+		update_field( $field, $value, $searcher );
30
+		return $value;
31
+	}
32
+
33
+	function term_get_meta( $fields, $term_id, $term ) {
34
+		$searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
+		$fds = get_fields( $searcher );
36
+		if ( is_array( $fds ) ) {
37
+			foreach ( $fds as $key => $value ) {
38
+				$key = preg_replace( '/_/', '', $key, 1 );
39
+				$key = str_replace( $searcher, '', $key );
40
+				$key = preg_replace( '/_/', '', $key, 1 );
41
+				$field = get_field( $key, $searcher );
42
+				$fields[$key] = $field;
43
+			}
44
+			$fields = array_merge( $fields, $fds );
45
+		}
46
+		return $fields;
47
+	}
48
+
49
+	function user_get_meta( $fields, $user_id ) {
50
+		return $fields;
51
+	}
52
+
53
+	function user_get_meta_field( $value, $uid, $field ) {
54
+		return get_field( $field, 'user_' . $uid );
55
+	}
56 56
 }
57 57
 
58 58
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -3,55 +3,55 @@
 block discarded – undo
3 3
 class ACFTimber {
4 4
 
5 5
     function __construct() {
6
-        add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
-        add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
-        add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
-        add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
-        add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
-        add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
6
+        add_filter('timber_post_get_meta', array($this, 'post_get_meta'), 10, 2);
7
+        add_filter('timber_post_get_meta_field', array($this, 'post_get_meta_field'), 10, 3);
8
+        add_filter('timber_term_get_meta', array($this, 'term_get_meta'), 10, 3);
9
+        add_filter('timber_term_get_meta_field', array($this, 'term_get_meta_field'), 10, 4);
10
+        add_filter('timber_user_get_meta_field_pre', array($this, 'user_get_meta_field'), 10, 3);
11
+        add_filter('timber_term_set_meta', array($this, 'term_set_meta'), 10, 4);
12 12
     }
13 13
 
14
-    function post_get_meta( $customs, $post_id ) {
14
+    function post_get_meta($customs, $post_id) {
15 15
         return $customs;
16 16
     }
17 17
 
18
-    function post_get_meta_field( $value, $post_id, $field_name ) {
19
-        return get_field( $field_name, $post_id );
18
+    function post_get_meta_field($value, $post_id, $field_name) {
19
+        return get_field($field_name, $post_id);
20 20
     }
21 21
 
22
-    function term_get_meta_field( $value, $term_id, $field_name, $term ) {
22
+    function term_get_meta_field($value, $term_id, $field_name, $term) {
23 23
         $searcher = $term->taxonomy . "_" . $term->ID;
24
-        return get_field( $field_name, $searcher );
24
+        return get_field($field_name, $searcher);
25 25
     }
26 26
 
27
-    function term_set_meta( $value, $field, $term_id, $term ) {
27
+    function term_set_meta($value, $field, $term_id, $term) {
28 28
         $searcher = $term->taxonomy . "_" . $term->ID;
29
-        update_field( $field, $value, $searcher );
29
+        update_field($field, $value, $searcher);
30 30
         return $value;
31 31
     }
32 32
 
33
-    function term_get_meta( $fields, $term_id, $term ) {
33
+    function term_get_meta($fields, $term_id, $term) {
34 34
         $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
-        $fds = get_fields( $searcher );
36
-        if ( is_array( $fds ) ) {
37
-            foreach ( $fds as $key => $value ) {
38
-                $key = preg_replace( '/_/', '', $key, 1 );
39
-                $key = str_replace( $searcher, '', $key );
40
-                $key = preg_replace( '/_/', '', $key, 1 );
41
-                $field = get_field( $key, $searcher );
35
+        $fds = get_fields($searcher);
36
+        if ( is_array($fds) ) {
37
+            foreach ($fds as $key => $value) {
38
+                $key = preg_replace('/_/', '', $key, 1);
39
+                $key = str_replace($searcher, '', $key);
40
+                $key = preg_replace('/_/', '', $key, 1);
41
+                $field = get_field($key, $searcher);
42 42
                 $fields[$key] = $field;
43 43
             }
44
-            $fields = array_merge( $fields, $fds );
44
+            $fields = array_merge($fields, $fds);
45 45
         }
46 46
         return $fields;
47 47
     }
48 48
 
49
-    function user_get_meta( $fields, $user_id ) {
49
+    function user_get_meta($fields, $user_id) {
50 50
         return $fields;
51 51
     }
52 52
 
53
-    function user_get_meta_field( $value, $uid, $field ) {
54
-        return get_field( $field, 'user_' . $uid );
53
+    function user_get_meta_field($value, $uid, $field) {
54
+        return get_field($field, 'user_' . $uid);
55 55
     }
56 56
 }
57 57
 
Please login to merge, or discard this patch.
lib/integrations/timber-command.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
  */
7 7
 class TimberCommand {
8 8
 
9
-    public static function clear_cache($mode = 'all'){
10
-        if (is_array($mode)){
11
-            $mode = reset($mode);
12
-        }
13
-        if ($mode == 'all') {
14
-            $twig_cache = self::clear_cache_twig();
15
-            $timber_cache = self::clear_cache_timber();
16
-            if ($twig_cache && $timber_cache){
17
-                return true;
18
-            }
19
-        } else if ($mode == 'twig') {
20
-            return self::clear_cache_twig();
21
-        } else if ($mode == 'timber') {
22
-            return self::clear_cache_timber();
23
-        }
24
-    }
9
+	public static function clear_cache($mode = 'all'){
10
+		if (is_array($mode)){
11
+			$mode = reset($mode);
12
+		}
13
+		if ($mode == 'all') {
14
+			$twig_cache = self::clear_cache_twig();
15
+			$timber_cache = self::clear_cache_timber();
16
+			if ($twig_cache && $timber_cache){
17
+				return true;
18
+			}
19
+		} else if ($mode == 'twig') {
20
+			return self::clear_cache_twig();
21
+		} else if ($mode == 'timber') {
22
+			return self::clear_cache_timber();
23
+		}
24
+	}
25 25
 
26
-    static function clear_cache_timber(){
27
-        $loader = new TimberLoader();
28
-        return $loader->clear_cache_timber();
29
-    }
26
+	static function clear_cache_timber(){
27
+		$loader = new TimberLoader();
28
+		return $loader->clear_cache_timber();
29
+	}
30 30
 
31
-    static function clear_cache_twig(){
32
-        $loader = new TimberLoader();
33
-        return $loader->clear_cache_twig();
34
-    }
31
+	static function clear_cache_twig(){
32
+		$loader = new TimberLoader();
33
+		return $loader->clear_cache_twig();
34
+	}
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
  */
7 7
 class TimberCommand {
8 8
 
9
-    public static function clear_cache($mode = 'all'){
10
-        if (is_array($mode)){
9
+    public static function clear_cache($mode = 'all') {
10
+        if ( is_array($mode) ) {
11 11
             $mode = reset($mode);
12 12
         }
13
-        if ($mode == 'all') {
13
+        if ( $mode == 'all' ) {
14 14
             $twig_cache = self::clear_cache_twig();
15 15
             $timber_cache = self::clear_cache_timber();
16
-            if ($twig_cache && $timber_cache){
16
+            if ( $twig_cache && $timber_cache ) {
17 17
                 return true;
18 18
             }
19
-        } else if ($mode == 'twig') {
19
+        } else if ( $mode == 'twig' ) {
20 20
             return self::clear_cache_twig();
21
-        } else if ($mode == 'timber') {
21
+        } else if ( $mode == 'timber' ) {
22 22
             return self::clear_cache_timber();
23 23
         }
24 24
     }
25 25
 
26
-    static function clear_cache_timber(){
26
+    static function clear_cache_timber() {
27 27
         $loader = new TimberLoader();
28 28
         return $loader->clear_cache_timber();
29 29
     }
30 30
 
31
-    static function clear_cache_twig(){
31
+    static function clear_cache_twig() {
32 32
         $loader = new TimberLoader();
33 33
         return $loader->clear_cache_twig();
34 34
     }
Please login to merge, or discard this patch.
lib/integrations/wpcli-timber.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -5,53 +5,53 @@
 block discarded – undo
5 5
 
6 6
 class Timber_WP_CLI_Command extends WP_CLI_Command {
7 7
 
8
-    /**
9
-     * Clears Timber and Twig's Cache
10
-     *
11
-     * ## EXAMPLES
12
-     *
13
-     *    wp timber clear_cache
14
-     *
15
-     */
16
-    public function clear_cache($mode = 'all') {
17
-        TimberCommand::clear_cache($mode);
18
-    }
8
+	/**
9
+	 * Clears Timber and Twig's Cache
10
+	 *
11
+	 * ## EXAMPLES
12
+	 *
13
+	 *    wp timber clear_cache
14
+	 *
15
+	 */
16
+	public function clear_cache($mode = 'all') {
17
+		TimberCommand::clear_cache($mode);
18
+	}
19 19
 
20
-    /**
21
-     * Clears Twig's Cache
22
-     *
23
-     * ## EXAMPLES
24
-     *
25
-     *    wp timber clear_cache_twig
26
-     *
27
-     */
28
-    function clear_cache_twig(){
29
-        $clear = TimberCommand::clear_cache_twig();
30
-        if ($clear){
31
-            WP_CLI::success('Cleared contents of twig cache');
32
-        } else {
33
-            WP_CLI::warning('Failed to clear twig cache');
34
-        }
35
-    }
20
+	/**
21
+	 * Clears Twig's Cache
22
+	 *
23
+	 * ## EXAMPLES
24
+	 *
25
+	 *    wp timber clear_cache_twig
26
+	 *
27
+	 */
28
+	function clear_cache_twig(){
29
+		$clear = TimberCommand::clear_cache_twig();
30
+		if ($clear){
31
+			WP_CLI::success('Cleared contents of twig cache');
32
+		} else {
33
+			WP_CLI::warning('Failed to clear twig cache');
34
+		}
35
+	}
36 36
 
37
-    /**
38
-     * Clears Timber's Cache
39
-     *
40
-     * ## EXAMPLES
41
-     *
42
-     *    wp timber clear_cache_timber
43
-     *
44
-     */
45
-    function clear_cache_timber() {
46
-        $clear = TimberCommand::clear_cache_timber();
47
-        $message = 'Failed to clear timber cache';
48
-        if ($clear){
49
-            $message = "Cleared contents of Timber's Cache";
50
-            WP_CLI::success($message);
51
-        } else {
52
-            WP_CLI::warning($message);
53
-        }
54
-        return $message;
55
-    }
37
+	/**
38
+	 * Clears Timber's Cache
39
+	 *
40
+	 * ## EXAMPLES
41
+	 *
42
+	 *    wp timber clear_cache_timber
43
+	 *
44
+	 */
45
+	function clear_cache_timber() {
46
+		$clear = TimberCommand::clear_cache_timber();
47
+		$message = 'Failed to clear timber cache';
48
+		if ($clear){
49
+			$message = "Cleared contents of Timber's Cache";
50
+			WP_CLI::success($message);
51
+		} else {
52
+			WP_CLI::warning($message);
53
+		}
54
+		return $message;
55
+	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!class_exists('WP_CLI_Command')) {
2
+if ( !class_exists('WP_CLI_Command') ) {
3 3
 	return;
4 4
 }
5 5
 
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      *    wp timber clear_cache_twig
26 26
      *
27 27
      */
28
-    function clear_cache_twig(){
28
+    function clear_cache_twig() {
29 29
         $clear = TimberCommand::clear_cache_twig();
30
-        if ($clear){
30
+        if ( $clear ) {
31 31
             WP_CLI::success('Cleared contents of twig cache');
32 32
         } else {
33 33
             WP_CLI::warning('Failed to clear twig cache');
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     function clear_cache_timber() {
46 46
         $clear = TimberCommand::clear_cache_timber();
47 47
         $message = 'Failed to clear timber cache';
48
-        if ($clear){
48
+        if ( $clear ) {
49 49
             $message = "Cleared contents of Timber's Cache";
50 50
             WP_CLI::success($message);
51 51
         } else {
Please login to merge, or discard this patch.