| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: Profile Builder |
| 4 | -Plugin URI: http://www.cozmoslabs.com/wordpress-profile-builder/ | |
| 4 | +Plugin URI: https://www.cozmoslabs.com/wordpress-profile-builder/ | |
| 5 | 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.0.2 | |
| 7 | -Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel | |
| 8 | -Author URI: http://www.cozmoslabs.com/ | |
| 6 | +Version: 2.7.1 | |
| 7 | +Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel, Mihai Iova | |
| 8 | +Author URI: https://www.cozmoslabs.com/ | |
| 9 | 9 | License: GPL2 |
| 10 | 10 | |
| 11 | 11 | == Copyright == |
| 12 | 12 | Copyright 2014 Cozmoslabs (www.cozmoslabs.com) |
| @@ -23,130 +23,180 @@ | ||
| 23 | 23 | along with this program; if not, write to the Free Software |
| 24 | 24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -/** | |
| 28 | - * Convert memory value from ini file to a readable form | |
| 29 | - * | |
| 30 | - * @since v.1.0 | |
| 31 | - * | |
| 32 | - * @return integer | |
| 33 | - */ | |
| 34 | -function wppb_return_bytes( $val ) { | |
| 35 | - $val = trim( $val ); | |
| 36 | - | |
| 37 | - switch( strtolower( $val[strlen( $val )-1] ) ) { | |
| 38 | - // The 'G' modifier is available since PHP 5.1.0 | |
| 39 | - case 'g': | |
| 40 | - $val *= 1024; | |
| 41 | - case 'm': | |
| 42 | - $val *= 1024; | |
| 43 | - case 'k': | |
| 44 | - $val *= 1024; | |
| 45 | - } | |
| 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 | + } | |
| 46 | 42 | |
| 47 | - return $val; | |
| 48 | -} | |
| 43 | + add_action('admin_notices', 'wppb_admin_notice'); | |
| 44 | + add_action( 'admin_init', 'wppb_plugin_deactivate' ); | |
| 45 | + } else { | |
| 49 | 46 | |
| 50 | -/** | |
| 51 | - * Definitions | |
| 52 | - * | |
| 53 | - * | |
| 54 | - */ | |
| 55 | -define( 'PROFILE_BUILDER_VERSION', '2.0.2' ); | |
| 56 | -define( 'WPPB_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) ); | |
| 57 | -define( 'WPPB_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); | |
| 58 | -define( 'WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE', apply_filters( 'wppb_server_max_upload_size_byte_constant', wppb_return_bytes( ini_get( 'upload_max_filesize') ) ) ); | |
| 59 | -define( 'WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA', apply_filters( 'wppb_server_max_upload_size_mega_constant', ini_get( 'upload_max_filesize') ) ); | |
| 60 | -define( 'WPPB_SERVER_MAX_POST_SIZE_BYTE', apply_filters( 'wppb_server_max_post_size_byte_constant', wppb_return_bytes( ini_get( 'post_max_size') ) ) ); | |
| 61 | -define( 'WPPB_SERVER_MAX_POST_SIZE_MEGA', apply_filters( 'wppb_server_max_post_size_mega_constant', ini_get( 'post_max_size') ) ); | |
| 62 | -define( 'WPPB_TRANSLATE_DIR', WPPB_PLUGIN_DIR.'/translation' ); | |
| 63 | -define( 'WPPB_TRANSLATE_DOMAIN', 'profilebuilder' ); | |
| 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); | |
| 64 | 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 | + } | |
| 65 | 67 | |
| 66 | -if ( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ) | |
| 67 | - define( 'PROFILE_BUILDER', 'Profile Builder Pro' ); | |
| 68 | -elseif ( file_exists ( WPPB_PLUGIN_DIR.'/front-end/extra-fields/extra-fields.php' ) ) | |
| 69 | - define( 'PROFILE_BUILDER', 'Profile Builder Hobbyist' ); | |
| 70 | -else | |
| 71 | - define( 'PROFILE_BUILDER', 'Profile Builder Free' ); | |
| 68 | + return $val; | |
| 69 | + } | |
| 72 | 70 | |
| 73 | -/** | |
| 74 | - * Initialize the translation for the Plugin. | |
| 75 | - * | |
| 76 | - * @since v.1.0 | |
| 77 | - * | |
| 78 | - * @return null | |
| 79 | - */ | |
| 80 | -function wppb_init_translation(){ | |
| 81 | - load_plugin_textdomain( 'profilebuilder', false, basename( dirname( __FILE__ ) ) . '/translation/' ); | |
| 82 | -} | |
| 83 | -add_action( 'init', 'wppb_init_translation' ); | |
| 71 | + /** | |
| 72 | + * Definitions | |
| 73 | + * | |
| 74 | + * | |
| 75 | + */ | |
| 76 | + define('PROFILE_BUILDER_VERSION', '2.7.1' ); | |
| 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'); | |
| 84 | 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'); | |
| 85 | 89 | |
| 86 | -/** | |
| 87 | - * Required files | |
| 88 | - * | |
| 89 | - * | |
| 90 | - */ | |
| 91 | -include_once( WPPB_PLUGIN_DIR.'/assets/lib/wck-api/wordpress-creation-kit.php' ); | |
| 92 | -include_once( WPPB_PLUGIN_DIR.'/features/upgrades/upgrades.php' ); | |
| 93 | -include_once( WPPB_PLUGIN_DIR.'/features/functions.php' ); | |
| 94 | -include_once( WPPB_PLUGIN_DIR.'/admin/admin-functions.php' ); | |
| 95 | -include_once( WPPB_PLUGIN_DIR.'/admin/basic-info.php' ); | |
| 96 | -include_once( WPPB_PLUGIN_DIR.'/admin/general-settings.php' ); | |
| 97 | -include_once( WPPB_PLUGIN_DIR.'/admin/admin-bar.php' ); | |
| 98 | -include_once( WPPB_PLUGIN_DIR.'/admin/manage-fields.php' ); | |
| 99 | -include_once( WPPB_PLUGIN_DIR.'/features/email-confirmation/email-confirmation.php' ); | |
| 100 | -include_once( WPPB_PLUGIN_DIR.'/features/email-confirmation/class-email-confirmation.php' ); | |
| 101 | -if ( file_exists ( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ) { | |
| 102 | - include_once(WPPB_PLUGIN_DIR . '/features/admin-approval/admin-approval.php'); | |
| 103 | - include_once(WPPB_PLUGIN_DIR . '/features/admin-approval/class-admin-approval.php'); | |
| 104 | -} | |
| 105 | -include_once( WPPB_PLUGIN_DIR.'/features/login-widget/login-widget.php' ); | |
| 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'); | |
| 106 | 96 | |
| 107 | -if ( file_exists ( WPPB_PLUGIN_DIR.'/update/update-checker.php' ) ){ | |
| 108 | - include_once ( WPPB_PLUGIN_DIR.'/update/update-checker.php' ); | |
| 109 | - include_once ( WPPB_PLUGIN_DIR.'/admin/register-version.php' ); | |
| 110 | -} | |
| 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 | + } | |
| 111 | 112 | |
| 112 | -if ( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ){ | |
| 113 | - include_once ( WPPB_PLUGIN_DIR.'/modules/modules.php' ); | |
| 114 | - include_once ( WPPB_PLUGIN_DIR.'/modules/custom-redirects/custom-redirects.php' ); | |
| 115 | - include_once ( WPPB_PLUGIN_DIR.'/modules/email-customizer/email-customizer.php' ); | |
| 116 | - include_once ( WPPB_PLUGIN_DIR.'/modules/multiple-forms/multiple-forms.php' ); | |
| 117 | - | |
| 118 | - $wppb_module_settings = get_option( 'wppb_module_settings' ); | |
| 119 | - if ( isset( $wppb_module_settings['wppb_userListing'] ) && ( $wppb_module_settings['wppb_userListing'] == 'show' ) ){ | |
| 120 | - include_once ( WPPB_PLUGIN_DIR.'/modules/user-listing/userlisting.php' ); | |
| 121 | - add_shortcode( 'wppb-list-users', 'wppb_user_listing_shortcode' ); | |
| 122 | - }else | |
| 123 | - add_shortcode( 'wppb-list-users', 'wppb_list_all_users_display_error' ); | |
| 124 | - | |
| 125 | - if ( isset( $wppb_module_settings['wppb_emailCustomizerAdmin'] ) && ( $wppb_module_settings['wppb_emailCustomizerAdmin'] == 'show' ) ) | |
| 126 | - include_once ( WPPB_PLUGIN_DIR.'/modules/email-customizer/admin-email-customizer.php' ); | |
| 127 | - | |
| 128 | - if ( isset( $wppb_module_settings['wppb_emailCustomizer'] ) && ( $wppb_module_settings['wppb_emailCustomizer'] == 'show' ) ) | |
| 129 | - include_once ( WPPB_PLUGIN_DIR.'/modules/email-customizer/user-email-customizer.php' ); | |
| 130 | -} | |
| 113 | + add_action('init', 'wppb_init_translation', 8); | |
| 131 | 114 | |
| 132 | 115 | |
| 133 | -/** | |
| 134 | - * Check for updates | |
| 135 | - * | |
| 136 | - * | |
| 137 | - */ | |
| 138 | -if ( file_exists ( WPPB_PLUGIN_DIR.'/update/update-checker.php' ) ){ | |
| 139 | - if ( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ){ | |
| 140 | - $localSerial = get_option( 'wppb_profile_builder_pro_serial' ); | |
| 141 | - $wppb_update = new wppb_PluginUpdateChecker( 'http://updatemetadata.cozmoslabs.com/?localSerialNumber='.$localSerial.'&uniqueproduct=CLPBP', __FILE__, 'profile-builder-pro-update' ); | |
| 142 | - | |
| 143 | - }else{ | |
| 144 | - $localSerial = get_option( 'wppb_profile_builder_hobbyist_serial' ); | |
| 145 | - $wppb_update = new wppb_PluginUpdateChecker( 'http://updatemetadata.cozmoslabs.com/?localSerialNumber='.$localSerial.'&uniqueproduct=CLPBH', __FILE__, 'profile-builder-hobbyist-update' ); | |
| 146 | - } | |
| 147 | -} | |
| 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 | + include_once(WPPB_PLUGIN_DIR . '/features/content-restriction/content-restriction.php'); | |
| 148 | 142 | |
| 143 | + if (file_exists(WPPB_PLUGIN_DIR . '/update/update-checker.php')) { | |
| 144 | + include_once(WPPB_PLUGIN_DIR . '/update/update-checker.php'); | |
| 145 | + include_once(WPPB_PLUGIN_DIR . '/admin/register-version.php'); | |
| 146 | + } | |
| 149 | 147 | |
| 148 | + if (file_exists(WPPB_PLUGIN_DIR . '/modules/modules.php')) { | |
| 149 | + include_once(WPPB_PLUGIN_DIR . '/modules/modules.php'); | |
| 150 | + include_once(WPPB_PLUGIN_DIR . '/modules/repeater-field/repeater-module.php'); | |
| 151 | + include_once(WPPB_PLUGIN_DIR . '/modules/custom-redirects/custom-redirects.php'); | |
| 152 | + include_once(WPPB_PLUGIN_DIR . '/modules/email-customizer/email-customizer.php'); | |
| 153 | + include_once(WPPB_PLUGIN_DIR . '/modules/multiple-forms/multiple-forms.php'); | |
| 154 | + include_once(WPPB_PLUGIN_DIR . '/modules/user-listing/userlisting.php'); | |
| 155 | + | |
| 156 | + $wppb_module_settings = get_option('wppb_module_settings'); | |
| 157 | + if (isset($wppb_module_settings['wppb_userListing']) && ($wppb_module_settings['wppb_userListing'] == 'show')) { | |
| 158 | + add_shortcode('wppb-list-users', 'wppb_user_listing_shortcode'); | |
| 159 | + } else | |
| 160 | + add_shortcode('wppb-list-users', 'wppb_list_all_users_display_error'); | |
| 161 | + | |
| 162 | + if (isset($wppb_module_settings['wppb_emailCustomizerAdmin']) && ($wppb_module_settings['wppb_emailCustomizerAdmin'] == 'show')) | |
| 163 | + include_once(WPPB_PLUGIN_DIR . '/modules/email-customizer/admin-email-customizer.php'); | |
| 164 | + | |
| 165 | + if (isset($wppb_module_settings['wppb_emailCustomizer']) && ($wppb_module_settings['wppb_emailCustomizer'] == 'show')) | |
| 166 | + include_once(WPPB_PLUGIN_DIR . '/modules/email-customizer/user-email-customizer.php'); | |
| 167 | + } | |
| 168 | + | |
| 169 | + include_once(WPPB_PLUGIN_DIR . '/admin/add-ons.php'); | |
| 170 | + include_once(WPPB_PLUGIN_DIR . '/assets/misc/plugin-compatibilities.php'); | |
| 171 | + | |
| 172 | + /* added recaptcha and user role field since version 2.6.2 */ | |
| 173 | + 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 | |
| 174 | + | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * Check for updates | |
| 178 | + * | |
| 179 | + * | |
| 180 | + */ | |
| 181 | + if (file_exists(WPPB_PLUGIN_DIR . '/update/update-checker.php')) { | |
| 182 | + if (file_exists(WPPB_PLUGIN_DIR . '/modules/modules.php')) { | |
| 183 | + $localSerial = get_option('wppb_profile_builder_pro_serial'); | |
| 184 | + $wppb_update = new wppb_PluginUpdateChecker('http://updatemetadata.cozmoslabs.com/?localSerialNumber=' . $localSerial . '&uniqueproduct=CLPBP', __FILE__, 'profile-builder-pro-update'); | |
| 185 | + | |
| 186 | + } else { | |
| 187 | + $localSerial = get_option('wppb_profile_builder_hobbyist_serial'); | |
| 188 | + $wppb_update = new wppb_PluginUpdateChecker('http://updatemetadata.cozmoslabs.com/?localSerialNumber=' . $localSerial . '&uniqueproduct=CLPBH', __FILE__, 'profile-builder-hobbyist-update'); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + | |
| 192 | + | |
| 150 | 193 | // these settings are important, so besides running them on page load, we also need to do a check on plugin activation |
| 151 | -register_activation_hook( __FILE__, 'wppb_generate_default_settings_defaults' ); //prepoulate general settings | |
| 152 | -register_activation_hook( __FILE__, 'wppb_prepopulate_fields' ); //prepopulate manage fields list | |
| 194 | + add_action('init', 'wppb_generate_default_settings_defaults'); //prepoulate general settings | |
| 195 | + add_action('init', 'wppb_prepopulate_fields'); //prepopulate manage fields list | |
| 196 | + | |
| 197 | + } | |
| 198 | +} //end wppb_free_plugin_init | |
| 199 | +add_action( 'plugins_loaded', 'wppb_free_plugin_init' ); | |
| 200 | + | |
| 201 | +if (file_exists( plugin_dir_path(__FILE__) . '/front-end/extra-fields/upload/upload_helper_functions.php')) | |
| 202 | + include_once( plugin_dir_path(__FILE__) . '/front-end/extra-fields/upload/upload_helper_functions.php'); | |