settings = $settings; } /** * Initializes all hooks. * * @since 1.3.0 */ public function register(): void { add_action( 'web_stories_print_analytics', [ $this, 'print_ad_manager_tag' ] ); } /** * Get the list of service IDs required for this service to be registered. * * Needed because settings needs to be registered first. * * @since 1.13.0 * * @return string[] List of required services. */ public static function get_requirements(): array { return [ 'settings' ]; } /** * Prints the tag for single stories. * * @since 1.3.0 */ public function print_ad_manager_tag(): void { $slot = $this->get_slot_id(); $enabled = $this->is_enabled(); if ( ! $enabled || ! $slot ) { return; } $configuration = [ 'ad-attributes' => [ 'type' => 'doubleclick', 'data-slot' => $slot, ], ]; /** * Filters Google Ad Manager configuration passed to ``. * * @since 1.10.0 * * @param array $settings Ad Manager configuration. * @param string $slot Google Ad_Manager slot ID. */ $configuration = apply_filters( 'web_stories_ad_manager_configuration', $configuration, $slot ); ?> settings->get_setting( $this->settings::SETTING_NAME_AD_MANAGER_SLOT_ID ); } /** * Returns if Google manager is enabled. * * @since 1.3.0 */ private function is_enabled(): bool { return ( 'admanager' === $this->settings->get_setting( $this->settings::SETTING_NAME_AD_NETWORK, 'none' ) ); } }