PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.1
Jetpack – WP Security, Backup, Speed, & Growth v7.1
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 14.3.1 All 501 releases
jetpack / modules / shortcodes / wordads.php

wordads.php in Jetpack – WP Security, Backup, Speed, & Growth 7.1, at modules/shortcodes/wordads.php

65 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Embed WordAds 'ad' in post
5 */
6 class Jetpack_WordAds_Shortcode {
7
8 private $scripts_and_style_included = false;
9
10 function __construct() {
11 add_action( 'init', array( $this, 'action_init' ) );
12 }
13
14 /**
15 * Register our shortcode and enqueue necessary files.
16 */
17 function action_init() {
18 global $wordads;
19
20 if ( empty( $wordads ) ) {
21 return null;
22 }
23
24 add_shortcode( 'wordads', array( $this, 'wordads_shortcode' ) );
25 }
26
27 /**
28 * Our [wordads] shortcode.
29 * Prints a WordAds Ad.
30 *
31 * @param array $atts Array of shortcode attributes.
32 * @param string $content Post content.
33 *
34 * @return string HTML for WordAds shortcode.
35 */
36 static function wordads_shortcode( $atts, $content = '' ) {
37 $atts = shortcode_atts( array(), $atts, 'wordads' );
38
39 return self::wordads_shortcode_html( $atts, $content );
40 }
41
42 /**
43 * The shortcode output
44 *
45 * @param array $atts Array of shortcode attributes.
46 * @param string $content Post content.
47 *
48 * @return string HTML output
49 */
50 static function wordads_shortcode_html( $atts, $content = '' ) {
51 global $wordads;
52
53 if ( empty( $wordads ) ) {
54 return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>';
55 }
56
57 $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock"></div>';
58 $html = $wordads->insert_inline_ad( $html );
59
60 return $html;
61 }
62 }
63
64 new Jetpack_WordAds_Shortcode();
65