| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Profile Builder |
| 4 |
Plugin URI: https://www.cozmoslabs.com/wordpress-profile-builder/ |
| 5 |
Description: Login, registration and edit profile shortcodes for the front-end. Also you can chose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard. |
| 6 |
Version: 2.6.2 |
| 7 |
Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel, Mihai Iova |
| 8 |
Author URI: https://www.cozmoslabs.com/ |
| 9 |
License: GPL2 |
| 10 |
|
| 11 |
== Copyright == |
| 12 |
Copyright 2014 Cozmoslabs (www.cozmoslabs.com) |
| 13 |
|
| 14 |
This program is free software; you can redistribute it and/or modify |
| 15 |
it under the terms of the GNU General Public License as published by |
| 16 |
the Free Software Foundation; either version 2 of the License, or |
| 17 |
(at your option) any later version. |
| 18 |
This program is distributed in the hope that it will be useful, |
| 19 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
GNU General Public License for more details. |
| 22 |
You should have received a copy of the GNU General Public License |
| 23 |
along with this program; if not, write to the Free Software |
| 24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
*/ |
| 26 |
|
| 27 |
/* Check if another version of Profile Builder is activated, to prevent fatal errors*/ |
| 28 |
function wppb_free_plugin_init() { |
| 29 |
if (function_exists('wppb_return_bytes')) { |
| 30 |
function wppb_admin_notice() |
| 31 |
{ |
| 32 |
?> |
| 33 |
<div class="error"> |
| 34 |
<p><?php _e( PROFILE_BUILDER . ' is also activated. You need to deactivate it before activating this version of the plugin.', 'profile-builder'); ?></p> |
| 35 |
</div> |
| 36 |
<?php |
| 37 |
} |
| 38 |
function wppb_plugin_deactivate() { |
| 39 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 40 |
unset($_GET['activate']); |
| 41 |
} |
| 42 |
|
| 43 |
add_action('admin_notices', 'wppb_admin_notice'); |
| 44 |
add_action( 'admin_init', 'wppb_plugin_deactivate' ); |
| 45 |
} else { |
| 46 |
|
| 47 |
/** |
| 48 |
* Convert memory value from ini file to a readable form |
| 49 |
* |
| 50 |
* @since v.1.0 |
| 51 |
* |
| 52 |
* @return integer |
| 53 |
*/ |
| 54 |
function wppb_return_bytes($val) |
| 55 |
{ |
| 56 |
$val = trim($val); |
| 57 |
|
| 58 |
switch (strtolower($val[strlen($val) - 1])) { |
| 59 |
// The 'G' modifier is available since PHP 5.1.0 |
| 60 |
case 'g': |
| 61 |
$val = intval($val) * 1024; |
| 62 |
case 'm': |
| 63 |
$val = intval($val) * 1024; |
| 64 |
case 'k': |
| 65 |
$val = intval($val) * 1024; |
| 66 |
} |
| 67 |
|
| 68 |
return $val; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Definitions |
| 73 |
* |
| 74 |
* |
| 75 |
*/ |
| 76 |
define('PROFILE_BUILDER_VERSION', '2.6.2' ); |
| 77 |
define('WPPB_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
| 78 |
define('WPPB_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 79 |
define('WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE', apply_filters('wppb_server_max_upload_size_byte_constant', wppb_return_bytes(ini_get('upload_max_filesize')))); |
| 80 |
define('WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA', apply_filters('wppb_server_max_upload_size_mega_constant', ini_get('upload_max_filesize'))); |
| 81 |
define('WPPB_SERVER_MAX_POST_SIZE_BYTE', apply_filters('wppb_server_max_post_size_byte_constant', wppb_return_bytes(ini_get('post_max_size')))); |
| 82 |
define('WPPB_SERVER_MAX_POST_SIZE_MEGA', apply_filters('wppb_server_max_post_size_mega_constant', ini_get('post_max_size'))); |
| 83 |
define('WPPB_TRANSLATE_DIR', WPPB_PLUGIN_DIR . '/translation'); |
| 84 |
define('WPPB_TRANSLATE_DOMAIN', 'profile-builder'); |
| 85 |
|
| 86 |
/* include notices class */ |
| 87 |
if (file_exists(WPPB_PLUGIN_DIR . '/assets/lib/class_notices.php')) |
| 88 |
include_once(WPPB_PLUGIN_DIR . '/assets/lib/class_notices.php'); |
| 89 |
|
| 90 |
if (file_exists(WPPB_PLUGIN_DIR . '/modules/modules.php')) |
| 91 |
define('PROFILE_BUILDER', 'Profile Builder Pro'); |
| 92 |
elseif (file_exists(WPPB_PLUGIN_DIR . '/front-end/extra-fields/extra-fields.php')) |
| 93 |
define('PROFILE_BUILDER', 'Profile Builder Hobbyist'); |
| 94 |
else |
| 95 |
define('PROFILE_BUILDER', 'Profile Builder Free'); |
| 96 |
|
| 97 |
/** |
| 98 |
* Initialize the translation for the Plugin. |
| 99 |
* |
| 100 |
* @since v.1.0 |
| 101 |
* |
| 102 |
* @return null |
| 103 |
*/ |
| 104 |
function wppb_init_translation() |
| 105 |
{ |
| 106 |
$current_theme = wp_get_theme(); |
| 107 |
if( !empty( $current_theme->stylesheet ) && file_exists( get_theme_root().'/'. $current_theme->stylesheet .'/local_pb_lang' ) ) |
| 108 |
load_plugin_textdomain( 'profile-builder', false, basename( dirname( __FILE__ ) ).'/../../themes/'.$current_theme->stylesheet.'/local_pb_lang' ); |
| 109 |
else |
| 110 |
load_plugin_textdomain( 'profile-builder', false, basename(dirname(__FILE__)) . '/translation/' ); |
| 111 |
} |
| 112 |
|
| 113 |
add_action('init', 'wppb_init_translation', 8); |
| 114 |
|
| 115 |
|
| 116 |
/** |
| 117 |
* Required files |
| 118 |
* |
| 119 |
* |
| 120 |
*/ |
| 121 |
include_once(WPPB_PLUGIN_DIR . '/assets/lib/wck-api/wordpress-creation-kit.php'); |
| 122 |
include_once(WPPB_PLUGIN_DIR . '/features/upgrades/upgrades.php'); |
| 123 |
include_once(WPPB_PLUGIN_DIR . '/features/functions.php'); |
| 124 |
include_once(WPPB_PLUGIN_DIR . '/admin/admin-functions.php'); |
| 125 |
include_once(WPPB_PLUGIN_DIR . '/admin/basic-info.php'); |
| 126 |
include_once(WPPB_PLUGIN_DIR . '/admin/general-settings.php'); |
| 127 |
include_once(WPPB_PLUGIN_DIR . '/admin/admin-bar.php'); |
| 128 |
include_once(WPPB_PLUGIN_DIR . '/admin/manage-fields.php'); |
| 129 |
include_once(WPPB_PLUGIN_DIR . '/admin/pms-cross-promotion.php'); |
| 130 |
include_once(WPPB_PLUGIN_DIR . '/features/email-confirmation/email-confirmation.php'); |
| 131 |
include_once(WPPB_PLUGIN_DIR . '/features/email-confirmation/class-email-confirmation.php'); |
| 132 |
if (file_exists(WPPB_PLUGIN_DIR . '/features/admin-approval/admin-approval.php')) { |
| 133 |
include_once(WPPB_PLUGIN_DIR . '/features/admin-approval/admin-approval.php'); |
| 134 |
include_once(WPPB_PLUGIN_DIR . '/features/admin-approval/class-admin-approval.php'); |
| 135 |
} |
| 136 |
if (file_exists(WPPB_PLUGIN_DIR . '/features/conditional-fields/conditional-fields.php')) { |
| 137 |
include_once(WPPB_PLUGIN_DIR . '/features/conditional-fields/conditional-fields.php'); |
| 138 |
} |
| 139 |
include_once(WPPB_PLUGIN_DIR . '/features/login-widget/login-widget.php'); |
| 140 |
include_once(WPPB_PLUGIN_DIR . '/features/roles-editor/roles-editor.php'); |
| 141 |
|
| 142 |
if (file_exists(WPPB_PLUGIN_DIR . '/update/update-checker.php')) { |
| 143 |
include_once(WPPB_PLUGIN_DIR . '/update/update-checker.php'); |
| 144 |
include_once(WPPB_PLUGIN_DIR . '/admin/register-version.php'); |
| 145 |
} |
| 146 |
|
| 147 |
if (file_exists(WPPB_PLUGIN_DIR . '/modules/modules.php')) { |
| 148 |
include_once(WPPB_PLUGIN_DIR . '/modules/modules.php'); |
| 149 |
include_once(WPPB_PLUGIN_DIR . '/modules/repeater-field/repeater-module.php'); |
| 150 |
include_once(WPPB_PLUGIN_DIR . '/modules/custom-redirects/custom-redirects.php'); |
| 151 |
include_once(WPPB_PLUGIN_DIR . '/modules/email-customizer/email-customizer.php'); |
| 152 |
include_once(WPPB_PLUGIN_DIR . '/modules/multiple-forms/multiple-forms.php'); |
| 153 |
include_once(WPPB_PLUGIN_DIR . '/modules/user-listing/userlisting.php'); |
| 154 |
|
| 155 |
$wppb_module_settings = get_option('wppb_module_settings'); |
| 156 |
if (isset($wppb_module_settings['wppb_userListing']) && ($wppb_module_settings['wppb_userListing'] == 'show')) { |
| 157 |
add_shortcode('wppb-list-users', 'wppb_user_listing_shortcode'); |
| 158 |
} else |
| 159 |
add_shortcode('wppb-list-users', 'wppb_list_all_users_display_error'); |
| 160 |
|
| 161 |
if (isset($wppb_module_settings['wppb_emailCustomizerAdmin']) && ($wppb_module_settings['wppb_emailCustomizerAdmin'] == 'show')) |
| 162 |
include_once(WPPB_PLUGIN_DIR . '/modules/email-customizer/admin-email-customizer.php'); |
| 163 |
|
| 164 |
if (isset($wppb_module_settings['wppb_emailCustomizer']) && ($wppb_module_settings['wppb_emailCustomizer'] == 'show')) |
| 165 |
include_once(WPPB_PLUGIN_DIR . '/modules/email-customizer/user-email-customizer.php'); |
| 166 |
} |
| 167 |
|
| 168 |
include_once(WPPB_PLUGIN_DIR . '/admin/add-ons.php'); |
| 169 |
include_once(WPPB_PLUGIN_DIR . '/assets/misc/plugin-compatibilities.php'); |
| 170 |
|
| 171 |
/* added recaptcha and user role field since version 2.6.2 */ |
| 172 |
include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/recaptcha/recaptcha.php'); //need to load this here for displaying reCAPTCHA on Login and Recover Password forms |
| 173 |
|
| 174 |
|
| 175 |
/** |
| 176 |
* Check for updates |
| 177 |
* |
| 178 |
* |
| 179 |
*/ |
| 180 |
if (file_exists(WPPB_PLUGIN_DIR . '/update/update-checker.php')) { |
| 181 |
if (file_exists(WPPB_PLUGIN_DIR . '/modules/modules.php')) { |
| 182 |
$localSerial = get_option('wppb_profile_builder_pro_serial'); |
| 183 |
$wppb_update = new wppb_PluginUpdateChecker('http://updatemetadata.cozmoslabs.com/?localSerialNumber=' . $localSerial . '&uniqueproduct=CLPBP', __FILE__, 'profile-builder-pro-update'); |
| 184 |
|
| 185 |
} else { |
| 186 |
$localSerial = get_option('wppb_profile_builder_hobbyist_serial'); |
| 187 |
$wppb_update = new wppb_PluginUpdateChecker('http://updatemetadata.cozmoslabs.com/?localSerialNumber=' . $localSerial . '&uniqueproduct=CLPBH', __FILE__, 'profile-builder-hobbyist-update'); |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
// these settings are important, so besides running them on page load, we also need to do a check on plugin activation |
| 193 |
add_action('init', 'wppb_generate_default_settings_defaults'); //prepoulate general settings |
| 194 |
add_action('init', 'wppb_prepopulate_fields'); //prepopulate manage fields list |
| 195 |
|
| 196 |
} |
| 197 |
} //end wppb_free_plugin_init |
| 198 |
add_action( 'plugins_loaded', 'wppb_free_plugin_init' ); |
| 199 |
|
| 200 |
if (file_exists( plugin_dir_path(__FILE__) . '/front-end/extra-fields/upload/upload_helper_functions.php')) |
| 201 |
include_once( plugin_dir_path(__FILE__) . '/front-end/extra-fields/upload/upload_helper_functions.php'); |