Completed
Push — master ( e11db9...57ccf2 )
by Warwick
18:16 queued 02:51
created
classes/class-admin.php 3 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Display the importer administration screen
79 79
 	 */
80 80
 	public function display_page() {
81
-        ?>
81
+		?>
82 82
         <div class="wrap">
83 83
             <?php screen_icon(); ?>
84 84
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		            </ul> 
101 101
 	             	            
102 102
             <?php } else {
103
-            	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104
-            } ?>
103
+				do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104
+			} ?>
105 105
         </div>
106 106
         <?php
107 107
 	}
@@ -148,37 +148,37 @@  discard block
 block discarded – undo
148 148
 	 * set_taxonomy with some terms
149 149
 	 */
150 150
 	public function set_taxonomy($taxonomy,$terms,$id) {
151
-        $result=array();
152
-        if(!empty($data))
153
-        {
154
-            foreach($data as $k)
155
-            {
156
-                if($id)
157
-                {
158
-                    if(!$term = term_exists(trim($k), $tax))
159
-                    {
160
-                        $term = wp_insert_term(trim($k), $tax);
161
-                        if ( is_wp_error($term) )
162
-                        {
163
-                            echo $term->get_error_message();
164
-                        }
165
-                        else
166
-                        {
167
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
-                        }
169
-                    }
170
-                    else
171
-                    {
172
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
-                    }
174
-                }
175
-                else
176
-                {
177
-                    $result[]=trim($k);
178
-                }
179
-            }
180
-        }
181
-        return $result;
151
+		$result=array();
152
+		if(!empty($data))
153
+		{
154
+			foreach($data as $k)
155
+			{
156
+				if($id)
157
+				{
158
+					if(!$term = term_exists(trim($k), $tax))
159
+					{
160
+						$term = wp_insert_term(trim($k), $tax);
161
+						if ( is_wp_error($term) )
162
+						{
163
+							echo $term->get_error_message();
164
+						}
165
+						else
166
+						{
167
+							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168
+						}
169
+					}
170
+					else
171
+					{
172
+						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173
+					}
174
+				}
175
+				else
176
+				{
177
+					$result[]=trim($k);
178
+				}
179
+			}
180
+		}
181
+		return $result;
182 182
 	}
183 183
 
184 184
 	/**
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
 		if(post_type_exists('team')) { ?>
189 189
     		<ul>
190 190
     			<?php
191
-    				$team_args=array(
192
-    					'post_type'	=>	'team',
193
-    					'post_status' => 'publish',
194
-    					'nopagin' => true,
195
-    					'fields' => 'ids'
196
-    				);
197
-    				$team_members = new WP_Query($team_args);
198
-    					if($team_members->have_posts()){
199
-    						foreach($team_members->posts as $member){ ?>
191
+					$team_args=array(
192
+						'post_type'	=>	'team',
193
+						'post_status' => 'publish',
194
+						'nopagin' => true,
195
+						'fields' => 'ids'
196
+					);
197
+					$team_members = new WP_Query($team_args);
198
+						if($team_members->have_posts()){
199
+							foreach($team_members->posts as $member){ ?>
200 200
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
201 201
     						<?php }
202
-    					}else{ ?>
202
+						}else{ ?>
203 203
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
204 204
     					<?php }
205
-    				?>
205
+					?>
206 206
     		</ul>
207 207
     	<?php }		
208 208
 	}
@@ -254,40 +254,40 @@  discard block
 block discarded – undo
254 254
 		if(false !== $id){
255 255
 			if(empty($this->found_attachments)){
256 256
 
257
-		    	$attachments_args = array(
258
-		    			'post_parent' => $id,
259
-		    			'post_status' => 'inherit',
260
-		    			'post_type' => 'attachment',
261
-		    			'order' => 'ASC',
262
-		    	);   	
257
+				$attachments_args = array(
258
+						'post_parent' => $id,
259
+						'post_status' => 'inherit',
260
+						'post_type' => 'attachment',
261
+						'order' => 'ASC',
262
+				);   	
263 263
 		    	 
264
-		    	$attachments = new WP_Query($attachments_args);
265
-		    	if($attachments->have_posts()){
266
-		    		foreach($attachments->posts as $attachment){
267
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
268
-		    			$this->gallery_meta[] = $attachment->ID;
269
-		    		}
270
-		    	}
264
+				$attachments = new WP_Query($attachments_args);
265
+				if($attachments->have_posts()){
266
+					foreach($attachments->posts as $attachment){
267
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
268
+						$this->gallery_meta[] = $attachment->ID;
269
+					}
270
+				}
271 271
 			}
272 272
 		}
273 273
 	}
274 274
 
275 275
 	/**
276 276
 	 * Checks to see if an item is selected.
277
-     *
278
-     * @param $haystack array|string
279
-     * @param $needle string
280
-     * @return string
277
+	 *
278
+	 * @param $haystack array|string
279
+	 * @param $needle string
280
+	 * @return string
281 281
 	 */
