PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 1.1.7
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v1.1.7
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
profile-builder / functions / functions.load.php

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

219 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (!defined('ProfileBuilderVersion')) exit('No direct script access allowed');
2 /*
3 Original Plugin Name: OptionTree
4 Original Plugin URI: http://wp.envato.com
5 Original Author: Derek Herman
6 Original Author URI: http://valendesigns.com
7 */
8
9 /**
10 * Functions Load
11 *
12 */
13 /* whitelist options, you can add more register_settings changing the second parameter */
14
15 function wppb_register_settings() {
16 $premiumPresent = wppb_plugin_dir . '/premium/premium.php';
17 $addonPresent = wppb_plugin_dir . '/premium/addon/addon.php';
18
19 register_setting( 'wppb_option_group', 'wppb_default_settings' );
20 register_setting( 'wppb_default_style', 'wppb_default_style' );
21 register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
22 if (file_exists($premiumPresent)){
23 register_setting( 'wppb_profile_builder_pro_serial', 'wppb_profile_builder_pro_serial' );
24 }
25 if (file_exists($addonPresent)){
26 register_setting( 'wppb_premium_addon_settings', 'wppb_premium_addon_settings' );
27 register_setting( 'customRedirectSettings', 'customRedirectSettings' );
28 register_setting( 'userListingSettings', 'userListingSettings' );
29 }
30
31
32 }
33
34
35 function wppb_add_plugin_stylesheet() {
36 $wppb_showDefaultCss = get_option('wppb_default_style');
37 $styleUrl_default = wppb_plugin_url . '/assets/css/front.end.css';
38 $styleUrl_white = wppb_plugin_url . '/premium/assets/css/front.end.white.css';
39 $styleUrl_black = wppb_plugin_url . '/premium/assets/css/front.end.black.css';
40 $styleFile_default = wppb_plugin_dir . '/assets/css/front.end.css';
41 $styleFile_white = wppb_plugin_dir . '/premium/assets/css/front.end.white.css';
42 $styleFile_black = wppb_plugin_dir . '/premium/assets/css/front.end.black.css';
43 if ( (file_exists($styleFile_default)) && ($wppb_showDefaultCss == 'yes') ) {
44 wp_register_style('wppb_stylesheet', $styleUrl_default);
45 wp_enqueue_style( 'wppb_stylesheet');
46 }elseif ( (file_exists($styleFile_white)) && ($wppb_showDefaultCss == 'white') ) {
47 wp_register_style('wppb_stylesheet', $styleUrl_white);
48 wp_enqueue_style( 'wppb_stylesheet');
49 }elseif ( (file_exists($styleFile_black)) && ($wppb_showDefaultCss == 'black') ) {
50 wp_register_style('wppb_stylesheet', $styleUrl_black);
51 wp_enqueue_style( 'wppb_stylesheet');
52 }
53 }
54
55
56 function wppb_show_admin_bar($content){
57 global $current_user;
58 $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
59 if ($admintSettingsPresent != 'not_found'){
60 $wppb_showAdminBar = get_option('wppb_display_admin_settings');
61 if ($current_user->ID != 0){
62 $userRole = ($current_user->data->wp_capabilities);
63 if ($userRole != NULL){
64 $currentRole = key($userRole);
65 $getSettings = $wppb_showAdminBar[$currentRole];
66 if ($getSettings == 'show')
67 return true;
68 elseif ($getSettings == 'hide')
69 return false;
70 }
71 }
72 }
73 else
74 return true;
75 }
76
77 if(!function_exists('curPageURL')){
78 function curPageURL() {
79 $pageURL = 'http';
80 if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on")) {
81 $pageURL .= "s";
82 }
83 $pageURL .= "://";
84 if ($_SERVER["SERVER_PORT"] != "80") {
85 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
86 } else {
87 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
88 }
89 return $pageURL;
90 }
91 }
92
93
94 if ( is_admin() ){
95 /* include the css for the datepicker */
96 $wppb_premiumDatepicker = wppb_plugin_dir . '/premium/assets/css/';
97 if (file_exists ( $wppb_premiumDatepicker.'admin.style.css' ))
98 wp_enqueue_style( 'profile-builder-admin-datepicker-style', wppb_plugin_url.'/premium/assets/css/admin.style.css', false, ProfileBuilderVersion);
99
100
101
102 /* register the settings for the menu only display sidebar menu for a user with a certain capability, in this case only the "admin" */
103 add_action('admin_init', 'wppb_register_settings');
104
105 $wppb_premiumAdmin = wppb_plugin_dir . '/premium/functions/';
106 if (file_exists ( $wppb_premiumAdmin.'premium.functions.load.php' )){
107 include_once($wppb_premiumAdmin.'premium.functions.load.php');
108
109 /* check whether a delete attachment has been requested */
110 add_action('admin_init', 'deleteAttachment');
111
112 /* check whether a delete avatar has been requested */
113 add_action('admin_init', 'deleteAvatar');
114
115 }
116
117
118 /* display the same extra profile fields in the admin panel also */
119 $wppb_premium = wppb_plugin_dir . '/premium/functions/';
120 if (file_exists ( $wppb_premium.'extra.fields.php' )){
121 include( $wppb_premium.'extra.fields.php' );
122 add_action( 'show_user_profile', 'display_profile_extra_fields', 10 );
123 add_action( 'edit_user_profile', 'display_profile_extra_fields', 10 );
124 add_action( 'personal_options_update', 'save_extra_profile_fields', 10 );
125 add_action( 'edit_user_profile_update', 'save_extra_profile_fields', 10 );
126
127 /* check to see if the inserted serial number is valid or not; purely for visual needs */
128 add_action('admin_init', 'wppb_check_serial_number');
129 }
130
131 }
132 else if ( !is_admin() ){
133 //check if the plugin has the addons module
134 $addonPresent = wppb_plugin_dir . '/premium/addon/addon.php';
135 if (file_exists($addonPresent)){
136 //check if the required action was the "wordpress register new user" or the login
137 $wpLogin = curPageURL();
138 $findLoginPage = strpos($wpLogin, 'wp-login.php');
139
140 if ((isset($_GET['action'])) && ($_GET['action'] == 'register')){
141 //check to see if it's been requested a redirect on this page
142 $customRedirectSettings = get_option('customRedirectSettings','not_found');
143 if ($customRedirectSettings != 'not_found'){
144 if (($customRedirectSettings['registerRedirect'] == 'yes') && (trim($customRedirectSettings['registerRedirectTarget']) != '')){
145 $redirectLink = trim($customRedirectSettings['registerRedirectTarget']);
146 include ('wp-includes/pluggable.php');
147 $findHttp = strpos($redirectLink, 'http');
148 if ($findHttp === false)
149 wp_redirect( 'http://'.$redirectLink );
150 else wp_redirect( $redirectLink );
151 exit;
152 }
153 }
154 //}elseif (($findLoginPage !== false) && ( isset($_GET['action']) && (($_GET['action'] != 'logout') || ($_GET['action'] != 'lostpassword') ))){
155 }elseif (($findLoginPage !== false) && (($_GET['action'] != 'logout') && ($_GET['action'] != 'lostpassword'))) {
156 $customRedirectSettings = get_option('customRedirectSettings','not_found');
157 if ($customRedirectSettings != 'not_found'){
158 if (($customRedirectSettings['loginRedirect'] == 'yes') && (trim($customRedirectSettings['loginRedirectTarget']) != '')){
159 $redirectLink = trim($customRedirectSettings['loginRedirectTarget']);
160 include ('wp-includes/pluggable.php');
161 $findHttp = strpos($redirectLink, 'http');
162 if ($findHttp === false)
163 wp_redirect( 'http://'.$redirectLink );
164 else wp_redirect( $redirectLink );
165 exit;
166 }
167 }
168 }
169
170 }
171
172 /* include the stylesheet */
173 add_action('wp_print_styles', 'wppb_add_plugin_stylesheet');
174
175 $wppb_plugin = wppb_plugin_dir . '/';
176
177 /* include the menu file for the profile informations */
178 include_once($wppb_plugin.'front-end/wppb.edit.profile.php');
179 add_shortcode('wppb-edit-profile', 'wppb_front_end_profile_info');
180
181 /*include the menu file for the login screen */
182 include_once($wppb_plugin.'front-end/wppb.login.php');
183 add_shortcode('wppb-login', 'wppb_front_end_login');
184
185 /* include the menu file for the register screen */
186 include_once($wppb_plugin.'front-end/wppb.register.php');
187 add_shortcode('wppb-register', 'wppb_front_end_register');
188
189 /* set the front-end admin bar to show/hide */
190 add_filter( 'show_admin_bar' , 'wppb_show_admin_bar');
191
192 /* Shortcodes used for the widget area. Just uncomment whichever you need */
193 add_filter('widget_text', 'do_shortcode', 11);
194
195 /* check to see if the premium functions are present */
196 $wppb_premiumAdmin = wppb_plugin_dir . '/premium/functions/';
197 if (file_exists ( $wppb_premiumAdmin.'premium.functions.load.php' )){
198
199 include_once($wppb_premiumAdmin.'premium.functions.load.php');
200
201 /* filter to set current users custom avatar */
202 add_filter('get_avatar', 'changeDefaultAvatar', 21, 5);
203
204 /* check if there is a need to resize the current avatar image for all the users*/
205 add_action('init', 'wppb_resize_avatar');
206 }
207
208 $wppb_premiumAddon = wppb_plugin_dir . '/premium/addon/';
209 if (file_exists ( $wppb_premiumAddon.'addon.functions.php' )){
210 //include the file containing the addon functions
211 include_once($wppb_premiumAddon.'addon.functions.php');
212
213 $wppb_addonOptions = get_option('wppb_premium_addon_settings');
214 if ($wppb_addonOptions['userListing'] == 'show'){
215 //add shortcode for the user-listing functionality
216 add_shortcode('wppb-list-users', 'wppb_list_all_users');
217 }
218 }
219 }