ActBlue.php
5 years ago
Adways.php
5 years ago
Altru.php
5 years ago
AmCharts.php
5 years ago
Animoto.php
5 years ago
AnnieMusic.php
5 years ago
Apester.php
5 years ago
Archivos.php
5 years ago
AudioClip.php
5 years ago
Audioboom.php
5 years ago
Audiomack.php
5 years ago
Avocode.php
5 years ago
Backtracks.php
5 years ago
BeautifulAI.php
5 years ago
BlackfireIO.php
5 years ago
Blogcast.php
5 years ago
Buttondown.php
5 years ago
Byzart.php
5 years ago
Ceros.php
5 years ago
ChartBlocks.php
5 years ago
Chirbit.php
5 years ago
CircuitLab.php
5 years ago
Clyp.php
5 years ago
CocoCorp.php
5 years ago
CodeHS.php
5 years ago
CodePen.php
5 years ago
CodeSandbox.php
5 years ago
Codepoints.php
5 years ago
Commaful.php
5 years ago
Coub.php
5 years ago
Cueup.php
5 years ago
DailyMotion.php
5 years ago
Datawrapper.php
5 years ago
Deseretnews.php
5 years ago
Deviantart.php
5 years ago
Didacte.php
5 years ago
Digiteka.php
5 years ago
DocDroid.php
5 years ago
DotSUB.php
5 years ago
EduMedia.php
5 years ago
Embedery.php
5 years ago
Ethfiddle.php
5 years ago
Eyrie.php
5 years ago
FITE.php
5 years ago
Facebook.php
5 years ago
Fader.php
5 years ago
FaithLifeTV.php
5 years ago
Fitapp.php
5 years ago
Flickr.php
5 years ago
Flourish.php
5 years ago
GeographCI.php
5 years ago
GeographDE.php
5 years ago
GeographUk.php
5 years ago
GetShow.php
5 years ago
GettyImages.php
5 years ago
Gfycat.php
5 years ago
Giphy.php
5 years ago
GloriaTV.php
5 years ago
Gyazo.php
5 years ago
Hearthis.php
5 years ago
HiHaHo.php
5 years ago
Huffduffer.php
5 years ago
IHeartRadio.php
5 years ago
Infogram.php
5 years ago
Infoveave.php
5 years ago
Injurymap.php
5 years ago
Inoreader.php
5 years ago
Instagram.php
5 years ago
Issuu.php
5 years ago
Jovian.php
5 years ago
KakaoTV.php
5 years ago
Kickstarter.php
5 years ago
Kidoju.php
5 years ago
KirimEmail.php
5 years ago
Kit.php
5 years ago
Kmdr.php
5 years ago
Knacki.php
5 years ago
LearningApps.php
5 years ago
LillePod.php
5 years ago
Livestream.php
5 years ago
Loom.php
5 years ago
Ludus.php
5 years ago
Lumiere.php
5 years ago
Matterport.php
5 years ago
MediaLab.php
5 years ago
MedienArchivKuenste.php
5 years ago
Meetup.php
4 years ago
MermaidInk.php
5 years ago
MessesInfo.php
5 years ago
MicrosoftStream.php
5 years ago
MixCloud.php
5 years ago
ModeloIO.php
5 years ago
MusicboxManiacs.php
5 years ago
Namchey.php
5 years ago
Nanoo.php
5 years ago
NaturalAtlas.php
5 years ago
Nfb.php
5 years ago
NoPaste.php
5 years ago
Omniscope.php
5 years ago
OnSizzle.php
5 years ago
OraTV.php
5 years ago
Orbitvu.php
5 years ago
Outplayed.php
5 years ago
OverflowIO.php
5 years ago
Oz.php
5 years ago
Padlet.php
5 years ago
Pastery.php
5 years ago
Pinpoll.php
5 years ago
Pixdor.php
5 years ago
Playbuzz.php
5 years ago
Podbean.php
5 years ago
PolariShare.php
5 years ago
Polldaddy.php
5 years ago
Portfolium.php
5 years ago
Posixion.php
5 years ago
ProviderAdapter.php
5 years ago
ProviderInterface.php
4 years ago
RadioPublic.php
5 years ago
Rcvis.php
5 years ago
Reddit.php
5 years ago
ReleaseWire.php
5 years ago
Replit.php
5 years ago
ReverbNation.php
5 years ago
Roomshare.php
5 years ago
RoosterTeeth.php
5 years ago
Rumble.php
5 years ago
RunKit.php
5 years ago
Saooti.php
5 years ago
SapoVideos.php
5 years ago
ScreenNine.php
5 years ago
Screencast.php
5 years ago
ScribbleMaps.php
5 years ago
Scribd.php
5 years ago
SendToNews.php
5 years ago
Shortnote.php
5 years ago
Shoudio.php
5 years ago
ShowTheWay.php
5 years ago
Simplecast.php
5 years ago
Sketchfab.php
5 years ago
Slideshare.php
5 years ago
SmashNotes.php
5 years ago
Smugmug.php
5 years ago
SocialExplorer.php
5 years ago
SongLink.php
5 years ago
SoundCloud.php
5 years ago
SpeakerDeck.php
5 years ago
Spotful.php
5 years ago
Spotify.php
5 years ago
Spreaker.php
5 years ago
StandfordDigitalRepository.php
5 years ago
Streamable.php
5 years ago
Subscribi.php
5 years ago
Sudomemo.php
5 years ago
Sutori.php
5 years ago
Sway.php
5 years ago
Ted.php
5 years ago
TheNewYorkTimes.php
5 years ago
Tickcounter.php
5 years ago
TikTok.php
5 years ago
Toornament.php
5 years ago
TourHero.php
5 years ago
Tumblr.php
5 years ago
Tuxx.php
5 years ago
Tvcf.php
5 years ago
TwentyThreeHq.php
5 years ago
Twitter.php
5 years ago
Typecast.php
5 years ago
Typlog.php
5 years ago
UniversitePantheonSorbonne.php
5 years ago
UniversityCambridgeMap.php
5 years ago
Uppy.php
5 years ago
UstreamTV.php
5 years ago
Ustudio.php
5 years ago
Veer.php
5 years ago
Verse.php
5 years ago
Vidyard.php
5 years ago
Vimeo.php
5 years ago
Viously.php
5 years ago
Vlipsy.php
5 years ago
Vlive.php
5 years ago
VoxSnap.php
5 years ago
WaveVideo.php
5 years ago
Wistia.php
5 years ago
Wizer.php
5 years ago
Wokwi.php
5 years ago
WolframCloud.php
5 years ago
Wordpress.php
5 years ago
Wordwall.php
5 years ago
Youtube.php
5 years ago
Zeplin.php
5 years ago
Zingsoft.php
5 years ago
ZnipeTV.php
5 years ago
Zoomable.php
5 years ago
iFixit.php
5 years ago
Meetup.php
210 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Meetup.php |
| 4 | * |
| 5 | * @package Embera |
| 6 | * @author Michael Pratt <yo@michael-pratt.com> |
| 7 | * @link http://www.michael-pratt.com/ |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | namespace Embera\Provider; |
| 14 | |
| 15 | use Embera\Url; |
| 16 | |
| 17 | /** |
| 18 | * Meetup Provider |
| 19 | * @link https://meetup.com |
| 20 | */ |
| 21 | class Meetup extends ProviderAdapter implements ProviderInterface |
| 22 | { |
| 23 | /** inline {@inheritdoc} */ |
| 24 | protected $shouldSendRequest = false; |
| 25 | /** inline {@inheritdoc} */ |
| 26 | protected $endpoint = 'https://api.meetup.com/oembed?format=json'; |
| 27 | |
| 28 | /** inline {@inheritdoc} */ |
| 29 | protected static $hosts = [ |
| 30 | 'meetup.com' |
| 31 | ]; |
| 32 | |
| 33 | /** inline {@inheritdoc} */ |
| 34 | protected $httpsSupport = true; |
| 35 | |
| 36 | /** inline {@inheritdoc} */ |
| 37 | protected $responsiveSupport = true; |
| 38 | |
| 39 | /** inline {@inheritdoc} */ |
| 40 | public function validateUrl(Url $url) |
| 41 | { |
| 42 | return (bool) ( |
| 43 | preg_match('~meetup\.com/(?:.+)~i', (string) $url) || |
| 44 | preg_match('~meetu\.ps/(?:\w+)/?$~i', (string) $url) |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | /** inline {@inheritdoc} */ |
| 49 | public function normalizeUrl(Url $url) |
| 50 | { |
| 51 | $url->convertToHttps(); |
| 52 | $url->removeQueryString(); |
| 53 | |
| 54 | return $url; |
| 55 | } |
| 56 | |
| 57 | public function getStaticResponse() { |
| 58 | $meetup_website = 'https://meetup.com'; |
| 59 | $response = []; |
| 60 | $response['type'] = 'rich'; |
| 61 | $response['provider_name'] = 'Meetup'; |
| 62 | $response['provider_url'] = $meetup_website; |
| 63 | $response['url'] = $this->getUrl(); |
| 64 | $search = ['href="/', 'src="/']; |
| 65 | $replace = ['href="'.$meetup_website.'/', 'src="'.$meetup_website.'/']; |
| 66 | $hash = 'mu_'.md5( $this->getUrl()); |
| 67 | $filename = wp_get_upload_dir()['basedir'] ."/embedpress/$hash.txt"; |
| 68 | //$params =$this->getParams(); |
| 69 | |
| 70 | if ( file_exists( $filename) ) { |
| 71 | $response['html'] = file_get_contents( $filename); |
| 72 | return $response; |
| 73 | }else{ |
| 74 | $t = wp_remote_get( $this->getUrl() , ['timeout'=>10]); |
| 75 | if ( !is_wp_error( $t) ) { |
| 76 | if ( $meetup_page_content = wp_remote_retrieve_body( $t) ) { |
| 77 | $dom = str_get_html($meetup_page_content); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if ( empty( $dom) || !is_object( $dom) ) { |
| 83 | $response['html'] = $this->getUrl(); |
| 84 | return $response; |
| 85 | } |
| 86 | |
| 87 | // Event info |
| 88 | $date = $dom->find('.eventTimeDisplay-startDate span', 0); |
| 89 | |
| 90 | $date = $this->embedpress_get_markup_from_node( $date ); |
| 91 | $title = $dom->find('.pageHead-headline', 0); |
| 92 | $title = $this->embedpress_get_markup_from_node( $title); |
| 93 | $content = $dom->find('.event-description--wrapper', 0); |
| 94 | $content = str_replace( $search, $replace, $this->embedpress_get_markup_from_node( $content )) ; |
| 95 | |
| 96 | $host_info = $dom->find('.event-host-info', 0); |
| 97 | $host_info = str_replace( $search, $replace, $this->embedpress_get_markup_from_node( $host_info )) ; |
| 98 | |
| 99 | $attendees = $dom->find('.attendees-sample', 0); |
| 100 | $attendees = str_replace( $search, $replace, $this->embedpress_get_markup_from_node( $attendees )) ; |
| 101 | |
| 102 | |
| 103 | // Group info |
| 104 | $group_name = $dom->find('.event-group-name span', 0); |
| 105 | $group_name = $this->embedpress_get_markup_from_node( $group_name ); |
| 106 | $group_link = $dom->find('a.event-group', 0); |
| 107 | $group_link = $meetup_website.$this->embedpress_get_markup_from_node( $group_link, false, 'href'); |
| 108 | $group_img = $dom->find('.event-group-photo', 0); |
| 109 | $group_img = $this->embedpress_get_markup_from_node( $group_img, false, 'src') ; |
| 110 | |
| 111 | // Time |
| 112 | $datetime = $dom->find('.eventDateTime--hover time', 0); |
| 113 | $datetime = $this->embedpress_get_markup_from_node( $datetime, 'outertext'); |
| 114 | $recurrence = $dom->find('.eventTimeDisplay-recurrence', 0); |
| 115 | $recurrence = $this->embedpress_get_markup_from_node( $recurrence); |
| 116 | |
| 117 | // Location |
| 118 | $location = $dom->find('.event-info address', 0); |
| 119 | $location = $this->embedpress_get_markup_from_node( $location, 'outertext'); |
| 120 | |
| 121 | $data = [ |
| 122 | 'date' => $date, |
| 123 | 'title' => $title, |
| 124 | 'host_info' => $host_info, |
| 125 | 'content' => $content, |
| 126 | 'attendees' => $attendees, |
| 127 | 'group_name' => $group_name, |
| 128 | 'group_link' => $group_link, |
| 129 | 'group_img' => $group_img, |
| 130 | 'datetime' => $datetime, |
| 131 | 'recurrence' => $recurrence, |
| 132 | 'location' => $location, |
| 133 | ]; |
| 134 | ob_start(); |
| 135 | ?> |
| 136 | <article class="embedpress-event"> |
| 137 | <header class="ep-event-header"> |
| 138 | <!--Date--> |
| 139 | <span class="ep-event--date"><?php echo esc_html( $date); ?></span> |
| 140 | <!--Event Title --> |
| 141 | <a class="ep-event-link" href="<?php echo esc_url( $this->getUrl()); ?>" target="_blank"> |
| 142 | <h1 class="ep-event--title"><?php echo esc_html( $title); ?></h1> |
| 143 | </a> |
| 144 | <!-- Event Host --> |
| 145 | <div class="ep-event--host"> |
| 146 | <?php echo wp_kses_post( $host_info );?> |
| 147 | </div> |
| 148 | </header> |
| 149 | |
| 150 | <section class="ep-event-content"> |
| 151 | <div class="ep-event--description"> |
| 152 | <?php echo wp_kses_post( $content );?> |
| 153 | </div> |
| 154 | <div class="ep-event--attendees"> |
| 155 | <?php echo wp_kses_post( $attendees );?> |
| 156 | </div> |
| 157 | </section> |
| 158 | |
| 159 | <aside> |
| 160 | <a class="ep-event-group-link" href="<?php echo esc_url( $group_link); ?>"> |
| 161 | <img class="ep-event-group--image" src="<?php echo esc_url( $group_img)?>" alt="<?php echo esc_attr( $title ); ?>"/ > |
| 162 | <h4 class="ep-event-group--name"><?php echo wp_kses_post( $group_name );?></h4> |
| 163 | </a> |
| 164 | <div class="ep-event-time-location"> |
| 165 | <div class="ep-event-datetime"> |
| 166 | <?php echo wp_kses_post( $datetime ); ?> |
| 167 | <?php echo wp_kses_post( $recurrence ); ?> |
| 168 | </div> |
| 169 | <div class="ep-event-location"> |
| 170 | <?php echo wp_kses_post( $location ); ?> |
| 171 | </div> |
| 172 | </div> |
| 173 | </aside> |
| 174 | |
| 175 | </article> |
| 176 | |
| 177 | |
| 178 | |
| 179 | <?php |
| 180 | $event_output = ob_get_clean(); |
| 181 | file_put_contents( $filename, $event_output); |
| 182 | embedpress_schedule_cache_cleanup(); |
| 183 | $response['html'] = $event_output; |
| 184 | return $response; |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * It checks for data in the node before returning. |
| 189 | * |
| 190 | * @param \simple_html_dom_node $node |
| 191 | * @param string $method |
| 192 | * @param string $attr_name |
| 193 | * |
| 194 | * @return string it returns data from the node if found or empty strings otherwise. |
| 195 | */ |
| 196 | public function embedpress_get_markup_from_node( $node, $method='innertext', $attr_name=''){ |
| 197 | if ( !empty( $node) && is_object( $node) ) { |
| 198 | if ( !empty( $attr_name) ) { |
| 199 | return $node->getAttribute( $attr_name ); |
| 200 | } |
| 201 | if ( !empty( $method) && method_exists( $node, $method) ) { |
| 202 | return $node->{$method}(); |
| 203 | } |
| 204 | return ''; |
| 205 | } |
| 206 | return ''; |
| 207 | } |
| 208 | |
| 209 | } |
| 210 |