Code Duplication    Length = 29-30 lines in 2 locations

classes/PodsAPI.php 2 locations

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