Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 559-577 (lines=19) @@
556
			}
557
		}
558
559
		if ( $atts['orderby'] ) {
560
			$atts['orderby'] = urldecode( $atts['orderby'] );
561
			$atts['orderby'] = strtolower( $atts['orderby'] );
562
			$allowed_keys = array('author', 'date', 'title', 'rand');
563
564
			$parsed = array();
565
			foreach ( explode( ',', $atts['orderby'] ) as $testimonial_index_number => $orderby ) {
566
				if ( ! in_array( $orderby, $allowed_keys ) ) {
567
					continue;
568
				}
569
				$parsed[] = $orderby;
570
			}
571
572
			if ( empty( $parsed ) ) {
573
				unset($atts['orderby']);
574
			} else {
575
				$atts['orderby'] = implode( ' ', $parsed );
576
			}
577
		}
578
579
		// enqueue shortcode styles when shortcode is used
580
		wp_enqueue_style( 'jetpack-testimonial-style', plugins_url( 'css/testimonial-shortcode.css', __FILE__ ), array(), '20140326' );

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

@@ 613-631 (lines=19) @@
610
			}
611
		}
612
613
		if ( $atts['orderby'] ) {
614
			$atts['orderby'] = urldecode( $atts['orderby'] );
615
			$atts['orderby'] = strtolower( $atts['orderby'] );
616
			$allowed_keys = array( 'author', 'date', 'title', 'rand' );
617
618
			$parsed = array();
619
			foreach ( explode( ',', $atts['orderby'] ) as $portfolio_index_number => $orderby ) {
620
				if ( ! in_array( $orderby, $allowed_keys ) ) {
621
					continue;
622
				}
623
				$parsed[] = $orderby;
624
			}
625
626
			if ( empty( $parsed ) ) {
627
				unset( $atts['orderby'] );
628
			} else {
629
				$atts['orderby'] = implode( ' ', $parsed );
630
			}
631
		}
632
633
		// enqueue shortcode styles when shortcode is used
634
		wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' );