PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
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 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 All 502 releases
jetpack / modules / wordads / php / class-wordads-shortcode.php

class-wordads-shortcode.php in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at modules/wordads/php/class-wordads-shortcode.php

53 lines 957 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
53