Code Duplication    Length = 23-25 lines in 3 locations

modules/shortcodes/recipe.php 3 locations

@@ 287-311 (lines=25) @@
284
	 *
285
	 * @return string HTML for recipe notes shortcode.
286
	 */
287
	static function recipe_notes_shortcode( $atts, $content = '' ) {
288
		$atts = shortcode_atts( array(
289
			'title' => '', // string.
290
		), $atts, 'recipe-notes' );
291
292
		$html = '';
293
294
		// Print a title if one exists.
295
		if ( '' !== $atts['title'] ) {
296
			$html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>';
297
		}
298
299
		$html .= '<div class="jetpack-recipe-notes">';
300
301
		// Format content using list functionality, if desired.
302
		$html .= self::output_list_content( $content, 'notes' );
303
304
		$html .= '</div>';
305
306
		// Sanitize html.
307
		$html = wp_kses_post( $html );
308
309
		// Return the HTML block.
310
		return $html;
311
	}
312
313
	/**
314
	 * Our [recipe-ingredients] shortcode.
@@ 322-344 (lines=23) @@
319
	 *
320
	 * @return string HTML for recipe ingredients shortcode.
321
	 */
322
	static function recipe_ingredients_shortcode( $atts, $content = '' ) {
323
		$atts = shortcode_atts( array(
324
			'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
325
		), $atts, 'recipe-ingredients' );
326
327
		$html = '<div class="jetpack-recipe-ingredients">';
328
329
		// Print a title unless the user has opted to exclude it.
330
		if ( 'false' !== $atts['title'] ) {
331
			$html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>';
332
		}
333
334
		// Format content using list functionality.
335
		$html .= self::output_list_content( $content, 'ingredients' );
336
337
		$html .= '</div>';
338
339
		// Sanitize html.
340
		$html = wp_kses_post( $html );
341
342
		// Return the HTML block.
343
		return $html;
344
	}
345
346
	/**
347
	 * Reusable function to check for shortened formatting.
@@ 437-459 (lines=23) @@
434
	 *
435
	 * @return string HTML for recipe directions shortcode.
436
	 */
437
	static function recipe_directions_shortcode( $atts, $content = '' ) {
438
		$atts = shortcode_atts( array(
439
				'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
440
		), $atts, 'recipe-directions' );
441
442
		$html = '<div class="jetpack-recipe-directions">';
443
444
		// Print a title unless the user has specified to exclude it.
445
		if ( 'false' !== $atts['title'] ) {
446
			$html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>';
447
		}
448
449
		// Format content using list functionality.
450
		$html .= self::output_list_content( $content, 'directions' );
451
452
		$html .= '</div>';
453
454
		// Sanitize html.
455
		$html = wp_kses_post( $html );
456
457
		// Return the HTML block.
458
		return $html;
459
	}
460
461
	/**
462
	 * Use $themecolors array to style the Recipes shortcode