Code Duplication    Length = 25-27 lines in 3 locations

classes/class-wetu-importer-tours.php 1 location

@@ 336-360 (lines=25) @@
333
	/**
334
	 * Grab all the current tour posts via the lsx_wetu_id field.
335
	 */
336
	public function find_current_tours() {
337
		global $wpdb;
338
		$return = array();
339
340
		$current_tours = $wpdb->get_results("
341
			SELECT key1.post_id,key1.meta_value
342
			FROM {$wpdb->postmeta} key1
343
344
			INNER JOIN  {$wpdb->posts} key2
345
			ON key1.post_id = key2.ID
346
347
			WHERE key1.meta_key = 'lsx_wetu_id'
348
			AND key2.post_type = 'tour'
349
350
			LIMIT 0,500
351
		");
352
353
		if ( null !== $current_tours && ! empty( $current_tours ) ) {
354
			foreach ( $current_tours as $tour ) {
355
				$return[ $tour->meta_value ] = $tour;
356
			}
357
		}
358
359
		return $return;
360
	}
361
362
	/**
363
	 * Run through the accommodation grabbed from the DB.

classes/class-wetu-importer-destination.php 1 location

@@ 298-324 (lines=27) @@
295
	/**
296
	 * Grab all the current destination posts via the lsx_wetu_id field.
297
	 */
298
	public function find_current_destination( $post_type = 'destination' ) {
299
		global $wpdb;
300
		$return = array();
301
302
		// @codingStandardsIgnoreStart
303
		$current_destination = $wpdb->get_results("
304
			SELECT key1.post_id,key1.meta_value,key2.post_title as name,key2.post_date as last_modified
305
			FROM {$wpdb->postmeta} key1
306
307
			INNER JOIN  {$wpdb->posts} key2
308
			ON key1.post_id = key2.ID
309
310
			WHERE key1.meta_key = 'lsx_wetu_id'
311
			AND key2.post_type = '{$post_type}'
312
313
			LIMIT 0,1000
314
		");
315
		// @codingStandardsIgnoreEnd
316
317
		if ( null !== $current_destination && ! empty( $current_destination ) ) {
318
			foreach ( $current_destination as $accom ) {
319
				$return[ $accom->meta_value ] = $accom;
320
			}
321
		}
322
323
		return $return;
324
	}
325
326
	/**
327
	 * Run through the accommodation grabbed from the DB.

classes/class-wetu-importer.php 1 location

@@ 1208-1234 (lines=27) @@
1205
	/**
1206
	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1207
	 */
1208
	public function find_current_accommodation( $post_type = 'accommodation' ) {
1209
		global $wpdb;
1210
		$return = array();
1211
1212
		// @codingStandardsIgnoreStart
1213
		$current_accommodation = $wpdb->get_results("
1214
			SELECT key1.post_id,key1.meta_value
1215
			FROM {$wpdb->postmeta} key1
1216
1217
			INNER JOIN  {$wpdb->posts} key2
1218
			ON key1.post_id = key2.ID
1219
1220
			WHERE key1.meta_key = 'lsx_wetu_id'
1221
			AND key2.post_type = '{$post_type}'
1222
1223
			LIMIT 0,5000
1224
		");
1225
		// @codingStandardsIgnoreEnd
1226
1227
		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1228
			foreach ( $current_accommodation as $accom ) {
1229
				$return[ $accom->meta_value ] = $accom;
1230
			}
1231
		}
1232
1233
		return $return;
1234
	}
1235
1236
	/**
1237
	 * Set the Video date