Code Duplication    Length = 19-19 lines in 2 locations

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

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

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

@@ 469-487 (lines=19) @@
466
			}
467
		}
468
469
		if ( $atts['orderby'] ) {
470
			$atts['orderby'] = urldecode( $atts['orderby'] );
471
			$atts['orderby'] = strtolower( $atts['orderby'] );
472
			$allowed_keys = array( 'author', 'date', 'title', 'rand' );
473
474
			$parsed = array();
475
			foreach ( explode( ',', $atts['orderby'] ) as $portfolio_index_number => $orderby ) {
476
				if ( ! in_array( $orderby, $allowed_keys ) ) {
477
					continue;
478
				}
479
				$parsed[] = $orderby;
480
			}
481
482
			if ( empty( $parsed ) ) {
483
				unset( $atts['orderby'] );
484
			} else {
485
				$atts['orderby'] = implode( ' ', $parsed );
486
			}
487
		}
488
489
		// enqueue shortcode styles when shortcode is used
490
		wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' );