Code Duplication    Length = 27-29 lines in 4 locations

modules/shortcodes/recipe.php 4 locations

@@ 332-360 (lines=29) @@
329
	 *
330
	 * @return string HTML for recipe notes shortcode.
331
	 */
332
	public static function recipe_notes_shortcode( $atts, $content = '' ) {
333
		$atts = shortcode_atts(
334
			array(
335
				'title' => '', // string.
336
			),
337
			$atts,
338
			'recipe-notes'
339
		);
340
341
		$html = '';
342
343
		// Print a title if one exists.
344
		if ( '' !== $atts['title'] ) {
345
			$html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>';
346
		}
347
348
		$html .= '<div class="jetpack-recipe-notes">';
349
350
		// Format content using list functionality, if desired.
351
		$html .= self::output_list_content( $content, 'notes' );
352
353
		$html .= '</div>';
354
355
		// Sanitize html.
356
		$html = wp_kses( $html, self::kses_tags() );
357
358
		// Return the HTML block.
359
		return $html;
360
	}
361
362
	/**
363
	 * Our [recipe-ingredients] shortcode.
@@ 371-397 (lines=27) @@
368
	 *
369
	 * @return string HTML for recipe ingredients shortcode.
370
	 */
371
	public static function recipe_ingredients_shortcode( $atts, $content = '' ) {
372
		$atts = shortcode_atts(
373
			array(
374
				'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
375
			),
376
			$atts,
377
			'recipe-ingredients'
378
		);
379
380
		$html = '<div class="jetpack-recipe-ingredients">';
381
382
		// Print a title unless the user has opted to exclude it.
383
		if ( 'false' !== $atts['title'] ) {
384
			$html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>';
385
		}
386
387
		// Format content using list functionality.
388
		$html .= self::output_list_content( $content, 'ingredients' );
389
390
		$html .= '</div>';
391
392
		// Sanitize html.
393
		$html = wp_kses( $html, self::kses_tags() );
394
395
		// Return the HTML block.
396
		return $html;
397
	}
398
399
	/**
400
	 * Our [recipe-nutrition] shortcode.
@@ 408-434 (lines=27) @@
405
	 *
406
	 * @return string HTML for recipe nutrition shortcode.
407
	 */
408
	public static function recipe_nutrition_shortcode( $atts, $content = '' ) {
409
		$atts = shortcode_atts(
410
			array(
411
				'title' => esc_html_x( 'Nutrition', 'recipe', 'jetpack' ), // string.
412
			),
413
			$atts,
414
			'recipe-nutrition'
415
		);
416
417
		$html = '<div class="jetpack-recipe-nutrition p-nutrition nutrition">';
418
419
		// Print a title unless the user has opted to exclude it.
420
		if ( 'false' !== $atts['title'] ) {
421
			$html .= '<h4 class="jetpack-recipe-nutrition-title">' . esc_html( $atts['title'] ) . '</h4>';
422
		}
423
424
		// Format content using list functionality.
425
		$html .= self::output_list_content( $content, 'nutrition' );
426
427
		$html .= '</div>';
428
429
		// Sanitize html.
430
		$html = wp_kses( $html, self::kses_tags() );
431
432
		// Return the HTML block.
433
		return $html;
434
	}
435
436
	/**
437
	 * Reusable function to check for shortened formatting.
@@ 537-563 (lines=27) @@
534
	 *
535
	 * @return string HTML for recipe directions shortcode.
536
	 */
537
	public static function recipe_directions_shortcode( $atts, $content = '' ) {
538
		$atts = shortcode_atts(
539
			array(
540
				'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
541
			),
542
			$atts,
543
			'recipe-directions'
544
		);
545
546
		$html = '<div class="jetpack-recipe-directions e-instructions">';
547
548
		// Print a title unless the user has specified to exclude it.
549
		if ( 'false' !== $atts['title'] ) {
550
			$html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>';
551
		}
552
553
		// Format content using list functionality.
554
		$html .= self::output_list_content( $content, 'directions' );
555
556
		$html .= '</div>';
557
558
		// Sanitize html.
559
		$html = wp_kses( $html, self::kses_tags() );
560
561
		// Return the HTML block.
562
		return $html;
563
	}
564
565
	/**
566
	 * Outputs time meta tag.