Code Duplication    Length = 25-27 lines in 3 locations

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

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

classes/class-wetu-importer.php 1 location

@@ 1225-1251 (lines=27) @@
1222
	/**
1223
	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1224
	 */
1225
	public function find_current_accommodation( $post_type = 'accommodation' ) {
1226
		global $wpdb;
1227
		$return = array();
1228
1229
		// @codingStandardsIgnoreStart
1230
		$current_accommodation = $wpdb->get_results("
1231
			SELECT key1.post_id,key1.meta_value
1232
			FROM {$wpdb->postmeta} key1
1233
1234
			INNER JOIN  {$wpdb->posts} key2
1235
			ON key1.post_id = key2.ID
1236
1237
			WHERE key1.meta_key = 'lsx_wetu_id'
1238
			AND key2.post_type = '{$post_type}'
1239
1240
			LIMIT 0,5000
1241
		");
1242
		// @codingStandardsIgnoreEnd
1243
1244
		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1245
			foreach ( $current_accommodation as $accom ) {
1246
				$return[ $accom->meta_value ] = $accom;
1247
			}
1248
		}
1249
1250
		return $return;
1251
	}
1252
1253
	/**
1254
	 * Set the Video date

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

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