Completed
Push — master ( 608c6b...fdd09c )
by Jared
03:03
created
lib/timber-posts-collection.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,50 +1,50 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( !defined( 'ABSPATH' ) )
4
+if ( !defined('ABSPATH') )
5 5
     exit;
6 6
 
7 7
 class TimberPostsCollection extends ArrayObject {
8 8
 
9
-    public function __construct( $posts = array(), $post_class = 'TimberPost' ) {
9
+    public function __construct($posts = array(), $post_class = 'TimberPost') {
10 10
         $returned_posts = array();
11
-        if ( is_null( $posts ) ){
11
+        if ( is_null($posts) ) {
12 12
             $posts = array();
13 13
         }
14
-        foreach ( $posts as $post_object ) {
14
+        foreach ($posts as $post_object) {
15 15
             $post_class_use = $post_class;
16 16
 
17
-            if ( is_array( $post_class ) ) {
18
-                $post_type      = get_post_type( $post_object );
17
+            if ( is_array($post_class) ) {
18
+                $post_type      = get_post_type($post_object);
19 19
                 $post_class_use = 'TimberPost';
20 20
 
21
-                if ( isset( $post_class[$post_type] ) ) {
21
+                if ( isset($post_class[$post_type]) ) {
22 22
                     $post_class_use = $post_class[$post_type];
23 23
 
24 24
                 } else {
25
-                    if ( is_array( $post_class ) ) {
26
-                        TimberHelper::error_log( $post_type . ' of ' . $post_object->ID . ' not found in ' . print_r( $post_class, true ) );
25
+                    if ( is_array($post_class) ) {
26
+                        TimberHelper::error_log($post_type . ' of ' . $post_object->ID . ' not found in ' . print_r($post_class, true));
27 27
                     } else {
28
-                        TimberHelper::error_log( $post_type . ' not found in ' . $post_class );
28
+                        TimberHelper::error_log($post_type . ' not found in ' . $post_class);
29 29
                     }
30 30
                 }
31 31
             }
32 32
 
33 33
             // Don't create yet another object if $post_object is already of the right type
34
-            if ( is_a( $post_object, $post_class_use ) ) {
34
+            if ( is_a($post_object, $post_class_use) ) {
35 35
                 $post = $post_object;
36 36
             } else {
37
-                $post = new $post_class_use( $post_object );
37
+                $post = new $post_class_use($post_object);
38 38
             }
39 39
 
40
-            if ( isset( $post->ID ) ) {
40
+            if ( isset($post->ID) ) {
41 41
                 $returned_posts[] = $post;
42 42
             }
43 43
         }
44 44
 
45 45
         $returned_posts = self::maybe_set_preview($returned_posts);
46 46
 
47
-        parent::__construct( $returned_posts, $flags = 0, 'TimberPostsIterator' );
47
+        parent::__construct($returned_posts, $flags = 0, 'TimberPostsIterator');
48 48
     }
49 49
 
50 50
     public function get_posts() {
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
      * @param array $posts
56 56
      * @return array
57 57
      */
58
-    static function maybe_set_preview( $posts ) {
59
-        if ( is_array( $posts ) && isset( $_GET['preview'] ) && $_GET['preview']
60
-               && isset( $_GET['preview_id'] ) && $_GET['preview_id']
61
-               && current_user_can( 'edit_post', $_GET['preview_id'] ) ) {
58
+    static function maybe_set_preview($posts) {
59
+        if ( is_array($posts) && isset($_GET['preview']) && $_GET['preview']
60
+               && isset($_GET['preview_id']) && $_GET['preview_id']
61
+               && current_user_can('edit_post', $_GET['preview_id']) ) {
62 62
             // No need to check the nonce, that already happened in _show_post_preview on init
63 63
 
64 64
             $preview_id = $_GET['preview_id'];
65
-            foreach( $posts as &$post ) {
66
-                if ( is_object( $post ) && $post->ID == $preview_id ) {
65
+            foreach ($posts as &$post) {
66
+                if ( is_object($post) && $post->ID == $preview_id ) {
67 67
                     // Based on _set_preview( $post ), but adds import_custom
68
-                    $preview = wp_get_post_autosave( $preview_id );
68
+                    $preview = wp_get_post_autosave($preview_id);
69 69
                     if ( is_object($preview) ) {
70 70
 
71 71
                         $preview = sanitize_post($preview);
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
                         $post->post_content = $preview->post_content;
74 74
                         $post->post_title = $preview->post_title;
75 75
                         $post->post_excerpt = $preview->post_excerpt;
76
-                        $post->import_custom( $preview_id );
76
+                        $post->import_custom($preview_id);
77 77
 
78
-                        add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 );
78
+                        add_filter('get_the_terms', '_wp_preview_terms_filter', 10, 3);
79 79
                     }
80 80
                 }
81 81
             }
Please login to merge, or discard this patch.
lib/timber-query-iterator.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( !defined( 'ABSPATH' ) )
3
+if ( !defined('ABSPATH') )
4 4
     exit;
5 5
 
6 6
 class TimberQueryIterator implements Iterator {
@@ -13,38 +13,38 @@  discard block
 block discarded – undo
13 13
     private $_query = null;
14 14
     private $_posts_class = 'TimberPost';
15 15
 
16
-    public function __construct( $query = false, $posts_class = 'TimberPost' ) {
17
-        add_action( 'pre_get_posts', array($this, 'fix_number_posts_wp_quirk' ));
16
+    public function __construct($query = false, $posts_class = 'TimberPost') {
17
+        add_action('pre_get_posts', array($this, 'fix_number_posts_wp_quirk'));
18 18
         if ( $posts_class )
19 19
             $this->_posts_class = $posts_class;
20 20
 
21
-        if ( is_a( $query, 'WP_Query' ) ) {
21
+        if ( is_a($query, 'WP_Query') ) {
22 22
             // We got a full-fledged WP Query, look no further!
23 23
             $the_query = $query;
24 24
 
25 25
         } elseif ( false === $query ) {
26 26
             // If query is explicitly set to false, use the main loop
27 27
             global $wp_query;
28
-            $the_query =& $wp_query;
28
+            $the_query = & $wp_query;
29 29
             //if we're on a custom posts page?
30 30
             $the_query = self::handle_maybe_custom_posts_page($the_query);
31
-        } elseif ( TimberHelper::is_array_assoc( $query ) || ( is_string( $query ) && strstr( $query, '=' ) ) ) {
31
+        } elseif ( TimberHelper::is_array_assoc($query) || (is_string($query) && strstr($query, '=')) ) {
32 32
             // We have a regularly formed WP query string or array to use
33
-            $the_query = new WP_Query( $query );
33
+            $the_query = new WP_Query($query);
34 34
 
35
-        } elseif ( is_numeric( $query ) || is_string( $query ) ) {
35
+        } elseif ( is_numeric($query) || is_string($query) ) {
36 36
             // We have what could be a post name or post ID to pull out
37
-            $the_query = self::get_query_from_string( $query );
37
+            $the_query = self::get_query_from_string($query);
38 38
 
39
-        } elseif ( is_array( $query ) && count( $query ) && ( is_integer( $query[0] ) || is_string( $query[0] ) ) ) {
39
+        } elseif ( is_array($query) && count($query) && (is_integer($query[0]) || is_string($query[0])) ) {
40 40
             // We have a list of pids (post IDs) to extract from
41
-            $the_query = self::get_query_from_array_of_ids( $query );
42
-        } elseif ( is_array($query) && empty($query)) {
41
+            $the_query = self::get_query_from_array_of_ids($query);
42
+        } elseif ( is_array($query) && empty($query) ) {
43 43
             // it's an empty array
44 44
             $the_query = array();
45 45
         } else {
46
-            TimberHelper::error_log( 'I have failed you! in ' . basename( __FILE__ ) . '::' . __LINE__ );
47
-            TimberHelper::error_log( $query );
46
+            TimberHelper::error_log('I have failed you! in ' . basename(__FILE__) . '::' . __LINE__);
47
+            TimberHelper::error_log($query);
48 48
 
49 49
             // We have failed hard, at least let get something.
50 50
             $the_query = new WP_Query();
@@ -54,49 +54,49 @@  discard block
 block discarded – undo
54 54
 
55 55
     }
56 56
 
57
-    public function get_posts( $return_collection = false ) {
58
-        if (isset($this->_query->posts)){
59
-            $posts = new TimberPostsCollection( $this->_query->posts, $this->_posts_class );
60
-            return ( $return_collection ) ? $posts : $posts->get_posts();
57
+    public function get_posts($return_collection = false) {
58
+        if ( isset($this->_query->posts) ) {
59
+            $posts = new TimberPostsCollection($this->_query->posts, $this->_posts_class);
60
+            return ($return_collection) ? $posts : $posts->get_posts();
61 61
         }
62 62
     }
63 63
 
64 64
     //
65 65
     // GET POSTS
66 66
     //
67
-    public static function get_query_from_array_of_ids( $query = array() ) {
68
-        if ( !is_array( $query ) || !count( $query ) )
67
+    public static function get_query_from_array_of_ids($query = array()) {
68
+        if ( !is_array($query) || !count($query) )
69 69
             return null;
70 70
 
71
-        return new WP_Query( array(
71
+        return new WP_Query(array(
72 72
                 'post_type'=> 'any',
73 73
                 'ignore_sticky_posts' => true,
74 74
                 'post__in' => $query,
75 75
                 'orderby'  => 'post__in',
76 76
                 'nopaging' => true
77
-            ) );
77
+            ));
78 78
     }
79 79
 
80
-    public static function get_query_from_string( $string = '' ) {
80
+    public static function get_query_from_string($string = '') {
81 81
         $post_type = false;
82 82
 
83
-        if ( is_string( $string ) && strstr( $string, '#' ) ) {
83
+        if ( is_string($string) && strstr($string, '#') ) {
84 84
             //we have a post_type directive here
85
-            list( $post_type, $string ) = explode( '#', $string );
85
+            list($post_type, $string) = explode('#', $string);
86 86
         }
87 87
 
88 88
         $query = array(
89
-            'post_type' => ( $post_type ) ? $post_type : 'any'
89
+            'post_type' => ($post_type) ? $post_type : 'any'
90 90
         );
91 91
 
92
-        if ( is_numeric( $string ) ) {
92
+        if ( is_numeric($string) ) {
93 93
             $query['p'] = $string;
94 94
 
95 95
         } else {
96 96
             $query['name'] = $string;
97 97
         }
98 98
 
99
-        return new WP_Query( $query );
99
+        return new WP_Query($query);
100 100
     }
101 101
 
102 102
     //
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
         // Sets up the global post, but also return the post, for use in Twig template
116 116
         $posts_class = $this->_posts_class;
117
-        return new $posts_class( $post );
117
+        return new $posts_class($post);
118 118
     }
119 119
 
120 120
     /**
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
     }
132 132
 
133 133
     //get_posts users numberposts
134
-    static function fix_number_posts_wp_quirk( $query ) {
135
-        if (isset($query->query) && isset($query->query['numberposts'])
136
-                && !isset($query->query['posts_per_page'])) {
137
-            $query->set( 'posts_per_page', $query->query['numberposts'] );
134
+    static function fix_number_posts_wp_quirk($query) {
135
+        if ( isset($query->query) && isset($query->query['numberposts'])
136
+                && !isset($query->query['posts_per_page']) ) {
137
+            $query->set('posts_per_page', $query->query['numberposts']);
138 138
         }
139 139
         return $query;
140 140
     }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      * @param  WP_Query $query the original query recived from WordPress
145 145
      * @return WP_Query
146 146
      */
147
-    static function handle_maybe_custom_posts_page( $query ) {
148
-    	if ($custom_posts_page = get_option('page_for_posts')) {
147
+    static function handle_maybe_custom_posts_page($query) {
148
+    	if ( $custom_posts_page = get_option('page_for_posts') ) {
149 149
         	if ( isset($query->query['p']) && $query->query['p'] == $custom_posts_page ) {
150 150
         		return new WP_Query(array('post_type' => 'post'));
151 151
         	}
Please login to merge, or discard this patch.
lib/timber-routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 	/**
6 6
 	 * @deprecated since 0.21.1 use Upstatement/routes instead
7 7
 	 */
8
-	public static function init( $timber ) {
8
+	public static function init($timber) {
9 9
 		// Install ourselves in Timber
10 10
 		$timber->routes = new TimberRoutes();
11 11
 	}
Please login to merge, or discard this patch.
lib/timber-site.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 	 * ```
102 102
 	 * @param string|int $site_name_or_id
103 103
 	 */
104
-	function __construct( $site_name_or_id = null ) {
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
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @internal
115 115
 	 * @param string|int $site_name_or_id
116 116
 	 */
117
-	protected function init_as_multisite( $site_name_or_id ) {
117
+	protected function init_as_multisite($site_name_or_id) {
118 118
 		if ( $site_name_or_id === null ) {
119 119
 			//this is necessary for some reason, otherwise returns 1 all the time
120 120
 			if ( is_multisite() ) {
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	/**
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 	 * @param string  $field
175 175
 	 * @return mixed
176 176
 	 */
177
-	function __get( $field ) {
178
-		if ( !isset( $this->$field ) ) {
177
+	function __get($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;
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	/**
227 227
 	 * @ignore
228 228
 	 */
229
-	public function meta( $field ) {
230
-		return $this->__get( $field );
229
+	public function meta($field) {
230
+		return $this->__get($field);
231 231
 	}
232 232
 
233 233
 	/**
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 	 * @param string  $key
237 237
 	 * @param mixed   $value
238 238
 	 */
239
-	public function update( $key, $value ) {
240
-		$value = apply_filters( 'timber_site_set_meta', $value, $key, $this->ID, $this );
239
+	public function update($key, $value) {
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
 	}
Please login to merge, or discard this patch.
lib/timber-term-getter.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -9,40 +9,40 @@  discard block
 block discarded – undo
9 9
      * @param string $TermClass
10 10
      * @return mixed
11 11
      */
12
-    public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm'){
13
-        if (is_string($maybe_args) && !strstr($maybe_args, '=')){
12
+    public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') {
13
+        if ( is_string($maybe_args) && !strstr($maybe_args, '=') ) {
14 14
             //the user is sending the $TermClass in the second argument
15 15
             $TermClass = $maybe_args;
16 16
         }
17
-        if (is_string($maybe_args) && strstr($maybe_args, '=')){
17
+        if ( is_string($maybe_args) && strstr($maybe_args, '=') ) {
18 18
             parse_str($maybe_args, $maybe_args);
19 19
         }
20
-        if (is_string($args) && strstr($args, '=')){
20
+        if ( is_string($args) && strstr($args, '=') ) {
21 21
             //a string and a query string!
22 22
             $parsed = TimberTermGetter::get_term_query_from_query_string($args);
23
-            if (is_array($maybe_args)){
23
+            if ( is_array($maybe_args) ) {
24 24
                 $parsed->args = array_merge($parsed->args, $maybe_args);
25 25
             }
26 26
             return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
27
-        } else if (is_string($args)){
27
+        } else if ( is_string($args) ) {
28 28
             //its just a string with a single taxonomy
29 29
             $parsed = TimberTermGetter::get_term_query_from_string($args);
30
-            if (is_array($maybe_args)){
30
+            if ( is_array($maybe_args) ) {
31 31
                 $parsed->args = array_merge($parsed->args, $maybe_args);
32 32
             }
33 33
             return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
34
-        } else if (is_array($args) && TimberHelper::is_array_assoc($args)){
34
+        } else if ( is_array($args) && TimberHelper::is_array_assoc($args) ) {
35 35
             //its an associative array, like a good ole query
36 36
             $parsed = TimberTermGetter::get_term_query_from_assoc_array($args);
37 37
             return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
38
-        } else if (is_array($args)){
38
+        } else if ( is_array($args) ) {
39 39
             //its just an array of strings or IDs (hopefully)
40 40
             $parsed = TimberTermGetter::get_term_query_from_array($args);
41
-            if (is_array($maybe_args)){
41
+            if ( is_array($maybe_args) ) {
42 42
                 $parsed->args = array_merge($parsed->args, $maybe_args);
43 43
             }
44 44
             return self::handle_term_query($parsed->taxonomies, $parsed->args, $TermClass);
45
-        } else if (is_null($args)) {
45
+        } else if ( is_null($args) ) {
46 46
             return self::handle_term_query(get_taxonomies(), array(), $TermClass);
47 47
         }
48 48
         return null;
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
      * @param string $TermClass
55 55
      * @return mixed
56 56
      */
57
-    public static function handle_term_query($taxonomies, $args, $TermClass){
58
-        if (!isset($args['hide_empty'])){
57
+    public static function handle_term_query($taxonomies, $args, $TermClass) {
58
+        if ( !isset($args['hide_empty']) ) {
59 59
             $args['hide_empty'] = false;
60 60
         }
61
-        if (isset($args['term_id']) && is_int($args['term_id'])){
61
+        if ( isset($args['term_id']) && is_int($args['term_id']) ) {
62 62
             $args['term_id'] = array($args['term_id']);
63 63
         }
64
-        if (isset($args['term_id'])){
64
+        if ( isset($args['term_id']) ) {
65 65
             $args['include'] = $args['term_id'];
66 66
         }
67 67
         $terms = get_terms($taxonomies, $args);
68
-        foreach($terms as &$term){
68
+        foreach ($terms as &$term) {
69 69
             $term = new $TermClass($term->term_id, $term->taxonomy);
70 70
         }
71 71
         return $terms;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     public static function get_term_query_from_string($taxs) {
90 90
         $ret = new stdClass();
91 91
         $ret->args = array();
92
-        if (is_string($taxs)) {
92
+        if ( is_string($taxs) ) {
93 93
             $taxs = array($taxs);
94 94
         }
95 95
         $ret->taxonomies = self::correct_taxonomy_names($taxs);
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
     public static function get_term_query_from_assoc_array($args) {
104 104
         $ret = new stdClass();
105 105
         $ret->args = $args;
106
-        if (isset($ret->args['tax'])) {
106
+        if ( isset($ret->args['tax']) ) {
107 107
             $ret->taxonomies = $ret->args['tax'];
108
-        } else if (isset($ret->args['taxonomies'])) {
108
+        } else if ( isset($ret->args['taxonomies']) ) {
109 109
             $ret->taxonomies = $ret->args['taxonomies'];
110
-        } else if (isset($ret->args['taxs'])) {
110
+        } else if ( isset($ret->args['taxs']) ) {
111 111
             $ret->taxonomies = $ret->args['taxs'];
112
-        } else if (isset($ret->args['taxonomy'])) {
112
+        } else if ( isset($ret->args['taxonomy']) ) {
113 113
             $ret->taxonomies = $ret->args['taxonomy'];
114 114
         }
115
-        if (isset($ret->taxonomies)) {
116
-            if (is_string($ret->taxonomies)) {
115
+        if ( isset($ret->taxonomies) ) {
116
+            if ( is_string($ret->taxonomies) ) {
117 117
                 $ret->taxonomies = array($ret->taxonomies);
118 118
             }
119 119
             $ret->taxonomies = self::correct_taxonomy_names($ret->taxonomies);
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
      * @return stdClass
129 129
      */
130 130
     public static function get_term_query_from_array($args) {
131
-        if (is_array($args) && !empty($args)) {
131
+        if ( is_array($args) && !empty($args) ) {
132 132
             //okay its an array with content
133
-            if (is_int($args[0])) {
133
+            if ( is_int($args[0]) ) {
134 134
                 return self::get_term_query_from_array_of_ids($args);
135
-            } else if (is_string($args[0])) {
135
+            } else if ( is_string($args[0]) ) {
136 136
                 return self::get_term_query_from_array_of_strings($args);
137 137
             }
138 138
         }
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
      * @return array
167 167
      */
168 168
     private static function correct_taxonomy_names($taxs) {
169
-        if (is_string($taxs)) {
169
+        if ( is_string($taxs) ) {
170 170
             $taxs = array($taxs);
171 171
         }
172 172
         foreach ($taxs as &$tax) {
173
-            if ($tax == 'tags' || $tax == 'tag') {
173
+            if ( $tax == 'tags' || $tax == 'tag' ) {
174 174
                 $tax = 'post_tag';
175
-            } else if ($tax == 'categories') {
175
+            } else if ( $tax == 'categories' ) {
176 176
                 $tax = 'category';
177 177
             }
178 178
         }
Please login to merge, or discard this patch.
lib/timber-term.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 * @param int $tid
55 55
 	 * @param string $tax
56 56
 	 */
57
-	public function __construct( $tid = null, $tax = '' ) {
58
-		if ($tid === null) {
57
+	public function __construct($tid = null, $tax = '') {
58
+		if ( $tid === null ) {
59 59
 			$tid = $this->get_term_from_query();
60 60
 		}
61
-		if (strlen($tax)) {
61
+		if ( strlen($tax) ) {
62 62
 			$this->taxonomy = $tax;
63 63
 		}
64 64
 		$this->init($tid);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return static
79 79
 	 */
80
-	public static function from( $tid, $taxonomy ) {
80
+	public static function from($tid, $taxonomy) {
81 81
 		return new static($tid, $taxonomy);
82 82
 	}
83 83
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		global $wp_query;
94 94
 		if ( isset($wp_query->queried_object) ) {
95 95
 			$qo = $wp_query->queried_object;
96
-			if (isset($qo->term_id)) {
96
+			if ( isset($qo->term_id) ) {
97 97
 				return $qo->term_id;
98 98
 			}
99 99
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @internal
107 107
 	 * @param int $tid
108 108
 	 */
109
-	protected function init( $tid ) {
109
+	protected function init($tid) {
110 110
 		$term = $this->get_term($tid);
111 111
 		if ( isset($term->id) ) {
112 112
 			$term->ID = $term->id;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			//echo 'bad call using '.$tid;
117 117
 			//TimberHelper::error_log(debug_backtrace());
118 118
 		}
119
-		if ( isset($term->ID) ){
119
+		if ( isset($term->ID) ) {
120 120
 			$term->id = $term->ID;
121 121
 			$this->import($term);
122 122
 			if ( isset($term->term_id) ) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param int $tid
143 143
 	 * @return mixed
144 144
 	 */
145
-	protected function get_term( $tid ) {
145
+	protected function get_term($tid) {
146 146
 		if ( is_object($tid) || is_array($tid) ) {
147 147
 			return $tid;
148 148
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			global $wpdb;
155 155
 			$query = $wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $tid);
156 156
 			$tax = $wpdb->get_var($query);
157
-			if (isset($tax) && strlen($tax)) {
157
+			if ( isset($tax) && strlen($tax) ) {
158 158
 				$this->taxonomy = $tax;
159 159
 				return get_term($tid, $tax);
160 160
 			}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param int $tid
168 168
 	 * @return int
169 169
 	 */
170
-	protected function get_tid( $tid ) {
170
+	protected function get_tid($tid) {
171 171
 		global $wpdb;
172 172
 		if ( is_numeric($tid) ) {
173 173
 			return $tid;
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	 * @param string $field_name
206 206
 	 * @return string
207 207
 	 */
208
-	public function get_meta_field( $field_name ) {
209
-		if (!isset($this->$field_name)) {
208
+	public function get_meta_field($field_name) {
209
+		if ( !isset($this->$field_name) ) {
210 210
 			$field_value = '';
211 211
 			$field_value = apply_filters('timber_term_get_meta_field', $field_value, $this->ID, $field_name, $this);
212 212
 			$field_value = apply_filters('timber/term/meta/field', $field_value, $this->ID, $field_name, $this);
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 * @param string $PostClass
245 245
 	 * @return array|bool|null
246 246
 	 */
247
-	public function get_posts( $numberposts = 10, $post_type = 'any', $PostClass = '' ) {
248
-		if (!strlen($PostClass)) {
247
+	public function get_posts($numberposts = 10, $post_type = 'any', $PostClass = '') {
248
+		if ( !strlen($PostClass) ) {
249 249
 			$PostClass = $this->PostClass;
250 250
 		}
251 251
 		$default_tax_query = array(array(
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 			parse_str($args, $new_args);
260 260
 			$args = $new_args;
261 261
 			$args['tax_query'] = $default_tax_query;
262
-			if (!isset($args['post_type'])) {
262
+			if ( !isset($args['post_type']) ) {
263 263
 				$args['post_type'] = 'any';
264 264
 			}
265
-			if (class_exists($post_type)) {
265
+			if ( class_exists($post_type) ) {
266 266
 				$PostClass = $post_type;
267 267
 			}
268 268
 		} else if ( is_array($numberposts) ) {
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 	 * @param string  $key
309 309
 	 * @param mixed   $value
310 310
 	 */
311
-	function update( $key, $value ) {
312
-		$value = apply_filters( 'timber_term_set_meta', $value, $key, $this->ID, $this );
311
+	function update($key, $value) {
312
+		$value = apply_filters('timber_term_set_meta', $value, $key, $this->ID, $this);
313 313
 		$this->$key = $value;
314 314
 	}
315 315
 
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
 	public function description() {
332 332
 		$prefix = '<p>';
333 333
 		$suffix = '</p>';
334
-		$desc = term_description( $this->ID, $this->taxonomy );
335
-		if (substr($desc, 0, strlen($prefix)) == $prefix) {
334
+		$desc = term_description($this->ID, $this->taxonomy);
335
+		if ( substr($desc, 0, strlen($prefix)) == $prefix ) {
336 336
     		$desc = substr($desc, strlen($prefix));
337 337
 		}
338
-		$desc = preg_replace('/'. preg_quote('</p>', '/') . '$/', '', $desc);
338
+		$desc = preg_replace('/' . preg_quote('</p>', '/') . '$/', '', $desc);
339 339
 		return trim($desc);
340 340
 	}
341 341
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @param string $field_name
370 370
 	 * @return string
371 371
 	 */
372
-	public function meta( $field_name ) {
372
+	public function meta($field_name) {
373 373
 		return $this->get_meta_field($field_name);
374 374
 	}
375 375
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * ```
398 398
 	 * @return array|bool|null
399 399
 	 */
400
-	public function posts( $numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '' ) {
400
+	public function posts($numberposts_or_args = 10, $post_type_or_class = 'any', $post_class = '') {
401 401
 		return $this->get_posts($numberposts_or_args, $post_type_or_class, $post_class);
402 402
 	}
403 403
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @param int $i
423 423
 	 * @return string
424 424
 	 */
425
-	function get_page( $i ) {
425
+	function get_page($i) {
426 426
 		return $this->get_path() . '/page/' . $i;
427 427
 	}
428 428
 
Please login to merge, or discard this patch.
lib/timber-theme.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$ss = $data->get_stylesheet();
77 77
 		$this->slug = $ss;
78 78
 
79
-		if ( ! function_exists( 'get_home_path' ) ) {
79
+		if ( !function_exists('get_home_path') ) {
80 80
 			require_once(ABSPATH . 'wp-admin/includes/file.php');
81 81
 		}
82 82
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return  string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`)
104 104
 	 */
105 105
 	public function path() {
106
-		return TimberURLHelper::get_rel_url( $this->link() );
106
+		return TimberURLHelper::get_rel_url($this->link());
107 107
 	}
108 108
 
109 109
 	/**
Please login to merge, or discard this patch.
lib/timber-url-helper.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 	 */
10 10
 	public static function get_current_url() {
11 11
 		$pageURL = "http://";
12
-		if ( isset( $_SERVER['HTTPS'] ) && $_SERVER["HTTPS"] == "on" ) {
13
-			$pageURL = "https://";;
12
+		if ( isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on" ) {
13
+			$pageURL = "https://"; ;
14 14
 		}
15 15
 		if ( isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != "80" ) {
16 16
 			$pageURL .= self::get_host() . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 * @param string  $url
27 27
 	 * @return bool
28 28
 	 */
29
-	public static function is_url( $url ) {
30
-		if ( !is_string( $url ) ) {
29
+	public static function is_url($url) {
30
+		if ( !is_string($url) ) {
31 31
 			return false;
32 32
 		}
33
-		$url = strtolower( $url );
34
-		if ( strstr( $url, '://' ) ) {
33
+		$url = strtolower($url);
34
+		if ( strstr($url, '://') ) {
35 35
 			return true;
36 36
 		}
37 37
 		return false;
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 	 * @return string
44 44
 	 */
45 45
 	public static function get_path_base() {
46
-		$struc = get_option( 'permalink_structure' );
47
-		$struc = explode( '/', $struc );
46
+		$struc = get_option('permalink_structure');
47
+		$struc = explode('/', $struc);
48 48
 		$p = '/';
49
-		foreach ( $struc as $s ) {
50
-			if ( !strstr( $s, '%' ) && strlen( $s ) ) {
49
+		foreach ($struc as $s) {
50
+			if ( !strstr($s, '%') && strlen($s) ) {
51 51
 				$p .= $s . '/';
52 52
 			}
53 53
 		}
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 	 * @param bool    $force
62 62
 	 * @return string
63 63
 	 */
64
-	public static function get_rel_url( $url, $force = false ) {
65
-		$url_info = parse_url( $url );
66
-		if ( isset( $url_info['host'] ) && $url_info['host'] != self::get_host() && !$force ) {
64
+	public static function get_rel_url($url, $force = false) {
65
+		$url_info = parse_url($url);
66
+		if ( isset($url_info['host']) && $url_info['host'] != self::get_host() && !$force ) {
67 67
 			return $url;
68 68
 		}
69 69
 		$link = '';
70
-		if ( isset( $url_info['path'] ) ) {
70
+		if ( isset($url_info['path']) ) {
71 71
 			$link = $url_info['path'];
72 72
 		}
73
-		if ( isset( $url_info['query'] ) && strlen( $url_info['query'] ) ) {
73
+		if ( isset($url_info['query']) && strlen($url_info['query']) ) {
74 74
 			$link .= '?' . $url_info['query'];
75 75
 		}
76
-		if ( isset( $url_info['fragment'] ) && strlen( $url_info['fragment'] ) ) {
76
+		if ( isset($url_info['fragment']) && strlen($url_info['fragment']) ) {
77 77
 			$link .= '#' . $url_info['fragment'];
78 78
 		}
79
-		$link = TimberURLHelper::remove_double_slashes( $link );
79
+		$link = TimberURLHelper::remove_double_slashes($link);
80 80
 		return $link;
81 81
 	}
82 82
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 * @return string the HTTP_HOST or SERVER_NAME
87 87
 	 */
88 88
 	public static function get_host() {
89
-		if (isset($_SERVER['HTTP_HOST'])) {
89
+		if ( isset($_SERVER['HTTP_HOST']) ) {
90 90
 			return $_SERVER['HTTP_HOST'];
91 91
 		}
92
-		if (isset($_SERVER['SERVER_NAME'])) {
92
+		if ( isset($_SERVER['SERVER_NAME']) ) {
93 93
 			return $_SERVER['SERVER_NAME'];
94 94
 		}
95 95
 		return '';
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @param string  $url
102 102
 	 * @return bool
103 103
 	 */
104
-	public static function is_local( $url ) {
105
-		if ( strstr( $url, self::get_host() ) ) {
104
+	public static function is_local($url) {
105
+		if ( strstr($url, self::get_host()) ) {
106 106
 			return true;
107 107
 		}
108 108
 		return false;
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 * @param string  $src
115 115
 	 * @return string
116 116
 	 */
117
-	public static function get_full_path( $src ) {
117
+	public static function get_full_path($src) {
118 118
 		$root = ABSPATH;
119 119
 		$old_root_path = $root . $src;
120
-		$old_root_path = str_replace( '//', '/', $old_root_path );
120
+		$old_root_path = str_replace('//', '/', $old_root_path);
121 121
 		return $old_root_path;
122 122
 	}
123 123
 
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 	 * @param string  $url
130 130
 	 * @return string
131 131
 	 */
132
-	public static function url_to_file_system( $url ) {
133
-		$url_parts = parse_url( $url );
132
+	public static function url_to_file_system($url) {
133
+		$url_parts = parse_url($url);
134 134
 		$path = ABSPATH . $url_parts['path'];
135
-		$path = str_replace( '//', '/', $path );
135
+		$path = str_replace('//', '/', $path);
136 136
 		return $path;
137 137
 	}
138 138
 
139
-	public static function file_system_to_url( $fs ) {
140
-		$relative_path = self::get_rel_path( $fs );
141
-		$home = home_url( '/'.$relative_path );
139
+	public static function file_system_to_url($fs) {
140
+		$relative_path = self::get_rel_path($fs);
141
+		$home = home_url('/' . $relative_path);
142 142
 		return $home;
143 143
 	}
144 144
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * @param string  $src
149 149
 	 * @return string
150 150
 	 */
151
-	public static function get_rel_path( $src ) {
152
-		if ( strstr( $src, ABSPATH ) ) {
153
-			return str_replace( ABSPATH, '', $src );
151
+	public static function get_rel_path($src) {
152
+		if ( strstr($src, ABSPATH) ) {
153
+			return str_replace(ABSPATH, '', $src);
154 154
 		}
155 155
 		//its outside the wordpress directory, alternate setups:
156
-		$src = str_replace( WP_CONTENT_DIR, '', $src );
156
+		$src = str_replace(WP_CONTENT_DIR, '', $src);
157 157
 		return WP_CONTENT_SUBDIR . $src;
158 158
 	}
159 159
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	 * @param string  $url
164 164
 	 * @return string
165 165
 	 */
166
-	public static function remove_double_slashes( $url ) {
167
-		$url = str_replace( '//', '/', $url );
168
-		if ( strstr( $url, 'http:' ) && !strstr( $url, 'http://' ) ) {
169
-			$url = str_replace( 'http:/', 'http://', $url );
166
+	public static function remove_double_slashes($url) {
167
+		$url = str_replace('//', '/', $url);
168
+		if ( strstr($url, 'http:') && !strstr($url, 'http://') ) {
169
+			$url = str_replace('http:/', 'http://', $url);
170 170
 		}
171 171
 		return $url;
172 172
 	}
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
 	 * @param string  $path
179 179
 	 * @return string
180 180
 	 */
181
-	public static function prepend_to_url( $url, $path ) {
182
-		if ( strstr( strtolower( $url ), 'http' ) ) {
183
-			$url_parts = parse_url( $url );
181
+	public static function prepend_to_url($url, $path) {
182
+		if ( strstr(strtolower($url), 'http') ) {
183
+			$url_parts = parse_url($url);
184 184
 			$url = $url_parts['scheme'] . '://' . $url_parts['host'] . $path . $url_parts['path'];
185
-			if ( isset( $url_parts['query'] ) ) {
185
+			if ( isset($url_parts['query']) ) {
186 186
 				$url .= $url_parts['query'];
187 187
 			}
188
-			if ( isset( $url_parts['fragment'] ) ) {
188
+			if ( isset($url_parts['fragment']) ) {
189 189
 				$url .= $url_parts['fragment'];
190 190
 			}
191 191
 		} else {
192 192
 			$url = $url . $path;
193 193
 		}
194
-		return self::remove_double_slashes( $url );
194
+		return self::remove_double_slashes($url);
195 195
 	}
196 196
 
197 197
 	/**
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @param string  $path
201 201
 	 * @return string
202 202
 	 */
203
-	public static function preslashit( $path ) {
204
-		if ( strpos( $path, '/' ) != 0 ) {
203
+	public static function preslashit($path) {
204
+		if ( strpos($path, '/') != 0 ) {
205 205
 			$path = '/' . $path;
206 206
 		}
207 207
 		return $path;
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return boolean true if $path is an absolute url, false if relative.
214 214
 	 */
215
-	public static function is_absolute( $path ) {
216
-		return (boolean) ( strstr( $path, 'http' ) );
215
+	public static function is_absolute($path) {
216
+		return (boolean) (strstr($path, 'http'));
217 217
 	}
218 218
 
219 219
 	/**
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param string  $url a URL to evaluate against
225 225
 	 * @return boolean if $url points to an external location returns true
226 226
 	 */
227
-	public static function is_external_content( $url ) {
228
-		$is_external = TimberURLHelper::is_absolute( $url ) && ! TimberURLHelper::is_internal_content( $url );
227
+	public static function is_external_content($url) {
228
+		$is_external = TimberURLHelper::is_absolute($url) && !TimberURLHelper::is_internal_content($url);
229 229
 
230 230
 		return $is_external;
231 231
 	}
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 		// otherwise you run into errors with sites that:
236 236
 		// 1. use WPML plugin
237 237
 		// 2. or redefine content directory
238
-		$is_content_url = strstr( $url, content_url() );
238
+		$is_content_url = strstr($url, content_url());
239 239
 
240 240
 		// this case covers when the upload directory has been redefined
241 241
 		$upload_dir = wp_upload_dir();
242
-		$is_upload_url = strstr( $url, $upload_dir['baseurl'] );
242
+		$is_upload_url = strstr($url, $upload_dir['baseurl']);
243 243
 
244 244
 		return $is_content_url || $is_upload_url;
245 245
 	}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @return bool     true if $path is an external url, false if relative or local.
252 252
 	 *                  true if it's a subdomain (http://cdn.example.org = true)
253 253
 	 */
254
-	public static function is_external( $url ) {
255
-		$has_http = strstr( strtolower( $url ), 'http' );
256
-		$on_domain = strstr( $url, self::get_host() );
254
+	public static function is_external($url) {
255
+		$has_http = strstr(strtolower($url), 'http');
256
+		$on_domain = strstr($url, self::get_host());
257 257
 		if ( $has_http && !$on_domain ) {
258 258
 			return true;
259 259
 		}
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 * @param string  $link
267 267
 	 * @return string
268 268
 	 */
269
-	public static function remove_trailing_slash( $link ) {
269
+	public static function remove_trailing_slash($link) {
270 270
 		if ( $link != "/" )
271
-			$link = untrailingslashit( $link );
271
+			$link = untrailingslashit($link);
272 272
 		return $link;
273 273
 	}
274 274
 
@@ -280,25 +280,25 @@  discard block
 block discarded – undo
280 280
 	 * @return string|WP_Error the location of the temporay file name or an error
281 281
 	 * @deprecated since 0.20.0
282 282
 	 */
283
-	static function download_url( $url, $timeout = 300 ) {
283
+	static function download_url($url, $timeout = 300) {
284 284
 		if ( !$url ) {
285
-			return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
285
+			return new WP_Error('http_no_url', __('Invalid URL Provided.'));
286 286
 		}
287 287
 
288
-		$tmpfname = wp_tempnam( $url );
288
+		$tmpfname = wp_tempnam($url);
289 289
 		if ( !$tmpfname ) {
290
-			return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.' ) );
290
+			return new WP_Error('http_no_file', __('Could not create Temporary file.'));
291 291
 		}
292 292
 
293
-		$response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
293
+		$response = wp_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
294 294
 
295
-		if ( is_wp_error( $response ) ) {
296
-			unlink( $tmpfname );
295
+		if ( is_wp_error($response) ) {
296
+			unlink($tmpfname);
297 297
 			return $response;
298 298
 		}
299
-		if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
300
-			unlink( $tmpfname );
301
-			return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
299
+		if ( 200 != wp_remote_retrieve_response_code($response) ) {
300
+			unlink($tmpfname);
301
+			return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
302 302
 		}
303 303
 		return $tmpfname;
304 304
 	}
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 	 * @param int $i the position of the parameter to grab.
312 312
 	 * @return array|string
313 313
 	 */
314
-	public static function get_params( $i = false ) {
315
-		$args = explode( '/', trim( strtolower( $_SERVER['REQUEST_URI'] ) ) );
314
+	public static function get_params($i = false) {
315
+		$args = explode('/', trim(strtolower($_SERVER['REQUEST_URI'])));
316 316
 		$newargs = array();
317
-		foreach ( $args as $arg ) {
318
-			if ( strlen( $arg ) ) {
317
+		foreach ($args as $arg) {
318
+			if ( strlen($arg) ) {
319 319
 				$newargs[] = $arg;
320 320
 			}
321 321
 		}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 		if ( $i < 0 ) {
326 326
 			//count from end
327
-			$i = count( $newargs ) + $i;
327
+			$i = count($newargs) + $i;
328 328
 		}
329
-		if ( isset( $newargs[$i] ) ) {
329
+		if ( isset($newargs[$i]) ) {
330 330
 			return $newargs[$i];
331 331
 		}
332 332
 	}
Please login to merge, or discard this patch.
lib/timber-comment.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		$this->init($cid);
45 45
 	}
46 46
 
47
-	function __toString(){
47
+	function __toString() {
48 48
 		return $this->content();
49 49
 	}
50 50
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	function init($cid) {
56 56
 		$comment_data = $cid;
57
-		if (is_integer($cid)) {
57
+		if ( is_integer($cid) ) {
58 58
 			$comment_data = get_comment($cid);
59 59
 		}
60 60
 		$this->import($comment_data);
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	 * @return TimberUser
87 87
 	 */
88 88
 	public function author() {
89
-		if ($this->user_id) {
89
+		if ( $this->user_id ) {
90 90
 			return new TimberUser($this->user_id);
91 91
 		} else {
92 92
 			$author = new TimberUser(0);
93
-			if (isset($this->comment_author) && $this->comment_author) {
93
+			if ( isset($this->comment_author) && $this->comment_author ) {
94 94
 				$author->name = $this->comment_author;
95 95
 			} else {
96 96
 				$author->name = 'Anonymous';
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 	 * @return bool|mixed|string
115 115
 	 */
116 116
 	public function avatar($size = 92, $default = '') {
117
-		if (!get_option('show_avatars')) {
117
+		if ( !get_option('show_avatars') ) {
118 118
 			return false;
119 119
 		}
120
-		if (!is_numeric($size)) {
120
+		if ( !is_numeric($size) ) {
121 121
 			$size = '92';
122 122
 		}
123 123
 
124 124
 		$email = $this->avatar_email();
125 125
 		$email_hash = '';
126
-		if (!empty($email)) {
126
+		if ( !empty($email) ) {
127 127
 			$email_hash = md5(strtolower(trim($email)));
128 128
 		}
129 129
 		$host = $this->avatar_host($email_hash);
130 130
 		$default = $this->avatar_default($default, $email, $size, $host);
131
-		if (!empty($email)) {
131
+		if ( !empty($email) ) {
132 132
 			$avatar = $this->avatar_out($default, $host, $email_hash, $size);
133 133
 		} else {
134 134
 			$avatar = $default;
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	 * ```
180 180
 	 * @return string
181 181
 	 */
182
-	public function date( $date_format = '' ) {
182
+	public function date($date_format = '') {
183 183
 		$df = $date_format ? $date_format : get_option('date_format');
184
-		$the_date = (string)mysql2date($df, $this->comment_date);
184
+		$the_date = (string) mysql2date($df, $this->comment_date);
185 185
 		return apply_filters('get_comment_date ', $the_date, $df);
186 186
 	}
187 187
 
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	 * ```
205 205
 	 * @return string
206 206
 	 */
207
-	public function time( $time_format = '' ) {
207
+	public function time($time_format = '') {
208 208
 		$tf = $time_format ? $time_format : get_option('time_format');
209
-		$the_time = (string)mysql2date($tf, $this->comment_date);
209
+		$the_time = (string) mysql2date($tf, $this->comment_date);
210 210
 		return apply_filters('get_comment_time', $the_time, $tf);
211 211
 	}
212 212
 
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
 	 * @return mixed
233 233
 	 */
234 234
 	protected function get_meta_fields($comment_id = null) {
235
-		if ($comment_id === null) {
235
+		if ( $comment_id === null ) {
236 236
 			$comment_id = $this->ID;
237 237
 		}
238 238
 		//Could not find a WP function to fetch all comment meta data, so I made one.
239 239
 		apply_filters('timber_comment_get_meta_pre', array(), $comment_id);
240 240
 		$comment_metas = get_comment_meta($comment_id);
241 241
 		foreach ($comment_metas as &$cm) {
242
-			if (is_array($cm) && count($cm) == 1) {
242
+			if ( is_array($cm) && count($cm) == 1 ) {
243 243
 				$cm = $cm[0];
244 244
 			}
245 245
 		}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	protected function get_meta_field($field_name) {
256 256
 		$value = apply_filters('timber_comment_get_meta_field_pre', null, $this->ID, $field_name, $this);
257
-		if ($value === null) {
257
+		if ( $value === null ) {
258 258
 			$value = get_comment_meta($this->ID, $field_name, true);
259 259
 		}
260 260
 		$value = apply_filters('timber_comment_get_meta_field', $value, $this->ID, $field_name, $this);
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
 	 * @param int $post_id
270 270
 	 * @return string
271 271
 	 */
272
-	public function reply_link( $reply_text = 'Reply' ) {
272
+	public function reply_link($reply_text = 'Reply') {
273 273
 		if ( is_singular() && comments_open() && get_option('thread_comments') ) {
274
-			wp_enqueue_script( 'comment-reply' );
274
+			wp_enqueue_script('comment-reply');
275 275
 		}
276 276
 
277 277
 		// Get the comments depth option from the admin panel
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			'max_depth' => $max_depth,
287 287
 		);
288 288
 
289
-		return get_comment_reply_link( $args, $this->ID, $this->post_id );
289
+		return get_comment_reply_link($args, $this->ID, $this->post_id);
290 290
 	}
291 291
 
292 292
 	/* AVATAR Stuff
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	 * @return string
298 298
 	 */
299 299
 	protected function avatar_email() {
300
-		$id = (int)$this->user_id;
300
+		$id = (int) $this->user_id;
301 301
 		$user = get_userdata($id);
302
-		if ($user) {
302
+		if ( $user ) {
303 303
 			$email = $user->user_email;
304 304
 		} else {
305 305
 			$email = $this->comment_author_email;
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 	 * @return string
314 314
 	 */
315 315
 	protected function avatar_host($email_hash) {
316
-		if (is_ssl()) {
316
+		if ( is_ssl() ) {
317 317
 			$host = 'https://secure.gravatar.com';
318 318
 		} else {
319
-			if (!empty($email_hash)) {
319
+			if ( !empty($email_hash) ) {
320 320
 				$host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2));
321 321
 			} else {
322 322
 				$host = 'http://0.gravatar.com';
@@ -335,28 +335,28 @@  discard block
 block discarded – undo
335 335
 	 * @return string
336 336
 	 */
337 337
 	protected function avatar_default($default, $email, $size, $host) {
338
-		if (substr($default, 0, 1) == '/') {
338
+		if ( substr($default, 0, 1) == '/' ) {
339 339
 			$default = home_url() . $default;
340 340
 		}
341 341
 
342
-		if (empty($default)) {
342
+		if ( empty($default) ) {
343 343
 			$avatar_default = get_option('avatar_default');
344
-			if (empty($avatar_default)) {
344
+			if ( empty($avatar_default) ) {
345 345
 				$default = 'mystery';
346 346
 			} else {
347 347
 				$default = $avatar_default;
348 348
 			}
349 349
 		}
350
-		if ('mystery' == $default) {
350
+		if ( 'mystery' == $default ) {
351 351
 			$default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size;
352 352
 			// ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]')
353
-		} else if ('blank' == $default) {
353
+		} else if ( 'blank' == $default ) {
354 354
 			$default = $email ? 'blank' : includes_url('images/blank.gif');
355
-		} else if (!empty($email) && 'gravatar_default' == $default) {
355
+		} else if ( !empty($email) && 'gravatar_default' == $default ) {
356 356
 			$default = '';
357
-		} else if ('gravatar_default' == $default) {
357
+		} else if ( 'gravatar_default' == $default ) {
358 358
 			$default = $host . '/avatar/?s=' . $size;
359
-		} else if (empty($email) && !strstr($default, 'http://')) {
359
+		} else if ( empty($email) && !strstr($default, 'http://') ) {
360 360
 			$default = $host . '/avatar/?d=' . $default . '&amp;s=' . $size;
361 361
 		}
362 362
 		return $default;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	protected function avatar_out($default, $host, $email_hash, $size) {
374 374
 		$out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&amp;d=' . urlencode($default);
375 375
 		$rating = get_option('avatar_rating');
376
-		if (!empty($rating)) {
376
+		if ( !empty($rating) ) {
377 377
 			$out .= '&amp;r=' . $rating;
378 378
 		}
379 379
 		return str_replace('&#038;', '&amp;', esc_url($out));
Please login to merge, or discard this patch.