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

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

381 lines 10.2 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 > ConvertKit > Member's Content.
11 *
12 * @package ConvertKit
13 * @author ConvertKit
14 */
15 class ConvertKit_Admin_Settings_Restrict_Content extends ConvertKit_Settings_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 // Enqueue scripts.
36 add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
37
38 parent::__construct();
39
40 }
41
42 /**
43 * Enqueues scripts for the Settings > Member's Content screen.
44 *
45 * @since 2.2.4
46 *
47 * @param string $section Settings section / tab (general|tools|restrict-content).
48 */
49 public function enqueue_scripts( $section ) {
50
51 // Bail if we're not on the Member's Content section.
52 if ( $section !== $this->name ) {
53 return;
54 }
55
56 // Enqueue JS.
57 wp_enqueue_script( 'convertkit-admin-settings-conditional-display', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/settings-conditional-display.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true );
58
59 }
60
61 /**
62 * Registers settings fields for this section.
63 *
64 * @since 2.1.0
65 */
66 public function register_fields() {
67
68 // Permit Crawlers.
69 add_settings_field(
70 'permit_crawlers',
71 __( 'Permit Search Engine Crawlers', 'convertkit' ),
72 array( $this, 'permit_crawlers_callback' ),
73 $this->settings_key,
74 $this->name,
75 array(
76 'name' => 'permit_crawlers',
77 'label_for' => 'permit_crawlers',
78 'label' => __( 'When enabled, search engine crawlers (such as Google and Bing) are able to access Member Content for indexing.', 'convertkit' ),
79 'description' => '',
80 )
81 );
82
83 // Restrict by Product.
84 add_settings_field(
85 'subscribe_heading',
86 __( 'Product: Subscribe Heading', 'convertkit' ),
87 array( $this, 'text_callback' ),
88 $this->settings_key,
89 $this->name,
90 array(
91 'name' => 'subscribe_heading',
92 'label_for' => 'subscribe_heading',
93 'description' => array(
94 __( 'When a Page, Post or Custom Post\'s Member Content setting is set to a ConvertKit Product, displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
95 ),
96 )
97 );
98
99 add_settings_field(
100 'subscribe_text',
101 __( 'Product: Subscribe Text', 'convertkit' ),
102 array( $this, 'textarea_callback' ),
103 $this->settings_key,
104 $this->name,
105 array(
106 'name' => 'subscribe_text',
107 'label_for' => 'subscribe_text',
108 'description' => array(
109 __( 'When a Page, Post or Custom Post\'s Member Content setting is set to a ConvertKit Product, displays text explaining why the content is only available to subscribers.', 'convertkit' ),
110 ),
111 )
112 );
113
114 // Restrict by Tag.
115 add_settings_field(
116 'subscribe_heading_tag',
117 __( 'Tag: Subscribe Heading', 'convertkit' ),
118 array( $this, 'text_callback' ),
119 $this->settings_key,
120 $this->name,
121 array(
122 'name' => 'subscribe_heading_tag',
123 'label_for' => 'subscribe_heading_tag',
124 'description' => array(
125 __( 'When a Page, Post or Custom Post\'s Member Content setting is set to a ConvertKit Tag, displays text in a heading explaining why the content is only available to subscribers.', 'convertkit' ),
126 ),
127 )
128 );
129
130 add_settings_field(
131 'subscribe_text_tag',
132 __( 'Tag: Subscribe Text', 'convertkit' ),
133 array( $this, 'textarea_callback' ),
134 $this->settings_key,
135 $this->name,
136 array(
137 'name' => 'subscribe_text_tag',
138 'label_for' => 'subscribe_text_tag',
139 'description' => array(
140 __( 'When a Page, Post or Custom Post\'s Member Content setting is set to a ConvertKit Tag, displays text explaining why the content is only available to subscribers.', 'convertkit' ),
141 ),
142 )
143 );
144
145 // All.
146 add_settings_field(
147 'subscribe_button_label',
148 __( 'Subscribe Button Label', 'convertkit' ),
149 array( $this, 'text_callback' ),
150 $this->settings_key,
151 $this->name,
152 array(
153 'name' => 'subscribe_button_label',
154 'label_for' => 'subscribe_button_label',
155 'description' => array(
156 __( 'The text to display for the call to action button to subscribe.', 'convertkit' ),
157 ),
158 )
159 );
160
161 add_settings_field(
162 'email_text',
163 __( 'Email Text', 'convertkit' ),
164 array( $this, 'text_callback' ),
165 $this->settings_key,
166 $this->name,
167 array(
168 'name' => 'email_text',
169 'label_for' => 'email_text',
170 'description' => array(
171 __( 'The text to display asking if the subscriber has already subscribed.', 'convertkit' ),
172 ),
173 )
174 );
175
176 add_settings_field(
177 'email_heading',
178 __( 'Email Heading', 'convertkit' ),
179 array( $this, 'text_callback' ),
180 $this->settings_key,
181 $this->name,
182 array(
183 'name' => 'email_heading',
184 'label_for' => 'email_heading',
185 'description' => array(
186 __( 'The heading to display above the email field, directing the subscriber to log in.', 'convertkit' ),
187 ),
188 )
189 );
190
191 add_settings_field(
192 'email_description_text',
193 __( 'Email Field Description', 'convertkit' ),
194 array( $this, 'text_callback' ),
195 $this->settings_key,
196 $this->name,
197 array(
198 'name' => 'email_description_text',
199 'label_for' => 'email_description_text',
200 'description' => array(
201 __( 'The text to display below the email field, explaining the subscriber will receive a code by email.', 'convertkit' ),
202 ),
203 )
204 );
205
206 add_settings_field(
207 'email_button_label',
208 __( 'Email Button Label', 'convertkit' ),
209 array( $this, 'text_callback' ),
210 $this->settings_key,
211 $this->name,
212 array(
213 'name' => 'email_button_label',
214 'label_for' => 'email_button_label',
215 'description' => array(
216 __( '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' ),
217 ),
218 )
219 );
220
221 add_settings_field(
222 'email_check_heading',
223 __( 'Email Check Heading', 'convertkit' ),
224 array( $this, 'text_callback' ),
225 $this->settings_key,
226 $this->name,
227 array(
228 'name' => 'email_check_heading',
229 'label_for' => 'email_check_heading',
230 'description' => array(
231 __( 'The heading to display telling the subscriber an email with a log in code was just sent.', 'convertkit' ),
232 ),
233 )
234 );
235
236 add_settings_field(
237 'email_check_text',
238 __( 'Email Check Text', 'convertkit' ),
239 array( $this, 'text_callback' ),
240 $this->settings_key,
241 $this->name,
242 array(
243 'name' => 'email_check_text',
244 'label_for' => 'email_check_text',
245 'description' => array(
246 __( 'The text to display instructing the subscriber to check their email for the login link that was sent.', 'convertkit' ),
247 ),
248 )
249 );
250
251 add_settings_field(
252 'no_access_text',
253 __( 'No Access Text', 'convertkit' ),
254 array( $this, 'text_callback' ),
255 $this->settings_key,
256 $this->name,
257 array(
258 'name' => 'no_access_text',
259 'label_for' => 'no_access_text',
260 'description' => array(
261 __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ),
262 ),
263 )
264 );
265
266 }
267
268 /**
269 * Prints help info for this section
270 *
271 * @since 2.1.0
272 */
273 public function print_section_info() {
274
275 ?>
276 <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>
277 <div class="notice notice-warning">
278 <p>
279 <?php
280 printf(
281 '%s %s %s',
282 esc_html__( 'If your web host has caching configured (or you are using a caching plugin), you must configure it to disable caching when the', 'convertkit' ),
283 '<code>ck_subscriber_id</code>',
284 esc_html__( 'cookie is present. Failing to do so will result in errors.', 'convertkit' )
285 );
286 ?>
287 </p>
288 </div>
289 <?php
290
291 }
292
293
294 /**
295 * Returns the URL for the ConvertKit documentation for this setting section.
296 *
297 * @since 2.1.0
298 *
299 * @return string Documentation URL.
300 */
301 public function documentation_url() {
302
303 return 'https://help.convertkit.com/en/articles/2502591-the-convertkit-wordpress-plugin';
304
305 }
306
307 /**
308 * Renders the input for the Enable setting.
309 *
310 * @since 2.4.1
311 *
312 * @param array $args Setting field arguments (name,description).
313 */
314 public function permit_crawlers_callback( $args ) {
315
316 // Output field.
317 echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput
318 $args['name'],
319 'on',
320 $this->settings->permit_crawlers(), // phpcs:ignore WordPress.Security.EscapeOutput
321 $args['label'], // phpcs:ignore WordPress.Security.EscapeOutput
322 $args['description'] // phpcs:ignore WordPress.Security.EscapeOutput
323 );
324
325 }
326
327 /**
328 * Renders the input for the text setting.
329 *
330 * @since 2.1.0
331 *
332 * @param array $args Setting field arguments (name,description).
333 */
334 public function text_callback( $args ) {
335
336 // Output field.
337 echo $this->get_text_field( // phpcs:ignore WordPress.Security.EscapeOutput
338 $args['name'],
339 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
340 $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput
341 array(
342 'widefat',
343 )
344 );
345
346 }
347
348 /**
349 * Renders the input for the textarea setting.
350 *
351 * @since 2.3.5
352 *
353 * @param array $args Setting field arguments (name,description).
354 */
355 public function textarea_callback( $args ) {
356
357 // Output field.
358 echo $this->get_textarea_field( // phpcs:ignore WordPress.Security.EscapeOutput
359 $args['name'],
360 esc_attr( $this->settings->get_by_key( $args['name'] ) ),
361 $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput
362 array(
363 'widefat',
364 )
365 );
366
367 }
368
369 }
370
371 // Bootstrap.
372 add_action(
373 'convertkit_admin_settings_register_sections',
374 function ( $sections ) {
375
376 $sections['restrict-content'] = new ConvertKit_Admin_Settings_Restrict_Content();
377 return $sections;
378
379 }
380 );
381