Exemple #1
0
	/**
	 * Plugin initialization function.
	 *
	 * @since 3.0.0
	 */
	function __construct() {
	
		/**
		 * Filter the options before they are loaded into constants.
		 *
		 * @since 2.9.0
		 * @since 3.0.0 Moved to the WP_Members class.
		 *
		 * @param array $this->settings An array of the WP-Members settings.
		 */
		$settings = apply_filters( 'wpmem_settings', get_option( 'wpmembers_settings' ) );

		// Validate that v3 settings are loaded.
		if ( ! isset( $settings['version'] ) ) {
			// If settings were not properly built during plugin upgrade.
			/**
			 * Load installation routine.
			 */
			require_once( WPMEM_PATH . 'wp-members-install.php' );
			// Update settings for 3.x
			$settings = apply_filters( 'wpmem_settings', wpmem_update_settings() );
		}
		
		// Assemble settings.
		foreach ( $settings as $key => $val ) {
			$this->$key = $val;
		}

		// Set the stylesheet.
		$this->cssurl = ( isset( $this->style ) && $this->style == 'use_custom' ) ? $this->cssurl : $this->style;
	}
 /**
  * Plugin initialization function.
  *
  * @since 3.0.0
  */
 function __construct()
 {
     /**
      * Filter the options before they are loaded into constants.
      *
      * @since 2.9.0
      * @since 3.0.0 Moved to the WP_Members class.
      *
      * @param array $this->settings An array of the WP-Members settings.
      */
     $settings = apply_filters('wpmem_settings', get_option('wpmembers_settings'));
     // Validate that v3 settings are loaded.
     if (!isset($settings['version']) || $settings['version'] != WPMEM_VERSION) {
         /**
          * Load installation routine.
          */
         require_once WPMEM_PATH . 'wp-members-install.php';
         // Update settings.
         $settings = apply_filters('wpmem_settings', wpmem_update_settings());
     }
     // Assemble settings.
     foreach ($settings as $key => $val) {
         $this->{$key} = $val;
     }
     $this->load_user_pages();
     // Set the stylesheet.
     $this->cssurl = isset($this->style) && $this->style == 'use_custom' ? $this->cssurl : $this->style;
 }
/**
 * 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) {
        // This is a clean install (or an upgrade from 2.1 or earlier).
        $wpmem_settings = array('version' => WPMEM_VERSION, 'block' => array('post' => is_multisite() ? 0 : 1, 'page' => 0), 'show_excerpt' => array('post' => 0, 'page' => 0), 'show_reg' => array('post' => 1, 'page' => 1), 'show_login' => array('post' => 1, 'page' => 1), 'autoex' => array('post' => array('enabled' => 0, 'length' => ''), 'page' => array('enabled' => 0, 'length' => '')), 'notify' => 0, 'mod_reg' => 0, 'captcha' => 0, 'use_exp' => 0, 'use_trial' => 0, 'warnings' => 0, 'user_pages' => array('profile' => '', 'register' => '', 'login' => ''), 'cssurl' => '', 'style' => plugin_dir_url(__FILE__) . 'css/generic-no-float.css', 'attrib' => 0, 'post_types' => array());
        // Using update_option to allow for forced update.
        update_option('wpmembers_settings', $wpmem_settings, '', 'yes');
        /*
         * Field array elements:
         * 
         * 	array(
         * 		order, 
         * 		label, 
         *		optionname, 
         * 		type, 
         * 		display, 
         * 		required, 
         * 		native, 
         * 		checked value, 
         * 		checked by default,
         * 	);
         */
        $wpmem_fields_options_arr = array(array(1, 'First Name', 'first_name', 'text', 'y', 'y', 'y'), array(2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y'), array(3, 'Address 1', 'addr1', 'text', 'y', 'y', 'n'), array(4, 'Address 2', 'addr2', 'text', 'y', 'n', 'n'), array(5, 'City', 'city', 'text', 'y', 'y', 'n'), array(6, 'State', 'thestate', 'text', 'y', 'y', 'n'), array(7, 'Zip', 'zip', 'text', 'y', 'y', 'n'), array(8, 'Country', 'country', 'text', 'y', 'y', 'n'), array(9, 'Day Phone', 'phone1', 'text', 'y', 'y', 'n'), array(10, 'Email', 'user_email', 'text', 'y', 'y', 'y'), array(11, 'Confirm Email', 'confirm_email', 'text', 'n', 'n', 'n'), array(12, 'Website', 'user_url', 'text', 'n', 'n', 'y'), array(13, 'Biographical Info', 'description', 'textarea', 'n', 'n', 'y'), array(14, 'Password', 'password', 'password', 'n', 'n', 'n'), array(15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n'), array(16, 'TOS', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n'));
        update_option('wpmembers_fields', $wpmem_fields_options_arr, '', 'yes');
        // using update_option to allow for forced update
        $wpmem_dialogs_arr = array("This content is restricted to site members.  If you are an existing user, please log in.  New users may register below.", "Sorry, that username is taken, please try another.", "Sorry, that email address already has an account.<br />Please try another.", "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.", "Your information was updated!", "Passwords did not match.<br /><br />Please try again.", "Password successfully changed!", "Either the username or email address do not exist in our records.", "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.");
        // Insert TOS dialog placeholder.
        $dummy_tos = "Put your TOS (Terms of Service) text here.  You can use HTML markup.";
        update_option('wpmembers_tos', $dummy_tos);
        update_option('wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes');
        // using update_option to allow for forced update
        wpmem_append_email();
        // If it's a new install, use the Twenty Twelve stylesheet.
        update_option('wpmembers_style', plugin_dir_url(__FILE__) . 'css/generic-no-float.css', '', 'yes');
    } else {
        wpmem_update_settings();
        wpmem_update_captcha();
        wpmem_update_dialogs();
        wpmem_append_email();
    }
}