css
2 years ago
images
2 years ago
img
2 years ago
js
1 year ago
archiveorg-book.php
5 years ago
archiveorg.php
5 years ago
archives.php
5 years ago
bandcamp.php
3 years ago
brightcove.php
5 years ago
cartodb.php
5 years ago
class.filter-embedded-html-objects.php
2 years ago
codepen.php
5 years ago
crowdsignal.php
2 years ago
dailymotion.php
3 years ago
descript.php
4 years ago
facebook.php
1 year ago
flatio.php
5 years ago
flickr.php
2 years ago
getty.php
2 years ago
gist.php
3 years ago
googleapps.php
2 years ago
googlemaps.php
2 years ago
googleplus.php
5 years ago
gravatar.php
2 years ago
houzz.php
5 years ago
inline-pdfs.php
4 years ago
instagram.php
1 year ago
kickstarter.php
3 years ago
mailchimp.php
3 years ago
medium.php
3 years ago
mixcloud.php
2 years ago
others.php
1 year ago
pinterest.php
2 years ago
presentations.php
2 years ago
quiz.php
4 years ago
recipe.php
2 years ago
scribd.php
5 years ago
sitemap.php
5 years ago
slideshare.php
5 years ago
slideshow.php
1 year ago
smartframe.php
3 years ago
soundcloud.php
3 years ago
spotify.php
2 years ago
ted.php
5 years ago
tweet.php
2 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
twitter.php
1 year ago
unavailable.php
3 years ago
untappd-menu.php
3 years ago
upcoming-events.php
1 year ago
ustream.php
5 years ago
videopress.php
4 years ago
vimeo.php
2 years ago
vine.php
5 years ago
vr.php
2 years ago
wufoo.php
3 years ago
youtube.php
1 year ago
untappd-menu.php
84 lines
| 1 | <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Untappd Shortcodes |
| 4 | * |
| 5 | * @author kraftbj |
| 6 | * |
| 7 | * [untappd-menu location="123" theme="123"] |
| 8 | * @since 4.1.0 |
| 9 | * @param location int Location ID for the Untappd venue. Required. |
| 10 | * @param theme int Theme ID for the Untappd menu. Required. |
| 11 | * |
| 12 | * @package automattic/jetpack |
| 13 | */ |
| 14 | |
| 15 | /** |
| 16 | * Display Untappd data in posts and pages. |
| 17 | */ |
| 18 | class Jetpack_Untappd { |
| 19 | |
| 20 | /** |
| 21 | * Constructor |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | add_action( 'init', array( $this, 'action_init' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Register our shortcodes. |
| 29 | */ |
| 30 | public function action_init() { |
| 31 | add_shortcode( 'untappd-menu', array( $this, 'menu_shortcode' ) ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * [untappd-menu] shortcode. |
| 36 | * |
| 37 | * @param array $atts Shortocde attributes. |
| 38 | * @param string $content Post content. |
| 39 | */ |
| 40 | public static function menu_shortcode( $atts, $content = '' ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 41 | // Let's bail if we don't have location or theme. |
| 42 | if ( ! isset( $atts['location'] ) || ! isset( $atts['theme'] ) ) { |
| 43 | if ( current_user_can( 'edit_posts' ) ) { |
| 44 | return __( 'No location or theme ID provided in the untappd-menu shortcode.', 'jetpack' ); |
| 45 | } |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | // Let's apply some defaults. |
| 50 | $atts = shortcode_atts( |
| 51 | array( |
| 52 | 'location' => '', |
| 53 | 'theme' => '', |
| 54 | ), |
| 55 | $atts, |
| 56 | 'untappd-menu' |
| 57 | ); |
| 58 | |
| 59 | // We're going to clean the user input. |
| 60 | $atts = array_map( 'absint', $atts ); |
| 61 | |
| 62 | if ( $atts['location'] < 1 || $atts['theme'] < 1 ) { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | static $untappd_menu = 1; |
| 67 | |
| 68 | $html = '<div id="menu-container-untappd-' . $untappd_menu . '" class="untappd-menu"></div>'; |
| 69 | $html .= '<script type="text/javascript">' . PHP_EOL; |
| 70 | $html .= '!function(e,n){var t=document.createElement("script"),a=document.getElementsByTagName("script")[0];' . PHP_EOL; |
| 71 | $html .= 't.async=1,a.parentNode.insertBefore(t,a),t.onload=t.onreadystatechange=function(e,a){' . PHP_EOL; |
| 72 | $html .= '(a||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t=void 0,a||n&&n())},' . PHP_EOL; |
| 73 | $html .= 't.src=e}("https://embed-menu-preloader.untappdapi.com/embed-menu-preloader.min.js",function(){' . PHP_EOL; |
| 74 | $html .= 'PreloadEmbedMenu( "menu-container-untappd-' . $untappd_menu . '",' . $atts['location'] . ',' . $atts['theme'] . ' )});' . PHP_EOL; |
| 75 | $html .= '</script>'; |
| 76 | |
| 77 | ++$untappd_menu; |
| 78 | |
| 79 | return $html; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | new Jetpack_Untappd(); |
| 84 |