/** * Get the CSS stylesheet for the ID password reset * * @return mixed */ public static function get_password_reset_css($password_reset_builder_id) { // if no id is set return if (!isset($password_reset_builder_id)) { return; } $password_reset_css = PROFILEPRESS_sql::get_a_builder_css('password_reset', $password_reset_builder_id); return "<style type=\"text/css\">\r\n {$password_reset_css} \r\n</style>"; }
/** * Get the CSS stylesheet for the ID registration * * @return mixed */ public static function get_registration_css($registration_builder_id) { // if no id is set return if (!isset($registration_builder_id)) { return; } $registration_css = PROFILEPRESS_sql::get_a_builder_css('registration', $registration_builder_id); return "<style type=\"text/css\">\r\n {$registration_css} \r\n</style>"; }
/** * Get the CSS stylesheet for the ID login * * @return mixed */ public static function get_login_css($login_builder_id) { // if no id is set return if (!isset($login_builder_id)) { return; } $login_css = PROFILEPRESS_sql::get_a_builder_css('login', $login_builder_id); // added a break-line to the style tag to keep it in a new line - viewed when viewing site source code return "\r\n <style type=\"text/css\">\r\n" . $login_css . "\r\n</style>\r\n\r\n"; }
function process_bulk_action() { //Detect when a bulk action is being triggered... if ('delete' === $this->current_action()) { // In our file that handles the request, verify the nonce. $nonce = @esc_attr($_REQUEST['_wpnonce']); if (!wp_verify_nonce($nonce, 'pp_delete_registration')) { die('Weird: Plugin is resolving itself'); } PROFILEPRESS_sql::sql_delete_registration_builder(esc_sql($_GET['registration'])); wp_redirect(esc_attr('?page=' . REGISTRATION_BUILDER_SETTINGS_PAGE_SLUG)); exit; } if (isset($_POST['action']) && $_POST['action'] == 'bulk-delete' || isset($_POST['action2']) && $_POST['action2'] == 'bulk-delete') { $delete_array = $_POST['bulk-delete']; foreach ($delete_array as $id) { PROFILEPRESS_sql::sql_delete_registration_builder(absint($id)); } wp_redirect(esc_attr('?page=' . REGISTRATION_BUILDER_SETTINGS_PAGE_SLUG)); exit; } }
<?php // @GET field id to edit. $login_id = absint($_GET['login']); // get the login row for the id $edit_login = PROFILEPRESS_sql::sql_edit_login_builder($login_id); require_once VIEWS . '/include.settings-page-tab.php'; ?> <br/> <a class="button-secondary" href="?page=<?php echo LOGIN_BUILDER_SETTINGS_PAGE_SLUG; ?> " title="Back to Catalog">Back to Catalog</a> <div id="poststuff" class="ppview"> <div id="post-body" class="metabox-holder columns-2"> <div id="post-body-content"> <div class="meta-box-sortables ui-sortable"> <form method="post"> <div class="postbox"> <div class="handlediv" title="Click to toggle"><br></div> <h3 class="hndle ui-sortable-handle"><span>Edit Login Form</span></h3> <div class="inside"> <table class="form-table"> <tr> <th scope="row"><label for="title">Theme Name</label></th>
<?php // @GET field id to edit. $password_reset_id = absint($_GET['password-reset']); // get the password reset row for the id $edit_password_reset = PROFILEPRESS_sql::sql_edit_password_reset_builder($password_reset_id); require_once VIEWS . '/include.settings-page-tab.php'; ?> <br/> <a class="button-secondary" href="?page=<?php echo PASSWORD_RESET_BUILDER_SETTINGS_PAGE_SLUG; ?> " title="Back to Catalog">Back to Catalog</a> <div id="poststuff" class="ppview"> <div id="post-body" class="metabox-holder columns-2"> <div id="post-body-content"> <div class="meta-box-sortables ui-sortable"> <form method="post"> <div class="postbox"> <div class="handlediv" title="Click to toggle"><br></div> <h3 class="hndle ui-sortable-handle"><span>Edit Password Reset Form</span></h3> <div class="inside"> <table class="form-table"> <tr> <th scope="row"><label for="title"><?php _e('Theme Name', 'profilepress');
/** * Save edit_login_builder * * Add a new builder to the DB and also update builder * * @param $operation string add/edit * @param $id int builder id */ public function save_add_edit_login_builder($operation, $id = '') { if (isset($_POST['add_login']) || isset($_POST['edit_login'])) { $title = esc_attr($_POST['lfb_title']); $structure = stripslashes($_POST['lfb_structure']); $css = stripslashes($_POST['lfb_css']); // catch and save form generated errors in property @login_builder_errors if (empty($_POST['lfb_title'])) { $this->login_builder_errors = 'Title is empty'; } elseif (empty($_POST['lfb_structure'])) { $this->login_builder_errors = 'Login Design is missing'; } if (isset($this->login_builder_errors)) { return; } if (isset($_POST['edit_login']) && check_admin_referer('edit_login_builder', '_wpnonce') && $operation == 'edit') { // update login in db PROFILEPRESS_sql::sql_update_login_builder($id, $title, $structure, $css, date('Y-m-d')); wp_redirect(add_query_arg('login-edited', 'true')); exit; } elseif (isset($_POST['add_login']) && check_admin_referer('add_login_builder', '_wpnonce') && $operation == 'add') { // insert the login to db $added_login_id = PROFILEPRESS_sql::sql_insert_login_builder($title, $structure, $css, date('Y-m-d')); wp_redirect(sprintf('?page=%s&action=%s&login=%s&_wpnonce=%s&login-added=true', LOGIN_BUILDER_SETTINGS_PAGE_SLUG, 'edit', absint($added_login_id), wp_create_nonce('pp_edit_login'))); exit; } } }
/** * @param $operation * @param string $id */ public function save_add_edit_password_reset_builder($operation, $id = '') { if (isset($_POST['add_password_reset']) || isset($_POST['edit_password_reset'])) { $title = @esc_attr($_POST['prb_title']); $structure = @stripslashes($_POST['prb_structure']); $css = @stripslashes($_POST['prb_css']); $success_password_reset = @stripslashes($_POST['prb_success_password_reset']); // catch and save form generated errors in property @password_reset_builder_errors if (empty($_POST['prb_title'])) { $this->password_reset_builder_errors = 'Title is empty'; } elseif (empty($_POST['prb_structure'])) { $this->password_reset_builder_errors = 'Password Reset Design is missing'; } if (isset($this->password_reset_builder_errors)) { return; } if (isset($_POST['edit_password_reset']) && check_admin_referer('edit_password_reset_builder', '_wpnonce') && $operation == 'edit') { PROFILEPRESS_sql::sql_update_password_reset_builder($id, $title, $structure, $css, $success_password_reset, date('Y-m-d')); wp_redirect(add_query_arg('password-reset-edited', 'true')); exit; } elseif (isset($_POST['add_password_reset']) && check_admin_referer('add_password_reset_builder', '_wpnonce') && $operation == 'add') { global $wpdb; $id = PROFILEPRESS_sql::sql_insert_password_reset_builder($title, $structure, $css, $success_password_reset, date('Y-m-d')); wp_redirect(sprintf('?page=%s&action=%s&password-reset=%s&_wpnonce=%s&password-reset-added=true', PASSWORD_RESET_BUILDER_SETTINGS_PAGE_SLUG, 'edit', absint($id), wp_create_nonce('pp_edit_pass'))); exit; } } }
/** * @param $operation * @param string $id */ function save_add_edit_registration_builder($operation, $id = '') { if (isset($_POST['add_registration']) || isset($_POST['edit_registration'])) { $title = @esc_attr($_POST['rfb_title']); $structure = @stripslashes($_POST['rfb_structure']); $css = @stripslashes($_POST['rfb_css']); $success_registration = @stripslashes($_POST['rfb_success_registration']); // catch and save form generated errors in property @registration_builder_errors if (empty($_POST['rfb_title'])) { $this->registration_builder_errors = 'Title is empty'; } elseif (empty($_POST['rfb_structure'])) { $this->registration_builder_errors = 'Registration Design is missing'; } if (isset($this->registration_builder_errors)) { return; } if (isset($_POST['edit_registration']) && check_admin_referer('edit_registration_builder', '_wpnonce') && $operation == 'edit') { PROFILEPRESS_sql::sql_update_registration_builder($id, $title, $structure, $css, $success_registration, date('Y-m-d')); wp_redirect(add_query_arg('registration-edited', 'true')); exit; } if (isset($_POST['add_registration']) && check_admin_referer('add_registration_builder', '_wpnonce') && $operation == 'add') { $id = PROFILEPRESS_sql::sql_insert_registration_builder($title, $structure, $css, $success_registration, date('Y-m-d')); wp_redirect(sprintf('?page=%s&action=%s®istration=%s&_wpnonce=%s®istration-added=true', REGISTRATION_BUILDER_SETTINGS_PAGE_SLUG, 'edit', absint($id), wp_create_nonce('pp_edit_registration'))); exit; } } }
/** * The error or success message received from the retrieve_password_func * * @param $user_login string username/email * @param $form_id int password_reset id * * @return string */ public static function password_reset_status($user_login, $form_id) { /** * Fires before password reset is processed * * @param $user_login string username/email * @param $form_id int password reset builder ID */ do_action('pp_before_password_reset', $user_login, $form_id); /** filter to validate additional password field */ $errors = ''; $password_reset_validation = apply_filters('pp_password_reset_validation', $errors, $form_id); // if the action is contain WP_Error message, set the password response to the object // for reuse further down to return its WP_Error message if (is_wp_error($password_reset_validation) && $password_reset_validation->get_error_code() != '') { $password_reset_response = $password_reset_validation; } else { $password_reset_response = self::retrieve_password_func($user_login); } /** * Fires after password reset is processed * * @param $user_login string username/email * @param $password_reset_response string password reset response message */ do_action('pp_after_password_reset', $form_id, $user_login, $password_reset_response); // filter for the css class of the error message $password_reset_status_css_class = apply_filters('pp_password_reset_error_css_class', 'profilepress-reset-status', $form_id); // return the response of the password reset process if (is_wp_error($password_reset_response)) { return '<div class="' . $password_reset_status_css_class . '">' . $password_reset_response->get_error_message() . '</div>'; } else { $message_on_password_reset = PROFILEPRESS_sql::get_db_success_password_reset($form_id); return isset($message_on_password_reset) ? $message_on_password_reset : apply_filters('pp_default_password_reset_text', '<h4>' . __('Check your e-mail for further instruction', 'profilepress') . '</h4>'); } }
<?php // @GET field id to edit. $registration_id = absint($_GET['registration']); // get the registration row for the id $edit_registration = PROFILEPRESS_sql::sql_edit_registration_builder($registration_id); require_once VIEWS . '/include.settings-page-tab.php'; ?> <br/> <a class="button-secondary" href="?page=<?php echo REGISTRATION_BUILDER_SETTINGS_PAGE_SLUG; ?> " title="Back to Catalog">Back to Catalog</a> <div id="poststuff" class="ppview"> <div id="post-body" class="metabox-holder columns-2"> <div id="post-body-content"> <div class="meta-box-sortables ui-sortable"> <form method="post"> <div class="postbox"> <div class="handlediv" title="Click to toggle"><br></div> <h3 class="hndle ui-sortable-handle"><span>Edit Registration Form</span></h3> <div class="inside"> <table class="form-table"> <tr> <th scope="row"><label for="title">Theme Name</label></th> <td> <input type="text" id="title" name="rfb_title" class="regular-text code" value="<?php echo isset($_POST['rfb_title']) ? esc_attr($_POST['rfb_title']) : $edit_registration['title']; ?>
/** * Insert the theme structure, CSS and success_message to the Database * * @param $theme_type * * @return bool|WP_Error */ public function insert_theme_to_db($theme_type) { $title = $this->theme_name; $structure = $this->theme_structure; $css = $this->theme_css; $date = date('Y-m-d'); $success_message = isset($this->theme_success_message) ? $this->theme_success_message : null; switch ($theme_type) { case 'login': $insert = PROFILEPRESS_sql::sql_insert_login_builder($title, $structure, $css, $date); break; case 'registration': $insert = PROFILEPRESS_sql::sql_insert_registration_builder($title, $structure, $css, $success_message, $date); break; case 'password-reset': $insert = PROFILEPRESS_sql::sql_insert_password_reset_builder($title, $structure, $css, $success_message, $date); break; case 'edit-user-profile': $insert = PROFILEPRESS_sql::sql_insert_edit_profile_builder($title, $structure, $css, $success_message, $date); break; case 'front-end-profile': $insert = PROFILEPRESS_sql::sql_insert_user_profile_builder($title, $structure, $css, $date); break; } if (isset($insert) && !$insert) { return new WP_Error('install_failed', __('<strong>Error:</strong> Theme installation failed. Please try again.', 'profilepress')); } return true; }
/** * Register new users * * @param $post array $_POST data * @param $form_id int Registration builder ID * * @return string */ public static function register_new_user($post, $form_id, $files = '', $redirect = '') { // create an array of acceptable userdata for use by wp_insert_user $valid_userdata = array('reg_username', 'reg_password', 'reg_email', 'reg_website', 'reg_nickname', 'reg_display_name', 'reg_first_name', 'reg_last_name', 'reg_bio'); // get the data for userdata $segregated_userdata = array(); // loop over the $_POST data and create an array of the wp_insert_user userdata foreach ($post as $key => $value) { if ($key == 'reg_submit') { continue; } if (in_array($key, $valid_userdata)) { $segregated_userdata[$key] = esc_attr($value); } } // get the data for use by update_meta $custom_usermeta = array(); // loop over the $_POST data and create an array of the invalid userdata/ custom usermeta foreach ($post as $key => $value) { if ($key == 'reg_submit') { continue; } if (!in_array($key, $valid_userdata)) { $custom_usermeta[$key] = esc_attr($value); } } // get convert the form post data to userdata for use by wp_insert_users $username = isset($segregated_userdata['reg_username']) ? $segregated_userdata['reg_username'] : ''; $password = isset($segregated_userdata['reg_password']) ? $segregated_userdata['reg_password'] : ''; $email = isset($segregated_userdata['reg_email']) ? $segregated_userdata['reg_email'] : ''; $website = isset($segregated_userdata['reg_website']) ? $segregated_userdata['reg_website'] : ''; $nickname = isset($segregated_userdata['reg_nickname']) ? $segregated_userdata['reg_nickname'] : ''; $display_name = isset($segregated_userdata['reg_display_name']) ? $segregated_userdata['reg_display_name'] : ''; $first_name = isset($segregated_userdata['reg_first_name']) ? $segregated_userdata['reg_first_name'] : ''; $last_name = isset($segregated_userdata['reg_last_name']) ? $segregated_userdata['reg_last_name'] : ''; $bio = isset($segregated_userdata['reg_bio']) ? $segregated_userdata['reg_bio'] : ''; // real uer data $real_userdata = array('user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'user_url' => $website, 'nickname' => $nickname, 'display_name' => $display_name, 'first_name' => $first_name, 'last_name' => $last_name, 'description' => $bio); // filter for the css class of the error message $reg_status_css_class = apply_filters('pp_registration_error_css_class', 'profilepress-reg-status', $form_id); /* start filter Hook */ $reg_errors = new WP_Error(); if (!is_email($real_userdata['user_email'])) { $reg_errors->add('invalid_email', __('Email address is not valid', 'profilepress')); } // call validate reg from function $reg_form_errors = apply_filters('pp_registration_validation', $reg_errors, $form_id); if (is_wp_error($reg_form_errors) && $reg_form_errors->get_error_code() != '') { return '<div class="' . $reg_status_css_class . '">' . $reg_form_errors->get_error_message() . '</div>'; } /* End Filter Hook */ //merge real data(for use by wp_insert_user()) and custom profile fields data $user_data = array_merge($real_userdata, $custom_usermeta); /* Start Action Hook */ do_action('pp_before_registration', $form_id, $user_data); /* End Action Hook */ // proceed to registration using wp_insert_user method which return the new user id $register_user = wp_insert_user($real_userdata); // register custom profile field if (!is_wp_error($register_user)) { // if @$register_user is no WP_Error, add the extra user profile field if (is_array($custom_usermeta)) { foreach ($custom_usermeta as $key => $value) { update_user_meta($register_user, $key, esc_attr($value)); } } /* Start Action Hook */ do_action('pp_after_registration', $form_id, $user_data); /* End Action Hook */ // get the "registration successful message" for the registration page $message_on_successful_registration = PROFILEPRESS_sql::get_db_success_registration($form_id); return !empty($message_on_successful_registration) ? $message_on_successful_registration : '<div class="profilepress-reg-status">Registration successful</div>'; } else { return '<div class="' . $reg_status_css_class . '">' . $register_user->get_error_message() . '</div>'; } }
/** * Insert the theme structure, CSS and success_message to the Database * * @param $theme_type * * @return bool|WP_Error */ public function insert_theme_to_db($theme_type) { $title = $this->theme_name; $structure = $this->theme_structure; $css = $this->theme_css; $date = date('Y-m-d'); $success_message = isset($this->theme_success_message) ? $this->theme_success_message : null; // melange success messages $reg_success = $this->melange_reg_success; $reset_success = $this->melange_reset_success; $edit_profile_success = $this->melange_edit_profile_success; $handler_structure = $this->password_reset_handler_structure; switch ($theme_type) { case 'login': $insert = PROFILEPRESS_sql::sql_insert_login_builder($title, $structure, $css, $date); break; case 'registration': $insert = PROFILEPRESS_sql::sql_insert_registration_builder($title, $structure, $css, $success_message, $date); break; case 'password-reset': $handler_structure = $this->password_reset_handler_structure; if (empty($handler_structure)) { $handler_structure = <<<FORM <div class="pp-reset-password-form"> \t<h3>Enter your new password below.</h3> \t<label for="password1">New password<span class="req">*</span></label> \t[enter-password id="password1" required autocomplete="off"] \t<label for="password2">Re-enter new password<span class="req">*</span></label> \t[re-enter-password id="password2" required autocomplete="off"] \t[password-reset-submit class="pp-reset-button pp-reset-button-block" value="Save"] </div> FORM; } $insert = PROFILEPRESS_sql::sql_insert_password_reset_builder($title, $structure, $handler_structure, $css, $success_message, $date); break; case 'edit-user-profile': $insert = PROFILEPRESS_sql::sql_insert_edit_profile_builder($title, $structure, $css, $success_message, $date); break; case 'front-end-profile': $insert = PROFILEPRESS_sql::sql_insert_user_profile_builder($title, $structure, $css, $date); break; case 'melange': $insert = PROFILEPRESS_sql::sql_insert_melange_builder($title, $structure, $css, $reg_success, $edit_profile_success, $reset_success, $date); break; } if (isset($insert) && !$insert) { return new WP_Error('install_failed', __('<strong>Error:</strong> Theme installation failed. Please try again.', 'profilepress')); } return true; }