Code Duplication    Length = 19-19 lines in 2 locations

modules/custom-post-types/testimonial.php 1 location

@@ 539-557 (lines=19) @@
536
			}
537
		}
538
539
		if ( $atts['orderby'] ) {
540
			$atts['orderby'] = urldecode( $atts['orderby'] );
541
			$atts['orderby'] = strtolower( $atts['orderby'] );
542
			$allowed_keys = array('author', 'date', 'title', 'rand');
543
544
			$parsed = array();
545
			foreach ( explode( ',', $atts['orderby'] ) as $testimonial_index_number => $orderby ) {
546
				if ( ! in_array( $orderby, $allowed_keys ) ) {
547
					continue;
548
				}
549
				$parsed[] = $orderby;
550
			}
551
552
			if ( empty( $parsed ) ) {
553
				unset($atts['orderby']);
554
			} else {
555
				$atts['orderby'] = implode( ' ', $parsed );
556
			}
557
		}
558
559
		// enqueue shortcode styles when shortcode is used
560
		wp_enqueue_style( 'jetpack-testimonial-style', plugins_url( 'css/testimonial-shortcode.css', __FILE__ ), array(), '20140326' );

modules/custom-post-types/portfolios.php 1 location

@@ 452-470 (lines=19) @@
449
			}
450
		}
451
452
		if ( $atts['orderby'] ) {
453
			$atts['orderby'] = urldecode( $atts['orderby'] );
454
			$atts['orderby'] = strtolower( $atts['orderby'] );
455
			$allowed_keys = array( 'author', 'date', 'title', 'rand' );
456
457
			$parsed = array();
458
			foreach ( explode( ',', $atts['orderby'] ) as $portfolio_index_number => $orderby ) {
459
				if ( ! in_array( $orderby, $allowed_keys ) ) {
460
					continue;
461
				}
462
				$parsed[] = $orderby;
463
			}
464
465
			if ( empty( $parsed ) ) {
466
				unset( $atts['orderby'] );
467
			} else {
468
				$atts['orderby'] = implode( ' ', $parsed );
469
			}
470
		}
471
472
		// enqueue shortcode styles when shortcode is used
473
		wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' );