Code Duplication    Length = 23-25 lines in 3 locations

modules/shortcodes/recipe.php 3 locations

@@ 298-322 (lines=25) @@
295
	 *
296
	 * @return string HTML for recipe notes shortcode.
297
	 */
298
	static function recipe_notes_shortcode( $atts, $content = '' ) {
299
		$atts = shortcode_atts( array(
300
			'title' => '', // string.
301
		), $atts, 'recipe-notes' );
302
303
		$html = '';
304
305
		// Print a title if one exists.
306
		if ( '' !== $atts['title'] ) {
307
			$html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>';
308
		}
309
310
		$html .= '<div class="jetpack-recipe-notes">';
311
312
		// Format content using list functionality, if desired.
313
		$html .= self::output_list_content( $content, 'notes' );
314
315
		$html .= '</div>';
316
317
		// Sanitize html.
318
		$html = wp_kses_post( $html );
319
320
		// Return the HTML block.
321
		return $html;
322
	}
323
324
	/**
325
	 * Our [recipe-ingredients] shortcode.
@@ 333-355 (lines=23) @@
330
	 *
331
	 * @return string HTML for recipe ingredients shortcode.
332
	 */
333
	static function recipe_ingredients_shortcode( $atts, $content = '' ) {
334
		$atts = shortcode_atts( array(
335
			'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
336
		), $atts, 'recipe-ingredients' );
337
338
		$html = '<div class="jetpack-recipe-ingredients">';
339
340
		// Print a title unless the user has opted to exclude it.
341
		if ( 'false' !== $atts['title'] ) {
342
			$html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>';
343
		}
344
345
		// Format content using list functionality.
346
		$html .= self::output_list_content( $content, 'ingredients' );
347
348
		$html .= '</div>';
349
350
		// Sanitize html.
351
		$html = wp_kses_post( $html );
352
353
		// Return the HTML block.
354
		return $html;
355
	}
356
357
	/**
358
	 * Reusable function to check for shortened formatting.
@@ 448-470 (lines=23) @@
445
	 *
446
	 * @return string HTML for recipe directions shortcode.
447
	 */
448
	static function recipe_directions_shortcode( $atts, $content = '' ) {
449
		$atts = shortcode_atts( array(
450
				'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
451
		), $atts, 'recipe-directions' );
452
453
		$html = '<div class="jetpack-recipe-directions">';
454
455
		// Print a title unless the user has specified to exclude it.
456
		if ( 'false' !== $atts['title'] ) {
457
			$html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>';
458
		}
459
460
		// Format content using list functionality.
461
		$html .= self::output_list_content( $content, 'directions' );
462
463
		$html .= '</div>';
464
465
		// Sanitize html.
466
		$html = wp_kses_post( $html );
467
468
		// Return the HTML block.
469
		return $html;
470
	}
471
472
	/**
473
	 * Use $themecolors array to style the Recipes shortcode