Code Duplication    Length = 27-29 lines in 4 locations

modules/shortcodes/recipe.php 4 locations

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