Exemple #1
0
 /**
  * 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;
 }
 /**
  * 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;
         }
     }
 }
Exemple #3
0
    /**
     * 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;
    }