← All changes
|
features/content-restriction/content-restriction-meta-box.php
+379
-97
3.9.6
→
4.0.3
View file →
| @@ -13,27 +13,226 @@ | ||
| 13 | 13 | $post_types = get_post_types( array( 'public' => true ) ); |
| 14 | 14 | |
| 15 | 15 | if( ! empty( $post_types ) ) { |
| 16 | 16 | foreach( $post_types as $post_type ) { |
| 17 | - add_meta_box( | |
| 18 | - 'wppb_post_content_restriction', | |
| 19 | - __( 'Profile Builder Content Restriction', 'profile-builder' ), | |
| 20 | - 'wppb_content_restriction_meta_box_output', | |
| 21 | - $post_type, | |
| 22 | - 'normal' | |
| 23 | - ); | |
| 17 | + | |
| 18 | + if( apply_filters( 'wppb_content_restriction_enabled_for_post_type', true, $post_type ) ){ | |
| 19 | + add_meta_box( | |
| 20 | + 'wppb_post_content_restriction', | |
| 21 | + __( 'Profile Builder Content Restriction', 'profile-builder' ), | |
| 22 | + 'wppb_content_restriction_meta_box_output', | |
| 23 | + $post_type, | |
| 24 | + 'normal' | |
| 25 | + ); | |
| 26 | + } | |
| 27 | + | |
| 24 | 28 | } |
| 25 | 29 | } |
| 26 | 30 | |
| 27 | 31 | } |
| 28 | 32 | |
| 33 | +function wppb_content_restriction_get_supported_taxonomies() { | |
| 34 | + | |
| 35 | + $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); | |
| 36 | + | |
| 37 | + if ( empty( $taxonomies ) ) { | |
| 38 | + return array(); | |
| 39 | + } | |
| 40 | + | |
| 41 | + $disabled_taxonomies = array( | |
| 42 | + 'nav_menu', | |
| 43 | + 'link_category', | |
| 44 | + 'post_format', | |
| 45 | + 'product_visibility', | |
| 46 | + 'product_shipping_class', | |
| 47 | + 'action-group', | |
| 48 | + 'product_type', | |
| 49 | + 'wp_theme', | |
| 50 | + 'wp_template_part_area', | |
| 51 | + ); | |
| 52 | + | |
| 53 | + foreach ( $taxonomies as $taxonomy => $taxonomy_object ) { | |
| 54 | + if ( in_array( $taxonomy, $disabled_taxonomies, true ) ) { | |
| 55 | + unset( $taxonomies[ $taxonomy ] ); | |
| 56 | + continue; | |
| 57 | + } | |
| 58 | + | |
| 59 | + if ( ! apply_filters( 'wppb_content_restriction_enabled_for_taxonomy', true, $taxonomy, $taxonomy_object ) ) { | |
| 60 | + unset( $taxonomies[ $taxonomy ] ); | |
| 61 | + } | |
| 62 | + } | |
| 63 | + | |
| 64 | + return $taxonomies; | |
| 65 | +} | |
| 66 | + | |
| 67 | +function wppb_content_restriction_initialize_taxonomy_fields() { | |
| 68 | + | |
| 69 | + $taxonomies = wppb_content_restriction_get_supported_taxonomies(); | |
| 70 | + | |
| 71 | + foreach ( $taxonomies as $taxonomy => $taxonomy_object ) { | |
| 72 | + add_action( $taxonomy . '_add_form_fields', 'wppb_content_restriction_taxonomy_add_form_fields' ); | |
| 73 | + add_action( $taxonomy . '_edit_form_fields', 'wppb_content_restriction_taxonomy_edit_form_fields', 10, 2 ); | |
| 74 | + } | |
| 75 | + | |
| 76 | + add_action( 'create_term', 'wppb_content_restriction_save_term_data', 10, 3 ); | |
| 77 | + add_action( 'edit_term', 'wppb_content_restriction_save_term_data', 10, 3 ); | |
| 78 | +} | |
| 79 | +add_action( 'init', 'wppb_content_restriction_initialize_taxonomy_fields', 1000 ); | |
| 80 | + | |
| 81 | +function wppb_content_restriction_taxonomy_add_form_fields( $taxonomy ) { | |
| 82 | + wppb_content_restriction_taxonomy_fields_output( null, $taxonomy ); | |
| 83 | +} | |
| 84 | + | |
| 85 | +function wppb_content_restriction_taxonomy_edit_form_fields( $term, $taxonomy ) { | |
| 86 | + wppb_content_restriction_taxonomy_fields_output( $term, $taxonomy ); | |
| 87 | +} | |
| 88 | + | |
| 89 | +function wppb_content_restriction_taxonomy_fields_output( $term = null, $taxonomy = '' ) { | |
| 90 | + | |
| 91 | + $term_id = ! empty( $term->term_id ) ? (int) $term->term_id : 0; | |
| 92 | + $wppb_content_restrict_types = apply_filters( 'wppb_single_post_content_restrict_types', array( 'message' => __( 'Message', 'profile-builder' ), 'redirect' => __( 'Redirect', 'profile-builder' ) ) ); | |
| 93 | + $wppb_content_restrict_type = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-type', true ) : ''; | |
| 94 | + $wppb_user_status = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-user-status', true ) : ''; | |
| 95 | + $wppb_selected_roles = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-user-role' ) : array(); | |
| 96 | + $wppb_custom_redirect_url_enabled = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url-enabled', true ) : ''; | |
| 97 | + $wppb_custom_redirect_url = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url', true ) : ''; | |
| 98 | + $wppb_custom_messages_enabled = $term_id ? get_term_meta( $term_id, 'wppb-content-restrict-messages-enabled', true ) : ''; | |
| 99 | + $wppb_roles = get_editable_roles(); | |
| 100 | + $object = get_taxonomy( $taxonomy ); | |
| 101 | + $description_label = ! empty( $object->labels->singular_name ) ? $object->labels->singular_name : __( 'term', 'profile-builder' ); | |
| 102 | + | |
| 103 | + if ( empty( $wppb_selected_roles ) || ! is_array( $wppb_selected_roles ) ) { | |
| 104 | + $wppb_selected_roles = array(); | |
| 105 | + } | |
| 106 | + | |
| 107 | + ob_start(); | |
| 108 | + ?> | |
| 109 | + <div class="wppb-meta-box-fields-wrapper wppb-taxonomy-content-restriction cozmoslabs-form-subsection-wrapper"> | |
| 110 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Profile Builder Content Restriction', 'profile-builder' ); ?></h4> | |
| 111 | + | |
| 112 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper"> | |
| 113 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label"><?php esc_html_e( 'Type of Restriction', 'profile-builder' ); ?></label> | |
| 114 | + | |
| 115 | + <div class="cozmoslabs-radio-inputs-row"> | |
| 116 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-type-default"> | |
| 117 | + <input type="radio" id="wppb-content-restrict-type-default" value="default" <?php checked( empty( $wppb_content_restrict_type ) || $wppb_content_restrict_type === 'default' ); ?> name="wppb-content-restrict-type"> | |
| 118 | + <?php esc_html_e( 'Settings Default', 'profile-builder' ); ?> | |
| 119 | + </label> | |
| 120 | + | |
| 121 | + <?php foreach ( $wppb_content_restrict_types as $type_slug => $type_label ) : ?> | |
| 122 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-type-<?php echo esc_attr( $type_slug ); ?>"> | |
| 123 | + <input type="radio" id="wppb-content-restrict-type-<?php echo esc_attr( $type_slug ); ?>" value="<?php echo esc_attr( $type_slug ); ?>" <?php checked( $wppb_content_restrict_type, $type_slug ); ?> name="wppb-content-restrict-type"> | |
| 124 | + <?php echo esc_html( $type_label ); ?> | |
| 125 | + </label> | |
| 126 | + <?php endforeach; ?> | |
| 127 | + </div> | |
| 128 | + </div> | |
| 129 | + | |
| 130 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-checkbox-list-wrapper"> | |
| 131 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label"><?php esc_html_e( 'Display For', 'profile-builder' ); ?></label> | |
| 132 | + | |
| 133 | + <div class="cozmoslabs-checkbox-list cozmoslabs-checkbox-multi-col-list"> | |
| 134 | + <div class="cozmoslabs-chckbox-container"> | |
| 135 | + <input type="checkbox" value="loggedin" <?php checked( $wppb_user_status, 'loggedin' ); ?> name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status"> | |
| 136 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-user-status"> | |
| 137 | + <?php esc_html_e( 'Logged In Users', 'profile-builder' ); ?> | |
| 138 | + </label> | |
| 139 | + </div> | |
| 140 | + | |
| 141 | + <?php foreach ( $wppb_roles as $wppb_role => $wppb_role_details ) : ?> | |
| 142 | + <div class="cozmoslabs-chckbox-container"> | |
| 143 | + <input type="checkbox" value="<?php echo esc_attr( $wppb_role ); ?>" <?php checked( in_array( $wppb_role, $wppb_selected_roles, true ) ); ?> name="wppb-content-restrict-user-role[]" id="wppb-content-restrict-user-role-<?php echo esc_attr( $wppb_role ); ?>"> | |
| 144 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-user-role-<?php echo esc_attr( $wppb_role ); ?>"> | |
| 145 | + <?php echo ! empty( $wppb_role_details['name'] ) ? esc_html( $wppb_role_details['name'] ) : esc_html( $wppb_role ); ?> | |
| 146 | + </label> | |
| 147 | + </div> | |
| 148 | + <?php endforeach; ?> | |
| 149 | + | |
| 150 | + <p class="cozmoslabs-description"> | |
| 151 | + <?php echo esc_html( sprintf( __( 'Checking only "Logged In Users" will show this %s to all logged in users, regardless of user role.', 'profile-builder' ), $description_label ) ); ?> | |
| 152 | + </p> | |
| 153 | + | |
| 154 | + <p class="cozmoslabs-description"> | |
| 155 | + <?php echo esc_html( sprintf( __( 'Checking any user role will show this %s only to users that have one of those user roles assigned.', 'profile-builder' ), $description_label ) ); ?> | |
| 156 | + </p> | |
| 157 | + </div> | |
| 158 | + </div> | |
| 159 | + </div> | |
| 160 | + | |
| 161 | + <div id="wppb-meta-box-fields-wrapper-restriction-redirect-url" class="wppb-meta-box-fields-wrapper wppb-taxonomy-content-restriction cozmoslabs-form-subsection-wrapper <?php echo ( $wppb_content_restrict_type === 'redirect' ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 162 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Restriction Redirect URL', 'profile-builder' ); ?></h4> | |
| 163 | + | |
| 164 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch"> | |
| 165 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label" for="wppb-content-restrict-custom-redirect-url-enabled"><?php esc_html_e( 'Enable Custom Redirect URL', 'profile-builder' ); ?></label> | |
| 166 | + | |
| 167 | + <div class="cozmoslabs-toggle-container"> | |
| 168 | + <input type="checkbox" value="yes" <?php checked( ! empty( $wppb_custom_redirect_url_enabled ) ); ?> name="wppb-content-restrict-custom-redirect-url-enabled" id="wppb-content-restrict-custom-redirect-url-enabled"> | |
| 169 | + <label class="cozmoslabs-toggle-track" for="wppb-content-restrict-custom-redirect-url-enabled"></label> | |
| 170 | + </div> | |
| 171 | + <div class="cozmoslabs-toggle-description"> | |
| 172 | + <label for="wppb-content-restrict-custom-redirect-url-enabled" class="cozmoslabs-description"><?php echo esc_html( sprintf( __( 'Enable if you wish to add a custom redirect URL for this %s.', 'profile-builder' ), $description_label ) ); ?></label> | |
| 173 | + </div> | |
| 174 | + </div> | |
| 175 | + | |
| 176 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper wppb-meta-box-field-wrapper-custom-redirect-url <?php echo ( ! empty( $wppb_custom_redirect_url_enabled ) ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 177 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label" for="wppb-content-restrict-custom-redirect-url"><?php esc_html_e( 'Custom Redirect URL', 'profile-builder' ); ?></label> | |
| 178 | + <input type="text" value="<?php echo esc_attr( $wppb_custom_redirect_url ); ?>" name="wppb-content-restrict-custom-redirect-url" id="wppb-content-restrict-custom-redirect-url" class="widefat"> | |
| 179 | + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html( sprintf( __( 'Add a URL where you wish to redirect users that do not have access to this %s and try to access it directly.', 'profile-builder' ), $description_label ) ); ?></p> | |
| 180 | + </div> | |
| 181 | + </div> | |
| 182 | + | |
| 183 | + <div id="wppb-meta-box-fields-wrapper-restriction-custom-messages" class="wppb-meta-box-fields-wrapper wppb-taxonomy-content-restriction cozmoslabs-form-subsection-wrapper"> | |
| 184 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Restriction Messages', 'profile-builder' ); ?></h4> | |
| 185 | + | |
| 186 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch"> | |
| 187 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label" for="wppb-content-restrict-messages-enabled"><?php esc_html_e( 'Enable Custom Messages', 'profile-builder' ); ?></label> | |
| 188 | + | |
| 189 | + <div class="cozmoslabs-toggle-container"> | |
| 190 | + <input type="checkbox" value="yes" <?php checked( ! empty( $wppb_custom_messages_enabled ) ); ?> name="wppb-content-restrict-messages-enabled" id="wppb-content-restrict-messages-enabled"> | |
| 191 | + <label class="cozmoslabs-toggle-track" for="wppb-content-restrict-messages-enabled"></label> | |
| 192 | + </div> | |
| 193 | + <div class="cozmoslabs-toggle-description"> | |
| 194 | + <label for="wppb-content-restrict-messages-enabled" class="cozmoslabs-description"><?php echo esc_html( sprintf( __( 'Enable if you wish to add custom messages for this %s.', 'profile-builder' ), $description_label ) ); ?></label> | |
| 195 | + </div> | |
| 196 | + </div> | |
| 197 | + | |
| 198 | + <div class="wppb-meta-box-field-wrapper-custom-messages <?php echo ( ! empty( $wppb_custom_messages_enabled ) ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 199 | + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper cozmoslabs-wysiwyg-indented"> | |
| 200 | + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Messages for logged-out users', 'profile-builder' ); ?></label> | |
| 201 | + <?php wp_editor( get_term_meta( $term_id, 'wppb-content-restrict-message-logged_out', true ), 'wppb-content-restrict-message-logged_out', array( 'textarea_name' => 'wppb-content-restrict-message-logged_out', 'editor_height' => 180 ) ); ?> | |
| 202 | + </div> | |
| 203 | + | |
| 204 | + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper cozmoslabs-wysiwyg-indented"> | |
| 205 | + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Messages for logged-in users', 'profile-builder' ); ?></label> | |
| 206 | + <?php wp_editor( get_term_meta( $term_id, 'wppb-content-restrict-message-logged_in', true ), 'wppb-content-restrict-message-logged_in', array( 'textarea_name' => 'wppb-content-restrict-message-logged_in', 'editor_height' => 180 ) ); ?> | |
| 207 | + </div> | |
| 208 | + </div> | |
| 209 | + </div> | |
| 210 | + | |
| 211 | + <?php wp_nonce_field( 'wppb_meta_box_single_content_restriction_nonce', 'wppb_content_restriction_token', false ); ?> | |
| 212 | + <?php | |
| 213 | + | |
| 214 | + $content = ob_get_clean(); | |
| 215 | + | |
| 216 | + if ( empty( $term_id ) ) { | |
| 217 | + echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 218 | + return; | |
| 219 | + } | |
| 220 | + ?> | |
| 221 | + <tr class="form-field wppb-taxonomy-content-restriction-row"> | |
| 222 | + <th scope="row"><?php esc_html_e( 'Content Restriction', 'profile-builder' ); ?></th> | |
| 223 | + <td class="wppb-taxonomy-content-restriction-cell"><?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td> | |
| 224 | + </tr> | |
| 225 | + <?php | |
| 226 | +} | |
| 227 | + | |
| 29 | 228 | function wppb_content_restriction_meta_box_output( $post ) { |
| 30 | 229 | |
| 31 | 230 | ?> |
| 32 | - <div class="wppb-meta-box-fields-wrapper"> | |
| 33 | - <h4><?php echo esc_html__( 'Display Options', 'profile-builder' ); ?></h4> | |
| 231 | + <div class="wppb-meta-box-fields-wrapper cozmoslabs-form-subsection-wrapper"> | |
| 232 | + <h4 class="cozmoslabs-subsection-title"><?php echo esc_html__( 'Display Options', 'profile-builder' ); ?></h4> | |
| 34 | 233 | |
| 35 | - <div class="wppb-meta-box-field-wrapper"> | |
| 234 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper"> | |
| 36 | 235 | <?php |
| 37 | 236 | $wppb_content_restrict_types = apply_filters( 'wppb_single_post_content_restrict_types', array( 'message' => __( 'Message', 'profile-builder' ), 'redirect' => __( 'Redirect', 'profile-builder' ) ) ); |
| 38 | 237 | |
| 39 | 238 | $wppb_content_restrict_type = get_post_meta( $post->ID, 'wppb-content-restrict-type', true ); |
| @@ -38,25 +237,28 @@ | ||
| 38 | 237 | |
| 39 | 238 | $wppb_content_restrict_type = get_post_meta( $post->ID, 'wppb-content-restrict-type', true ); |
| 40 | 239 | ?> |
| 41 | 240 | |
| 42 | - <label class="wppb-meta-box-field-label"><?php esc_html_e( 'Type of Restriction', 'profile-builder' ); ?></label> | |
| 241 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label"><?php esc_html_e( 'Type of Restriction', 'profile-builder' ); ?></label> | |
| 43 | 242 | |
| 44 | - <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-type-default"> | |
| 45 | - <input type="radio" id="wppb-content-restrict-type-default" value="default" <?php if( empty( $wppb_content_restrict_type ) || $wppb_content_restrict_type == 'default' ) echo 'checked="checked"'; ?> name="wppb-content-restrict-type"> | |
| 46 | - <?php echo esc_html__( 'Settings Default', 'profile-builder' ); ?> | |
| 47 | - </label> | |
| 243 | + <div class="cozmoslabs-radio-inputs-row"> | |
| 244 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-type-default"> | |
| 245 | + <input type="radio" id="wppb-content-restrict-type-default" value="default" <?php if( empty( $wppb_content_restrict_type ) || $wppb_content_restrict_type == 'default' ) echo 'checked="checked"'; ?> name="wppb-content-restrict-type"> | |
| 246 | + <?php echo esc_html__( 'Settings Default', 'profile-builder' ); ?> | |
| 247 | + </label> | |
| 48 | 248 | |
| 49 | - <?php foreach( $wppb_content_restrict_types as $type_slug => $type_label ) { ?> | |
| 50 | - <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-type-<?php echo esc_attr( $type_slug ); ?>"> | |
| 51 | - <input type="radio" id="wppb-content-restrict-type-<?php echo esc_attr( $type_slug ); ?>" value="<?php echo esc_attr( $type_slug ); ?>" <?php if( $wppb_content_restrict_type == $type_slug ) echo 'checked="checked"'; ?> name="wppb-content-restrict-type"> | |
| 52 | - <?php echo esc_html( $type_label ); ?> | |
| 53 | - </label> | |
| 54 | - <?php } ?> | |
| 249 | + <?php foreach( $wppb_content_restrict_types as $type_slug => $type_label ) { ?> | |
| 250 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-type-<?php echo esc_attr( $type_slug ); ?>"> | |
| 251 | + <input type="radio" id="wppb-content-restrict-type-<?php echo esc_attr( $type_slug ); ?>" value="<?php echo esc_attr( $type_slug ); ?>" <?php if( $wppb_content_restrict_type == $type_slug ) echo 'checked="checked"'; ?> name="wppb-content-restrict-type"> | |
| 252 | + <?php echo esc_html( $type_label ); ?> | |
| 253 | + </label> | |
| 254 | + <?php } ?> | |
| 255 | + </div> | |
| 256 | + | |
| 55 | 257 | </div> |
| 56 | 258 | |
| 57 | - <div class="wppb-meta-box-field-wrapper"> | |
| 58 | - <label class="wppb-meta-box-field-label"><?php esc_html_e( 'Display For', 'profile-builder' ); ?></label> | |
| 259 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-checkbox-list-wrapper"> | |
| 260 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label"><?php esc_html_e( 'Display For', 'profile-builder' ); ?></label> | |
| 59 | 261 | |
| 60 | 262 | <?php |
| 61 | 263 | $wppb_roles = get_editable_roles(); |
| 62 | 264 | $wppb_user_status = get_post_meta( $post->ID, 'wppb-content-restrict-user-status', true ); |
| @@ -62,37 +264,45 @@ | ||
| 62 | 264 | $wppb_user_status = get_post_meta( $post->ID, 'wppb-content-restrict-user-status', true ); |
| 63 | 265 | $wppb_selected_roles = get_post_meta( $post->ID, 'wppb-content-restrict-user-role' ); |
| 64 | 266 | ?> |
| 65 | 267 | |
| 66 | - <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-user-status"> | |
| 67 | - <input type="checkbox" value="loggedin" <?php if( ! empty( $wppb_user_status ) && $wppb_user_status == 'loggedin' ) echo 'checked="checked"'; ?> name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status"> | |
| 68 | - <?php echo esc_html__( 'Logged In Users', 'profile-builder' ); ?> | |
| 69 | - </label> | |
| 268 | + <div class="cozmoslabs-checkbox-list cozmoslabs-checkbox-multi-col-list"> | |
| 70 | 269 | |
| 71 | - <?php | |
| 72 | - if( ! empty( $wppb_roles ) ) { | |
| 73 | - foreach( $wppb_roles as $wppb_role => $wppb_role_details ) { | |
| 74 | - ?> | |
| 75 | - <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 76 | - <input type="checkbox" value="<?php echo esc_attr( $wppb_role ); ?>" <?php if( in_array( $wppb_role, $wppb_selected_roles ) ) echo 'checked="checked"'; ?> name="wppb-content-restrict-user-role[]" id="wppb-content-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 77 | - <?php echo !empty( $wppb_role_details['name'] ) ? esc_html( $wppb_role_details['name'] ) : esc_html( $wppb_role ); ?> | |
| 270 | + <div class="cozmoslabs-chckbox-container"> | |
| 271 | + <input type="checkbox" value="loggedin" <?php if( ! empty( $wppb_user_status ) && $wppb_user_status == 'loggedin' ) echo 'checked="checked"'; ?> name="wppb-content-restrict-user-status" id="wppb-content-restrict-user-status"> | |
| 272 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-user-status"> | |
| 273 | + <?php echo esc_html__( 'Logged In Users', 'profile-builder' ); ?> | |
| 78 | 274 | </label> |
| 275 | + </div> | |
| 276 | + | |
| 277 | + <?php | |
| 278 | + if( ! empty( $wppb_roles ) ) { | |
| 279 | + foreach( $wppb_roles as $wppb_role => $wppb_role_details ) { | |
| 280 | + ?> | |
| 281 | + <div class="cozmoslabs-chckbox-container"> | |
| 282 | + <input type="checkbox" value="<?php echo esc_attr( $wppb_role ); ?>" <?php if( in_array( $wppb_role, $wppb_selected_roles ) ) echo 'checked="checked"'; ?> name="wppb-content-restrict-user-role[]" id="wppb-content-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 283 | + <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 284 | + <?php echo !empty( $wppb_role_details['name'] ) ? esc_html( $wppb_role_details['name'] ) : esc_html( $wppb_role ); ?> | |
| 285 | + </label> | |
| 286 | + </div> | |
| 287 | + <?php } ?> | |
| 288 | + | |
| 289 | + <p class="cozmoslabs-description"> | |
| 290 | + <?php echo esc_html( sprintf( __( 'Checking only "Logged In Users" will show this %s to all logged in users, regardless of user role.', 'profile-builder' ), apply_filters( 'wppb_content_restrict_settings_description_cpt', $post->post_type ) ) ); ?> | |
| 291 | + </p> | |
| 292 | + | |
| 293 | + <p class="cozmoslabs-description"> | |
| 294 | + <?php echo esc_html( sprintf( __( 'Checking any user role will show this %s only to users that have one of those user roles assigned.', 'profile-builder' ), apply_filters( 'wppb_content_restrict_settings_description_cpt', $post->post_type ) ) ); ?> | |
| 295 | + </p> | |
| 79 | 296 | <?php } ?> |
| 80 | 297 | |
| 81 | - <p class="description" style="margin-top: 10px;"> | |
| 82 | - <?php echo esc_html( sprintf( __( 'Checking only "Logged In Users" will show this %s to all logged in users, regardless of user role.', 'profile-builder' ), $post->post_type) ); ?> | |
| 83 | - </p> | |
| 84 | - | |
| 85 | - <p class="description"> | |
| 86 | - <?php echo esc_html( sprintf( __( 'Checking any user role will show this %s only to users that have one of those user roles assigned.', 'profile-builder' ), $post->post_type) ); ?> | |
| 87 | - </p> | |
| 88 | - <?php } ?> | |
| 298 | + </div> | |
| 89 | 299 | </div> |
| 90 | 300 | </div> |
| 91 | 301 | |
| 92 | 302 | <?php if( isset( $post->post_type ) && $post->post_type == 'product' ) : ?> |
| 93 | - <div class="wppb-meta-box-fields-wrapper"> | |
| 94 | - <h4><?php esc_html_e( 'Purchase Options', 'profile-builder' ); ?></h4> | |
| 303 | + <div class="wppb-meta-box-fields-wrapper cozmoslabs-form-subsection-wrapper"> | |
| 304 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Purchase Options', 'profile-builder' ); ?></h4> | |
| 95 | 305 | |
| 96 | 306 | <?php |
| 97 | 307 | $wppb_purchase_user_status = get_post_meta( $post->ID, 'wppb-purchase-restrict-user-status', true ); |
| 98 | 308 | $wppb_selected_purchase_roles = get_post_meta( $post->ID, 'wppb-purchase-restrict-user-role' ); |
| @@ -98,95 +308,121 @@ | ||
| 98 | 308 | $wppb_selected_purchase_roles = get_post_meta( $post->ID, 'wppb-purchase-restrict-user-role' ); |
| 99 | 309 | ?> |
| 100 | 310 | |
| 101 | 311 | <!-- Who Can Purchase? options --> |
| 102 | - <div class="wppb-meta-box-field-wrapper"> | |
| 103 | - <label class="wppb-meta-box-field-label"><?php esc_html_e( 'Who can purchase?', 'profile-builder' ); ?></label> | |
| 312 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-checkbox-list-wrapper"> | |
| 313 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label"><?php esc_html_e( 'Who can purchase?', 'profile-builder' ); ?></label> | |
| 104 | 314 | |
| 105 | - <label class="wppb-meta-box-checkbox-label" for="wppb-purchase-restrict-user-status"> | |
| 106 | - <input type="checkbox" value="loggedin" <?php if( ! empty( $wppb_purchase_user_status ) ) checked($wppb_purchase_user_status, 'loggedin' ); ?> name="wppb-purchase-restrict-user-status" id="wppb-purchase-restrict-user-status"> | |
| 107 | - <?php esc_html_e( 'Logged In Users', 'profile-builder' ); ?> | |
| 108 | - </label> | |
| 315 | + <div class="cozmoslabs-checkbox-list cozmoslabs-checkbox-multi-col-list"> | |
| 109 | 316 | |
| 110 | - <?php if( !empty( $wppb_roles ) ): foreach( $wppb_roles as $wppb_role => $wppb_role_details ): ?> | |
| 317 | + <div class="cozmoslabs-chckbox-container"> | |
| 318 | + <input type="checkbox" value="loggedin" <?php if( ! empty( $wppb_purchase_user_status ) ) checked($wppb_purchase_user_status, 'loggedin' ); ?> name="wppb-purchase-restrict-user-status" id="wppb-purchase-restrict-user-status"> | |
| 319 | + <label class="wppb-meta-box-checkbox-label" for="wppb-purchase-restrict-user-status"> | |
| 320 | + <?php esc_html_e( 'Logged In Users', 'profile-builder' ); ?> | |
| 321 | + </label> | |
| 322 | + </div> | |
| 111 | 323 | |
| 112 | - <label class="wppb-meta-box-checkbox-label" for="wppb-purchase-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 113 | - <input type="checkbox" value="<?php echo esc_attr( $wppb_role ); ?>" <?php if( in_array( $wppb_role, $wppb_selected_purchase_roles ) ) echo 'checked="checked"'; ?> name="wppb-purchase-restrict-user-role[]" id="wppb-purchase-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 114 | - <?php echo !empty( $wppb_role_details['name'] ) ? esc_html( $wppb_role_details['name'] ) : esc_html( $wppb_role ); ?> | |
| 115 | - </label> | |
| 324 | + <?php if( !empty( $wppb_roles ) ): foreach( $wppb_roles as $wppb_role => $wppb_role_details ): ?> | |
| 116 | 325 | |
| 117 | - <?php endforeach; ?> | |
| 326 | + <div class="cozmoslabs-chckbox-container"> | |
| 327 | + <input type="checkbox" value="<?php echo esc_attr( $wppb_role ); ?>" <?php if( in_array( $wppb_role, $wppb_selected_purchase_roles ) ) echo 'checked="checked"'; ?> name="wppb-purchase-restrict-user-role[]" id="wppb-purchase-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 328 | + <label class="wppb-meta-box-checkbox-label" for="wppb-purchase-restrict-user-role-<?php echo esc_attr( $wppb_role ) ?>"> | |
| 329 | + <?php echo !empty( $wppb_role_details['name'] ) ? esc_html( $wppb_role_details['name'] ) : esc_html( $wppb_role ); ?> | |
| 330 | + </label> | |
| 331 | + </div> | |
| 118 | 332 | |
| 119 | - <p class="description" style="margin-top: 10px;"> | |
| 120 | - <?php esc_html_e( 'Select who can purchase this product.', 'profile-builder' ); ?> | |
| 121 | - </p> | |
| 333 | + <?php endforeach; ?> | |
| 122 | 334 | |
| 123 | - <?php endif; ?> | |
| 335 | + <p class="cozmoslabs-description" style="margin-top: 10px;"> | |
| 336 | + <?php esc_html_e( 'Select who can purchase this product.', 'profile-builder' ); ?> | |
| 337 | + </p> | |
| 124 | 338 | |
| 339 | + <?php endif; ?> | |
| 340 | + </div> | |
| 341 | + | |
| 125 | 342 | </div> |
| 126 | 343 | </div> |
| 127 | 344 | <?php endif; ?> |
| 128 | 345 | |
| 129 | - <div id="wppb-meta-box-fields-wrapper-restriction-redirect-url" class="wppb-meta-box-fields-wrapper <?php echo ( $wppb_content_restrict_type == 'redirect' ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 130 | - <h4><?php echo esc_html__( 'Restriction Redirect URL', 'profile-builder' ); ?></h4> | |
| 346 | + <div id="wppb-meta-box-fields-wrapper-restriction-redirect-url" class="wppb-meta-box-fields-wrapper cozmoslabs-form-subsection-wrapper <?php echo ( $wppb_content_restrict_type == 'redirect' ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 347 | + <h4 class="cozmoslabs-subsection-title"><?php echo esc_html__( 'Restriction Redirect URL', 'profile-builder' ); ?></h4> | |
| 131 | 348 | |
| 132 | - <div class="wppb-meta-box-field-wrapper"> | |
| 349 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch"> | |
| 133 | 350 | |
| 134 | 351 | <?php $wppb_custom_redirect_url_enabled = get_post_meta( $post->ID, 'wppb-content-restrict-custom-redirect-url-enabled', true ); ?> |
| 135 | 352 | |
| 136 | - <label class="wppb-meta-box-field-label"><?php esc_html_e( 'Enable Custom Redirect URL', 'profile-builder' ); ?></label> | |
| 353 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label" for="wppb-content-restrict-custom-redirect-url-enabled"><?php esc_html_e( 'Enable Custom Redirect URL', 'profile-builder' ); ?></label> | |
| 137 | 354 | |
| 138 | - <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-custom-redirect-url-enabled"> | |
| 355 | + <div class="cozmoslabs-toggle-container"> | |
| 139 | 356 | <input type="checkbox" value="yes" <?php echo ( ! empty( $wppb_custom_redirect_url_enabled ) ? 'checked="checked"' : '' ); ?> name="wppb-content-restrict-custom-redirect-url-enabled" id="wppb-content-restrict-custom-redirect-url-enabled"> |
| 140 | - <span class="description"><?php echo esc_html( sprintf( __( 'Check if you wish to add a custom redirect URL for this %s.', 'profile-builder' ), $post->post_type ) ); ?></span> | |
| 141 | - </label> | |
| 357 | + <label class="cozmoslabs-toggle-track" for="wppb-content-restrict-custom-redirect-url-enabled"></label> | |
| 358 | + </div> | |
| 359 | + <div class="cozmoslabs-toggle-description"> | |
| 360 | + <label for="wppb-content-restrict-custom-redirect-url-enabled" class="cozmoslabs-description"><?php echo esc_html( sprintf( __( 'Enable if you wish to add a custom redirect URL for this %s.', 'profile-builder' ), apply_filters( 'wppb_content_restrict_settings_description_cpt', $post->post_type ) ) ); ?></label> | |
| 361 | + </div> | |
| 142 | 362 | </div> |
| 143 | 363 | |
| 144 | - <div class="wppb-meta-box-field-wrapper wppb-meta-box-field-wrapper-custom-redirect-url <?php echo ( ! empty( $wppb_custom_redirect_url_enabled ) ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 364 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper wppb-meta-box-field-wrapper-custom-redirect-url <?php echo ( ! empty( $wppb_custom_redirect_url_enabled ) ? 'wppb-content-restriction-enabled' : '' ); ?>"> | |
| 145 | 365 | <?php $wppb_custom_redirect_url = get_post_meta( $post->ID, 'wppb-content-restrict-custom-redirect-url', true ); ?> |
| 146 | 366 | |
| 147 | - <label class="wppb-meta-box-field-label" for="wppb-content-restrict-custom-redirect-url"><?php esc_html_e( 'Custom Redirect URL', 'profile-builder' ); ?></label> | |
| 148 | - | |
| 149 | - <label class="wppb-meta-box-checkbox-label"> | |
| 150 | - <input type="text" value="<?php echo ( ! empty( $wppb_custom_redirect_url ) ? esc_url( $wppb_custom_redirect_url ) : '' ); ?>" name="wppb-content-restrict-custom-redirect-url" id="wppb-content-restrict-custom-redirect-url" class="widefat"> | |
| 151 | - <p class="description"><?php echo esc_html( sprintf( __( 'Add a URL where you wish to redirect users that do not have access to this %s and try to access it directly.', 'profile-builder' ), $post->post_type ) ); ?></p> | |
| 152 | - </label> | |
| 367 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label" for="wppb-content-restrict-custom-redirect-url"><?php esc_html_e( 'Custom Redirect URL', 'profile-builder' ); ?></label> | |
| 368 | + <input type="text" value="<?php echo ( ! empty( $wppb_custom_redirect_url ) ? esc_url( $wppb_custom_redirect_url ) : '' ); ?>" name="wppb-content-restrict-custom-redirect-url" id="wppb-content-restrict-custom-redirect-url" class="widefat"> | |
| 369 | + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html( sprintf( __( 'Add a URL where you wish to redirect users that do not have access to this %s and try to access it directly.', 'profile-builder' ), apply_filters( 'wppb_content_restrict_settings_description_cpt', $post->post_type ) ) ); ?></p> | |
| 153 | 370 | </div> |
| 154 | 371 | </div> |
| 155 | 372 | |
| 156 | - <div id="wppb-meta-box-fields-wrapper-restriction-custom-messages" class="wppb-meta-box-fields-wrapper"> | |
| 157 | - <h4><?php echo esc_html__( 'Restriction Messages', 'profile-builder' ); ?></h4> | |
| 373 | + <div id="wppb-meta-box-fields-wrapper-restriction-custom-messages" class="wppb-meta-box-fields-wrapper cozmoslabs-form-subsection-wrapper"> | |
| 374 | + <h4 class="cozmoslabs-subsection-title"><?php echo esc_html__( 'Restriction Messages', 'profile-builder' ); ?></h4> | |
| 158 | 375 | |
| 159 | - <div class="wppb-meta-box-field-wrapper"> | |
| 376 | + <div class="wppb-meta-box-field-wrapper cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch"> | |
| 160 | 377 | <?php |
| 161 | 378 | $wppb_custom_messages_enabled = get_post_meta( $post->ID, 'wppb-content-restrict-messages-enabled', true ); |
| 162 | 379 | ?> |
| 163 | - <label class="wppb-meta-box-field-label"><?php esc_html_e( 'Enable Custom Messages', 'profile-builder' ); ?></label> | |
| 380 | + <label class="wppb-meta-box-field-label cozmoslabs-form-field-label" for="wppb-content-restrict-messages-enabled"><?php esc_html_e( 'Enable Custom Messages', 'profile-builder' ); ?></label> | |
| 164 | 381 | |
| 165 | - <label class="wppb-meta-box-checkbox-label" for="wppb-content-restrict-messages-enabled"> | |
| 382 | + <div class="cozmoslabs-toggle-container"> | |
| 166 | 383 | <input type="checkbox" value="yes" <?php echo ( ! empty( $wppb_custom_messages_enabled ) ? 'checked="checked"' : '' ); ?> name="wppb-content-restrict-messages-enabled" id="wppb-content-restrict-messages-enabled"> |
| 167 | - <span class="description"><?php echo esc_html( sprintf( __( 'Check if you wish to add custom messages for this %s.', 'profile-builder' ), $post->post_type ) ); ?></span> | |
| 168 | - </label> | |
| 384 | + <label class="cozmoslabs-toggle-track" for="wppb-content-restrict-messages-enabled"></label> | |
| 385 | + </div> | |
| 386 | + <div class="cozmoslabs-toggle-description"> | |
| 387 | + <label for="wppb-content-restrict-messages-enabled" class="cozmoslabs-description"><?php echo esc_html( sprintf( __( 'Enable if you wish to add custom messages for this %s.', 'profile-builder' ), apply_filters( 'wppb_content_restrict_settings_description_cpt', $post->post_type ) ) ); ?></label> | |
| 388 | + </div> | |
| 169 | 389 | </div> |
| 170 | 390 | |
| 171 | 391 | <div class="wppb-meta-box-field-wrapper-custom-messages <?php echo ( ! empty( $wppb_custom_messages_enabled ) ? 'wppb-content-restriction-enabled' : '' ); ?>"> |
| 172 | 392 | <?php do_action( 'wppb_view_meta_box_content_restrict_restriction_messages_top', $post->ID ); ?> |
| 173 | 393 | |
| 174 | - <p><strong><?php esc_html_e( 'Messages for logged-out users', 'profile-builder' ); ?></strong></p> | |
| 175 | - <?php wp_editor( get_post_meta( $post->ID, 'wppb-content-restrict-message-logged_out', true ), 'wppb-content-restrict-message-logged_out', array( 'textarea_name' => 'wppb-content-restrict-message-logged_out', 'editor_height' => 200 ) ); ?> | |
| 394 | + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper cozmoslabs-wysiwyg-indented"> | |
| 395 | + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Messages for logged-out users', 'profile-builder' ); ?></label> | |
| 396 | + <?php wp_editor( get_post_meta( $post->ID, 'wppb-content-restrict-message-logged_out', true ), 'wppb-content-restrict-message-logged_out', array( 'textarea_name' => 'wppb-content-restrict-message-logged_out', 'editor_height' => 180 ) ); ?> | |
| 397 | + </div> | |
| 176 | 398 | |
| 177 | - <p><strong><?php esc_html_e( 'Messages for logged-in users', 'profile-builder' ); ?></strong></p> | |
| 178 | - <?php wp_editor( get_post_meta( $post->ID, 'wppb-content-restrict-message-logged_in', true ), 'wppb-content-restrict-message-logged_in', array( 'textarea_name' => 'wppb-content-restrict-message-logged_in', 'editor_height' => 200 ) ); ?> | |
| 399 | + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper cozmoslabs-wysiwyg-indented"> | |
| 400 | + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Messages for logged-in users', 'profile-builder' ); ?></label> | |
| 401 | + <?php wp_editor( get_post_meta( $post->ID, 'wppb-content-restrict-message-logged_in', true ), 'wppb-content-restrict-message-logged_in', array( 'textarea_name' => 'wppb-content-restrict-message-logged_in', 'editor_height' => 180 ) ); ?> | |
| 402 | + </div> | |
| 179 | 403 | |
| 180 | 404 | <?php if( isset( $post->post_type ) && $post->post_type == 'product' ) : ?> |
| 181 | - | |
| 182 | - <p><strong><?php esc_html_e( 'Messages for restricted product purchase', 'profile-builder' ); ?></strong></p> | |
| 183 | - <?php wp_editor( wp_kses_post( get_post_meta( $post->ID, 'wppb-content-restrict-message-purchasing_restricted', true ) ), 'wppb-content-restrict-message-purchasing_restricted', array( 'textarea_name' => 'wppb-content-restrict-message-purchasing_restricted', 'editor_height' => 200 ) ); ?> | |
| 184 | 405 | |
| 406 | + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper cozmoslabs-wysiwyg-indented"> | |
| 407 | + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Messages for restricted product purchase', 'profile-builder' ); ?></label> | |
| 408 | + <?php wp_editor( wp_kses_post( get_post_meta( $post->ID, 'wppb-content-restrict-message-purchasing_restricted', true ) ), 'wppb-content-restrict-message-purchasing_restricted', array( 'textarea_name' => 'wppb-content-restrict-message-purchasing_restricted', 'editor_height' => 180 ) ); ?> | |
| 409 | + </div> | |
| 410 | + | |
| 185 | 411 | <?php endif; ?> |
| 186 | 412 | </div> |
| 187 | 413 | </div> |
| 188 | 414 | |
| 415 | + <?php if ( ! defined( 'WPPB_PAID_PLUGIN_DIR' ) || ( defined( 'PROFILE_BUILDER_PAID_VERSION' ) && PROFILE_BUILDER_PAID_VERSION === 'dev' ) ) : ?> | |
| 416 | + | |
| 417 | + <div class="cozmoslabs-form-field-wrapper"> | |
| 418 | + <p class="cozmoslabs-description"> | |
| 419 | + <?php echo wp_kses_post( sprintf( __( 'Have a question? %1$sOpen a support ticket.%2$s', 'profile-builder' ), '<a href="' . esc_url( 'https://wordpress.org/support/plugin/profile-builder/#new-topic-0' ) . '" target="_blank" rel="noopener">', '</a>' ) ); ?> | |
| 420 | + </p> | |
| 421 | + </div> | |
| 422 | + | |
| 423 | + <?php endif; ?> | |
| 424 | + | |
| 189 | 425 | <?php |
| 190 | 426 | wp_nonce_field( 'wppb_meta_box_single_content_restriction_nonce', 'wppb_content_restriction_token', false ); |
| 191 | 427 | |
| 192 | 428 | } |
| @@ -203,17 +439,14 @@ | ||
| 203 | 439 | if( ! empty( $_POST['wppb-content-restrict-type'] ) ) { |
| 204 | 440 | update_post_meta( $post_id, 'wppb-content-restrict-type', sanitize_text_field( $_POST['wppb-content-restrict-type'] ) ); |
| 205 | 441 | } |
| 206 | 442 | |
| 207 | - if( isset( $_POST['wppb-content-restrict-user-status'] ) && $_POST['wppb-content-restrict-user-status'] === 'loggedin' ) { | |
| 208 | - delete_post_meta( $post_id, 'wppb-content-restrict-user-role' ); | |
| 209 | - | |
| 210 | - if( isset( $_POST['wppb-content-restrict-user-role'] ) && is_array( $_POST['wppb-content-restrict-user-role'] ) ) { | |
| 211 | - $user_role_ids = array_map( 'sanitize_text_field', $_POST['wppb-content-restrict-user-role'] ); | |
| 212 | - foreach( $user_role_ids as $user_role_id ) { | |
| 213 | - if( ! empty( $user_role_id ) ) { | |
| 214 | - add_post_meta( $post_id, 'wppb-content-restrict-user-role', $user_role_id ); | |
| 215 | - } | |
| 443 | + delete_post_meta( $post_id, 'wppb-content-restrict-user-role' ); | |
| 444 | + if( isset( $_POST['wppb-content-restrict-user-role'] ) && is_array( $_POST['wppb-content-restrict-user-role'] ) ) { | |
| 445 | + $user_role_ids = array_map( 'sanitize_text_field', $_POST['wppb-content-restrict-user-role'] ); | |
| 446 | + foreach( $user_role_ids as $user_role_id ) { | |
| 447 | + if( ! empty( $user_role_id ) ) { | |
| 448 | + add_post_meta( $post_id, 'wppb-content-restrict-user-role', $user_role_id ); | |
| 216 | 449 | } |
| 217 | 450 | } |
| 218 | 451 | } |
| 219 | 452 | |
| @@ -263,4 +496,53 @@ | ||
| 263 | 496 | |
| 264 | 497 | } |
| 265 | 498 | add_action( 'save_post', 'wppb_content_restriction_save_data' ); |
| 266 | 499 | add_action( 'edit_attachment', 'wppb_content_restriction_save_data' ); |
| 500 | + | |
| 501 | +function wppb_content_restriction_save_term_data( $term_id, $tt_id = 0, $taxonomy = '' ) { | |
| 502 | + | |
| 503 | + if ( empty( $_POST['wppb_content_restriction_token'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['wppb_content_restriction_token'] ), 'wppb_meta_box_single_content_restriction_nonce' ) ) { | |
| 504 | + return; | |
| 505 | + } | |
| 506 | + | |
| 507 | + $supported_taxonomies = wppb_content_restriction_get_supported_taxonomies(); | |
| 508 | + | |
| 509 | + if ( ! empty( $taxonomy ) && ! isset( $supported_taxonomies[ $taxonomy ] ) ) { | |
| 510 | + return; | |
| 511 | + } | |
| 512 | + | |
| 513 | + delete_term_meta( $term_id, 'wppb-content-restrict-type' ); | |
| 514 | + if ( ! empty( $_POST['wppb-content-restrict-type'] ) ) { | |
| 515 | + update_term_meta( $term_id, 'wppb-content-restrict-type', sanitize_text_field( $_POST['wppb-content-restrict-type'] ) ); | |
| 516 | + } | |
| 517 | + | |
| 518 | + delete_term_meta( $term_id, 'wppb-content-restrict-user-role' ); | |
| 519 | + if ( isset( $_POST['wppb-content-restrict-user-role'] ) && is_array( $_POST['wppb-content-restrict-user-role'] ) ) { | |
| 520 | + $user_role_ids = array_map( 'sanitize_text_field', $_POST['wppb-content-restrict-user-role'] ); | |
| 521 | + foreach ( $user_role_ids as $user_role_id ) { | |
| 522 | + if ( ! empty( $user_role_id ) ) { | |
| 523 | + add_term_meta( $term_id, 'wppb-content-restrict-user-role', $user_role_id ); | |
| 524 | + } | |
| 525 | + } | |
| 526 | + } | |
| 527 | + | |
| 528 | + if ( isset( $_POST['wppb-content-restrict-user-status'] ) && $_POST['wppb-content-restrict-user-status'] === 'loggedin' ) { | |
| 529 | + update_term_meta( $term_id, 'wppb-content-restrict-user-status', 'loggedin' ); | |
| 530 | + } else { | |
| 531 | + delete_term_meta( $term_id, 'wppb-content-restrict-user-status' ); | |
| 532 | + } | |
| 533 | + | |
| 534 | + delete_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url-enabled' ); | |
| 535 | + if ( isset( $_POST['wppb-content-restrict-custom-redirect-url-enabled'] ) ) { | |
| 536 | + update_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url-enabled', 'yes' ); | |
| 537 | + } | |
| 538 | + | |
| 539 | + update_term_meta( $term_id, 'wppb-content-restrict-custom-redirect-url', ( ! empty( $_POST['wppb-content-restrict-custom-redirect-url'] ) ? esc_url_raw( $_POST['wppb-content-restrict-custom-redirect-url'] ) : '' ) ); | |
| 540 | + | |
| 541 | + delete_term_meta( $term_id, 'wppb-content-restrict-messages-enabled' ); | |
| 542 | + if ( isset( $_POST['wppb-content-restrict-messages-enabled'] ) ) { | |
| 543 | + update_term_meta( $term_id, 'wppb-content-restrict-messages-enabled', 'yes' ); | |
| 544 | + } | |
| 545 | + | |
| 546 | + update_term_meta( $term_id, 'wppb-content-restrict-message-logged_out', ( ! empty( $_POST['wppb-content-restrict-message-logged_out'] ) ? wp_kses_post( $_POST['wppb-content-restrict-message-logged_out'] ) : '' ) ); | |
| 547 | + update_term_meta( $term_id, 'wppb-content-restrict-message-logged_in', ( ! empty( $_POST['wppb-content-restrict-message-logged_in'] ) ? wp_kses_post( $_POST['wppb-content-restrict-message-logged_in'] ) : '' ) ); | |
| 548 | +} | |