Code Duplication    Length = 27-29 lines in 4 locations

modules/shortcodes/recipe.php 4 locations

@@ 343-371 (lines=29) @@
340
	 *
341
	 * @return string HTML for recipe notes shortcode.
342
	 */
343
	public static function recipe_notes_shortcode( $atts, $content = '' ) {
344
		$atts = shortcode_atts(
345
			array(
346
				'title' => '', // string.
347
			),
348
			$atts,
349
			'recipe-notes'
350
		);
351
352
		$html = '';
353
354
		// Print a title if one exists.
355
		if ( '' !== $atts['title'] ) {
356
			$html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>';
357
		}
358
359
		$html .= '<div class="jetpack-recipe-notes">';
360
361
		// Format content using list functionality, if desired.
362
		$html .= self::output_list_content( $content, 'notes' );
363
364
		$html .= '</div>';
365
366
		// Sanitize html.
367
		$html = wp_kses( $html, self::kses_tags() );
368
369
		// Return the HTML block.
370
		return $html;
371
	}
372
373
	/**
374
	 * Our [recipe-ingredients] shortcode.
@@ 382-408 (lines=27) @@
379
	 *
380
	 * @return string HTML for recipe ingredients shortcode.
381
	 */
382
	public static function recipe_ingredients_shortcode( $atts, $content = '' ) {
383
		$atts = shortcode_atts(
384
			array(
385
				'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
386
			),
387
			$atts,
388
			'recipe-ingredients'
389
		);
390
391
		$html = '<div class="jetpack-recipe-ingredients">';
392
393
		// Print a title unless the user has opted to exclude it.
394
		if ( 'false' !== $atts['title'] ) {
395
			$html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>';
396
		}
397
398
		// Format content using list functionality.
399
		$html .= self::output_list_content( $content, 'ingredients' );
400
401
		$html .= '</div>';
402
403
		// Sanitize html.
404
		$html = wp_kses( $html, self::kses_tags() );
405
406
		// Return the HTML block.
407
		return $html;
408
	}
409
410
	/**
411
	 * Our [recipe-nutrition] shortcode.
@@ 419-445 (lines=27) @@
416
	 *
417
	 * @return string HTML for recipe nutrition shortcode.
418
	 */
419
	public static function recipe_nutrition_shortcode( $atts, $content = '' ) {
420
		$atts = shortcode_atts(
421
			array(
422
				'title' => esc_html_x( 'Nutrition', 'recipe', 'jetpack' ), // string.
423
			),
424
			$atts,
425
			'recipe-nutrition'
426
		);
427
428
		$html = '<div class="jetpack-recipe-nutrition p-nutrition nutrition">';
429
430
		// Print a title unless the user has opted to exclude it.
431
		if ( 'false' !== $atts['title'] ) {
432
			$html .= '<h4 class="jetpack-recipe-nutrition-title">' . esc_html( $atts['title'] ) . '</h4>';
433
		}
434
435
		// Format content using list functionality.
436
		$html .= self::output_list_content( $content, 'nutrition' );
437
438
		$html .= '</div>';
439
440
		// Sanitize html.
441
		$html = wp_kses( $html, self::kses_tags() );
442
443
		// Return the HTML block.
444
		return $html;
445
	}
446
447
	/**
448
	 * Reusable function to check for shortened formatting.
@@ 548-574 (lines=27) @@
545
	 *
546
	 * @return string HTML for recipe directions shortcode.
547
	 */
548
	public static function recipe_directions_shortcode( $atts, $content = '' ) {
549
		$atts = shortcode_atts(
550
			array(
551
				'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
552
			),
553
			$atts,
554
			'recipe-directions'
555
		);
556
557
		$html = '<div class="jetpack-recipe-directions e-instructions">';
558
559
		// Print a title unless the user has specified to exclude it.
560
		if ( 'false' !== $atts['title'] ) {
561
			$html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>';
562
		}
563
564
		// Format content using list functionality.
565
		$html .= self::output_list_content( $content, 'directions' );
566
567
		$html .= '</div>';
568
569
		// Sanitize html.
570
		$html = wp_kses( $html, self::kses_tags() );
571
572
		// Return the HTML block.
573
		return $html;
574
	}
575
576
	/**
577
	 * Outputs time meta tag.