← All changes
|
modules/subscriptions/subscribe-overlay/class-jetpack-subscribe-overlay.php
+13
-3
13.5.2
→
16.3-a.5
View file →
| @@ -5,8 +5,12 @@ | ||
| 5 | 5 | * @package automattic/jetpack-subscriptions |
| 6 | 6 | * @since 13.5 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit( 0 ); | |
| 11 | +} | |
| 12 | + | |
| 9 | 13 | /** |
| 10 | 14 | * Jetpack_Subscribe_Overlay class. |
| 11 | 15 | */ |
| 12 | 16 | class Jetpack_Subscribe_Overlay { |
| @@ -108,8 +112,9 @@ | ||
| 108 | 112 | * |
| 109 | 113 | * @return string |
| 110 | 114 | */ |
| 111 | 115 | public function get_subscribe_overlay_template_content() { |
| 116 | + $home_url = get_home_url(); | |
| 112 | 117 | $site_tagline = get_bloginfo( 'description' ); |
| 113 | 118 | $default_tagline = __( 'Stay informed with curated content and the latest headlines, all delivered straight to your inbox. Subscribe now to stay ahead and never miss a beat!', 'jetpack' ); |
| 114 | 119 | $tagline_block = empty( $site_tagline ) |
| 115 | 120 | ? '<!-- wp:paragraph {"align":"center","fontSize":"medium"} --><p class="has-text-align-center has-medium-font-size">' . $default_tagline . '</p><!-- /wp:paragraph -->' |
| @@ -125,12 +130,12 @@ | ||
| 125 | 130 | <!-- wp:site-title {"textAlign":"center","isLink":false,"fontSize":"x-large"} /--> |
| 126 | 131 | |
| 127 | 132 | $tagline_block |
| 128 | 133 | |
| 129 | - <!-- wp:jetpack/subscriptions /--> | |
| 134 | + <!-- wp:jetpack/subscriptions {"appSource":"subscribe-overlay"} /--> | |
| 130 | 135 | |
| 131 | 136 | <!-- wp:paragraph {"align":"center","className":"jetpack-subscribe-overlay__to-content"} --> |
| 132 | - <p class="has-text-align-center jetpack-subscribe-overlay__to-content"><a href="#">$skip_to_content ↓</a></p> | |
| 137 | + <p class="has-text-align-center jetpack-subscribe-overlay__to-content"><a href="$home_url">$skip_to_content ↓</a></p> | |
| 133 | 138 | <!-- /wp:paragraph --> |
| 134 | 139 | </div> |
| 135 | 140 | <!-- /wp:group --> |
| 136 | 141 | HTML; |
| @@ -180,8 +185,13 @@ | ||
| 180 | 185 | if ( is_admin() ) { |
| 181 | 186 | return false; |
| 182 | 187 | } |
| 183 | 188 | |
| 189 | + // The overlay only appears on the blog home and front page. | |
| 190 | + if ( ! is_home() && ! is_front_page() ) { | |
| 191 | + return false; | |
| 192 | + } | |
| 193 | + | |
| 184 | 194 | // Needed because Elementor editor makes is_admin() return false |
| 185 | 195 | // See https://coreysalzano.com/wordpress/why-elementor-disobeys-is_admin/ |
| 186 | 196 | // Ignore nonce warning as just checking if is set |
| 187 | 197 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| @@ -208,9 +218,9 @@ | ||
| 208 | 218 | if ( ! class_exists( 'Jetpack_Memberships' ) || Jetpack_Memberships::is_current_user_subscribed() ) { |
| 209 | 219 | return false; |
| 210 | 220 | } |
| 211 | 221 | |
| 212 | - return is_home() || is_front_page(); | |
| 222 | + return true; | |
| 213 | 223 | } |
| 214 | 224 | } |
| 215 | 225 | |
| 216 | 226 | Jetpack_Subscribe_Overlay::init(); |