PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.7
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.7
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 2.0.7 All 340 releases
profile-builder / features / functions.php

functions.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.7, at features/functions.php

626 lines 26.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions Load
4 *
5 */
6
7 // whitelist options, you can add more register_settings changing the second parameter
8 function wppb_register_settings() {
9 register_setting( 'wppb_option_group', 'wppb_default_settings' );
10 register_setting( 'wppb_general_settings', 'wppb_general_settings', 'wppb_general_settings_sanitize' );
11 register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
12 register_setting( 'wppb_profile_builder_pro_serial', 'wppb_profile_builder_pro_serial' );
13 register_setting( 'wppb_profile_builder_hobbyist_serial', 'wppb_profile_builder_hobbyist_serial' );
14 register_setting( 'wppb_module_settings', 'wppb_module_settings' );
15 register_setting( 'wppb_module_settings_description', 'wppb_module_settings_description' );
16 register_setting( 'customRedirectSettings', 'customRedirectSettings' );
17 register_setting( 'customUserListingSettings', 'customUserListingSettings' );
18 register_setting( 'reCaptchaSettings', 'reCaptchaSettings' );
19 register_setting( 'emailCustomizer', 'emailCustomizer' );
20 }
21
22
23
24
25 // WPML support
26 function wppb_icl_t($context, $name, $value){
27 if( function_exists( 'icl_t' ) )
28 return icl_t( $context, $name, $value );
29
30 else
31 return $value;
32 }
33
34
35 function wppb_add_plugin_stylesheet() {
36 $wppb_generalSettings = get_option( 'wppb_general_settings' );
37
38 if ( ( file_exists( WPPB_PLUGIN_DIR . '/assets/css/style-front-end.css' ) ) && ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ){
39 wp_register_style( 'wppb_stylesheet', WPPB_PLUGIN_URL . 'assets/css/style-front-end.css' );
40 wp_enqueue_style( 'wppb_stylesheet' );
41 }
42 }
43
44
45 function wppb_show_admin_bar($content){
46 global $current_user;
47
48 $adminSettingsPresent = get_option('wppb_display_admin_settings','not_found');
49 $show = null;
50
51 if ($adminSettingsPresent != 'not_found' && $current_user->ID)
52 foreach ($current_user->roles as $role_key) {
53 if (empty($GLOBALS['wp_roles']->roles[$role_key]))
54 continue;
55 $role = $GLOBALS['wp_roles']->roles[$role_key];
56 if (isset($adminSettingsPresent[$role['name']])) {
57 if ($adminSettingsPresent[$role['name']] == 'show')
58 $show = true;
59 if ($adminSettingsPresent[$role['name']] == 'hide' && $show === null)
60 $show = false;
61 }
62 }
63 return $show === null ? $content : $show;
64 }
65
66
67 if(!function_exists('wppb_curpageurl')){
68 function wppb_curpageurl() {
69 $pageURL = 'http';
70
71 if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on"))
72 $pageURL .= "s";
73
74 $pageURL .= "://";
75
76 if ($_SERVER["SERVER_PORT"] != "80")
77 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
78
79 else
80 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
81
82 return $pageURL;
83 }
84 }
85
86
87 if ( is_admin() ){
88
89 // register the settings for the menu only display sidebar menu for a user with a certain capability, in this case only the "admin"
90 add_action( 'admin_init', 'wppb_register_settings' );
91
92 // display the same extra profile fields in the admin panel also
93 if ( file_exists ( WPPB_PLUGIN_DIR.'/front-end/extra-fields/extra-fields.php' ) ){
94 require_once( WPPB_PLUGIN_DIR.'/front-end/extra-fields/extra-fields.php' );
95
96 add_action( 'show_user_profile', 'display_profile_extra_fields_in_admin', 10 );
97 add_action( 'edit_user_profile', 'display_profile_extra_fields_in_admin', 10 );
98 add_action( 'user_profile_update_errors', 'wppb_validate_backend_fields', 10, 3 );
99 add_action( 'personal_options_update', 'save_profile_extra_fields_in_admin', 10 );
100 add_action( 'edit_user_profile_update', 'save_profile_extra_fields_in_admin', 10 );
101 }
102
103 }else if ( !is_admin() ){
104 // include the stylesheet
105 add_action( 'wp_print_styles', 'wppb_add_plugin_stylesheet' );
106
107 // include the menu file for the profile informations
108 include_once( WPPB_PLUGIN_DIR.'/front-end/edit-profile.php' );
109 include_once( WPPB_PLUGIN_DIR.'/front-end/class-formbuilder.php' );
110 add_shortcode( 'wppb-edit-profile', 'wppb_front_end_profile_info' );
111
112 // include the menu file for the login screen
113 include_once( WPPB_PLUGIN_DIR.'/front-end/login.php' );
114 add_shortcode( 'wppb-login', 'wppb_front_end_login' );
115
116 // include the menu file for the register screen
117 include_once( WPPB_PLUGIN_DIR.'/front-end/register.php' );
118 add_shortcode( 'wppb-register', 'wppb_front_end_register_handler' );
119
120 // include the menu file for the recover password screen
121 include_once( WPPB_PLUGIN_DIR.'/front-end/recover.php' );
122 add_shortcode( 'wppb-recover-password', 'wppb_front_end_password_recovery' );
123
124 // set the front-end admin bar to show/hide
125 add_filter( 'show_admin_bar' , 'wppb_show_admin_bar');
126
127 // Shortcodes used for the widget area
128 add_filter( 'widget_text', 'do_shortcode', 11 );
129 }
130
131
132 /**
133 * Function that overwrites the default wp_mail function and sends out emails
134 *
135 * @since v.2.0
136 *
137 * @param string $to
138 * @param string $subject
139 * @param string $message
140 * @param string $message_from
141 *
142 */
143 function wppb_mail($to, $subject, $message, $message_from){
144 $to = apply_filters ( 'wppb_send_email_to', $to );
145 $send_email = apply_filters ( 'wppb_send_email', true, $to, $subject, $message );
146
147 $message = apply_filters( 'wppb_email_message', $message );
148
149 do_action( 'wppb_before_sending_email', $to, $subject, $message, $send_email );
150
151 if ( $send_email ){
152 //we add this filter to enable html encoding
153 add_filter( 'wp_mail_content_type', create_function( '', 'return "text/html"; ' ) );
154
155 $sent = wp_mail( $to , $subject, $message );
156 }
157
158 do_action( 'wppb_after_sending_email', $sent, $to, $subject, $message, $send_email );
159
160 return $sent;
161 }
162
163 function wppb_activate_account_check(){
164 if ( ( isset( $_GET['activation_key'] ) ) && ( trim( $_GET['activation_key'] ) != '' ) ){
165 global $post;
166
167 $wppb_generalSettings = get_option( 'wppb_general_settings' );
168 $activation_landing_page_id = ( ( isset( $wppb_generalSettings['activationLandingPage'] ) && ( trim( $wppb_generalSettings['activationLandingPage'] ) != '' ) ) ? $wppb_generalSettings['activationLandingPage'] : 'not_set' );
169
170 if ( $activation_landing_page_id != 'not_set' ){
171 //an activation page was selected, but we still need to check if the current page doesn't already have the registration shortcode
172 if ( strpos( $post->post_content, '[wppb-register' ) === false )
173 add_filter( 'the_content', 'wppb_add_activation_message' );
174
175 }elseif ( strpos( $post->post_content, '[wppb-register' ) === false ){
176 //no activation page was selected, and the sent link pointed to the home url
177 wp_redirect( apply_filters( 'wppb_activatate_account_redirect_url', WPPB_PLUGIN_URL.'assets/misc/fallback-page.php?activation_key='.urlencode( $_GET['activation_key'] ).'&site_name='.urlencode( get_bloginfo( 'name' ) ).'&site_url='.urlencode( get_bloginfo( 'url' ) ).'&message='.urlencode( $activation_message = wppb_activate_signup( $_GET['activation_key'] ) ), $_GET['activation_key'], $activation_message ) );
178 exit;
179 }
180 }
181 }
182 add_action( 'template_redirect', 'wppb_activate_account_check' );
183
184
185 function wppb_add_activation_message( $content ){
186
187 return wppb_activate_signup( $_GET['activation_key'] ) . $content;
188 }
189
190
191 // Create a new, top-level page
192 $args = array(
193 'page_title' => __( 'Profile Builder', 'profilebuilder' ),
194 'menu_title' => __( 'Profile Builder', 'profilebuilder' ),
195 'capability' => 'manage_options',
196 'menu_slug' => 'profile-builder',
197 'page_type' => 'menu_page',
198 'position' => '70,69',
199 'priority' => 1,
200 'icon_url' => WPPB_PLUGIN_URL . 'assets/images/pb_menu_icon.png'
201 );
202 new WCK_Page_Creator_PB( $args );
203
204 /**
205 * Remove the automatically created submenu page
206 *
207 * @since v.2.0
208 *
209 * @return void
210 */
211 function wppb_remove_main_menu_page(){
212 remove_submenu_page( 'profile-builder', 'profile-builder' );
213 }
214 add_action( 'admin_menu', 'wppb_remove_main_menu_page', 11 );
215
216 /**
217 * Add scripts to the back-end CPT's to remove the slug from the edit page
218 *
219 * @since v.2.0
220 *
221 * @return void
222 */
223 function wppb_print_cpt_script( $hook ){
224 if ( $hook == 'profile-builder_page_manage-fields' ){
225 wp_enqueue_script( 'wppb-manage-fields-live-change', WPPB_PLUGIN_URL . 'assets/js/jquery-manage-fields-live-change.js', array(), PROFILE_BUILDER_VERSION, true );
226 }
227
228 if ( ( $hook == 'profile-builder_page_manage-fields' ) || ( $hook == 'profile-builder_page_profile-builder-basic-info' ) || ( $hook == 'profile-builder_page_profile-builder-modules' ) || ( $hook == 'profile-builder_page_profile-builder-general-settings' ) || ( $hook == 'profile-builder_page_profile-builder-admin-bar-settings' ) || ( $hook == 'profile-builder_page_profile-builder-register' ) || ( $hook == 'profile-builder_page_profile-builder-wppb_userListing' ) || ( $hook == 'profile-builder_page_profile-builder-wppb_customRedirect' ) || ( $hook == 'profile-builder_page_profile-builder-wppb_emailCustomizer' ) || ( $hook == 'profile-builder_page_profile-builder-wppb_emailCustomizerAdmin' ) ){
229 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', false, PROFILE_BUILDER_VERSION );
230 }
231
232 if ( $hook == 'profile-builder_page_profile-builder-general-settings' )
233 wp_enqueue_script( 'wppb-manage-fields-live-change', WPPB_PLUGIN_URL . 'assets/js/jquery-email-confirmation.js', array(), PROFILE_BUILDER_VERSION, true );
234
235 if ( isset( $_GET['post_type'] ) || isset( $_GET['post'] ) ){
236 if ( isset( $_GET['post_type'] ) )
237 $post_type = $_GET['post_type'];
238
239 elseif ( isset( $_GET['post'] ) )
240 $post_type = get_post_type( $_GET['post'] );
241
242 if ( ( 'wppb-epf-cpt' == $post_type ) || ( 'wppb-rf-cpt' == $post_type ) || ( 'wppb-ul-cpt' == $post_type ) ){
243 wp_enqueue_style( 'wppb-back-end-style', WPPB_PLUGIN_URL . 'assets/css/style-back-end.css', false, PROFILE_BUILDER_VERSION );
244 wp_enqueue_script( 'wppb-epf-rf', WPPB_PLUGIN_URL . 'assets/js/jquery-epf-rf.js', array(), PROFILE_BUILDER_VERSION, true );
245 }
246 }
247 if ( file_exists ( WPPB_PLUGIN_DIR.'/update/update-checker.php' ) ) {
248 wp_enqueue_style( 'wppb-serial-notice-css', WPPB_PLUGIN_URL . 'assets/css/serial-notice.css', false, PROFILE_BUILDER_VERSION );
249 wp_enqueue_script( 'wppb-sitewide', WPPB_PLUGIN_URL . 'assets/js/jquery-pb-sitewide.js', array(), PROFILE_BUILDER_VERSION, true );
250 }
251 }
252 add_action( 'admin_enqueue_scripts', 'wppb_print_cpt_script' );
253
254
255 // Set up the AJAX hooks
256 function wppb_delete(){
257 if ( isset( $_POST['_ajax_nonce'] ) ){
258
259 if ( ( isset( $_POST['what'] ) ) && ( $_POST['what'] == 'avatar' ) ){
260 if ( !wp_verify_nonce( $_POST['_ajax_nonce'], 'user'.base64_decode( $_POST['currentUser'] ).'_nonce_avatar' ) ){
261 echo __( 'The user-validation has failed - the avatar was not deleted!', 'profilebuilder' );
262 die();
263
264 }else{
265 update_user_meta( base64_decode( $_POST['currentUser'] ), base64_decode( $_POST['customFieldName'] ), '');
266 update_user_meta( base64_decode( $_POST['currentUser'] ), 'resized_avatar_'.base64_decode( $_POST['customFieldID'] ), '' );
267 echo 'done';
268 die();
269 }
270 }elseif ( ( isset( $_POST['what'] ) ) && ( $_POST['what'] == 'attachment' ) ){
271 if ( !wp_verify_nonce( $_POST['_ajax_nonce'], 'user'.base64_decode( $_POST['currentUser'] ).'_nonce_upload' ) ){
272 echo __( 'The user-validation has failed - the attachment was not deleted!', 'profilebuilder' );
273 die();
274
275 }else{
276 update_user_meta( base64_decode( $_POST['currentUser'] ), base64_decode( $_POST['customFieldName'] ), '');
277 echo 'done';
278 die();
279 }
280 }
281 }
282 }
283 add_action( 'wp_ajax_hook_wppb_delete', 'wppb_delete' );
284
285
286 //the function used to overwrite the avatar across the wp installation
287 function wppb_changeDefaultAvatar( $avatar, $id_or_email, $size, $default, $alt ){
288
289 global $wpdb;
290
291 /* Get user info. */
292 if(is_object($id_or_email)){
293 $my_user_id = $id_or_email->user_id;
294
295 }elseif(is_numeric($id_or_email)){
296 $my_user_id = $id_or_email;
297
298 }elseif(!is_integer($id_or_email)){
299 $user_info = get_user_by( 'email', $id_or_email );
300 $my_user_id = ( is_object( $user_info ) ? $user_info->ID : '' );
301 }else
302 $my_user_id = $id_or_email;
303
304 $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' );
305
306 if ( $wppb_manage_fields != 'not_found' ){
307 foreach( $wppb_manage_fields as $value ){
308 if ( $value['field'] == 'Avatar'){
309 $customUserAvatar = get_user_meta( $my_user_id, 'resized_avatar_'.$value['id'], true );
310 $customUserAvatarRelativePath = get_user_meta( $my_user_id, 'resized_avatar_'.$value['id'].'_relative_path', true );
311
312 if ( ( ($customUserAvatar != '') || ($customUserAvatar != null) ) && file_exists($customUserAvatarRelativePath) ){
313 $avatar = "<img alt='{$alt}' src='{$customUserAvatar}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
314 }
315 }
316 }
317 }
318
319 return $avatar;
320 }
321 add_filter( 'get_avatar', 'wppb_changeDefaultAvatar', 21, 5 );
322
323
324 //the function used to resize the avatar image; the new function uses a user ID as parameter to make pages load faster
325 function wppb_resize_avatar( $userID, $userlisting_size = null, $userlisting_crop = null ){
326 // include the admin image API
327 require_once( ABSPATH . '/wp-admin/includes/image.php' );
328
329 // retrieve first a list of all the current custom fields
330 $wppb_manage_fields = get_option( 'wppb_manage_fields' );
331
332 foreach ( $wppb_manage_fields as $key => $value ){
333 if ( $value['field'] == 'Avatar' ){
334
335 // retrieve width and height of the image
336 $width = $height = '';
337
338 //this checks if it only has 1 component
339 if ( is_numeric( $value['avatar-size'] ) ){
340 $width = $height = $value['avatar-size'];
341
342 }else{
343 //this checks if the entered value has 2 components
344 $sentValue = explode( ',', $value['avatar-size'] );
345 $width = $sentValue[0];
346 $height = $sentValue[1];
347 }
348
349 $width = ( !empty( $userlisting_size ) ? $userlisting_size : $width );
350 $height = ( !empty( $userlisting_size ) ? $userlisting_size : $height );
351
352 if( !strpos( get_user_meta( $userID, 'resized_avatar_'.$value['id'], true ), $width . 'x' . $height ) ) {
353 // retrieve the original image (in original size)
354 $avatar_directory_path = get_user_meta( $userID, 'avatar_directory_path_'.$value['id'], true );
355
356 $image = wp_get_image_editor( $avatar_directory_path );
357 if ( !is_wp_error( $image ) ) {
358 do_action( 'wppb_before_avatar_resizing', $image, $userID, $value['meta-name'], $value['avatar-size'] );
359
360 $crop = apply_filters( 'wppb_avatar_crop_resize', ( !empty( $userlisting_crop ) ? $userlisting_crop : false ) );
361
362 $resize = $image->resize( $width, $height, $crop );
363
364 if ($resize !== FALSE) {
365 do_action( 'wppb_avatar_resizing', $image, $resize );
366
367 $fileType = apply_filters( 'wppb_resized_file_extension', 'png' );
368
369 $wp_upload_array = wp_upload_dir(); // Array of key => value pairs
370
371 //create file(name); both with directory and url
372 $fileName_dir = $image->generate_filename( NULL, $wp_upload_array['basedir'].'/profile_builder/avatars/', $fileType );
373
374 if ( PHP_OS == "WIN32" || PHP_OS == "WINNT" )
375 $fileName_dir = str_replace( '\\', '/', $fileName_dir );
376
377 $fileName_url = str_replace( str_replace( '\\', '/', $wp_upload_array['basedir'] ), $wp_upload_array['baseurl'], $fileName_dir );
378
379 //save the newly created (resized) avatar on the disc
380 $image->save( $fileName_dir );
381
382 update_user_meta( $userID, 'resized_avatar_'.$value['id'], $fileName_url );
383 update_user_meta( $userID, 'resized_avatar_'.$value['id'].'_relative_path', $fileName_dir );
384
385 do_action( 'wppb_after_avatar_resizing', $image, $fileName_dir, $fileName_url );
386 }
387 }
388 }
389 }
390 }
391 }
392
393
394 if ( is_admin() ){
395 // add a hook to delete the user from the _signups table if either the email confirmation is activated, or it is a wpmu installation
396 function wppb_delete_user_from_signups_table($user_id) {
397 global $wpdb;
398
399 $userLogin = $wpdb->get_var( $wpdb->prepare( "SELECT user_login, user_email FROM " . $wpdb->users . " WHERE ID = %d LIMIT 1", $user_id ) );
400 if ( is_multisite() )
401 $delete = $wpdb->delete( $wpdb->signups, array( 'user_login' => $userLogin ) );
402 else
403 $delete = $wpdb->delete( $wpdb->prefix.'signups', array( 'user_login' => $userLogin ) );
404 }
405
406 if ( is_multisite() )
407 add_action( 'wpmu_delete_user', 'wppb_delete_user_from_signups_table' );
408
409 else{
410 $wppb_generalSettings = get_option( 'wppb_general_settings' );
411
412 if ( $wppb_generalSettings['emailConfirmation'] == 'yes' )
413 add_action( 'delete_user', 'wppb_delete_user_from_signups_table' );
414 }
415
416 }
417
418
419
420 // This function offers compatibility with the all in one event calendar plugin
421 function wppb_aioec_compatibility(){
422
423 wp_deregister_script( 'jquery.tools-form');
424 }
425 add_action('admin_print_styles-users_page_ProfileBuilderOptionsAndSettings', 'wppb_aioec_compatibility');
426
427
428 function wppb_user_meta_exists( $id, $meta_name ){
429 global $wpdb;
430
431 return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $id, $meta_name ) );
432 }
433
434
435 // function to check if there is a need to add the http:// prefix
436 function wppb_check_missing_http( $redirectLink ) {
437 return preg_match( '#^(?:[a-z\d]+(?:-+[a-z\d]+)*\.)+[a-z]+(?::\d+)?(?:/|$)#i', $redirectLink );
438 }
439
440
441
442 //function to output the password strength checker on frontend forms
443 function wppb_password_strength_checker_html(){
444 $wppb_generalSettings = get_option( 'wppb_general_settings' );
445 if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
446 $password_strength = '<span id="pass-strength-result">'.__('Strength indicator', 'profilebuilder' ).'</span>
447 <input type="hidden" value="" name="wppb_password_strength" id="wppb_password_strength"/>';
448 return $password_strength;
449 }
450 return '';
451 }
452
453 //function to check password length check
454 function wppb_check_password_length( $password ){
455 $wppb_generalSettings = get_option( 'wppb_general_settings' );
456 if( !empty( $wppb_generalSettings['minimum_password_length'] ) ){
457 if( strlen( $password ) < $wppb_generalSettings['minimum_password_length'] ){
458 return true;
459 }
460 else
461 return false;
462 }
463 return false;
464 }
465
466 //function to check password strength
467 function wppb_check_password_strength(){
468 $wppb_generalSettings = get_option( 'wppb_general_settings' );
469 if( isset( $_POST['wppb_password_strength'] ) && !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
470 $password_strength_array = array( 'short' => 0, 'bad' => 1, 'good' => 2, 'strong' => 3 );
471 $password_strength_text = array( 'short' => __( 'Very Weak', 'profilebuilder' ), 'bad' => __( 'Weak', 'profilebuilder' ), 'good' => __( 'Medium', 'profilebuilder' ), 'strong' => __( 'Strong', 'profilebuilder' ) );
472 if( $password_strength_array[$_POST['wppb_password_strength']] < $password_strength_array[$wppb_generalSettings['minimum_password_strength']] ){
473 return $password_strength_text[$wppb_generalSettings['minimum_password_strength']];
474 }
475 else
476 return false;
477 }
478 return false;
479 }
480
481 /* function to output password length requirements text */
482 function wppb_password_length_text(){
483 $wppb_generalSettings = get_option( 'wppb_general_settings' );
484 if( !empty( $wppb_generalSettings['minimum_password_length'] ) ){
485 return sprintf(__('Minimum length of %d characters', 'profilebuilder'), $wppb_generalSettings['minimum_password_length']);
486 }
487 return '';
488 }
489
490 /**
491 * Include password strength check scripts on frontend where we have shortoces present
492 */
493 add_action( 'wp_footer', 'wppb_enqueue_password_strength_check' );
494 function wppb_enqueue_password_strength_check() {
495 global $wppb_shortcode_on_front;
496 if( $wppb_shortcode_on_front ){
497 $wppb_generalSettings = get_option( 'wppb_general_settings' );
498 if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
499 wp_enqueue_script( 'password-strength-meter' );
500 }
501 }
502 }
503 add_action( 'wp_footer', 'wppb_password_strength_check', 102 );
504 function wppb_password_strength_check(){
505 global $wppb_shortcode_on_front;
506 if( $wppb_shortcode_on_front ){
507 $wppb_generalSettings = get_option( 'wppb_general_settings' );
508 if( !empty( $wppb_generalSettings['minimum_password_strength'] ) ){
509 ?>
510 <script type="text/javascript">
511 function check_pass_strength() {
512 var pass1 = jQuery('#passw1').val(), pass2 = jQuery('#passw2').val(), strength;
513
514 jQuery('#pass-strength-result').removeClass('short bad good strong');
515 if ( ! pass1 ) {
516 jQuery('#pass-strength-result').html( pwsL10n.empty );
517 return;
518 }
519
520 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );
521
522 switch ( strength ) {
523 case 2:
524 jQuery('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
525 jQuery('#wppb_password_strength').val('bad');
526 break;
527 case 3:
528 jQuery('#pass-strength-result').addClass('good').html( pwsL10n.good );
529 jQuery('#wppb_password_strength').val('good');
530 break;
531 case 4:
532 jQuery('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
533 jQuery('#wppb_password_strength').val('strong');
534 break;
535 case 5:
536 jQuery('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
537 jQuery('#wppb_password_strength').val('short');
538 break;
539 default:
540 jQuery('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
541 jQuery('#wppb_password_strength').val('short');
542 }
543 }
544 jQuery( document ).ready( function() {
545 // Binding to trigger checkPasswordStrength
546 jQuery('#passw1').val('').keyup( check_pass_strength );
547 jQuery('#passw2').val('').keyup( check_pass_strength );
548 jQuery('#pass-strength-result').show();
549 });
550 </script>
551 <?php
552 }
553 }
554 }
555 /**
556 * Create functions for repeating error messages in front-end forms
557 */
558 function wppb_required_field_error($field_title='') {
559 $required_error = apply_filters('wppb_required_error' , __('This field is required','profilebuilder') , $field_title);
560
561 return $required_error;
562
563 }
564
565 /* Create a wrapper function for get_query_var */
566 function wppb_get_query_var( $varname ){
567 return apply_filters( 'wppb_get_query_var_'.$varname, get_query_var( $varname ) );
568 }
569
570 /*Filter the "Save Changes" button text, to make it translatable*/
571 function wppb_change_save_changes_button($value){
572 $value = __('Save Changes','profilebuilder');
573 return $value;
574 }
575 add_filter( 'wck_save_changes_button', 'wppb_change_save_changes_button', 10, 2);
576
577 /*Filter the "Cancel" button text, to make it translatable*/
578 function wppb_change_cancel_button($value){
579 $value = __('Cancel','profilebuilder');
580 return $value;
581 }
582 add_filter( 'wck_cancel_button', 'wppb_change_cancel_button', 10, 2);
583
584 /*Filter the "Delete" button text, to make it translatable*/
585 function wppb_change_delete_button($value){
586 $value = __('Delete','profilebuilder');
587 return $value;
588 }
589 add_filter( 'wck_delete_button', 'wppb_change_delete_button', 10, 2);
590
591 /*Filter the "Edit" button text, to make it translatable*/
592 function wppb_change_edit_button($value){
593 $value = __('Edit','profilebuilder');
594 return $value;
595 }
596 add_filter( 'wck_edit_button', 'wppb_change_edit_button', 10, 2);
597
598 /*Filter the User Listing, Register Forms and Edit Profile forms metabox header content, to make it translatable*/
599 function wppb_change_metabox_content_header(){
600 return '<thead><tr><th class="wck-number">#</th><th class="wck-content">'. __( 'Content', 'profilebuilder' ) .'</th><th class="wck-edit">'. __( 'Edit', 'profilebuilder' ) .'</th><th class="wck-delete">'. __( 'Delete', 'profilebuilder' ) .'</th></tr></thead>';
601 }
602 add_filter('wck_metabox_content_header_wppb_ul_page_settings', 'wppb_change_metabox_content_header', 1);
603 add_filter('wck_metabox_content_header_wppb_rf_page_settings', 'wppb_change_metabox_content_header', 1);
604 add_filter('wck_metabox_content_header_wppb_epf_page_settings', 'wppb_change_metabox_content_header', 1);
605
606
607 /* Add a notice if people are not able to register via Profile Builder; Membership -> "Anyone can register" checkbox is not checked under WordPress admin UI -> Settings -> General tab */
608 if ( get_option('users_can_register') == false) {
609 new WPPB_Add_General_Notices('wppb_anyone_can_register',
610 sprintf(__('To allow users to register for your website via Profile Builder, you first must enable user registration. Go to %1$sSettings -> General%2$s tab, and under Membership make sure to check “Anyone can register”. %3$sDismiss%4$s', 'profilebuilder'), "<a href='".get_site_url()."/wp-admin/options-general.php'>", "</a>", "<a href='" . add_query_arg('wppb_anyone_can_register_dismiss_notification', '0') . "'>", "</a>"),
611 'update-nag');
612 }
613
614 /*Filter default WordPress notices ("Post published. Post updated."), add post type name for User Listing, Registration Forms and Edit Profile Forms*/
615 function wppb_change_default_post_updated_messages($messages){
616 global $post;
617 $post_type = get_post_type($post->ID);
618 $object = get_post_type_object($post_type);
619
620 if ( ($post_type == 'wppb-rf-cpt')||($post_type == 'wppb-epf-cpt')||($post_type == 'wppb-ul-cpt') ){
621 $messages['post'][1] = $object->labels->name . ' updated.';
622 $messages['post'][6] = $object->labels->name . ' published.';
623 }
624 return $messages;
625 }
626 add_filter('post_updated_messages','wppb_change_default_post_updated_messages', 2);