282 282
 	public function checked($haystack=false,$needle='') {
283
-	    $return = '';
284
-	    if(!is_array($haystack)){
283
+		$return = '';
284
+		if(!is_array($haystack)){
285 285
 			$haystack = array($haystack);
286
-        }
287
-        if(in_array($needle,$haystack)){
286
+		}
287
+		if(in_array($needle,$haystack)){
288 288
 			$return = 'checked="checked"';
289
-        }
290
-	    return $return;
289
+		}
290
+		return $return;
291 291
 	}
292 292
 }
293 293
 $wetu_importer_admin = new WETU_Importer_Admin();
294 294
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 	 * @access private
46 46
 	 */
47 47
 	public function __construct() {
48
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
49
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
48
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
49
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * Registers the admin page which will house the importer form.
54 54
 	 */
55 55
 	public function register_importer_page() {
56
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
56
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * Enqueue the JS needed to contact wetu and return your result.
61 61
 	 */
62 62
 	public function admin_scripts() {
63
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
63
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
64 64
 			$min = '';
65
-		} else {
65
+		}else {
66 66
 			$min = '.min';
67 67
 		}
68 68
 
69
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
70
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
71
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
69
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
70
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
71
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
72 72
 			'ajax_url' => admin_url('admin-ajax.php'),
73
-			) );			
73
+			));			
74 74
 		}
75 75
 	}			
76 76
 
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
         <div class="wrap">
83 83
             <?php screen_icon(); ?>
84 84
 
