diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2018-06-08 10:09:24 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2018-06-08 10:09:24 -0400 |
commit | a6b006c0f1ef757f23375f7906193370337d8bd7 (patch) | |
tree | 4467c6423b2c54e6ef8c3e79241a833fb17833a5 /plugins/jetpack/modules/shortcodes/wordads.php | |
parent | Update akismet 4.0.7 (diff) | |
download | blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.gz blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.bz2 blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.zip |
Update jetpack 6.2
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/wordads.php')
-rw-r--r-- | plugins/jetpack/modules/shortcodes/wordads.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/shortcodes/wordads.php b/plugins/jetpack/modules/shortcodes/wordads.php new file mode 100644 index 00000000..7306eb77 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/wordads.php @@ -0,0 +1,67 @@ +<?php + +/** + * Embed WordAds 'ad' in post + * + */ +class Jetpack_WordAds_Shortcode { + + private $scripts_and_style_included = false; + + function __construct() { + add_action( 'init', array( $this, 'action_init' ) ); + } + + /** + * Register our shortcode and enqueue necessary files. + */ + function action_init() { + global $wordads; + + if ( empty( $wordads ) ) { + return null; + } + add_shortcode( 'wordads', array( $this, 'wordads_shortcode' ) ); + } + + /** + * Our [wordads] shortcode. + * Prints a WordAds Ad. + * + * @param array $atts Array of shortcode attributes. + * @param string $content Post content. + * + * @return string HTML for WordAds shortcode. + */ + static function wordads_shortcode( $atts, $content = '' ) { + $atts = shortcode_atts( array(), $atts, 'wordads'); + + return self::wordads_shortcode_html( $atts, $content ); + } + + /** + * The shortcode output + * + * @param array $atts Array of shortcode attributes. + * @param string $content Post content. + * + * @return string HTML output + */ + static function wordads_shortcode_html( $atts, $content = '' ) { + global $wordads; + + if ( empty( $wordads ) ) { + return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>'; + } + + $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock">'; + + $html .= '</div>'; + + $html = $wordads->insert_inline_ad( $html ); + + return $html; + } +} + +new Jetpack_WordAds_Shortcode(); |