Code Duplication    Length = 23-23 lines in 3 locations

modules/shortcodes/recipe.php 3 locations

@@ 193-215 (lines=23) @@
190
	 *
191
	 * @return string HTML for recipe notes shortcode.
192
	 */
193
	static function recipe_notes_shortcode( $atts, $content = '' ) {
194
		$atts = shortcode_atts( array(
195
			'title' => '', //string
196
		), $atts, 'recipe-notes' );
197
198
		// Print a title if one exists.
199
		if ( '' !== $atts['title'] ) {
200
			$html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>';
201
		}
202
203
		$html .= '<div class="jetpack-recipe-notes">';
204
205
		// Format content using list functionality, if desired.
206
		$html .= self::output_list_content( $content, 'notes' );
207
208
		$html .= '</div>';
209
210
		// Sanitize html.
211
		$html = wp_kses_post( $html );
212
213
		// Return the HTML block.
214
		return $html;
215
	}
216
217
	/**
218
	 * Our [recipe-ingredients] shortcode.
@@ 223-245 (lines=23) @@
220
	 *
221
	 * @return string HTML for recipe ingredients shortcode.
222
	 */
223
	static function recipe_ingredients_shortcode( $atts, $content = '' ) {
224
		$atts = shortcode_atts( array(
225
			'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), //string
226
		), $atts, 'recipe-ingredients' );
227
228
		$html = '<div class="jetpack-recipe-ingredients">';
229
230
		// Print a title unless the user has opted to exclude it.
231
		if ( 'false' !== $atts['title'] ) {
232
			$html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>';
233
		}
234
235
		// Format content using list functionality.
236
		$html .= self::output_list_content( $content, 'ingredients' );
237
238
		$html .= '</div>';
239
240
		// Sanitize html.
241
		$html = wp_kses_post( $html );
242
243
		// Return the HTML block.
244
		return $html;
245
	}
246
247
	/**
248
	 * Reusable function to check for shortened formatting.
@@ 327-349 (lines=23) @@
324
	 *
325
	 * @return string HTML for recipe notes shortcode.
326
	 */
327
	static function recipe_directions_shortcode( $atts, $content = '' ) {
328
		$atts = shortcode_atts( array(
329
				'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), //string
330
		), $atts, 'recipe-directions' );
331
332
		$html = '<div class="jetpack-recipe-directions">';
333
334
		// Print a title unless the user has specified to exclude it.
335
		if ( 'false' !== $atts['title'] ) {
336
			$html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>';
337
		}
338
339
		// Format content using list functionality.
340
		$html .= self::output_list_content( $content, 'directions' );
341
342
		$html .= '</div>';
343
344
		// Sanitize html.
345
		$html = wp_kses_post( $html );
346
347
		// Return the HTML block.
348
		return $html;
349
	}
350
}
351
352
new Jetpack_Recipes();