PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / trunk
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages vtrunk
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 trunk, at admin/section/class-convertkit-admin-section-restrict-content.php

519 lines 13.1 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 parent::__construct();
63
64 }
65
66 /**
67 * Enqueues scripts for the Settings > Member's Content screen.
68 *
69 * @since 2.2.4
70 *
71 * @param string $section Settings section / tab (general|tools|restrict-content).
72 */
73 public function enqueue_scripts( $section ) {
74
75 // Bail if we're not on the Member's Content section.
76 if ( $section !== $this->name ) {
77 return;
78 }
79
80 // Enqueue JS.
81 wp_enqueue_script( 'convertkit-admin-settings-conditional-display', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/settings-conditional-display.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true );
82
83 }
84
85 /**
86 * Registers settings fields for this section.
87 *
88 * @since 2.1.0
89 */
90 public function register_fields() {
91
92 // Permit Crawlers.
93 add_settings_field(
94 'permit_crawlers',
95 __( 'Permit Search Engine Crawlers', 'convertkit' ),
96 array( $this, 'permit_crawlers_callback' ),
97 $this->settings_key,
98 $this->name,
99 array(
100 'name' => 'permit_crawlers',
101 'label_for' => 'permit_crawlers',
102 'label' => __( 'When enabled, search engine crawlers (such as Google and Bing) are able to access Member Content for indexing.', 'convertkit' ),
103 'description' => '',
104 )
105 );
106
107 // Restrict by Form.
108 add_settings_field(
109 'no_access_text_form',
110 __( 'No Access Text', 'convertkit' ),
111 array( $this, 'text_callback' ),
112 $this->settings_key,
113 $this->name . '-forms',
114 array(
115 'name' => 'no_access_text_form',
116 'label_for' => 'no_access_text_form',
117 'description' => array(
118 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
119 ),
120 )
121 );
122
123 // Restrict by Tag.
124 add_settings_field(
125 'subscribe_heading_tag',
126 __( 'Subscribe Heading', 'convertkit' ),
127 array( $this, 'text_callback' ),
128 $this->settings_key,
129 $this->name . '-tags',
130 array(
131 'name' => 'subscribe_heading_tag',
132 'label_for' => 'subscribe_heading_tag',
133 'description' => array(
134 __( 'Displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
135 ),
136 )
137 );
138
139 add_settings_field(
140 'subscribe_text_tag',
141 __( 'Subscribe Text', 'convertkit' ),
142 array( $this, 'textarea_callback' ),
143 $this->settings_key,
144 $this->name . '-tags',
145 array(
146 'name' => 'subscribe_text_tag',
147 'label_for' => 'subscribe_text_tag',
148 'description' => array(
149 __( 'Displays text explaining why the content is only available to subscribers.', 'convertkit' ),
150 ),
151 )
152 );
153
154 add_settings_field(
155 'no_access_text_tag',
156 __( 'No Access Text', 'convertkit' ),
157 array( $this, 'text_callback' ),
158 $this->settings_key,
159 $this->name . '-tags',
160 array(
161 'name' => 'no_access_text_tag',
162 'label_for' => 'no_access_text_tag',
163 'description' => array(
164 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
165 ),
166 )
167 );
168
169 // All.
170 add_settings_field(
171 'subscribe_button_label',
172 __( 'Subscribe Button Label', 'convertkit' ),
173 array( $this, 'text_callback' ),
174 $this->settings_key,
175 $this->name,
176 array(
177 'name' => 'subscribe_button_label',
178 'label_for' => 'subscribe_button_label',
179 'description' => array(
180 __( 'The text to display for the call to action button to subscribe.', 'convertkit' ),
181 ),
182 )
183 );
184
185 // Restrict by Product.
186 add_settings_field(
187 'subscribe_heading',
188 __( 'Subscribe Heading', 'convertkit' ),
189 array( $this, 'text_callback' ),
190 $this->settings_key,
191 $this->name . '-products',
192 array(
193 'name' => 'subscribe_heading',
194 'label_for' => 'subscribe_heading',
195 'description' => array(
196 __( 'Displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
197 ),
198 )
199 );
200
201 add_settings_field(
202 'subscribe_text',
203 __( 'Subscribe Text', 'convertkit' ),
204 array( $this, 'textarea_callback' ),
205 $this->settings_key,
206 $this->name . '-products',
207 array(
208 'name' => 'subscribe_text',
209 'label_for' => 'subscribe_text',
210 'description' => array(
211 __( 'Displays text explaining why the content is only available to subscribers.', 'convertkit' ),
212 ),
213 )
214 );
215
216 add_settings_field(
217 'no_access_text',
218 __( 'No Access Text', 'convertkit' ),
219 array( $this, 'text_callback' ),
220 $this->settings_key,
221 $this->name . '-products',
222 array(
223 'name' => 'no_access_text',
224 'label_for' => 'no_access_text',
225 'description' => array(
226 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
227 ),
228 )
229 );
230
231 // Member Content.
232 add_settings_field(
233 'email_text',
234 __( 'Email Text', 'convertkit' ),
235 array( $this, 'text_callback' ),
236 $this->settings_key,
237 $this->name,
238 array(
239 'name' => 'email_text',
240 'label_for' => 'email_text',
241 'description' => array(
242 __( 'The text to display asking if the subscriber has already subscribed.', 'convertkit' ),
243 ),
244 )
245 );
246
247 add_settings_field(
248 'email_heading',
249 __( 'Email Heading', 'convertkit' ),
250 array( $this, 'text_callback' ),
251 $this->settings_key,
252 $this->name,
253 array(
254 'name' => 'email_heading',
255 'label_for' => 'email_heading',
256 'description' => array(
257 __( 'The heading to display above the email field, directing the subscriber to log in.', 'convertkit' ),
258 ),
259 )
260 );
261
262 add_settings_field(
263 'email_description_text',
264 __( 'Email Field Description', 'convertkit' ),
265 array( $this, 'text_callback' ),
266 $this->settings_key,
267 $this->name,
268 array(
269 'name' => 'email_description_text',
270 'label_for' => 'email_description_text',
271 'description' => array(
272 __( 'The text to display below the email field, explaining the subscriber will receive a code by email.', 'convertkit' ),
273 ),
274 )
275 );
276
277 add_settings_field(
278 'email_button_label',
279 __( 'Email Button Label', 'convertkit' ),
280 array( $this, 'text_callback' ),
281 $this->settings_key,
282 $this->name,
283 array(
284 'name' => 'email_button_label',
285 'label_for' => 'email_button_label',
286 'description' => array(
287 __( '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' ),
288 ),
289 )
290 );
291
292 add_settings_field(
293 'email_check_heading',
294 __( 'Email Check Heading', 'convertkit' ),
295 array( $this, 'text_callback' ),
296 $this->settings_key,
297 $this->name,
298 array(
299 'name' => 'email_check_heading',
300 'label_for' => 'email_check_heading',
301 'description' => array(
302 __( 'The heading to display telling the subscriber an email with a log in code was just sent.', 'convertkit' ),
303 ),
304 )
305 );
306
307 add_settings_field(
308 'email_check_text',
309 __( 'Email Check Text', 'convertkit' ),
310 array( $this, 'text_callback' ),
311 $this->settings_key,
312 $this->name,
313 array(
314 'name' => 'email_check_text',
315 'label_for' => 'email_check_text',
316 'description' => array(
317 __( 'The text to display instructing the subscriber to check their email for the login link that was sent.', 'convertkit' ),
318 ),
319 )
320 );
321
322 add_settings_field(
323 'container_css_classes',
324 __( 'Container CSS Classes', 'convertkit' ),
325 array( $this, 'text_callback' ),
326 $this->settings_key,
327 $this->name,
328 array(
329 'name' => 'container_css_classes',
330 'label_for' => 'container_css_classes',
331 'description' => array(
332 __( 'Optional CSS classes to apply to the container wrapping the content preview and call to action for non-authenticated subscribers.', 'convertkit' ),
333 ),
334 )
335 );
336
337 }
338
339 /**
340 * Prints help info for this section
341 *
342 * @since 2.1.0
343 */
344 public function print_section_info() {
345
346 ?>
347 <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>
348 <?php
349
350 }
351
352 /**
353 * Prints help info for the forms section of the settings screen.
354 *
355 * @since 2.7.3
356 */
357 public function print_section_info_forms() {
358
359 ?>
360 <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>
361 <?php
362
363 }
364
365 /**
366 * Prints help info for the products section of the settings screen.
367 *
368 * @since 2.7.1
369 */
370 public function print_section_info_products() {
371
372 ?>
373 <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>
374 <?php
375
376 }
377
378 /**
379 * Prints help info for the tags section of the settings screen.
380 *
381 * @since 2.7.1
382 */
383 public function print_section_info_tags() {
384
385 ?>
386 <p class="description">
387 <?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' ); ?>
388 <br />
389 <?php
390 $url = add_query_arg(
391 array(
392 'page' => '_wp_convertkit_settings',
393 'tab' => 'general',
394 ),
395 admin_url( 'options-general.php' )
396 );
397 printf(
398 /* translators: 1: General settings screen link, 2: Closing link tag */
399 esc_html__( 'Looking for reCAPTCHA settings? They can now be found in the %1$sGeneral settings screen%2$s.', 'convertkit' ),
400 '<a href="' . esc_url( $url ) . '">',
401 '</a>'
402 );
403 ?>
404 </p>
405 <?php
406
407 }
408
409 /**
410 * Returns the URL for the ConvertKit documentation for this setting section.
411 *
412 * @since 2.1.0
413 *
414 * @return string Documentation URL.
415 */
416 public function documentation_url() {
417
418 return 'https://help.kit.com/en/articles/7896769-how-to-customize-your-kit-subscribers-experience-on-your-wordpress-website';
419
420 }
421
422 /**
423 * Renders the input for the Permit Crawlers setting.
424 *
425 * @since 2.4.1
426 *
427 * @param array $args Setting field arguments (name,description).
428 */
429 public function permit_crawlers_callback( $args ) {
430
431 // Output field.
432 $this->output_checkbox_field(
433 $args['name'],
434 'on',
435 $this->settings->permit_crawlers(),
436 $args['label'],
437 $args['description']
438 );
439
440 }
441
442 /**
443 * Renders the input for the text setting.
444 *
445 * @since 2.1.0
446 *
447 * @param array $args Setting field arguments (name,description).
448 */
449 public function text_callback( $args ) {
450
451 // Output field.
452 $this->output_text_field(
453 $args['name'],
454 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
455 $args['description'],
456 array(
457 'widefat',
458 )
459 );
460
461 }
462
463 /**
464 * Renders the input for the decimal setting.
465 *
466 * @since 2.6.8
467 *
468 * @param array $args Setting field arguments (name,description).
469 */
470 public function number_callback( $args ) {
471
472 $this->output_number_field(
473 $args['name'],
474 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
475 $args['min'],
476 $args['max'],
477 $args['step'],
478 $args['description'],
479 array(
480 'widefat',
481 )
482 );
483
484 }
485
486 /**
487 * Renders the input for the textarea setting.
488 *
489 * @since 2.3.5
490 *
491 * @param array $args Setting field arguments (name,description).
492 */
493 public function textarea_callback( $args ) {
494
495 // Output field.
496 $this->output_textarea_field(
497 $args['name'],
498 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
499 $args['description'],
500 array(
501 'widefat',
502 )
503 );
504
505 }
506
507 }
508
509 // Bootstrap.
510 add_filter(
511 'convertkit_admin_settings_register_sections',
512 function ( $sections ) {
513
514 $sections['restrict-content'] = new ConvertKit_Admin_Section_Restrict_Content();
515 return $sections;
516
517 }
518 );
519