css
3 years ago
images
12 years ago
img
13 years ago
js
4 years 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
3 years ago
codepen.php
5 years ago
crowdsignal.php
2 years ago
dailymotion.php
3 years ago
descript.php
4 years ago
facebook.php
3 years ago
flatio.php
5 years ago
flickr.php
3 years ago
getty.php
3 years ago
gist.php
3 years ago
googleapps.php
3 years ago
googlemaps.php
5 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
3 years ago
kickstarter.php
3 years ago
mailchimp.php
3 years ago
medium.php
3 years ago
mixcloud.php
3 years ago
others.php
3 years ago
pinterest.php
5 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
3 years ago
smartframe.php
3 years ago
soundcloud.php
3 years ago
spotify.php
4 years ago
ted.php
5 years ago
tweet.php
2 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
unavailable.php
3 years ago
untappd-menu.php
3 years ago
upcoming-events.php
3 years ago
ustream.php
5 years ago
videopress.php
4 years ago
vimeo.php
3 years ago
vine.php
5 years ago
vr.php
3 years ago
wordads.php
5 years ago
wufoo.php
3 years ago
youtube.php
2 years ago
wordads.php
81 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Wordads shortcode. |
| 4 | * |
| 5 | * Examples: |
| 6 | * [wordads] |
| 7 | * |
| 8 | * @package automattic/jetpack |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * Embed WordAds 'ad' in post |
| 13 | */ |
| 14 | class Jetpack_WordAds_Shortcode { |
| 15 | |
| 16 | /** |
| 17 | * Used to determine whether scripts and styles have been enqueued already. |
| 18 | * |
| 19 | * @var bool false Should we enqueue scripts and styles. |
| 20 | */ |
| 21 | private $scripts_and_style_included = false; |
| 22 | |
| 23 | /** |
| 24 | * Initialize. |
| 25 | */ |
| 26 | public function __construct() { |
| 27 | add_action( 'init', array( $this, 'action_init' ) ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Register our shortcode and enqueue necessary files. |
| 32 | */ |
| 33 | public function action_init() { |
| 34 | global $wordads; |
| 35 | |
| 36 | if ( empty( $wordads ) ) { |
| 37 | return null; |
| 38 | } |
| 39 | |
| 40 | add_shortcode( 'wordads', array( $this, 'wordads_shortcode' ) ); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Our [wordads] shortcode. |
| 45 | * Prints a WordAds Ad. |
| 46 | * |
| 47 | * @param array $atts Array of shortcode attributes. |
| 48 | * @param string $content Post content. |
| 49 | * |
| 50 | * @return string HTML for WordAds shortcode. |
| 51 | */ |
| 52 | public static function wordads_shortcode( $atts, $content = '' ) { |
| 53 | $atts = shortcode_atts( array(), $atts, 'wordads' ); |
| 54 | |
| 55 | return self::wordads_shortcode_html( $atts, $content ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * The shortcode output |
| 60 | * |
| 61 | * @param array $atts Array of shortcode attributes. |
| 62 | * @param string $content Post content. |
| 63 | * |
| 64 | * @return string HTML output |
| 65 | */ |
| 66 | private static function wordads_shortcode_html( $atts, $content = '' ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 67 | global $wordads; |
| 68 | |
| 69 | if ( empty( $wordads ) ) { |
| 70 | return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>'; |
| 71 | } |
| 72 | |
| 73 | $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock"></div>'; |
| 74 | $html = $wordads->insert_inline_ad( $html ); |
| 75 | |
| 76 | return $html; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | new Jetpack_WordAds_Shortcode(); |
| 81 |