PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php +60 -7 13.0.2 → 16.3-a.5 View file →
@@ -61,8 +61,49 @@
61 61 public function enqueue_assets() {
62 62 if ( $this->should_user_see_modal() ) {
63 63 wp_enqueue_style( 'subscribe-modal-css', plugins_url( 'subscribe-modal.css', __FILE__ ), array(), JETPACK__VERSION );
64 64 wp_enqueue_script( 'subscribe-modal-js', plugins_url( 'subscribe-modal.js', __FILE__ ), array( 'wp-dom-ready' ), JETPACK__VERSION, true );
65 +
66 + /**
67 + * Filter how many milliseconds until the Subscribe Modal appears.
68 + *
69 + * @module subscriptions
70 + *
71 + * @since 13.4
72 + *
73 + * @param int 60000 Time in milliseconds for the Subscribe Modal to appear.
74 + */
75 + $load_time = absint( apply_filters( 'jetpack_subscribe_modal_load_time', 60000 ) );
76 +
77 + /**
78 + * Filter how many percentage of the page should be scrolled before the Subscribe Modal appears.
79 + *
80 + * @module subscriptions
81 + *
82 + * @since 13.6
83 + *
84 + * @param int Percentage of the page scrolled before the Subscribe Modal appears.
85 + */
86 + $scroll_threshold = absint( apply_filters( 'jetpack_subscribe_modal_scroll_threshold', 50 ) );
87 +
88 + /**
89 + * Filter to control the interval at which the subscribe modal is shown to the same user. The default interval is 24 hours.
90 + *
91 + * @since 13.7
92 + *
93 + * @param int 24 Hours before we show the same user the Subscribe Modal to again.
94 + */
95 + $modal_interval = absint( apply_filters( 'jetpack_subscribe_modal_interval', 24 ) );
96 +
97 + wp_localize_script(
98 + 'subscribe-modal-js',
99 + 'Jetpack_Subscriptions',
100 + array(
101 + 'modalLoadTime' => $load_time,
102 + 'modalScrollThreshold' => $scroll_threshold,
103 + 'modalInterval' => ( $modal_interval * HOUR_IN_SECONDS * 1000 ),
104 + )
105 + );
65 106 }
66 107 }
67 108
68 109 /**
@@ -117,9 +158,9 @@
117 158 $template->title = __( 'Jetpack Subscribe modal', 'jetpack' );
118 159 $template->status = 'publish';
119 160 $template->has_theme_file = false;
120 161 $template->is_custom = true;
121 - $template->description = __( 'A subscribe form that pops up when someone visits your site', 'jetpack' );
162 + $template->description = __( 'A subscribe form that pops up when someone visits your site.', 'jetpack' );
122 163
123 164 return $template;
124 165 }
125 166
@@ -131,13 +172,14 @@
131 172 */
132 173 public function get_subscribe_template_content() {
133 174 // translators: %s is the name of the site.
134 175 $discover_more_from = sprintf( __( 'Discover more from %s', 'jetpack' ), get_bloginfo( 'name' ) );
135 - $continue_reading = __( 'Continue Reading', 'jetpack' );
176 + $continue_reading = __( 'Continue reading', 'jetpack' );
136 177 $subscribe_text = __( 'Subscribe now to keep reading and get access to the full archive.', 'jetpack' );
178 + $group_block_name = esc_attr__( 'Subscription pop-up container', 'jetpack' );
137 179
138 180 return <<<HTML
139 - <!-- wp:group {"style":{"spacing":{"top":"32px","bottom":"32px","left":"32px","right":"32px"},"margin":{"top":"0","bottom":"0"}},"border":{"color":"#dddddd","width":"1px"}},"layout":{"type":"constrained","contentSize":"450px"}} -->
181 + <!-- wp:group {"metadata":{"name":"$group_block_name"},"style":{"spacing":{"padding":{"top":"32px","bottom":"32px","left":"32px","right":"32px"},"margin":{"top":"0","bottom":"0"}},"border":{"color":"#dddddd","width":"1px"}},"layout":{"type":"constrained","contentSize":"450px"}} -->
140 182 <div class="wp-block-group has-border-color" style="border-color:#dddddd;border-width:1px;margin-top:0;margin-bottom:0;padding-top:32px;padding-right:32px;padding-bottom:32px;padding-left:32px">
141 183
142 184 <!-- wp:heading {"textAlign":"center","style":{"typography":{"fontStyle":"normal","fontWeight":"600","fontSize":"26px"},"layout":{"selfStretch":"fit","flexSize":null},"spacing":{"margin":{"top":"4px","bottom":"10px"}}}} -->
143 185 <h2 class="wp-block-heading has-text-align-center" style="margin-top:4px;margin-bottom:10px;font-size:26px;font-style:normal;font-weight:600">$discover_more_from</h2>
@@ -143,15 +185,15 @@
143 185 <h2 class="wp-block-heading has-text-align-center" style="margin-top:4px;margin-bottom:10px;font-size:26px;font-style:normal;font-weight:600">$discover_more_from</h2>
144 186 <!-- /wp:heading -->
145 187
146 188 <!-- wp:paragraph {"align":"center","style":{"typography":{"fontSize":"15px"},"spacing":{"margin":{"top":"4px","bottom":"0px"}}}} -->
147 - <p class='has-text-align-center' style='margin-top:4px;margin-bottom:0px;font-size:15px'>$subscribe_text</p>
189 + <p class='has-text-align-center' style='margin-top:4px;margin-bottom:1em;font-size:15px'>$subscribe_text</p>
148 190 <!-- /wp:paragraph -->
149 191
150 - <!-- wp:jetpack/subscriptions {"buttonBackgroundColor":"primary","textColor":"secondary","borderRadius":50,"borderColor":"primary","className":"is-style-compact"} /-->
192 + <!-- wp:jetpack/subscriptions {"borderRadius":50,"className":"is-style-compact","appSource":"subscribe-modal"} /-->
151 193
152 194 <!-- wp:paragraph {"align":"center","style":{"spacing":{"margin":{"top":"20px"}},"typography":{"fontSize":"14px"}},"className":"jetpack-subscribe-modal__close"} -->
153 - <p class="has-text-align-center jetpack-subscribe-modal__close" style="margin-top:20px;font-size:14px"><a href="#">$continue_reading</a></p>
195 + <p class="has-text-align-center jetpack-subscribe-modal__close" style="margin-top:20px;margin-bottom:0;font-size:14px"><a href="#">$continue_reading</a></p>
154 196 <!-- /wp:paragraph -->
155 197 </div>
156 198 <!-- /wp:group -->
157 199 HTML;
@@ -168,8 +210,16 @@
168 210 if ( is_admin() || ! is_singular( 'post' ) ) {
169 211 return false;
170 212 }
171 213
214 + // Needed because Elementor editor makes is_admin() return false
215 + // See https://coreysalzano.com/wordpress/why-elementor-disobeys-is_admin/
216 + // Ignore nonce warning as just checking if is set
217 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended
218 + if ( isset( $_GET['elementor-preview'] ) ) {
219 + return false;
220 + }
221 +
172 222 // Don't show when previewing blog posts or site's theme
173 223 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
174 224 if ( isset( $_GET['preview'] ) || isset( $_GET['theme_preview'] ) || isset( $_GET['customize_preview'] ) || isset( $_GET['hide_banners'] ) ) {
175 225 return false;
@@ -182,10 +232,13 @@
182 232 if ( isset( $_GET['subscribe'] ) || isset( $_GET['blogsub'] ) ) {
183 233 return false;
184 234 }
185 235
186 - // Don't show if post is for subscribers only or has paywall block
236 + // Don't show if post is not a post, is for subscribers only, or has paywall block
187 237 global $post;
238 + if ( ! $post instanceof WP_Post ) {
239 + return false;
240 + }
188 241 if ( defined( 'Automattic\\Jetpack\\Extensions\\Subscriptions\\META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS' ) ) {
189 242 $access_level = get_post_meta( $post->ID, META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS, true );
190 243 } else {
191 244 $access_level = get_post_meta( $post->ID, '_jetpack_newsletter_access', true );