85
-            <?php if(!isset($_GET['tab'])){ ?>
86
-	            <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
85
+            <?php if (!isset($_GET['tab'])) { ?>
86
+	            <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
87 87
 	            <p>If this is the first time you are running the import, then follow the steps below.</p>
88 88
 	            <ul>
89
-                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li>
90
-	            	<li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li>
91
-                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
89
+                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li>
90
+	            	<li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li>
91
+                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
92 92
 	            </ul>
93 93
 
94
-		            <h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
94
+		            <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3>
95 95
 		            <ul>
96
-		            	<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li>
97
-		            	<?php if(class_exists('Lsx_Banners')){ ?>
98
-		            		<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li>
96
+		            	<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li>
97
+		            	<?php if (class_exists('Lsx_Banners')) { ?>
98
+		            		<li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li>
99 99
 		            	<?php } ?>
100 100
 		            </ul> 
101 101
 	             	            
102
-            <?php } else {
102
+            <?php }else {
103 103
             	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
104 104
             } ?>
105 105
         </div>
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	 * set_taxonomy with some terms
149 149
 	 */
150
-	public function set_taxonomy($taxonomy,$terms,$id) {
151
-        $result=array();
152
-        if(!empty($data))
150
+	public function set_taxonomy($taxonomy, $terms, $id) {
151
+        $result = array();
152
+        if (!empty($data))
153 153
         {
154
-            foreach($data as $k)
154
+            foreach ($data as $k)
155 155
             {
156
-                if($id)
156
+                if ($id)
157 157
                 {
158
-                    if(!$term = term_exists(trim($k), $tax))
158
+                    if (!$term = term_exists(trim($k), $tax))
159 159
                     {
160 160
                         $term = wp_insert_term(trim($k), $tax);
161
-                        if ( is_wp_error($term) )
161
+                        if (is_wp_error($term))
162 162
                         {
163 163
                             echo $term->get_error_message();
164 164
                         }
165 165
                         else
166 166
                         {
167
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
167
+                            wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
168 168
                         }
169 169
                     }
170 170
                     else
171 171
                     {
172
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
172
+                        wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
173 173
                     }
174 174
                 }
175 175
                 else
176 176
                 {
177
-                    $result[]=trim($k);
177
+                    $result[] = trim($k);
178 178
                 }
179 179
             }
180 180
         }
@@ -184,23 +184,23 @@  discard block
 block discarded – undo
184 184
 	/**
185 185
 	 * set_taxonomy with some terms
186 186
 	 */
187
-	public function team_member_checkboxes($selected=array()) {
188
-		if(post_type_exists('team')) { ?>
187
+	public function team_member_checkboxes($selected = array()) {
188
+		if (post_type_exists('team')) { ?>
189 189
     		<ul>
190 190
     			<?php
191
-    				$team_args=array(
191
+    				$team_args = array(
192 192
     					'post_type'	=>	'team',
193 193
     					'post_status' => 'publish',
194 194
     					'nopagin' => true,
195 195
     					'fields' => 'ids'
196 196
     				);
197 197
     				$team_members = new WP_Query($team_args);
198
-    					if($team_members->have_posts()){
199
-    						foreach($team_members->posts as $member){ ?>
200
-    							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
198
+    					if ($team_members->have_posts()) {
199
+    						foreach ($team_members->posts as $member) { ?>
200
+    							<li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
201 201
     						<?php }
202
-    					}else{ ?>
203
-    							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
202
+    					}else { ?>
203
+    							<li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
204 204
     					<?php }
205 205
     				?>
206 206
     		</ul>
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
 	/**
211 211
 	 * set_taxonomy with some terms
212 212
 	 */
213
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
213
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
214 214
 		$return = '';
215
-		if(false !== $taxonomy){
215
+		if (false !== $taxonomy) {
216 216
 			$return .= '<ul>';
217
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
217
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
218 218
 
219
-			if(!is_wp_error($terms)){
220
-				foreach($terms as $term){
221
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
219
+			if (!is_wp_error($terms)) {
220
+				foreach ($terms as $term) {
221
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
222 222
 				}
223
-			}else{
224
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
223
+			}else {
224
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
225 225
 			}
226 226
 			$return .= '</ul>';
227 227
 		}
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
 	/**
232 232
 	 * Saves the room data
233 233
 	 */
234
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
235
-		if(false !== $value){
236
-			if(false !== $decrease){
234
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
235
+		if (false !== $value) {
236
+			if (false !== $decrease) {
237 237
 				$value = intval($value);
238 238
 				$value--;
239 239
 			}
240
-			$prev = get_post_meta($id,$meta_key,true);
240
+			$prev = get_post_meta($id, $meta_key, true);
241 241
 
242
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
243
-				update_post_meta($id,$meta_key,$value,$prev);
244
-			}else{
245
-				add_post_meta($id,$meta_key,$value,$unique);
242
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
243
+				update_post_meta($id, $meta_key, $value, $prev);
244
+			}else {
245
+				add_post_meta($id, $meta_key, $value, $unique);
246 246
 			}
247 247
 		}
248 248
 	}
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	/**
251 251
 	 * grabs any attachments for the current item
252 252
 	 */
253
-	public function find_attachments($id=false) {
254
-		if(false !== $id){
255
-			if(empty($this->found_attachments)){
253
+	public function find_attachments($id = false) {
254
+		if (false !== $id) {
255
+			if (empty($this->found_attachments)) {
256 256
 
257 257
 		    	$attachments_args = array(
258 258
 		    			'post_parent' => $id,
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 		    	);   	
263 263
 		    	 
264 264
 		    	$attachments = new WP_Query($attachments_args);
265
-		    	if($attachments->have_posts()){
266
-		    		foreach($attachments->posts as $attachment){
267
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
265
+		    	if ($attachments->have_posts()) {
266
+		    		foreach ($attachments->posts as $attachment) {
267
+		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
268 268
 		    			$this->gallery_meta[] = $attachment->ID;
269 269
 		    		}
270 270
 		    	}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
      * @param $needle string
280 280
      * @return string
281 281
 	 */
282
-	public function checked($haystack=false,$needle='') {
282
+	public function checked($haystack = false, $needle = '') {
283 283
 	    $return = '';
284
-	    if(!is_array($haystack)){
284
+	    if (!is_array($haystack)) {
285 285
 			$haystack = array($haystack);
286 286
         }
287
-        if(in_array($needle,$haystack)){
287
+        if (in_array($needle, $haystack)) {
288 288
 			$return = 'checked="checked"';
289 289
         }
290 290
 	    return $return;
Please login to merge, or discard this patch.
Braces   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -161,18 +161,15 @@  discard block
 block discarded – undo
161 161
                         if ( is_wp_error($term) )
162 162
                         {
163 163
                             echo $term->get_error_message();
164
-                        }
165
-                        else
164
+                        } else
166 165
                         {
167 166
                             wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
168 167
                         }
169
-                    }
170
-                    else
168
+                    } else
171 169
                     {
172 170
                         wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
173 171
                     }
174
-                }
175
-                else
172
+                } else
176 173
                 {
177 174
                     $result[]=trim($k);
178 175
                 }
@@ -199,7 +196,7 @@  discard block
 block discarded – undo
199 196
     						foreach($team_members->posts as $member){ ?>
200 197
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
201 198
     						<?php }
202
-    					}else{ ?>
199
+    					} else{ ?>
203 200
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
204 201
     					<?php }
205 202
     				?>
@@ -220,7 +217,7 @@  discard block
 block discarded – undo
220 217
 				foreach($terms as $term){
221 218
 					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
222 219
 				}
223
-			}else{
220
+			} else{
224 221
 				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
225 222
 			}
226 223
 			$return .= '</ul>';
@@ -241,7 +238,7 @@  discard block
 block discarded – undo
241 238
 
242 239
 			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
243 240
 				update_post_meta($id,$meta_key,$value,$prev);
244
-			}else{
241
+			} else{
245 242
 				add_post_meta($id,$meta_key,$value,$unique);
246 243
 			}
247 244
 		}
Please login to merge, or discard this patch.