示例#1
0
/**
 * Installs or upgrades the plugin.
 *
 * @since 2.2.2
 */
function wpmem_do_install()
{
    /*
     * If you need to force an install, set $chk_force = true.
     *
     * Important notes:
     *
     * 1. This will override any settings you already have for any of the plugin settings.
     * 2. This will not effect any WP settings or registered users.
     */
    $chk_force = false;
    if (!get_option('wpmembers_settings') || $chk_force == true) {
        wpmem_install_settings();
        wpmem_install_fields();
        wpmem_install_dialogs();
        wpmem_append_email();
        update_option('wpmembers_style', plugin_dir_url(__FILE__) . 'css/generic-no-float.css', '', 'yes');
    } else {
        wpmem_upgrade_settings();
        wpmem_upgrade_captcha();
        wpmem_append_email();
    }
}
示例#2
0
 /**
  * Sets the registration fields.
  *
  * @since 3.0.0
  * @since 3.1.5 Added $form argument.
  *
  * @param string $form The form being generated.
  */
 function load_fields($form = 'default')
 {
     $fields = get_option('wpmembers_fields');
     // Validate fields settings.
     if (!isset($fields) || empty($fields)) {
         /**
          * Load installation routine.
          */
         require_once WPMEM_PATH . 'wp-members-install.php';
         // Update settings.
         $fields = wpmem_install_fields();
     }
     // Add new field array keys
     foreach ($fields as $key => $val) {
         // Key fields with meta key.
         $meta_key = $val[2];
         // Old format, new key.
         foreach ($val as $subkey => $subval) {
             $this->fields[$meta_key][$subkey] = $subval;
         }
         // Setup field properties.
         $this->fields[$meta_key]['label'] = $val[1];
         $this->fields[$meta_key]['type'] = $val[3];
         $this->fields[$meta_key]['register'] = 'y' == $val[4] ? true : false;
         $this->fields[$meta_key]['required'] = 'y' == $val[5] ? true : false;
         $this->fields[$meta_key]['profile'] = '';
         $this->fields[$meta_key]['native'] = 'y' == $val[6] ? true : false;
         // Certain field types have additional properties.
         switch ($val[3]) {
             case 'checkbox':
                 $this->fields[$meta_key]['checked_value'] = $val[7];
                 $this->fields[$meta_key]['checked_default'] = 'y' == $val[8] ? true : false;
                 break;
             case 'select':
             case 'multiselect':
             case 'multicheckbox':
             case 'radio':
                 $this->fields[$meta_key]['values'] = $val[7];
                 $this->fields[$meta_key]['delimiter'] = isset($val[8]) ? $val[8] : '|';
                 $this->fields[$meta_key]['options'] = array();
                 foreach ($val[7] as $value) {
                     $pieces = explode($this->fields[$meta_key]['delimiter'], trim($value));
                     if ($pieces[1] != '') {
                         $this->fields[$meta_key]['options'][$pieces[1]] = $pieces[0];
                     }
                 }
                 break;
             case 'file':
             case 'image':
                 $this->fields[$meta_key]['file_types'] = $val[7];
                 break;
             case 'hidden':
                 $this->fields[$meta_key]['value'] = $val[7];
                 break;
         }
     }
 }