Jetpack_Untappd

Untappd Shortcodes.

Defined (1)

The class is defined in the following location(s).

/modules/shortcodes/untappd-menu.php  
  1. class Jetpack_Untappd { 
  2.  
  3. function __construct() { 
  4. add_action( 'init', array( $this, 'action_init' ) ); 
  5.  
  6. function action_init() { 
  7. add_shortcode( 'untappd-menu', array( $this, 'menu_shortcode' ) ); 
  8.  
  9. /** 
  10. * [untappd-menu] shortcode. 
  11. */ 
  12. static function menu_shortcode( $atts, $content = '' ) { 
  13. // Let's bail if we don't have location or theme. 
  14. if ( ! isset( $atts['location'] ) || ! isset( $atts['theme'] ) ) { 
  15. if ( current_user_can( 'edit_posts') ) { 
  16. return __( 'No location or theme ID provided in the untappd-menu shortcode.', 'jetpack' ); 
  17. return; 
  18.  
  19. // Let's apply some defaults. 
  20. $atts = shortcode_atts( array( 
  21. 'location' => '',  
  22. 'theme' => '',  
  23. ), $atts, 'untappd-menu' ); 
  24.  
  25. // We're going to clean the user input. 
  26. $atts = array_map( 'absint', $atts ); 
  27.  
  28. if ( $atts['location'] < 1 || $atts['theme'] < 1 ) { 
  29. return; 
  30.  
  31. static $untappd_menu = 1; 
  32.  
  33. $html = '<div id="menu-container-untappd-' . $untappd_menu . '" class="untappd-menu"></div>'; 
  34. $html .= '<script type="text/javascript">' . PHP_EOL; 
  35. $html .= '!function(e, n) {var t=document.createElement("script"), a=document.getElementsByTagName("script")[0];' . PHP_EOL; 
  36. $html .= 't.async=1, a.parentNode.insertBefore(t, a), t.onload=t.onreadystatechange=function(e, a) {' . PHP_EOL; 
  37. $html .= '(a||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null, t=void 0, a||n&&n())}, ' . PHP_EOL; 
  38. $html .= 't.src=e}("https://embed-menu-preloader.untappdapi.com/embed-menu-preloader.min.js", function() {' . PHP_EOL; 
  39. $html .= 'PreloadEmbedMenu( "menu-container-untappd-' . $untappd_menu . '", ' . $atts["location"] . ', ' . $atts["theme"] . ' )});' . PHP_EOL; 
  40. $html .= '</script>'; 
  41.  
  42. $untappd_menu++; 
  43.  
  44. return $html;