Code Duplication    Length = 29-30 lines in 2 locations

classes/PodsAPI.php 2 locations

@@ 8185-8213 (lines=29) @@
8182
				 * Overwrite the current_language var if needed for post types
8183
				 */
8184
				if ( isset( $current_screen->base ) && ( $current_screen->base == 'post' || $current_screen->base == 'edit' ) ) {
8185
					if ( ! empty( $_GET['post'] ) ) {
8186
						/**
8187
						 * WPML support
8188
						 * In WPML the current language is always set to default when on an edit screen
8189
						 * We need to overwrite this when the current object is not-translateable to enable relationships with diferent languages
8190
						 */
8191
						if (   $translator == 'WPML' 
8192
							&& method_exists( $sitepress, 'is_translated_post_type') 
8193
							&& ! $sitepress->is_translated_post_type( get_post_type( $_GET['post'] ) ) 
8194
						) {
8195
							// Overwrite default language to nothing if this is a NOT-translateable post_type
8196
							$current_language = '';
8197
						}
8198
8199
						/**
8200
						 * Polylang support (1.5.4+)
8201
						 * In polylang the preffered language could be anything. 
8202
						 * We only want the related objects if they are not translateable OR the same language as the current object
8203
						 */
8204
						if (   $translator == 'PLL' 
8205
							&& function_exists( 'pll_get_post_language' ) 
8206
							&& pll_is_translated_post_type( get_post_type( $_GET['post'] ) ) 
8207
						) {
8208
							// Overwrite default language if this is a translateable post_type
8209
							$current_language = pll_get_post_language( (int) $_GET['post'] );
8210
						}
8211
					}
8212
8213
					/**
8214
					 * Polylang support (1.0.1+)
8215
					 * In polylang the preffered language could be anything. 
8216
					 * When we're adding a new object and the new language is set we only want the related objects if they are not translateable OR the same language as the current object
@@ 8231-8260 (lines=30) @@
8228
				 */
8229
				} elseif ( isset( $current_screen->base ) && ( $current_screen->base == 'term' || $current_screen->base == 'edit-tags' ) ) {
8230
					// @todo MAYBE: Similar function like get_post_type for taxonomies so we don't need to check for $_GET['taxonomy']
8231
					if ( ! empty( $_GET['taxonomy'] ) ) {
8232
						/**
8233
						 * WPML support
8234
						 * In WPML the current language is always set to default when on an edit screen
8235
						 * We need to overwrite this when the current object is not-translateable to enable relationships with diferent languages
8236
						 */
8237
						if (   $translator == 'WPML' 
8238
							&& method_exists( $sitepress, 'is_translated_taxonomy') 
8239
							&& ! $sitepress->is_translated_taxonomy( $_GET['taxonomy'] ) 
8240
						) {
8241
							// Overwrite default language to nothing if this is a NOT-translateable taxonomy
8242
							$current_language = '';
8243
						}
8244
8245
						/**
8246
						 * Polylang support (1.5.4+)
8247
						 * In polylang the preffered language could be anything. 
8248
						 * We only want the related objects if they are not translateable OR the same language as the current object
8249
						 */
8250
						if (   $translator == 'PLL' 
8251
							&& ! empty( $_GET['tag_ID'] ) 
8252
							&& function_exists( 'pll_get_term_language' ) 
8253
							&& pll_is_translated_taxonomy( sanitize_text_field( $_GET['taxonomy'] ) ) 
8254
						) {
8255
							// Overwrite default language if this is a translateable taxonomy
8256
							$current_language = pll_get_term_language( (int) $_GET['tag_ID'] );
8257
						}
8258
					}
8259
8260
					/**
8261
					 * Polylang support (1.0.1+)
8262
					 * In polylang the preffered language could be anything. 
8263
					 * When we're adding a new object and the new language is set we only want the related objects if they are not translateable OR the same language as the current object