# jetpack/16.2/modules/wordads/php/class-wordads-shortcode.php

Jetpack – WP Security, Backup, Speed, &amp; Growth, version 16.2. 53 lines.

- Page: https://pluginprobe.com/plugins/jetpack/16.2/code/modules/wordads/php/class-wordads-shortcode.php
- Raw: https://pluginprobe.com/plugins/jetpack/16.2/raw/modules/wordads/php/class-wordads-shortcode.php
- Modified: 2025-11-24T17:00:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetpack/16.2/code/modules/wordads/php/class-wordads-shortcode.php#L10-L20`.

```php
<?php
/**
 * Wordads shortcode.
 *
 * Examples:
 * [wordads]
 *
 * @package automattic/jetpack
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit( 0 );
}

/**
 * Class WordAds_Shortcode
 *
 * Handles the [wordads] shortcode.
 */
class WordAds_Shortcode {

	/**
	 * Register our shortcode and enqueue necessary files.
	 */
	public static function init() {
		global $wordads;

		if ( empty( $wordads ) ) {
			return null;
		}

		add_shortcode( 'wordads', array( self::class, 'handle_wordads_shortcode' ) );
	}

	/**
	 * Our [wordads] shortcode.
	 * Prints a WordAds Ad.
	 *
	 * @return string HTML for WordAds shortcode.
	 */
	public static function handle_wordads_shortcode() {
		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"></div>';

		return $wordads->insert_inline_ad( $html );
	}
}

```
