Code Duplication    Length = 23-25 lines in 3 locations

modules/shortcodes/recipe.php 3 locations

@@ 313-337 (lines=25) @@
310
	 *
311
	 * @return string HTML for recipe notes shortcode.
312
	 */
313
	static function recipe_notes_shortcode( $atts, $content = '' ) {
314
		$atts = shortcode_atts( array(
315
			'title' => '', // string.
316
		), $atts, 'recipe-notes' );
317
318
		$html = '';
319
320
		// Print a title if one exists.
321
		if ( '' !== $atts['title'] ) {
322
			$html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>';
323
		}
324
325
		$html .= '<div class="jetpack-recipe-notes">';
326
327
		// Format content using list functionality, if desired.
328
		$html .= self::output_list_content( $content, 'notes' );
329
330
		$html .= '</div>';
331
332
		// Sanitize html.
333
		$html = wp_kses_post( $html );
334
335
		// Return the HTML block.
336
		return $html;
337
	}
338
339
	/**
340
	 * Our [recipe-ingredients] shortcode.
@@ 348-370 (lines=23) @@
345
	 *
346
	 * @return string HTML for recipe ingredients shortcode.
347
	 */
348
	static function recipe_ingredients_shortcode( $atts, $content = '' ) {
349
		$atts = shortcode_atts( array(
350
			'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
351
		), $atts, 'recipe-ingredients' );
352
353
		$html = '<div class="jetpack-recipe-ingredients">';
354
355
		// Print a title unless the user has opted to exclude it.
356
		if ( 'false' !== $atts['title'] ) {
357
			$html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>';
358
		}
359
360
		// Format content using list functionality.
361
		$html .= self::output_list_content( $content, 'ingredients' );
362
363
		$html .= '</div>';
364
365
		// Sanitize html.
366
		$html = wp_kses_post( $html );
367
368
		// Return the HTML block.
369
		return $html;
370
	}
371
372
	/**
373
	 * Reusable function to check for shortened formatting.
@@ 463-485 (lines=23) @@
460
	 *
461
	 * @return string HTML for recipe directions shortcode.
462
	 */
463
	static function recipe_directions_shortcode( $atts, $content = '' ) {
464
		$atts = shortcode_atts( array(
465
				'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
466
		), $atts, 'recipe-directions' );
467
468
		$html = '<div class="jetpack-recipe-directions">';
469
470
		// Print a title unless the user has specified to exclude it.
471
		if ( 'false' !== $atts['title'] ) {
472
			$html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>';
473
		}
474
475
		// Format content using list functionality.
476
		$html .= self::output_list_content( $content, 'directions' );
477
478
		$html .= '</div>';
479
480
		// Sanitize html.
481
		$html = wp_kses_post( $html );
482
483
		// Return the HTML block.
484
		return $html;
485
	}
486
487
	/**
488
	 * Use $themecolors array to style the Recipes shortcode