Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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; |
||
|
0 ignored issues
–
show
|
|||
| 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 |
This check marks private properties in classes that are never used. Those properties can be removed.