Code Duplication    Length = 25-27 lines in 3 locations

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

@@ 259-283 (lines=25) @@
256
	/**
257
	 * Grab all the current tour posts via the lsx_wetu_id field.
258
	 */
259
	public function find_current_tours() {
260
		global $wpdb;
261
		$return = array();
262
263
		$current_tours = $wpdb->get_results("
264
			SELECT key1.post_id,key1.meta_value,key2.post_title
265
			FROM {$wpdb->postmeta} key1
266
267
			INNER JOIN  {$wpdb->posts} key2
268
			ON key1.post_id = key2.ID
269
270
			WHERE key1.meta_key = 'lsx_wetu_id'
271
			AND key2.post_type = 'tour'
272
273
			LIMIT 0,500
274
		");
275
276
		if ( null !== $current_tours && ! empty( $current_tours ) ) {
277
			foreach ( $current_tours as $tour ) {
278
				$return[ $tour->meta_value ] = $tour;
279
			}
280
		}
281
282
		return $return;
283
	}
284
285
	/**
286
	 * Run through the accommodation grabbed from the DB.

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

@@ 1243-1269 (lines=27) @@
1240
	/**
1241
	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1242
	 */
1243
	public function find_current_accommodation( $post_type = 'accommodation' ) {
1244
		global $wpdb;
1245
		$return = array();
1246
1247
		// @codingStandardsIgnoreStart
1248
		$current_accommodation = $wpdb->get_results("
1249
			SELECT key1.post_id,key1.meta_value
1250
			FROM {$wpdb->postmeta} key1
1251
1252
			INNER JOIN  {$wpdb->posts} key2
1253
			ON key1.post_id = key2.ID
1254
1255
			WHERE key1.meta_key = 'lsx_wetu_id'
1256
			AND key2.post_type = '{$post_type}'
1257
1258
			LIMIT 0,5000
1259
		");
1260
		// @codingStandardsIgnoreEnd
1261
1262
		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1263
			foreach ( $current_accommodation as $accom ) {
1264
				$return[ $accom->meta_value ] = $accom;
1265
			}
1266
		}
1267
1268
		return $return;
1269
	}
1270
1271
	/**
1272
	 * Set the Video date

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

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