ad_tags = $ad_tags; } /** * Add the AMP Ads Widget Area. */ public function amp_ads_widget_area_init() { if ( self::is_amp_automatic_placement_enabled() ) { register_sidebar( array( 'name' => 'AMP Ads', 'id' => 'amp_ads', 'description' => 'Drag the AdPlugg Widget here to have AdPlugg Ads automatically included in your AMP pages.', ) ); } } /** * Register the AdPlugg AMP Ad Injector Sanitizer Ads Widget Area. * * Docs: https://github.com/Automattic/amp-wp/wiki/Handling-Media#step-2-load-the-sanitizer * @param array $sanitizer_classes An array of sanitizers as * CLASS_NAME => ARGUMENTS * @param type $post * @returns array Returns an array of sanitizers as * CLASS_NAME => ARGUMENTS */ public function add_ad_sanitizer( $sanitizer_classes, $post ) { if ( self::is_amp_automatic_placement_enabled() ) { // Note: we require this here because it extends a class from the AMP plugin require_once( ADPLUGG_INCLUDES . 'amp/class-adplugg-amp-ad-injection-sanitizer.php' ); //if the ad_tags haven't been set, call the collector and get them //from the widget area if ( $this->ad_tags == null ) { $this->ad_tags = AdPlugg_Ad_Tag_Collector::get_instance() ->get_ad_tags( 'amp_ads' ); } // Note: the array can be used to pass args to your sanitizer and accessed within the class via `$this->args` $sanitizer_classes[ 'AdPlugg_AMP_Ad_Injection_Sanitizer' ] = array('ad_tags' => $this->ad_tags); } return $sanitizer_classes; } /** * Add our additional css styles. * @param AMP_Post_Template $amp_template */ public function add_additional_css_styles( $amp_template ) { if ( self::is_amp_automatic_placement_enabled() ) { if ( self::is_centering_enabled() ) { ?> amp-ad[type="adplugg"] { display:block; margin: 0 auto 1em auto; } amp-ad[type="adplugg"] { margin-bottom: 0.5em; }