PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.7.5
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.7.5
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / admin / section / class-convertkit-admin-section-restrict-content.php

class-convertkit-admin-section-restrict-content.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 2.7.5, at admin/section/class-convertkit-admin-section-restrict-content.php

572 lines 15.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ConvertKit Settings Restrict Content class.
4 *
5 * @package ConvertKit
6 * @author ConvertKit
7 */
8
9 /**
10 * Registers Restrict Content Settings that can be edited at Settings > Kit > Member's Content.
11 *
12 * @package ConvertKit
13 * @author ConvertKit
14 */
15 class ConvertKit_Admin_Section_Restrict_Content extends ConvertKit_Admin_Section_Base {
16
17 /**
18 * Constructor.
19 *
20 * @since 2.1.0
21 */
22 public function __construct() {
23
24 // Define the class that reads/writes settings.
25 $this->settings = new ConvertKit_Settings_Restrict_Content();
26
27 // Define the settings key.
28 $this->settings_key = $this->settings::SETTINGS_NAME;
29
30 // Define the programmatic name, Title and Tab Text.
31 $this->name = 'restrict-content';
32 $this->title = __( 'Member Content', 'convertkit' );
33 $this->tab_text = __( 'Member Content', 'convertkit' );
34
35 // Define settings sections.
36 $this->settings_sections = array(
37 'general' => array(
38 'title' => $this->title,
39 'callback' => array( $this, 'print_section_info' ),
40 'wrap' => true,
41 ),
42 'forms' => array(
43 'title' => __( 'Forms', 'convertkit' ),
44 'callback' => array( $this, 'print_section_info_forms' ),
45 'wrap' => true,
46 ),
47 'products' => array(
48 'title' => __( 'Products', 'convertkit' ),
49 'callback' => array( $this, 'print_section_info_products' ),
50 'wrap' => true,
51 ),
52 'tags' => array(
53 'title' => __( 'Tags', 'convertkit' ),
54 'callback' => array( $this, 'print_section_info_tags' ),
55 'wrap' => true,
56 ),
57 );
58
59 // Enqueue scripts.
60 add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
61
62 // Output the Intercom messenger.
63 if ( $this->on_settings_screen( $this->name ) ) {
64 add_action( 'admin_footer', array( $this, 'output_intercom' ) );
65 }
66
67 parent::__construct();
68
69 }
70
71 /**
72 * Enqueues scripts for the Settings > Member's Content screen.
73 *
74 * @since 2.2.4
75 *
76 * @param string $section Settings section / tab (general|tools|restrict-content).
77 */
78 public function enqueue_scripts( $section ) {
79
80 // Bail if we're not on the Member's Content section.
81 if ( $section !== $this->name ) {
82 return;
83 }
84
85 // Enqueue JS.
86 wp_enqueue_script( 'convertkit-admin-settings-conditional-display', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/settings-conditional-display.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true );
87
88 }
89
90 /**
91 * Registers settings fields for this section.
92 *
93 * @since 2.1.0
94 */
95 public function register_fields() {
96
97 // Permit Crawlers.
98 add_settings_field(
99 'permit_crawlers',
100 __( 'Permit Search Engine Crawlers', 'convertkit' ),
101 array( $this, 'permit_crawlers_callback' ),
102 $this->settings_key,
103 $this->name,
104 array(
105 'name' => 'permit_crawlers',
106 'label_for' => 'permit_crawlers',
107 'label' => __( 'When enabled, search engine crawlers (such as Google and Bing) are able to access Member Content for indexing.', 'convertkit' ),
108 'description' => '',
109 )
110 );
111
112 // Restrict by Form.
113 add_settings_field(
114 'no_access_text_form',
115 __( 'No Access Text', 'convertkit' ),
116 array( $this, 'text_callback' ),
117 $this->settings_key,
118 $this->name . '-forms',
119 array(
120 'name' => 'no_access_text_form',
121 'label_for' => 'no_access_text_form',
122 'description' => array(
123 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
124 ),
125 )
126 );
127
128 // Restrict by Tag.
129 add_settings_field(
130 'subscribe_heading_tag',
131 __( 'Subscribe Heading', 'convertkit' ),
132 array( $this, 'text_callback' ),
133 $this->settings_key,
134 $this->name . '-tags',
135 array(
136 'name' => 'subscribe_heading_tag',
137 'label_for' => 'subscribe_heading_tag',
138 'description' => array(
139 __( 'Displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
140 ),
141 )
142 );
143
144 add_settings_field(
145 'subscribe_text_tag',
146 __( 'Subscribe Text', 'convertkit' ),
147 array( $this, 'textarea_callback' ),
148 $this->settings_key,
149 $this->name . '-tags',
150 array(
151 'name' => 'subscribe_text_tag',
152 'label_for' => 'subscribe_text_tag',
153 'description' => array(
154 __( 'Displays text explaining why the content is only available to subscribers.', 'convertkit' ),
155 ),
156 )
157 );
158
159 add_settings_field(
160 'no_access_text_tag',
161 __( 'No Access Text', 'convertkit' ),
162 array( $this, 'text_callback' ),
163 $this->settings_key,
164 $this->name . '-tags',
165 array(
166 'name' => 'no_access_text_tag',
167 'label_for' => 'no_access_text_tag',
168 'description' => array(
169 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
170 ),
171 )
172 );
173
174 add_settings_field(
175 'require_tag_login',
176 __( 'Require Login', 'convertkit' ),
177 array( $this, 'require_tag_login_callback' ),
178 $this->settings_key,
179 $this->name . '-tags',
180 array(
181 'name' => 'require_tag_login',
182 'label_for' => 'require_tag_login',
183 'label' => __( 'When checked, subscribers are sent a code in an email to login after being subscribed and tagged.', 'convertkit' ),
184 'description' => '',
185 )
186 );
187
188 // reCAPTCHA.
189 add_settings_field(
190 'recaptcha_site_key',
191 __( 'reCAPTCHA: Site Key', 'convertkit' ),
192 array( $this, 'text_callback' ),
193 $this->settings_key,
194 $this->name . '-tags',
195 array(
196 'name' => 'recaptcha_site_key',
197 'label_for' => 'recaptcha_site_key',
198 'description' => array(
199 __( 'Enter your Google reCAPTCHA v3 Site Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
200 ),
201 )
202 );
203 add_settings_field(
204 'recaptcha_secret_key',
205 __( 'reCAPTCHA: Secret Key', 'convertkit' ),
206 array( $this, 'text_callback' ),
207 $this->settings_key,
208 $this->name . '-tags',
209 array(
210 'name' => 'recaptcha_secret_key',
211 'label_for' => 'recaptcha_secret_key',
212 'description' => array(
213 __( 'Enter your Google reCAPTCHA v3 Secret Key. When specified, this will be used to reduce spam signups.', 'convertkit' ),
214 ),
215 )
216 );
217 add_settings_field(
218 'recaptcha_minimum_score',
219 __( 'reCAPTCHA: Minimum Score', 'convertkit' ),
220 array( $this, 'number_callback' ),
221 $this->settings_key,
222 $this->name . '-tags',
223 array(
224 'name' => 'recaptcha_minimum_score',
225 'label_for' => 'recaptcha_minimum_score',
226 'min' => 0,
227 'max' => 1,
228 'step' => 0.01,
229 'description' => array(
230 __( 'Enter the minimum threshold for a subscriber to pass Google reCAPTCHA. A higher number will reduce spam signups (1.0 is very likely a good interaction, 0.0 is very likely a bot).', 'convertkit' ),
231 ),
232 )
233 );
234
235 // All.
236 add_settings_field(
237 'subscribe_button_label',
238 __( 'Subscribe Button Label', 'convertkit' ),
239 array( $this, 'text_callback' ),
240 $this->settings_key,
241 $this->name,
242 array(
243 'name' => 'subscribe_button_label',
244 'label_for' => 'subscribe_button_label',
245 'description' => array(
246 __( 'The text to display for the call to action button to subscribe.', 'convertkit' ),
247 ),
248 )
249 );
250
251 // Restrict by Product.
252 add_settings_field(
253 'subscribe_heading',
254 __( 'Subscribe Heading', 'convertkit' ),
255 array( $this, 'text_callback' ),
256 $this->settings_key,
257 $this->name . '-products',
258 array(
259 'name' => 'subscribe_heading',
260 'label_for' => 'subscribe_heading',
261 'description' => array(
262 __( 'Displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
263 ),
264 )
265 );
266
267 add_settings_field(
268 'subscribe_text',
269 __( 'Subscribe Text', 'convertkit' ),
270 array( $this, 'textarea_callback' ),
271 $this->settings_key,
272 $this->name . '-products',
273 array(
274 'name' => 'subscribe_text',
275 'label_for' => 'subscribe_text',
276 'description' => array(
277 __( 'Displays text explaining why the content is only available to subscribers.', 'convertkit' ),
278 ),
279 )
280 );
281
282 add_settings_field(
283 'no_access_text',
284 __( 'No Access Text', 'convertkit' ),
285 array( $this, 'text_callback' ),
286 $this->settings_key,
287 $this->name . '-products',
288 array(
289 'name' => 'no_access_text',
290 'label_for' => 'no_access_text',
291 'description' => array(
292 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
293 ),
294 )
295 );
296
297 // Member Content.
298 add_settings_field(
299 'email_text',
300 __( 'Email Text', 'convertkit' ),
301 array( $this, 'text_callback' ),
302 $this->settings_key,
303 $this->name,
304 array(
305 'name' => 'email_text',
306 'label_for' => 'email_text',
307 'description' => array(
308 __( 'The text to display asking if the subscriber has already subscribed.', 'convertkit' ),
309 ),
310 )
311 );
312
313 add_settings_field(
314 'email_heading',
315 __( 'Email Heading', 'convertkit' ),
316 array( $this, 'text_callback' ),
317 $this->settings_key,
318 $this->name,
319 array(
320 'name' => 'email_heading',
321 'label_for' => 'email_heading',
322 'description' => array(
323 __( 'The heading to display above the email field, directing the subscriber to log in.', 'convertkit' ),
324 ),
325 )
326 );
327
328 add_settings_field(
329 'email_description_text',
330 __( 'Email Field Description', 'convertkit' ),
331 array( $this, 'text_callback' ),
332 $this->settings_key,
333 $this->name,
334 array(
335 'name' => 'email_description_text',
336 'label_for' => 'email_description_text',
337 'description' => array(
338 __( 'The text to display below the email field, explaining the subscriber will receive a code by email.', 'convertkit' ),
339 ),
340 )
341 );
342
343 add_settings_field(
344 'email_button_label',
345 __( 'Email Button Label', 'convertkit' ),
346 array( $this, 'text_callback' ),
347 $this->settings_key,
348 $this->name,
349 array(
350 'name' => 'email_button_label',
351 'label_for' => 'email_button_label',
352 'description' => array(
353 __( 'The text to display for the button to submit the subscriber\'s email address and receive a login link to access the member-only content.', 'convertkit' ),
354 ),
355 )
356 );
357
358 add_settings_field(
359 'email_check_heading',
360 __( 'Email Check Heading', 'convertkit' ),
361 array( $this, 'text_callback' ),
362 $this->settings_key,
363 $this->name,
364 array(
365 'name' => 'email_check_heading',
366 'label_for' => 'email_check_heading',
367 'description' => array(
368 __( 'The heading to display telling the subscriber an email with a log in code was just sent.', 'convertkit' ),
369 ),
370 )
371 );
372
373 add_settings_field(
374 'email_check_text',
375 __( 'Email Check Text', 'convertkit' ),
376 array( $this, 'text_callback' ),
377 $this->settings_key,
378 $this->name,
379 array(
380 'name' => 'email_check_text',
381 'label_for' => 'email_check_text',
382 'description' => array(
383 __( 'The text to display instructing the subscriber to check their email for the login link that was sent.', 'convertkit' ),
384 ),
385 )
386 );
387
388 }
389
390 /**
391 * Prints help info for this section
392 *
393 * @since 2.1.0
394 */
395 public function print_section_info() {
396
397 ?>
398 <p class="description"><?php esc_html_e( 'Defines the text and button labels to display when a Page, Post or Custom Post has its Member Content setting defined.', 'convertkit' ); ?></p>
399 <?php
400
401 }
402
403 /**
404 * Prints help info for the forms section of the settings screen.
405 *
406 * @since 2.7.3
407 */
408 public function print_section_info_forms() {
409
410 ?>
411 <p class="description"><?php esc_html_e( 'Defines settings when a Page, Post or Custom Post type has its member content setting set to a Kit form.', 'convertkit' ); ?></p>
412 <?php
413
414 }
415
416 /**
417 * Prints help info for the products section of the settings screen.
418 *
419 * @since 2.7.1
420 */
421 public function print_section_info_products() {
422
423 ?>
424 <p class="description"><?php esc_html_e( 'Defines settings when a Page, Post or Custom Post type has its member content setting set to a Kit product.', 'convertkit' ); ?></p>
425 <?php
426
427 }
428
429 /**
430 * Prints help info for the tags section of the settings screen.
431 *
432 * @since 2.7.1
433 */
434 public function print_section_info_tags() {
435
436 ?>
437 <p class="description"><?php esc_html_e( 'Defines settings when a Page, Post or Custom Post type has its member content setting set to a Kit tag.', 'convertkit' ); ?></p>
438 <?php
439
440 }
441
442 /**
443 * Returns the URL for the ConvertKit documentation for this setting section.
444 *
445 * @since 2.1.0
446 *
447 * @return string Documentation URL.
448 */
449 public function documentation_url() {
450
451 return 'https://help.kit.com/en/articles/2502591-the-convertkit-wordpress-plugin';
452
453 }
454
455 /**
456 * Renders the input for the Permit Crawlers setting.
457 *
458 * @since 2.4.1
459 *
460 * @param array $args Setting field arguments (name,description).
461 */
462 public function permit_crawlers_callback( $args ) {
463
464 // Output field.
465 echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
466 $args['name'],
467 'on',
468 $this->settings->permit_crawlers(), // phpcs:ignore WordPress.Security.EscapeOutput
469 $args['label'], // phpcs:ignore WordPress.Security.EscapeOutput
470 $args['description'] // phpcs:ignore WordPress.Security.EscapeOutput
471 );
472
473 }
474
475 /**
476 * Renders the input for the Require Login setting.
477 *
478 * @since 2.7.2
479 *
480 * @param array $args Setting field arguments (name,description).
481 */
482 public function require_tag_login_callback( $args ) {
483
484 // Output field.
485 echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
486 $args['name'],
487 'on',
488 $this->settings->require_tag_login(), // phpcs:ignore WordPress.Security.EscapeOutput
489 $args['label'], // phpcs:ignore WordPress.Security.EscapeOutput
490 $args['description'] // phpcs:ignore WordPress.Security.EscapeOutput
491 );
492
493 }
494
495 /**
496 * Renders the input for the text setting.
497 *
498 * @since 2.1.0
499 *
500 * @param array $args Setting field arguments (name,description).
501 */
502 public function text_callback( $args ) {
503
504 // Output field.
505 echo $this->get_text_field( // phpcs:ignore WordPress.Security.EscapeOutput
506 $args['name'],
507 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
508 $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput
509 array(
510 'widefat',
511 )
512 );
513
514 }
515
516 /**
517 * Renders the input for the decimal setting.
518 *
519 * @since 2.6.8
520 *
521 * @param array $args Setting field arguments (name,description).
522 */
523 public function number_callback( $args ) {
524
525 echo $this->get_number_field( // phpcs:ignore WordPress.Security.EscapeOutput
526 $args['name'],
527 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
528 $args['min'], // phpcs:ignore WordPress.Security.EscapeOutput
529 $args['max'], // phpcs:ignore WordPress.Security.EscapeOutput
530 $args['step'], // phpcs:ignore WordPress.Security.EscapeOutput
531 $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput
532 array(
533 'widefat',
534 )
535 );
536
537 }
538
539 /**
540 * Renders the input for the textarea setting.
541 *
542 * @since 2.3.5
543 *
544 * @param array $args Setting field arguments (name,description).
545 */
546 public function textarea_callback( $args ) {
547
548 // Output field.
549 echo $this->get_textarea_field( // phpcs:ignore WordPress.Security.EscapeOutput
550 $args['name'],
551 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
552 $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput
553 array(
554 'widefat',
555 )
556 );
557
558 }
559
560 }
561
562 // Bootstrap.
563 add_action(
564 'convertkit_admin_settings_register_sections',
565 function ( $sections ) {
566
567 $sections['restrict-content'] = new ConvertKit_Admin_Section_Restrict_Content();
568 return $sections;
569
570 }
571 );
572