← All changes
|
admin/class-convertkit-admin-settings-restrict-content.php
+142
-23
2.2.4
→
2.5.2
View file →
| @@ -31,11 +31,8 @@ | ||
| 31 | 31 | $this->name = 'restrict-content'; |
| 32 | 32 | $this->title = __( 'Member Content', 'convertkit' ); |
| 33 | 33 | $this->tab_text = __( 'Member Content', 'convertkit' ); |
| 34 | 34 | |
| 35 | - // Identify that this is beta functionality. | |
| 36 | - $this->is_beta = true; | |
| 37 | - | |
| 38 | 35 | // Enqueue scripts. |
| 39 | 36 | add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 40 | 37 | |
| 41 | 38 | parent::__construct(); |
| @@ -67,35 +64,87 @@ | ||
| 67 | 64 | * @since 2.1.0 |
| 68 | 65 | */ |
| 69 | 66 | public function register_fields() { |
| 70 | 67 | |
| 68 | + // Permit Crawlers. | |
| 71 | 69 | add_settings_field( |
| 72 | - 'enabled', | |
| 73 | - __( 'Enable', 'convertkit' ), | |
| 74 | - array( $this, 'enable_callback' ), | |
| 70 | + 'permit_crawlers', | |
| 71 | + __( 'Permit Search Engine Crawlers', 'convertkit' ), | |
| 72 | + array( $this, 'permit_crawlers_callback' ), | |
| 75 | 73 | $this->settings_key, |
| 76 | 74 | $this->name, |
| 77 | 75 | array( |
| 78 | - 'name' => 'enabled', | |
| 79 | - 'description' => __( 'Enables the Member Content functionality, displaying configuration options on pages to require a subscription to a ConvertKit product', 'convertkit' ), | |
| 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 | 80 | ) |
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | + // Restrict by Product. | |
| 83 | 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( | |
| 84 | 100 | 'subscribe_text', |
| 85 | - __( 'Subscribe Text', 'convertkit' ), | |
| 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' ), | |
| 86 | 118 | array( $this, 'text_callback' ), |
| 87 | 119 | $this->settings_key, |
| 88 | 120 | $this->name, |
| 89 | 121 | array( |
| 90 | - 'name' => 'subscribe_text', | |
| 122 | + 'name' => 'subscribe_heading_tag', | |
| 123 | + 'label_for' => 'subscribe_heading_tag', | |
| 91 | 124 | 'description' => array( |
| 92 | - __( 'The text to display above the subscribe button, explaining why the content is only available to subscribers.', 'convertkit' ), | |
| 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' ), | |
| 93 | 126 | ), |
| 94 | 127 | ) |
| 95 | 128 | ); |
| 96 | 129 | |
| 97 | 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( | |
| 98 | 147 | 'subscribe_button_label', |
| 99 | 148 | __( 'Subscribe Button Label', 'convertkit' ), |
| 100 | 149 | array( $this, 'text_callback' ), |
| 101 | 150 | $this->settings_key, |
| @@ -101,10 +150,11 @@ | ||
| 101 | 150 | $this->settings_key, |
| 102 | 151 | $this->name, |
| 103 | 152 | array( |
| 104 | 153 | 'name' => 'subscribe_button_label', |
| 154 | + 'label_for' => 'subscribe_button_label', | |
| 105 | 155 | 'description' => array( |
| 106 | - __( 'The text to display for the call to action button to subscribe to the ConvertKit product.', 'convertkit' ), | |
| 156 | + __( 'The text to display for the call to action button to subscribe.', 'convertkit' ), | |
| 107 | 157 | ), |
| 108 | 158 | ) |
| 109 | 159 | ); |
| 110 | 160 | |
| @@ -115,15 +165,46 @@ | ||
| 115 | 165 | $this->settings_key, |
| 116 | 166 | $this->name, |
| 117 | 167 | array( |
| 118 | 168 | 'name' => 'email_text', |
| 169 | + 'label_for' => 'email_text', | |
| 119 | 170 | 'description' => array( |
| 120 | - __( 'The text to display above the email form, instructing the subscriber to enter their email address to receive a login link to access the member\'s only content.', 'convertkit' ), | |
| 171 | + __( 'The text to display asking if the subscriber has already subscribed.', 'convertkit' ), | |
| 121 | 172 | ), |
| 122 | 173 | ) |
| 123 | 174 | ); |
| 124 | 175 | |
| 125 | 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( | |
| 126 | 207 | 'email_button_label', |
| 127 | 208 | __( 'Email Button Label', 'convertkit' ), |
| 128 | 209 | array( $this, 'text_callback' ), |
| 129 | 210 | $this->settings_key, |
| @@ -129,15 +210,31 @@ | ||
| 129 | 210 | $this->settings_key, |
| 130 | 211 | $this->name, |
| 131 | 212 | array( |
| 132 | 213 | 'name' => 'email_button_label', |
| 214 | + 'label_for' => 'email_button_label', | |
| 133 | 215 | 'description' => array( |
| 134 | - __( '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' ), | |
| 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' ), | |
| 135 | 217 | ), |
| 136 | 218 | ) |
| 137 | 219 | ); |
| 138 | 220 | |
| 139 | 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( | |
| 140 | 237 | 'email_check_text', |
| 141 | 238 | __( 'Email Check Text', 'convertkit' ), |
| 142 | 239 | array( $this, 'text_callback' ), |
| 143 | 240 | $this->settings_key, |
| @@ -143,8 +240,9 @@ | ||
| 143 | 240 | $this->settings_key, |
| 144 | 241 | $this->name, |
| 145 | 242 | array( |
| 146 | 243 | 'name' => 'email_check_text', |
| 244 | + 'label_for' => 'email_check_text', | |
| 147 | 245 | 'description' => array( |
| 148 | 246 | __( 'The text to display instructing the subscriber to check their email for the login link that was sent.', 'convertkit' ), |
| 149 | 247 | ), |
| 150 | 248 | ) |
| @@ -157,10 +255,11 @@ | ||
| 157 | 255 | $this->settings_key, |
| 158 | 256 | $this->name, |
| 159 | 257 | array( |
| 160 | 258 | 'name' => 'no_access_text', |
| 259 | + 'label_for' => 'no_access_text', | |
| 161 | 260 | 'description' => array( |
| 162 | - __( 'The text to display for a subscriber who authenticates via the login link, but does not have access to the product.', 'convertkit' ), | |
| 261 | + __( 'The text to display for a subscriber who authenticates via the login link, but is not subscribed.', 'convertkit' ), | |
| 163 | 262 | ), |
| 164 | 263 | ) |
| 165 | 264 | ); |
| 166 | 265 | |
| @@ -173,14 +272,13 @@ | ||
| 173 | 272 | */ |
| 174 | 273 | public function print_section_info() { |
| 175 | 274 | |
| 176 | 275 | ?> |
| 177 | - <span class="convertkit-beta-label"><?php esc_html_e( 'Beta', 'convertkit' ); ?></span> | |
| 178 | - <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 set to a Product, and the visitor has not authenticated/subscribed.', 'convertkit' ); ?></p> | |
| 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> | |
| 179 | 277 | <div class="notice notice-warning"> |
| 180 | 278 | <p> |
| 181 | 279 | <?php |
| 182 | - echo sprintf( | |
| 280 | + printf( | |
| 183 | 281 | '%s %s %s', |
| 184 | 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' ), |
| 185 | 283 | '<code>ck_subscriber_id</code>', |
| 186 | 284 | esc_html__( 'cookie is present. Failing to do so will result in errors.', 'convertkit' ) |
| @@ -208,19 +306,20 @@ | ||
| 208 | 306 | |
| 209 | 307 | /** |
| 210 | 308 | * Renders the input for the Enable setting. |
| 211 | 309 | * |
| 212 | - * @since 2.1.0 | |
| 310 | + * @since 2.4.1 | |
| 213 | 311 | * |
| 214 | 312 | * @param array $args Setting field arguments (name,description). |
| 215 | 313 | */ |
| 216 | - public function enable_callback( $args ) { | |
| 314 | + public function permit_crawlers_callback( $args ) { | |
| 217 | 315 | |
| 218 | 316 | // Output field. |
| 219 | 317 | echo $this->get_checkbox_field( // phpcs:ignore WordPress.Security.EscapeOutput |
| 220 | 318 | $args['name'], |
| 221 | 319 | 'on', |
| 222 | - $this->settings->enabled(), // phpcs:ignore WordPress.Security.EscapeOutput | |
| 320 | + $this->settings->permit_crawlers(), // phpcs:ignore WordPress.Security.EscapeOutput | |
| 321 | + $args['label'], // phpcs:ignore WordPress.Security.EscapeOutput | |
| 223 | 322 | $args['description'] // phpcs:ignore WordPress.Security.EscapeOutput |
| 224 | 323 | ); |
| 225 | 324 | |
| 226 | 325 | } |
| @@ -240,20 +339,40 @@ | ||
| 240 | 339 | esc_attr( $this->settings->get_by_key( $args['name'] ) ), |
| 241 | 340 | $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput |
| 242 | 341 | array( |
| 243 | 342 | 'widefat', |
| 244 | - 'enabled', | |
| 245 | 343 | ) |
| 246 | 344 | ); |
| 247 | 345 | |
| 248 | 346 | } |
| 249 | 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 | + | |
| 250 | 369 | } |
| 251 | 370 | |
| 252 | 371 | // Bootstrap. |
| 253 | 372 | add_action( |
| 254 | 373 | 'convertkit_admin_settings_register_sections', |
| 255 | - function( $sections ) { | |
| 374 | + function ( $sections ) { | |
| 256 | 375 | |
| 257 | 376 | $sections['restrict-content'] = new ConvertKit_Admin_Settings_Restrict_Content(); |
| 258 | 377 | return $sections; |
| 259 | 378 | |