PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | modules/wordads/php/class-wordads-shortcode.php +52 -0 16.2-beta → 16.3 View file →
@@ -1,0 +1,52 @@
1 +<?php
2 +/**
3 + * Wordads shortcode.
4 + *
5 + * Examples:
6 + * [wordads]
7 + *
8 + * @package automattic/jetpack
9 + */
10 +
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit( 0 );
13 +}
14 +
15 +/**
16 + * Class WordAds_Shortcode
17 + *
18 + * Handles the [wordads] shortcode.
19 + */
20 +class WordAds_Shortcode {
21 +
22 + /**
23 + * Register our shortcode and enqueue necessary files.
24 + */
25 + public static function init() {
26 + global $wordads;
27 +
28 + if ( empty( $wordads ) ) {
29 + return null;
30 + }
31 +
32 + add_shortcode( 'wordads', array( self::class, 'handle_wordads_shortcode' ) );
33 + }
34 +
35 + /**
36 + * Our [wordads] shortcode.
37 + * Prints a WordAds Ad.
38 + *
39 + * @return string HTML for WordAds shortcode.
40 + */
41 + public static function handle_wordads_shortcode() {
42 + global $wordads;
43 +
44 + if ( empty( $wordads ) ) {
45 + return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>';
46 + }
47 +
48 + $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock"></div>';
49 +
50 + return $wordads->insert_inline_ad( $html );
51 + }
52 +}