| @@ -6,8 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Status; |
| 9 | 9 | |
| 10 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | + exit( 0 ); | |
| 12 | +} | |
| 13 | + | |
| 10 | 14 | /** |
| 11 | 15 | * Class WordAds_Params |
| 12 | 16 | * |
| 13 | 17 | * Sets parameters for WordAds. |
| @@ -71,8 +75,15 @@ | ||
| 71 | 75 | */ |
| 72 | 76 | public $page_type_ipw; |
| 73 | 77 | |
| 74 | 78 | /** |
| 79 | + * Is this an AMP request? | |
| 80 | + * | |
| 81 | + * @var bool | |
| 82 | + */ | |
| 83 | + public $is_amp; | |
| 84 | + | |
| 85 | + /** | |
| 75 | 86 | * Setup parameters for serving the ads |
| 76 | 87 | * |
| 77 | 88 | * @since 4.5.0 |
| 78 | 89 | */ |
| @@ -78,24 +89,26 @@ | ||
| 78 | 89 | */ |
| 79 | 90 | public function __construct() { |
| 80 | 91 | // WordAds setting => default. |
| 81 | 92 | $settings = array( |
| 82 | - 'wordads_approved' => false, | |
| 83 | - 'wordads_active' => false, | |
| 84 | - 'wordads_house' => true, | |
| 85 | - 'wordads_unsafe' => false, | |
| 86 | - 'enable_header_ad' => true, | |
| 87 | - 'wordads_second_belowpost' => true, | |
| 88 | - 'wordads_inline_enabled' => true, | |
| 89 | - 'wordads_display_front_page' => true, | |
| 90 | - 'wordads_display_post' => true, | |
| 91 | - 'wordads_display_page' => true, | |
| 92 | - 'wordads_display_archive' => true, | |
| 93 | - 'wordads_custom_adstxt' => '', | |
| 94 | - 'wordads_custom_adstxt_enabled' => false, | |
| 95 | - 'wordads_ccpa_enabled' => false, | |
| 96 | - 'wordads_ccpa_privacy_policy_url' => get_option( 'wp_page_for_privacy_policy' ) ? get_permalink( (int) get_option( 'wp_page_for_privacy_policy' ) ) : '', | |
| 97 | - 'wordads_cmp_enabled' => false, | |
| 93 | + 'wordads_approved' => false, | |
| 94 | + 'wordads_active' => false, | |
| 95 | + 'wordads_house' => true, | |
| 96 | + 'wordads_unsafe' => false, | |
| 97 | + 'enable_header_ad' => true, | |
| 98 | + 'wordads_second_belowpost' => true, | |
| 99 | + 'wordads_inline_enabled' => true, | |
| 100 | + 'wordads_bottom_sticky_enabled' => false, | |
| 101 | + 'wordads_sidebar_sticky_right_enabled' => false, | |
| 102 | + 'wordads_display_front_page' => true, | |
| 103 | + 'wordads_display_post' => true, | |
| 104 | + 'wordads_display_page' => true, | |
| 105 | + 'wordads_display_archive' => true, | |
| 106 | + 'wordads_custom_adstxt' => '', | |
| 107 | + 'wordads_custom_adstxt_enabled' => false, | |
| 108 | + 'wordads_ccpa_enabled' => false, | |
| 109 | + 'wordads_ccpa_privacy_policy_url' => get_option( 'wp_page_for_privacy_policy' ) ? get_permalink( (int) get_option( 'wp_page_for_privacy_policy' ) ) : '', | |
| 110 | + 'wordads_cmp_enabled' => false, | |
| 98 | 111 | ); |
| 99 | 112 | |
| 100 | 113 | // Grab settings, or set as default if it doesn't exist. |
| 101 | 114 | $this->options = array(); |
| @@ -135,8 +148,9 @@ | ||
| 135 | 148 | 'PageURL' => esc_js( $this->url ), |
| 136 | 149 | 'LangId' => str_contains( get_bloginfo( 'language' ), 'en' ) ? 1 : 0, // TODO something else? |
| 137 | 150 | 'AdSafe' => 1, // TODO. |
| 138 | 151 | ); |
| 152 | + $this->is_amp = function_exists( 'amp_is_request' ) && amp_is_request(); | |
| 139 | 153 | } |
| 140 | 154 | |
| 141 | 155 | /** |
| 142 | 156 | * Is this a mobile device? |