adthrive_ads = get_option( 'adthrive_ads' ); } /** * Add hooks */ public function setup() { add_filter( 'adthrive_ads_options', array( $this, 'add_options' ), 11, 1 ); if ( isset( $this->adthrive_ads['site_id'] ) && isset( $this->adthrive_ads['amp_stories'] ) && 'on' === $this->adthrive_ads['amp_stories'] ) { add_action( 'web_stories_print_analytics', array( $this, 'web_stories_print_analytics' ) ); } $site_ads = new \AdThrive_Ads\SiteAds(); $site_js_json = $site_ads->get_site_js(); $site_js = json_decode( $site_js_json ); if ( null !== $site_js && isset( $site_js->adOptions ) ) { $ad_options = $site_js->adOptions; if ( isset( $ad_options->gamMCMEnabled ) && $ad_options->gamMCMEnabled && isset( $ad_options->gamMCMChildNetworkCode ) ) { $this->dfp_account = $this->dfp_account . ',' . $ad_options->gamMCMChildNetworkCode; } } } /** * Get the local file content */ private function get_file_content( $filename ) { require_once ABSPATH . 'wp-admin/includes/file.php'; if ( \WP_Filesystem() ) { global $wp_filesystem; return $wp_filesystem->get_contents( ADTHRIVE_ADS_PATH . $filename ); } return false; } /** * Add the AMP Story Auto Ads */ public function web_stories_print_analytics() { $site_id = $this->adthrive_ads['site_id']; $slot = '/' . $this->dfp_account . '/AdThrive_WebStories_1/' . $site_id; ?> add_field( array( 'name' => __( 'Web Stories', 'adthrive_ads' ), 'desc' => __( 'Enable Web Stories ads
Learn more about monetizing Web Stories here. ', 'adthrive_ads' ), 'id' => 'amp_stories', 'type' => 'checkbox', ) ); return $cmb; } }