Completed
Push — master ( 3fb30d...2b3c4d )
by Jared
9s
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.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.
lib/timber-admin.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@
 block discarded – undo
2 2
 
3 3
 class TimberAdmin {
4 4
 
5
-    public static function init() {
6
-        return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 );
7
-    }
5
+	public static function init() {
6
+		return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 );
7
+	}
8 8
 
9 9
 	/**
10 10
 	 * @param array   $links
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class TimberAdmin {
4 4
 
5 5
     public static function init() {
6
-        return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 );
6
+        return add_filter('plugin_row_meta', array(__CLASS__, 'meta_links'), 10, 2);
7 7
     }
8 8
 
9 9
 	/**
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 	 * @param string  $file
12 12
 	 * @return array
13 13
 	 */
14
-	public static function meta_links( $links, $file ) {
15
-		if ( strstr( $file, '/timber.php' ) ) {
14
+	public static function meta_links($links, $file) {
15
+		if ( strstr($file, '/timber.php') ) {
16 16
 			unset($links[2]);
17 17
 			$links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&amp;plugin=timber-library&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
18 18
 			$links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
Please login to merge, or discard this patch.
lib/timber-core-interface.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 
3 3
 interface TimberCoreInterface {
4 4
 
5
-	public function __call( $field, $args );
5
+	public function __call($field, $args);
6 6
 
7
-	public function __get( $field );
7
+	public function __get($field);
8 8
 
9 9
 	/**
10 10
 	 * @return boolean
11 11
 	 */
12
-	public function __isset( $field );
12
+	public function __isset($field);
13 13
 
14
-	public function meta( $key );
14
+	public function meta($key);
15 15
 
16 16
 }
Please login to merge, or discard this patch.
lib/timber-core.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -2,116 +2,116 @@
 block discarded – undo
2 2
 
3 3
 abstract class TimberCore {
4 4
 
5
-    public $id;
6
-    public $ID;
7
-    public $object_type;
5
+	public $id;
6
+	public $ID;
7
+	public $object_type;
8 8
 
9
-    /**
10
-     *
11
-     *
12
-     * @return boolean
13
-     */
14
-    function __isset( $field ) {
15
-        if ( isset( $this->$field ) ) {
16
-            return $this->$field;
17
-        }
18
-        return false;
19
-    }
9
+	/**
10
+	 *
11
+	 *
12
+	 * @return boolean
13
+	 */
14
+	function __isset( $field ) {
15
+		if ( isset( $this->$field ) ) {
16
+			return $this->$field;
17
+		}
18
+		return false;
19
+	}
20 20
 
21
-    /**
22
-     * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
23
-     * @return mixed
24
-     */
25
-    function __call( $field, $args ) {
26
-        return $this->__get( $field );
27
-    }
21
+	/**
22
+	 * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
23
+	 * @return mixed
24
+	 */
25
+	function __call( $field, $args ) {
26
+		return $this->__get( $field );
27
+	}
28 28
 
29
-    /**
30
-     * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
31
-     *
32
-     * @return mixed
33
-     */
34
-    function __get( $field ) {
35
-    	if ( property_exists($this, $field) ) {
36
-    		return $this->$field;
37
-    	}
38
-        if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) {
39
-            return $this->$field = $meta_value;
40
-        }
41
-        if ( method_exists($this, $field) ) {
42
-            return $this->$field = $this->$field();
43
-        }
44
-        return $this->$field = false;
45
-    }
29
+	/**
30
+	 * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
31
+	 *
32
+	 * @return mixed
33
+	 */
34
+	function __get( $field ) {
35
+		if ( property_exists($this, $field) ) {
36
+			return $this->$field;
37
+		}
38
+		if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) {
39
+			return $this->$field = $meta_value;
40
+		}
41
+		if ( method_exists($this, $field) ) {
42
+			return $this->$field = $this->$field();
43
+		}
44
+		return $this->$field = false;
45
+	}
46 46
 
47
-    /**
48
-     * Takes an array or object and adds the properties to the parent object
49
-     * @example
50
-     * ```php
51
-     * $data = array('airplane' => '757-200', 'flight' => '5316');
52
-     * $post = new TimberPost()
53
-     * $post->import(data);
54
-     * echo $post->airplane; //757-200
55
-     * ```
56
-     * @param array|object $info an object or array you want to grab data from to attach to the Timber object
57
-     */
58
-    function import( $info, $force = false ) {
59
-        if ( is_object( $info ) ) {
60
-            $info = get_object_vars( $info );
61
-        }
62
-        if ( is_array( $info ) ) {
63
-            foreach ( $info as $key => $value ) {
64
-                if ( !empty( $key ) && $force ) {
65
-                    $this->$key = $value;
66
-                } else if ( !empty( $key ) && !method_exists($this, $key) ){
67
-                    $this->$key = $value;
68
-                }
69
-            }
70
-        }
71
-    }
47
+	/**
48
+	 * Takes an array or object and adds the properties to the parent object
49
+	 * @example
50
+	 * ```php
51
+	 * $data = array('airplane' => '757-200', 'flight' => '5316');
52
+	 * $post = new TimberPost()
53
+	 * $post->import(data);
54
+	 * echo $post->airplane; //757-200
55
+	 * ```
56
+	 * @param array|object $info an object or array you want to grab data from to attach to the Timber object
57
+	 */
58
+	function import( $info, $force = false ) {
59
+		if ( is_object( $info ) ) {
60
+			$info = get_object_vars( $info );
61
+		}
62
+		if ( is_array( $info ) ) {
63
+			foreach ( $info as $key => $value ) {
64
+				if ( !empty( $key ) && $force ) {
65
+					$this->$key = $value;
66
+				} else if ( !empty( $key ) && !method_exists($this, $key) ){
67
+					$this->$key = $value;
68
+				}
69
+			}
70
+		}
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @ignore
76
-     * @param string  $key
77
-     * @param mixed   $value
78
-     */
79
-    function update( $key, $value ) {
80
-        update_metadata( $this->object_type, $this->ID, $key, $value );
81
-    }
74
+	/**
75
+	 * @ignore
76
+	 * @param string  $key
77
+	 * @param mixed   $value
78
+	 */
79
+	function update( $key, $value ) {
80
+		update_metadata( $this->object_type, $this->ID, $key, $value );
81
+	}
82 82
 
83
-    /**
84
-     * Can you edit this post/term/user? Well good for you. You're no better than me.
85
-     * @example
86
-     * ```twig
87
-     * {% if post.can_edit %}
88
-     * <a href="{{ post.edit_link }}">Edit</a>
89
-     * {% endif %}
90
-     * ```
91
-     * ```html
92
-     * <a href="http://example.org/wp-admin/edit.php?p=242">Edit</a>
93
-     * ```
94
-     * @return bool
95
-     */
96
-    function can_edit() {
97
-        if ( !function_exists( 'current_user_can' ) ) {
98
-            return false;
99
-        }
100
-        if ( current_user_can( 'edit_post', $this->ID ) ) {
101
-            return true;
102
-        }
103
-        return false;
104
-    }
83
+	/**
84
+	 * Can you edit this post/term/user? Well good for you. You're no better than me.
85
+	 * @example
86
+	 * ```twig
87
+	 * {% if post.can_edit %}
88
+	 * <a href="{{ post.edit_link }}">Edit</a>
89
+	 * {% endif %}
90
+	 * ```
91
+	 * ```html
92
+	 * <a href="http://example.org/wp-admin/edit.php?p=242">Edit</a>
93
+	 * ```
94
+	 * @return bool
95
+	 */
96
+	function can_edit() {
97
+		if ( !function_exists( 'current_user_can' ) ) {
98
+			return false;
99
+		}
100
+		if ( current_user_can( 'edit_post', $this->ID ) ) {
101
+			return true;
102
+		}
103
+		return false;
104
+	}
105 105
 
106
-    /**
107
-     *
108
-     *
109
-     * @return array
110
-     */
111
-    function get_method_values() {
112
-        $ret = array();
113
-        $ret['can_edit'] = $this->can_edit();
114
-        return $ret;
115
-    }
106
+	/**
107
+	 *
108
+	 *
109
+	 * @return array
110
+	 */
111
+	function get_method_values() {
112
+		$ret = array();
113
+		$ret['can_edit'] = $this->can_edit();
114
+		return $ret;
115
+	}
116 116
 
117 117
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @return boolean
13 13
      */
14
-    function __isset( $field ) {
15
-        if ( isset( $this->$field ) ) {
14
+    function __isset($field) {
15
+        if ( isset($this->$field) ) {
16 16
             return $this->$field;
17 17
         }
18 18
         return false;
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
      * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
23 23
      * @return mixed
24 24
      */
25
-    function __call( $field, $args ) {
26
-        return $this->__get( $field );
25
+    function __call($field, $args) {
26
+        return $this->__get($field);
27 27
     }
28 28
 
29 29
     /**
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return mixed
33 33
      */
34
-    function __get( $field ) {
34
+    function __get($field) {
35 35
     	if ( property_exists($this, $field) ) {
36 36
     		return $this->$field;
37 37
     	}
38
-        if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) {
38
+        if ( method_exists($this, 'meta') && $meta_value = $this->meta($field) ) {
39 39
             return $this->$field = $meta_value;
40 40
         }
41 41
         if ( method_exists($this, $field) ) {
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
      * ```
56 56
      * @param array|object $info an object or array you want to grab data from to attach to the Timber object
57 57
      */
58
-    function import( $info, $force = false ) {
59
-        if ( is_object( $info ) ) {
60
-            $info = get_object_vars( $info );
58
+    function import($info, $force = false) {
59
+        if ( is_object($info) ) {
60
+            $info = get_object_vars($info);
61 61
         }
62
-        if ( is_array( $info ) ) {
63
-            foreach ( $info as $key => $value ) {
64
-                if ( !empty( $key ) && $force ) {
62
+        if ( is_array($info) ) {
63
+            foreach ($info as $key => $value) {
64
+                if ( !empty($key) && $force ) {
65 65
                     $this->$key = $value;
66
-                } else if ( !empty( $key ) && !method_exists($this, $key) ){
66
+                } else if ( !empty($key) && !method_exists($this, $key) ) {
67 67
                     $this->$key = $value;
68 68
                 }
69 69
             }
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
      * @param string  $key
77 77
      * @param mixed   $value
78 78
      */
79
-    function update( $key, $value ) {
80
-        update_metadata( $this->object_type, $this->ID, $key, $value );
79
+    function update($key, $value) {
80
+        update_metadata($this->object_type, $this->ID, $key, $value);
81 81
     }
82 82
 
83 83
     /**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
      * @return bool
95 95
      */
96 96
     function can_edit() {
97
-        if ( !function_exists( 'current_user_can' ) ) {
97
+        if ( !function_exists('current_user_can') ) {
98 98
             return false;
99 99
         }
100
-        if ( current_user_can( 'edit_post', $this->ID ) ) {
100
+        if ( current_user_can('edit_post', $this->ID) ) {
101 101
             return true;
102 102
         }
103 103
         return false;
Please login to merge, or discard this patch.
lib/timber-image-helper.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -108,23 +108,23 @@
 block discarded – undo
108 108
 		//its a gif so test
109 109
 		if(!($fh = @fopen($file, 'rb'))) {
110 110
 		  	return false;
111
-	    }
112
-	    $count = 0;
113
-	    //an animated gif contains multiple "frames", with each frame having a
114
-	    //header made up of:
115
-	    // * a static 4-byte sequence (\x00\x21\xF9\x04)
116
-	    // * 4 variable bytes
117
-	    // * a static 2-byte sequence (\x00\x2C)
111
+		}
112
+		$count = 0;
113
+		//an animated gif contains multiple "frames", with each frame having a
114
+		//header made up of:
115
+		// * a static 4-byte sequence (\x00\x21\xF9\x04)
116
+		// * 4 variable bytes
117
+		// * a static 2-byte sequence (\x00\x2C)
118 118
 
119
-	    // We read through the file til we reach the end of the file, or we've found
120
-	    // at least 2 frame headers
121
-	    while(!feof($fh) && $count < 2) {
122
-	        $chunk = fread($fh, 1024 * 100); //read 100kb at a time
123
-	        $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches);
124
-	    }
119
+		// We read through the file til we reach the end of the file, or we've found
120
+		// at least 2 frame headers
121
+		while(!feof($fh) && $count < 2) {
122
+			$chunk = fread($fh, 1024 * 100); //read 100kb at a time
123
+			$count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches);
124
+		}
125 125
 
126
-	    fclose($fh);
127
-	    return $count > 1;
126
+		fclose($fh);
127
+		return $count > 1;
128 128
 	}
129 129
 
130 130
 	/**
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * ```
44 44
 	 * @return string (ex: )
45 45
 	 */
46
-	public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
47
-		if (!is_numeric($w) && is_string($w)) {
48
-			if ($sizes = self::find_wp_dimensions($w)) {
46
+	public static function resize($src, $w, $h = 0, $crop = 'default', $force = false) {
47
+		if ( !is_numeric($w) && is_string($w) ) {
48
+			if ( $sizes = self::find_wp_dimensions($w) ) {
49 49
 				$w = $sizes['w'];
50 50
 				$h = $sizes['h'];
51 51
 			} else {
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 *     @type int h
67 67
 	 * }
68 68
 	 */
69
-	private static function find_wp_dimensions( $size ) {
69
+	private static function find_wp_dimensions($size) {
70 70
 		global $_wp_additional_image_sizes;
71
-		if (isset($_wp_additional_image_sizes[$size])) {
71
+		if ( isset($_wp_additional_image_sizes[$size]) ) {
72 72
 			$w = $_wp_additional_image_sizes[$size]['width'];
73 73
 			$h = $_wp_additional_image_sizes[$size]['height'];
74
-		} else if (in_array($size, array('thumbnail', 'medium', 'large'))) {
75
-			$w = get_option($size.'_size_w');
76
-			$h = get_option($size.'_size_h');
74
+		} else if ( in_array($size, array('thumbnail', 'medium', 'large')) ) {
75
+			$w = get_option($size . '_size_w');
76
+			$h = get_option($size . '_size_h');
77 77
 		}
78
-		if (isset($w) && isset($h) && ($w || $h)) {
78
+		if ( isset($w) && isset($h) && ($w || $h) ) {
79 79
 			return array('w' => $w, 'h' => $h);
80 80
 		}
81 81
 		return false;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return string url to the new image
92 92
 	 */
93
-	public static function retina_resize( $src, $multiplier = 2, $force = false ) {
93
+	public static function retina_resize($src, $multiplier = 2, $force = false) {
94 94
 		$op = new TimberImageOperationRetina($multiplier);
95 95
 		return self::_operate($src, $op, $force);
96 96
 	}
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 * @param  string  $file local filepath to a file, not a URL
101 101
 	 * @return boolean true if it's an animated gif, false if not
102 102
 	 */
103
-	public static function is_animated_gif( $file ) {
103
+	public static function is_animated_gif($file) {
104 104
 		if ( strpos(strtolower($file), '.gif') == -1 ) {
105 105
 			//doesn't have .gif, bail
106 106
 			return false;
107 107
 		}
108 108
 		//its a gif so test
109
-		if( !($fh = @fopen($file, 'rb')) ) {
109
+		if ( !($fh = @fopen($file, 'rb')) ) {
110 110
 		  	return false;
111 111
 	    }
112 112
 	    $count = 0;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 	    // We read through the file til we reach the end of the file, or we've found
120 120
 	    // at least 2 frame headers
121
-	    while(!feof($fh) && $count < 2) {
121
+	    while (!feof($fh) && $count < 2) {
122 122
 	        $chunk = fread($fh, 1024 * 100); //read 100kb at a time
123 123
 	        $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches);
124 124
 	    }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param bool    $force
139 139
 	 * @return mixed|null|string
140 140
 	 */
141
-	public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) {
141
+	public static function letterbox($src, $w, $h, $color = '#000000', $force = false) {
142 142
 		$op = new TimberImageOperationLetterbox($w, $h, $color);
143 143
 		return self::_operate($src, $op, $force);
144 144
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string  $bghex
151 151
 	 * @return string
152 152
 	 */
153
-	public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) {
153
+	public static function img_to_jpg($src, $bghex = '#FFFFFF', $force = false) {
154 154
 		$op = new TimberImageOperationToJpg($bghex);
155 155
 		return self::_operate($src, $op, $force);
156 156
 	}
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 	 * Deletes all resized versions of an image when the source is deleted
160 160
 	 */
161 161
 	protected static function add_actions() {
162
-		add_action( 'delete_attachment', function ( $post_id ) {
163
-			$post = get_post( $post_id );
164
-			$image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
165
-			if ( in_array( $post->post_mime_type, $image_types ) ) {
166
-				$attachment = new TimberImage( $post_id );
162
+		add_action('delete_attachment', function($post_id) {
163
+			$post = get_post($post_id);
164
+			$image_types = array('image/jpeg', 'image/png', 'image/gif', 'image/jpg');
165
+			if ( in_array($post->post_mime_type, $image_types) ) {
166
+				$attachment = new TimberImage($post_id);
167 167
 				if ( $attachment->file_loc ) {
168
-					TimberImageHelper::delete_generated_files( $attachment->file_loc );
168
+					TimberImageHelper::delete_generated_files($attachment->file_loc);
169 169
 				}
170 170
 			}
171 171
 		} );
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 * for example /wp-content or /content
177 177
 	 */
178 178
 	protected static function add_constants() {
179
-		if ( !defined( 'WP_CONTENT_SUBDIR' ) ) {
180
-			$wp_content_path = str_replace( home_url(), '', WP_CONTENT_URL );
181
-			define( 'WP_CONTENT_SUBDIR', $wp_content_path );
179
+		if ( !defined('WP_CONTENT_SUBDIR') ) {
180
+			$wp_content_path = str_replace(home_url(), '', WP_CONTENT_URL);
181
+			define('WP_CONTENT_SUBDIR', $wp_content_path);
182 182
 		}
183 183
 	}
184 184
 
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @return void
189 189
 	 */
190 190
 	static function add_filters() {
191
-		add_filter( 'upload_dir', function ( $arr ) {
192
-			$arr['relative'] = str_replace( home_url(), '', $arr['baseurl'] );
191
+		add_filter('upload_dir', function($arr) {
192
+			$arr['relative'] = str_replace(home_url(), '', $arr['baseurl']);
193 193
 			return $arr;
194 194
 		} );
195 195
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	 * @param string  $local_file   ex: /var/www/wp-content/uploads/2015/my-pic.jpg
201 201
 	 *                              or: http://example.org/wp-content/uploads/2015/my-pic.jpg
202 202
 	 */
203
-	static function delete_generated_files( $local_file ) {
204
-		if (TimberURLHelper::is_absolute( $local_file ) ) {
205
-			$local_file = TimberURLHelper::url_to_file_system( $local_file );
203
+	static function delete_generated_files($local_file) {
204
+		if ( TimberURLHelper::is_absolute($local_file) ) {
205
+			$local_file = TimberURLHelper::url_to_file_system($local_file);
206 206
 		}
207
-		$info = pathinfo( $local_file );
207
+		$info = pathinfo($local_file);
208 208
 		$dir = $info['dirname'];
209 209
 		$ext = $info['extension'];
210 210
 		$filename = $info['filename'];
211
-		self::process_delete_generated_files( $filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.' );
212
-		self::process_delete_generated_files( $filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.' );
211
+		self::process_delete_generated_files($filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.');
212
+		self::process_delete_generated_files($filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.');
213 213
 	}
214 214
 
215 215
 	/**
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 	 * @param string 	$search_pattern pattern of files to pluck from
227 227
 	 * @param string 	$match_pattern pattern of files to go forth and delete
228 228
 	 */
229
-	protected static function process_delete_generated_files( $filename, $ext, $dir, $search_pattern, $match_pattern ) {
229
+	protected static function process_delete_generated_files($filename, $ext, $dir, $search_pattern, $match_pattern) {
230 230
 		$searcher = '/' . $filename . $search_pattern;
231
-		foreach ( glob( $dir . $searcher ) as $found_file ) {
232
-			$regexdir = str_replace( '/', '\/', $dir );
233
-			$pattern = '/' . ( $regexdir ) . '\/' . $filename . $match_pattern . $ext . '/';
234
-			$match = preg_match( $pattern, $found_file );
231
+		foreach (glob($dir . $searcher) as $found_file) {
232
+			$regexdir = str_replace('/', '\/', $dir);
233
+			$pattern = '/' . ($regexdir) . '\/' . $filename . $match_pattern . $ext . '/';
234
+			$match = preg_match($pattern, $found_file);
235 235
 			if ( $match ) {
236
-				unlink( $found_file );
236
+				unlink($found_file);
237 237
 			}
238 238
 		}
239 239
 	}
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 	 * @param string  $url
246 246
 	 * @return string
247 247
 	 */
248
-	public static function get_server_location( $url ) {
248
+	public static function get_server_location($url) {
249 249
 		// if we're already an absolute dir, just return
250
-		if ( 0 === strpos( $url, ABSPATH ) ) {
250
+		if ( 0 === strpos($url, ABSPATH) ) {
251 251
 			return $url;
252 252
 		}
253 253
 		// otherwise, analyze URL then build mapping path
@@ -262,15 +262,15 @@  discard block
 block discarded – undo
262 262
 	 * @param string  $file
263 263
 	 * @return string
264 264
 	 */
265
-	public static function get_sideloaded_file_loc( $file ) {
265
+	public static function get_sideloaded_file_loc($file) {
266 266
 		$upload = wp_upload_dir();
267 267
 		$dir = $upload['path'];
268 268
 		$filename = $file;
269
-		$file = parse_url( $file );
270
-		$path_parts = pathinfo( $file['path'] );
271
-		$basename = md5( $filename );
269
+		$file = parse_url($file);
270
+		$path_parts = pathinfo($file['path']);
271
+		$basename = md5($filename);
272 272
 		$ext = 'jpg';
273
-		if ( isset( $path_parts['extension'] ) ) {
273
+		if ( isset($path_parts['extension']) ) {
274 274
 			$ext = $path_parts['extension'];
275 275
 		}
276 276
 		return $dir . '/' . $basename . '.' . $ext;
@@ -282,28 +282,28 @@  discard block
 block discarded – undo
282 282
 	 * @param string  $file the URL to the original file
283 283
 	 * @return string the URL to the downloaded file
284 284
 	 */
285
-	public static function sideload_image( $file ) {
286
-		$loc = self::get_sideloaded_file_loc( $file );
287
-		if ( file_exists( $loc ) ) {
288
-			return TimberURLHelper::preslashit( TimberURLHelper::get_rel_path( $loc ) );
285
+	public static function sideload_image($file) {
286
+		$loc = self::get_sideloaded_file_loc($file);
287
+		if ( file_exists($loc) ) {
288
+			return TimberURLHelper::preslashit(TimberURLHelper::get_rel_path($loc));
289 289
 		}
290 290
 		// Download file to temp location
291
-		if ( !function_exists( 'download_url' ) ) {
291
+		if ( !function_exists('download_url') ) {
292 292
 			require_once ABSPATH . '/wp-admin/includes/file.php';
293 293
 		}
294
-		$tmp = download_url( $file );
295
-		preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
294
+		$tmp = download_url($file);
295
+		preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
296 296
 		$file_array = array();
297
-		$file_array['name'] = basename( $matches[0] );
297
+		$file_array['name'] = basename($matches[0]);
298 298
 		$file_array['tmp_name'] = $tmp;
299 299
 		// If error storing temporarily, unlink
300
-		if ( is_wp_error( $tmp ) ) {
301
-			@unlink( $file_array['tmp_name'] );
300
+		if ( is_wp_error($tmp) ) {
301
+			@unlink($file_array['tmp_name']);
302 302
 			$file_array['tmp_name'] = '';
303 303
 		}
304 304
 		// do the validation and storage stuff
305
-		$locinfo = pathinfo( $loc );
306
-		$file = wp_upload_bits( $locinfo['basename'], null, file_get_contents( $file_array['tmp_name'] ) );
305
+		$locinfo = pathinfo($loc);
306
+		$file = wp_upload_bits($locinfo['basename'], null, file_get_contents($file_array['tmp_name']));
307 307
 		return $file['url'];
308 308
 	}
309 309
 
@@ -330,23 +330,23 @@  discard block
 block discarded – undo
330 330
 		if ( 0 === strpos($tmp, ABSPATH) ) { // we've been given a dir, not an url
331 331
 			$result['absolute'] = true;
332 332
 			if ( 0 === strpos($tmp, $upload_dir['basedir']) ) {
333
-				$result['base']= self::BASE_UPLOADS; // upload based
333
+				$result['base'] = self::BASE_UPLOADS; // upload based
334 334
 				$tmp = str_replace($upload_dir['basedir'], '', $tmp);
335 335
 			}
336 336
 			if ( 0 === strpos($tmp, WP_CONTENT_DIR) ) {
337
-				$result['base']= self::BASE_CONTENT; // content based
337
+				$result['base'] = self::BASE_CONTENT; // content based
338 338
 				$tmp = str_replace(WP_CONTENT_DIR, '', $tmp);
339 339
 			}
340 340
 		} else {
341
-			if (!$result['absolute']) {
342
-				$tmp = home_url().$tmp;
341
+			if ( !$result['absolute'] ) {
342
+				$tmp = home_url() . $tmp;
343 343
 			}
344
-			if (0 === strpos($tmp, $upload_dir['baseurl'])) {
345
-				$result['base']= self::BASE_UPLOADS; // upload based
344
+			if ( 0 === strpos($tmp, $upload_dir['baseurl']) ) {
345
+				$result['base'] = self::BASE_UPLOADS; // upload based
346 346
 				$tmp = str_replace($upload_dir['baseurl'], '', $tmp);
347 347
 			}
348
-			if (0 === strpos($tmp, content_url())) {
349
-				$result['base']= self::BASE_CONTENT; // content-based
348
+			if ( 0 === strpos($tmp, content_url()) ) {
349
+				$result['base'] = self::BASE_CONTENT; // content-based
350 350
 				$tmp = str_replace(content_url(), '', $tmp);
351 351
 			}
352 352
 		}
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	private static function _get_file_url($base, $subdir, $filename, $absolute) {
372 372
 		$url = '';
373
-		if( self::BASE_UPLOADS == $base ) {
373
+		if ( self::BASE_UPLOADS == $base ) {
374 374
 			$upload_dir = wp_upload_dir();
375 375
 			$url = $upload_dir['baseurl'];
376 376
 		}
377
-		if( self::BASE_CONTENT == $base ) {
377
+		if ( self::BASE_CONTENT == $base ) {
378 378
 			$url = content_url();
379 379
 		}
380
-		if(!empty($subdir)) {
380
+		if ( !empty($subdir) ) {
381 381
 			$url .= $subdir;
382 382
 		}
383
-		$url .= '/'.$filename;
384
-		if(!$absolute) {
383
+		$url .= '/' . $filename;
384
+		if ( !$absolute ) {
385 385
 			$url = str_replace(home_url(), '', $url);
386 386
 		}
387 387
 		// $url = TimberURLHelper::remove_double_slashes( $url);
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	private static function _get_file_path($base, $subdir, $filename) {
400 400
 		$path = '';
401
-		if(self::BASE_UPLOADS == $base) {
401
+		if ( self::BASE_UPLOADS == $base ) {
402 402
 			$upload_dir = wp_upload_dir();
403 403
 			$path = $upload_dir['basedir'];
404 404
 		}
405
-		if(self::BASE_CONTENT == $base) {
405
+		if ( self::BASE_CONTENT == $base ) {
406 406
 			$path = WP_CONTENT_DIR;
407 407
 		}
408
-		if(!empty($subdir)) {
408
+		if ( !empty($subdir) ) {
409 409
 			$path .= $subdir;
410 410
 		}
411
-		$path .= '/'.$filename;
411
+		$path .= '/' . $filename;
412 412
 		return $path;
413 413
 	}
414 414
 
@@ -426,13 +426,13 @@  discard block
 block discarded – undo
426 426
 	 * @return string         URL to the new image - or the source one if error
427 427
 	 *
428 428
 	 */
429
-	private static function _operate( $src, $op, $force = false ) {
430
-		if ( empty( $src ) ) {
429
+	private static function _operate($src, $op, $force = false) {
430
+		if ( empty($src) ) {
431 431
 			return '';
432 432
 		}
433 433
 		// if external image, load it first
434
-		if ( TimberURLHelper::is_external_content( $src ) ) {
435
-			$src = self::sideload_image( $src );
434
+		if ( TimberURLHelper::is_external_content($src) ) {
435
+			$src = self::sideload_image($src);
436 436
 		}
437 437
 		// break down URL into components
438 438
 		$au = self::analyze_url($src);
@@ -454,17 +454,17 @@  discard block
 block discarded – undo
454 454
 			$au['basename']
455 455
 		);
456 456
 		// if already exists...
457
-		if ( file_exists( $new_server_path ) ) {
457
+		if ( file_exists($new_server_path) ) {
458 458
 			if ( $force ) {
459 459
 				// Force operation - warning: will regenerate the image on every pageload, use for testing purposes only!
460
-				unlink( $new_server_path );
460
+				unlink($new_server_path);
461 461
 			} else {
462 462
 				// return existing file (caching)
463 463
 				return $new_url;
464 464
 			}
465 465
 		}
466 466
 		// otherwise generate result file
467
-		if($op->run($old_server_path, $new_server_path)) {
467
+		if ( $op->run($old_server_path, $new_server_path) ) {
468 468
 			return $new_url;
469 469
 		} else {
470 470
 			// in case of error, we return source file itself
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		);
487 487
 		return $new_url;
488 488
 	}
489
-	public static function get_letterbox_file_path($url, $w, $h, $color ) {
489
+	public static function get_letterbox_file_path($url, $w, $h, $color) {
490 490
 		$au = self::analyze_url($url);
491 491
 		$op = new TimberImageOperationLetterbox($w, $h, $color);
492 492
 		$new_path = self::_get_file_path(
Please login to merge, or discard this patch.