PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | features/content-restriction/content-restriction.php +121 -79 3.9.9 → 4.0.3 View file →
@@ -82,112 +82,141 @@
82 82
83 83 <form method="post" action="options.php">
84 84 <?php settings_fields( 'wppb_content_restriction_settings' ); ?>
85 85
86 - <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-no-title-section" id="wppb-content-restriction-settings">
86 + <div class="cozmoslabs-settings-container">
87 87
88 - <?php
89 - $wppb_generalSettings = get_option( 'wppb_general_settings' );
90 - $content_restriction_activated = 'no';
91 - if( !empty( $wppb_content_restriction_settings['contentRestriction'] ) ){
92 - $content_restriction_activated = $wppb_content_restriction_settings['contentRestriction'];
93 - }
94 - elseif( !empty( $wppb_generalSettings['contentRestriction'] ) ){
95 - $content_restriction_activated = $wppb_generalSettings['contentRestriction'];
96 - }
97 - ?>
88 + <div class="cozmoslabs-settings">
98 89
99 - <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
100 - <label class="cozmoslabs-form-field-label" for="contentRestrictionSelect"><?php esc_html_e( 'Content Restriction', 'profile-builder' ); ?></label>
90 + <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-no-title-section" id="wppb-content-restriction-settings">
101 91
102 - <div class="cozmoslabs-toggle-container">
103 - <input type="checkbox" name="wppb_content_restriction_settings[contentRestriction]" id="contentRestrictionSelect" value="yes" <?php echo ( $content_restriction_activated == 'yes' ) ? 'checked' : ''; ?> >
104 - <label class="cozmoslabs-toggle-track" for="contentRestrictionSelect"></label>
105 - </div>
92 + <?php
93 + $wppb_generalSettings = get_option( 'wppb_general_settings' );
94 + $content_restriction_activated = 'no';
95 + if( !empty( $wppb_content_restriction_settings['contentRestriction'] ) ){
96 + $content_restriction_activated = $wppb_content_restriction_settings['contentRestriction'];
97 + }
98 + elseif( !empty( $wppb_generalSettings['contentRestriction'] ) ){
99 + $content_restriction_activated = $wppb_generalSettings['contentRestriction'];
100 + }
101 + ?>
106 102
107 - <div class="cozmoslabs-toggle-description">
108 - <p class="cozmoslabs-description"><?php esc_html_e( 'Activate Content Restriction.', 'profile-builder' ); ?></p>
109 - </div>
110 - </div>
103 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
104 + <label class="cozmoslabs-form-field-label" for="contentRestrictionSelect"><?php esc_html_e( 'Content Restriction', 'profile-builder' ); ?></label>
111 105
112 - <div class="cozmoslabs-form-field-wrapper">
113 - <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Type of Restriction', 'profile-builder' ); ?></label>
106 + <div class="cozmoslabs-toggle-container">
107 + <input type="checkbox" name="wppb_content_restriction_settings[contentRestriction]" id="contentRestrictionSelect" value="yes" <?php echo ( $content_restriction_activated == 'yes' ) ? 'checked' : ''; ?> >
108 + <label class="cozmoslabs-toggle-track" for="contentRestrictionSelect"></label>
109 + </div>
114 110
115 - <div class="cozmoslabs-radio-inputs-row">
116 - <label for="wppb-content-restrict-type-message">
117 - <input type="radio" id="wppb-content-restrict-type-message" value="message" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' && $wppb_content_restriction_settings['restrict_type'] == 'message' ) ? 'checked="checked"' : '' ); ?> name="wppb_content_restriction_settings[restrict_type]">
118 - <?php esc_html_e( 'Message', 'profile-builder' ); ?>
119 - </label>
111 + <div class="cozmoslabs-toggle-description">
112 + <label for="contentRestrictionSelect" class="cozmoslabs-description"><?php esc_html_e( 'Activate Content Restriction.', 'profile-builder' ); ?></label>
113 + </div>
114 + </div>
120 115
121 - <label for="wppb-content-restrict-type-redirect">
122 - <input type="radio" id="wppb-content-restrict-type-redirect" value="redirect" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' && $wppb_content_restriction_settings['restrict_type'] == 'redirect' ) ? 'checked="checked"' : '' ); ?> name="wppb_content_restriction_settings[restrict_type]">
123 - <?php esc_html_e( 'Redirect', 'profile-builder' ); ?>
124 - </label>
125 - </div>
116 + <div class="cozmoslabs-form-field-wrapper">
117 + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Type of Restriction', 'profile-builder' ); ?></label>
126 118
127 - <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'If you select "Message", the post\'s content will be protected by being replaced with a custom message.', 'profile-builder' ); ?></p>
128 - <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'If you select "Redirect", the post\'s content will be protected by redirecting the user to the URL you specify. The redirect happens only when accessing a single post. On archive pages the restriction message will be displayed, instead of the content.', 'profile-builder' ); ?></p>
129 - </div>
119 + <div class="cozmoslabs-radio-inputs-row">
120 + <label for="wppb-content-restrict-type-message">
121 + <input type="radio" id="wppb-content-restrict-type-message" value="message" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' && $wppb_content_restriction_settings['restrict_type'] == 'message' ) ? 'checked="checked"' : '' ); ?> name="wppb_content_restriction_settings[restrict_type]">
122 + <?php esc_html_e( 'Message', 'profile-builder' ); ?>
123 + </label>
130 124
131 - <div class="cozmoslabs-form-field-wrapper">
132 - <label class="cozmoslabs-form-field-label" for="wppb-content-restrict-redirect-url"><?php esc_html_e( 'Redirect URL', 'profile-builder' ); ?></label>
133 - <input type="text" id="wppb-content-restrict-redirect-url" class="widefat" name="wppb_content_restriction_settings[redirect_url]" value="<?php echo ( ( $wppb_content_restriction_settings != 'not_found' && ! empty( $wppb_content_restriction_settings['redirect_url'] ) ) ? esc_url( $wppb_content_restriction_settings['redirect_url'] ) : '' ); ?>" />
125 + <label for="wppb-content-restrict-type-redirect">
126 + <input type="radio" id="wppb-content-restrict-type-redirect" value="redirect" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' && $wppb_content_restriction_settings['restrict_type'] == 'redirect' ) ? 'checked="checked"' : '' ); ?> name="wppb_content_restriction_settings[restrict_type]">
127 + <?php esc_html_e( 'Redirect', 'profile-builder' ); ?>
128 + </label>
129 + </div>
134 130
135 - <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'The URL where the user will be redirected if a redirect restriction is selected above.', 'profile-builder' ); ?></p>
136 - </div>
131 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'If you select "Message", the post\'s content will be protected by being replaced with a custom message.', 'profile-builder' ); ?></p>
132 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'If you select "Redirect", the post\'s content will be protected by redirecting the user to the URL you specify. The redirect happens only when accessing a single post. On archive pages the restriction message will be displayed, instead of the content.', 'profile-builder' ); ?></p>
133 + </div>
137 134
138 - <div class="cozmoslabs-form-field-wrapper cozmoslabs-column-radios-wrapper">
139 - <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Restricted Posts Preview', 'profile-builder' ); ?></label>
135 + <div class="cozmoslabs-form-field-wrapper">
136 + <label class="cozmoslabs-form-field-label" for="wppb-content-restrict-redirect-url"><?php esc_html_e( 'Redirect URL', 'profile-builder' ); ?></label>
137 + <input type="text" id="wppb-content-restrict-redirect-url" class="widefat" name="wppb_content_restriction_settings[redirect_url]" value="<?php echo ( ( $wppb_content_restriction_settings != 'not_found' && ! empty( $wppb_content_restriction_settings['redirect_url'] ) ) ? esc_url( $wppb_content_restriction_settings['redirect_url'] ) : '' ); ?>" />
140 138
141 - <div class="cozmoslabs-radio-inputs-column">
142 - <label>
143 - <input type="radio" name="wppb_content_restriction_settings[post_preview]" value="none" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' ) && $wppb_content_restriction_settings['post_preview'] == 'none' ? 'checked' : '' ); ?> />
144 - <?php esc_html_e( 'None', 'profile-builder' ); ?>
145 - </label>
139 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'The URL where the user will be redirected if a redirect restriction is selected above.', 'profile-builder' ); ?></p>
140 + </div>
146 141
147 - <label>
148 - <input type="radio" name="wppb_content_restriction_settings[post_preview]" value="trim-content" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' ) && $wppb_content_restriction_settings['post_preview'] == 'trim-content' ? 'checked' : '' ); ?> />
149 - <?php echo sprintf( __( 'Show the first %s words of the post\'s content', 'profile-builder' ), '<input name="wppb_content_restriction_settings[post_preview_length]" type="text" value="'. ( $wppb_content_restriction_settings != 'not_found' && ! empty( $wppb_content_restriction_settings['post_preview_length'] ) ? esc_attr( $wppb_content_restriction_settings['post_preview_length'] ) : 20 ) .'" style="width: 50px; height: 25px; min-height: 25px;" />' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
150 - </label>
142 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-column-radios-wrapper">
143 + <label class="cozmoslabs-form-field-label"><?php esc_html_e( 'Restricted Posts Preview', 'profile-builder' ); ?></label>
151 144
152 - <label>
153 - <input type="radio" name="wppb_content_restriction_settings[post_preview]" value="more-tag" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' ) && $wppb_content_restriction_settings['post_preview'] == 'more-tag' ? 'checked' : '' ); ?> />
154 - <?php echo esc_html__( 'Show the content before the "more" tag', 'profile-builder' ); ?>
155 - </label>
145 + <div class="cozmoslabs-radio-inputs-column">
146 + <label>
147 + <input type="radio" name="wppb_content_restriction_settings[post_preview]" value="none" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' ) && $wppb_content_restriction_settings['post_preview'] == 'none' ? 'checked' : '' ); ?> />
148 + <?php esc_html_e( 'None', 'profile-builder' ); ?>
149 + </label>
150 +
151 + <label>
152 + <input type="radio" name="wppb_content_restriction_settings[post_preview]" value="trim-content" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' ) && $wppb_content_restriction_settings['post_preview'] == 'trim-content' ? 'checked' : '' ); ?> />
153 + <?php echo sprintf( __( 'Show the first %s words of the post\'s content', 'profile-builder' ), '<input name="wppb_content_restriction_settings[post_preview_length]" type="text" value="'. ( $wppb_content_restriction_settings != 'not_found' && ! empty( $wppb_content_restriction_settings['post_preview_length'] ) ? esc_attr( $wppb_content_restriction_settings['post_preview_length'] ) : 20 ) .'" style="width: 50px; height: 25px; min-height: 25px;" />' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
154 + </label>
155 +
156 + <label>
157 + <input type="radio" name="wppb_content_restriction_settings[post_preview]" value="more-tag" <?php echo ( ( $wppb_content_restriction_settings != 'not_found' ) && $wppb_content_restriction_settings['post_preview'] == 'more-tag' ? 'checked' : '' ); ?> />
158 + <?php echo esc_html__( 'Show the content before the "more" tag', 'profile-builder' ); ?>
159 + </label>
160 + </div>
161 +
162 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'Show a portion of the restricted post to logged-out users or users that are not allowed to see it.', 'profile-builder' ); ?></p>
163 + </div>
164 +
165 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
166 + <label class="cozmoslabs-form-field-label" for="excludeRestrictedPosts"><?php esc_html_e( 'Exclude Restricted Posts from Queries', 'profile-builder' ); ?></label>
167 +
168 + <div class="cozmoslabs-toggle-container">
169 + <input type="checkbox" name="wppb_content_restriction_settings[excludePosts]" id="excludeRestrictedPosts" value="yes" <?php echo ( isset( $wppb_content_restriction_settings['excludePosts'] ) && $wppb_content_restriction_settings['excludePosts'] == 'yes' ) ? 'checked' : ''; ?> >
170 + <label class="cozmoslabs-toggle-track" for="excludeRestrictedPosts"></label>
171 + </div>
172 +
173 + <div class="cozmoslabs-toggle-description">
174 + <label for="excludeRestrictedPosts" class="cozmoslabs-description"><?php esc_html_e( 'Activate this option to exclude the restricted posts from default WordPress and WooCommerce queries.', 'profile-builder' ); ?></label>
175 + </div>
176 + </div>
177 +
178 + <?php do_action( 'wppb_extra_content_restriction_settings', $wppb_content_restriction_settings ); ?>
179 +
156 180 </div>
157 181
158 - <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php echo esc_html__( 'Show a portion of the restricted post to logged-out users or users that are not allowed to see it.', 'profile-builder' ); ?></p>
159 - </div>
182 + <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-wysiwyg-container">
183 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Message for logged-out users', 'profile-builder' ); ?></h4>
160 184
161 - </div>
185 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper">
186 + <?php wp_editor( wppb_get_restriction_content_message( 'logged_out' ), 'message_logged_out', array( 'textarea_name' => 'wppb_content_restriction_settings[message_logged_out]', 'editor_height' => 180 ) ); ?>
187 + </div>
188 + </div>
162 189
163 - <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-wysiwyg-container">
164 - <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Message for logged-out users', 'profile-builder' ); ?></h4>
190 + <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-wysiwyg-container">
191 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Message for logged-in users', 'profile-builder' ); ?></h4>
165 192
166 - <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper">
167 - <?php wp_editor( wppb_get_restriction_content_message( 'logged_out' ), 'message_logged_out', array( 'textarea_name' => 'wppb_content_restriction_settings[message_logged_out]', 'editor_height' => 180 ) ); ?>
168 - </div>
169 - </div>
193 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper">
194 + <?php wp_editor( wppb_get_restriction_content_message( 'logged_in' ), 'message_logged_in', array( 'textarea_name' => 'wppb_content_restriction_settings[message_logged_in]', 'editor_height' => 180 ) ); ?>
195 + </div>
196 + </div>
170 197
171 - <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-wysiwyg-container">
172 - <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Message for logged-in users', 'profile-builder' ); ?></h4>
198 + <?php if ( ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) || ( is_plugin_active_for_network('woocommerce/woocommerce.php') ) ) : ?>
199 + <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-wysiwyg-container">
200 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Message for WooCommerce Restricted Product Purchase', 'profile-builder' ); ?></h4>
173 201
174 - <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper">
175 - <?php wp_editor( wppb_get_restriction_content_message( 'logged_in' ), 'message_logged_in', array( 'textarea_name' => 'wppb_content_restriction_settings[message_logged_in]', 'editor_height' => 180 ) ); ?>
202 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper">
203 + <?php wp_editor( wppb_get_restriction_content_message( 'purchasing_restricted' ), 'messages_purchasing_restricted', array( 'textarea_name' => 'wppb_content_restriction_settings[purchasing_restricted]', 'editor_height' => 180 ) ); ?>
204 + </div>
205 + </div>
206 + <?php endif; ?>
207 +
176 208 </div>
177 - </div>
178 209
179 - <?php if ( ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) || ( is_plugin_active_for_network('woocommerce/woocommerce.php') ) ) : ?>
180 - <div class="cozmoslabs-form-subsection-wrapper cozmoslabs-wysiwyg-container">
181 - <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Message for WooCommerce Restricted Product Purchase', 'profile-builder' ); ?></h4>
182 -
183 - <div class="cozmoslabs-form-field-wrapper cozmoslabs-wysiwyg-wrapper">
184 - <?php wp_editor( wppb_get_restriction_content_message( 'purchasing_restricted' ), 'messages_purchasing_restricted', array( 'textarea_name' => 'wppb_content_restriction_settings[purchasing_restricted]', 'editor_height' => 180 ) ); ?>
210 + <div class="submit cozmoslabs-submit">
211 + <h3 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Update Settings', 'profile-builder' ) ?></h3>
212 + <div class="cozmoslabs-publish-button-group">
213 + <?php submit_button( __( 'Save Changes', 'profile-builder' ) ); ?>
185 214 </div>
186 215 </div>
187 - <?php endif; ?>
188 216
189 - <?php submit_button( __( 'Save Changes', 'profile-builder' ) ); ?>
217 + </div>
218 +
190 219 </form>
191 220 </div>
192 221 <?php
193 222
@@ -194,9 +223,9 @@
194 223 }
195 224
196 225 function wppb_content_restriction_scripts_styles($hook_suffix) {
197 226 //Check if it's an editing or adding new post page
198 - if( $hook_suffix === 'post-new.php' || $hook_suffix === 'edit.php' || ( $hook_suffix === 'post.php' && isset( $_GET['action'] ) && $_GET['action'] === 'edit' ) || ( isset( $_GET['page'] ) && $_GET['page'] === 'profile-builder-content_restriction' ) ){
227 + if( $hook_suffix === 'post-new.php' || $hook_suffix === 'edit.php' || $hook_suffix === 'edit-tags.php' || $hook_suffix === 'term.php' || ( $hook_suffix === 'post.php' && isset( $_GET['action'] ) && $_GET['action'] === 'edit' ) || ( isset( $_GET['page'] ) && $_GET['page'] === 'profile-builder-content_restriction' ) ){
199 228 wp_enqueue_script( 'wppb_content_restriction_js', plugin_dir_url( __FILE__ ) .'assets/js/content-restriction.js', array( 'jquery' ), PROFILE_BUILDER_VERSION );
200 229 wp_enqueue_style( 'wppb_content_restriction_css', plugin_dir_url( __FILE__ ) .'assets/css/content-restriction.css', array(), PROFILE_BUILDER_VERSION );
201 230
202 231 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', array(), PROFILE_BUILDER_VERSION );
@@ -202,4 +231,17 @@
202 231 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', array(), PROFILE_BUILDER_VERSION );
203 232 }
204 233 }
205 234
235 +// Declare HPOS compatibility
236 +add_action( 'before_woocommerce_init', 'wppb_woo_declare_hpos_compatibility' );
237 +function wppb_woo_declare_hpos_compatibility() {
238 +
239 + $plugin_slug = 'profile-builder/index.php';
240 +
241 + if( defined( 'PROFILE_BUILDER_PAID_VERSION' ) && PROFILE_BUILDER_PAID_VERSION == 'dev' )
242 + $plugin_slug = 'profile-builder-dev/index.php';
243 +
244 + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) )
245 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', $plugin_slug, true );
246 +
247 +}