class-wc-settings-accounts.php 6.56 KB
Newer Older
imac's avatar
imac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
<?php
/**
 * WooCommerce Account Settings
 *
 * @author      WooThemes
 * @category    Admin
 * @package     WooCommerce/Admin
 * @version     2.1.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

if ( ! class_exists( 'WC_Settings_Accounts', false ) ) :

/**
 * WC_Settings_Accounts.
 */
class WC_Settings_Accounts extends WC_Settings_Page {

	/**
	 * Constructor.
	 */
	public function __construct() {

		$this->id    = 'account';
		$this->label = __( 'Accounts', 'woocommerce' );

		add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
		add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
		add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
	}

	/**
	 * Get settings array.
	 *
	 * @return array
	 */
	public function get_settings() {
		$settings = apply_filters( 'woocommerce_' . $this->id . '_settings', array(

			array( 'title' => __( 'Account pages', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to access account related functionality.', 'woocommerce' ), 'id' => 'account_page_options' ),

			array(
				'title'    => __( 'My account page', 'woocommerce' ),
				'desc'     => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) ),
				'id'       => 'woocommerce_myaccount_page_id',
				'type'     => 'single_select_page',
				'default'  => '',
				'class'    => 'wc-enhanced-select',
				'css'      => 'min-width:300px;',
				'desc_tip' => true,
			),

			array( 'type' => 'sectionend', 'id' => 'account_page_options' ),

			array( 'title' => '', 'type' => 'title', 'id' => 'account_registration_options' ),

			array(
				'title'         => __( 'Customer registration', 'woocommerce' ),
				'desc'          => __( 'Enable customer registration on the "Checkout" page.', 'woocommerce' ),
				'id'            => 'woocommerce_enable_signup_and_login_from_checkout',
				'default'       => 'yes',
				'type'          => 'checkbox',
				'checkboxgroup' => 'start',
				'autoload'      => false,
			),

			array(
				'desc'          => __( 'Enable customer registration on the "My account" page.', 'woocommerce' ),
				'id'            => 'woocommerce_enable_myaccount_registration',
				'default'       => 'no',
				'type'          => 'checkbox',
				'checkboxgroup' => 'end',
				'autoload'      => false,
			),

			array(
				'title'         => __( 'Login', 'woocommerce' ),
				'desc'          => __( 'Display returning customer login reminder on the "Checkout" page.', 'woocommerce' ),
				'id'            => 'woocommerce_enable_checkout_login_reminder',
				'default'       => 'yes',
				'type'          => 'checkbox',
				'checkboxgroup' => 'start',
				'autoload'      => false,
			),

			array(
				'title'         => __( 'Account creation', 'woocommerce' ),
				'desc'          => __( 'Automatically generate username from customer email.', 'woocommerce' ),
				'id'            => 'woocommerce_registration_generate_username',
				'default'       => 'yes',
				'type'          => 'checkbox',
				'checkboxgroup' => 'start',
				'autoload'      => false,
			),

			array(
				'desc'          => __( 'Automatically generate customer password', 'woocommerce' ),
				'id'            => 'woocommerce_registration_generate_password',
				'default'       => 'no',
				'type'          => 'checkbox',
				'checkboxgroup' => 'end',
				'autoload'      => false,
			),

			array( 'type' => 'sectionend', 'id' => 'account_registration_options' ),

			array( 'title' => __( 'My account endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique and can be left blank to disable the endpoint.', 'woocommerce' ), 'id' => 'account_endpoint_options' ),

			array(
				'title'    => __( 'Orders', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; Orders" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_orders_endpoint',
				'type'     => 'text',
				'default'  => 'orders',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'View order', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; View order" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_view_order_endpoint',
				'type'     => 'text',
				'default'  => 'view-order',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'Downloads', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; Downloads" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_downloads_endpoint',
				'type'     => 'text',
				'default'  => 'downloads',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'Edit account', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; Edit account" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_edit_account_endpoint',
				'type'     => 'text',
				'default'  => 'edit-account',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'Addresses', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; Addresses" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_edit_address_endpoint',
				'type'     => 'text',
				'default'  => 'edit-address',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'Payment methods', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; Payment methods" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_payment_methods_endpoint',
				'type'     => 'text',
				'default'  => 'payment-methods',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'Lost password', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the "My account &rarr; Lost password" page.', 'woocommerce' ),
				'id'       => 'woocommerce_myaccount_lost_password_endpoint',
				'type'     => 'text',
				'default'  => 'lost-password',
				'desc_tip' => true,
			),

			array(
				'title'    => __( 'Logout', 'woocommerce' ),
				'desc'     => __( 'Endpoint for the triggering logout. You can add this to your menus via a custom link: yoursite.com/?customer-logout=true', 'woocommerce' ),
				'id'       => 'woocommerce_logout_endpoint',
				'type'     => 'text',
				'default'  => 'customer-logout',
				'desc_tip' => true,
			),

			array( 'type' => 'sectionend', 'id' => 'account_endpoint_options' ),

		) );

		return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
	}
}

endif;

return new WC_Settings_Accounts();