PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.2.2
Jetpack – WP Security, Backup, Speed, & Growth v6.2.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 14.3.1 All 501 releases
jetpack / modules / shortcodes / wordads.php
wordads.php
68 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 */
7 class Jetpack_WordAds_Shortcode {
8
9 private $scripts_and_style_included = false;
10
11 function __construct() {
12 add_action( 'init', array( $this, 'action_init' ) );
13 }
14
15 /**
16 * Register our shortcode and enqueue necessary files.
17 */
18 function action_init() {
19 global $wordads;
20
21 if ( empty( $wordads ) ) {
22 return null;
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">';
58
59 $html .= '</div>';
60
61 $html = $wordads->insert_inline_ad( $html );
62
63 return $html;
64 }
65 }
66
67 new Jetpack_WordAds_Shortcode();
68