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

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