post_content, 'recipe' ) ) { $this->scripts_and_style_included = true; break; } } if ( ! $this->scripts_and_style_included ) { return; } if( is_rtl() ) { wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/rtl/recipes-rtl.css', __FILE__ ), array(), '20130919' ); } else { wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/recipes.css', __FILE__ ), array(), '20130919' ); } wp_enqueue_script( 'jetpack-recipes-printthis', plugins_url( '/js/recipes-printthis.js', __FILE__ ), array( 'jquery' ), '20131230' ); wp_enqueue_script( 'jetpack-recipes-js', plugins_url( '/js/recipes.js', __FILE__ ), array( 'jquery', 'jetpack-recipes-printthis' ), '20131230' ); $title_var = wp_title( '|', false, 'right' ); $print_css_var = plugins_url( '/css/recipes-print.css', __FILE__ ); wp_localize_script( 'jetpack-recipes-js', 'jetpack_recipes_vars', array( 'pageTitle' => $title_var, 'loadCSS' => $print_css_var ) ); } /** * Our [recipe] shortcode. * Prints recipe data styled to look good on *any* theme. * * @return resume_shortcode_html */ static function recipe_shortcode( $atts, $content = '' ) { $atts = shortcode_atts( array( 'title' => '', //string 'servings' => '', //intval 'time' => '', //string 'difficulty' => '', //string 'print' => '', //string ), $atts, 'recipe' ); return self::recipe_shortcode_html( $atts, $content ); } /** * The recipe output * * @return Html */ static function recipe_shortcode_html( $atts, $content = '' ) { $html = false; $html = '
'; // Print the recipe title if exists if ( '' != $atts['title'] ) { $html .= '

' . esc_html( $atts['title'] ) . '

'; } // Print the recipe meta if exists if ( '' != $atts['servings'] || '' != $atts['time'] || '' != $atts['difficulty'] || '' != $atts['print'] ) { $html .= ''; } // Print content between codes $html .= '
' . do_shortcode( $content ) . '
'; // Close it up $html .= '
'; // If there is a recipe within a recipe, remove the shortcode if ( has_shortcode( $html, 'recipe' ) ) { remove_shortcode( 'recipe' ); } // Sanitize html $html = wp_kses_post( $html ); // Return the HTML block return $html; } } new Jetpack_Recipes();