Version Description
Download this release
Release Info
Developer | adampickering |
Plugin | Simple Registration for WooCommerce |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.3.0
- includes/wc-social-login.php +81 -0
- languages/woocommerce-simple-registration.pot +14 -2
- readme.txt +6 -1
- woocommerce-simple-registration.php +69 -9
includes/wc-social-login.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Load Class */
|
3 |
+
WooCommerce_Simple_Registration_WC_Social_Login::get_instance();
|
4 |
+
|
5 |
+
/**
|
6 |
+
* WooCommerce Social Login Support
|
7 |
+
* @link http://www.woothemes.com/products/woocommerce-social-login/
|
8 |
+
* @since 1.3.0
|
9 |
+
**/
|
10 |
+
class WooCommerce_Simple_Registration_WC_Social_Login{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Returns the instance.
|
14 |
+
*/
|
15 |
+
public static function get_instance(){
|
16 |
+
static $instance = null;
|
17 |
+
if ( is_null( $instance ) ) $instance = new self;
|
18 |
+
return $instance;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructor.
|
23 |
+
*/
|
24 |
+
public function __construct() {
|
25 |
+
|
26 |
+
/* Add Simple Registration Shortcode in "Display" Settings */
|
27 |
+
add_filter( 'woocommerce_social_login_settings', array( $this, 'settings' ) );
|
28 |
+
|
29 |
+
/* Render Buttons */
|
30 |
+
add_action( 'woocommerce_register_form_end', array( $this, 'render_social_login_buttons' ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Display Settings
|
35 |
+
*/
|
36 |
+
public function settings( $settings ){
|
37 |
+
|
38 |
+
/* Get the section */
|
39 |
+
$key = false;
|
40 |
+
foreach( $settings as $k => $v ){
|
41 |
+
if( isset( $v['id'] ) && 'wc_social_login_display' == $v['id'] ){
|
42 |
+
$key = $k;
|
43 |
+
break;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
/* Bail, if section not found */
|
47 |
+
if( false === $key ){
|
48 |
+
return $settings;
|
49 |
+
}
|
50 |
+
|
51 |
+
/* Add "Simple Registration" in Display Option So User can enable/disable it. */
|
52 |
+
$settings[$key]['options']['woocommerce_simple_registration'] = __( 'Simple Registration', 'woocommerce-simple-registration' );
|
53 |
+
|
54 |
+
return $settings;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Whether social login buttons are displayed on simple registration shortcode
|
59 |
+
*/
|
60 |
+
public function is_displayed_on( $handle = 'woocommerce_simple_registration' ) {
|
61 |
+
return in_array( 'woocommerce_simple_registration', apply_filters( 'wc_social_login_display', (array) get_option( 'wc_social_login_display', array() ) ) );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Render social login buttons on frontend
|
66 |
+
*/
|
67 |
+
public function render_social_login_buttons() {
|
68 |
+
/* Bail if not enabled in simple registration output */
|
69 |
+
if( ! $this->is_displayed_on() ){
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
/* Bail if in account page and this page already have login button. */
|
73 |
+
if ( is_account_page() && $this->is_displayed_on( 'my_account' ) ) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
/* Render button. */
|
77 |
+
woocommerce_social_login_buttons( wc_get_page_permalink( 'myaccount' ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
languages/woocommerce-simple-registration.pot
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
# This file is distributed under the same license as the WooCommerce Simple Registration package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: WooCommerce Simple Registration 1.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-simple-registration\n"
|
8 |
-
"POT-Creation-Date: 2016-
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -14,6 +14,10 @@ msgstr ""
|
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"X-Generator: grunt-wp-i18n 0.5.4\n"
|
16 |
|
|
|
|
|
|
|
|
|
17 |
#: templates/registration-form.php:17 templates/registration-form.php:54
|
18 |
msgid "Register"
|
19 |
msgstr ""
|
@@ -34,6 +38,14 @@ msgstr ""
|
|
34 |
msgid "Anti-spam"
|
35 |
msgstr ""
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
#. Plugin Name of the plugin/theme
|
38 |
msgid "WooCommerce Simple Registration"
|
39 |
msgstr ""
|
2 |
# This file is distributed under the same license as the WooCommerce Simple Registration package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce Simple Registration 1.3.0\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/woocommerce-simple-registration\n"
|
8 |
+
"POT-Creation-Date: 2016-11-16 01:42:08+00:00\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"X-Generator: grunt-wp-i18n 0.5.4\n"
|
16 |
|
17 |
+
#: includes/wc-social-login.php:52
|
18 |
+
msgid "Simple Registration"
|
19 |
+
msgstr ""
|
20 |
+
|
21 |
#: templates/registration-form.php:17 templates/registration-form.php:54
|
22 |
msgid "Register"
|
23 |
msgstr ""
|
38 |
msgid "Anti-spam"
|
39 |
msgstr ""
|
40 |
|
41 |
+
#: woocommerce-simple-registration.php:193
|
42 |
+
msgid "First Name"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: woocommerce-simple-registration.php:198
|
46 |
+
msgid "Last Name"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
#. Plugin Name of the plugin/theme
|
50 |
msgid "WooCommerce Simple Registration"
|
51 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/astoundify
|
|
4 |
Tags: woocommerce, woocommerce registration, woocommerce register, woocommerce registration form, woocommerce form
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -22,6 +22,11 @@ A simple plugin to add a [woocommerce_simple_registration] shortcode to display
|
|
22 |
|
23 |
== Changelog ==
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
= 1.2.0 =
|
26 |
|
27 |
* Update register form with latest WC. Enable Password Meter.
|
4 |
Tags: woocommerce, woocommerce registration, woocommerce register, woocommerce registration form, woocommerce form
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 1.3.0
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
22 |
|
23 |
== Changelog ==
|
24 |
|
25 |
+
= 1.3.0: November 17, 2016 =
|
26 |
+
|
27 |
+
* New: WooCommerce Social Login support. Add output in WooCommerce > Settings > Social Login.
|
28 |
+
* New: Collect first and last name on registration.
|
29 |
+
|
30 |
= 1.2.0 =
|
31 |
|
32 |
* Update register form with latest WC. Enable Password Meter.
|
woocommerce-simple-registration.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WooCommerce Simple Registration
|
4 |
* Plugin URI: https://astoundify.com/
|
5 |
* Description: A simple plugin to add a [woocommerce_simple_registration] shortcode to display the registration form on a separate page.
|
6 |
-
* Version: 1.
|
7 |
* Author: Astoundify
|
8 |
* Author URI: https://astoundify.com/
|
9 |
* Text Domain: woocommerce-simple-registration
|
@@ -30,7 +30,7 @@ class WooCommerce_Simple_Registration {
|
|
30 |
* @since 1.0.0
|
31 |
* @var string $version Plugin version number.
|
32 |
*/
|
33 |
-
public $version = '1.
|
34 |
|
35 |
|
36 |
/**
|
@@ -72,6 +72,19 @@ class WooCommerce_Simple_Registration {
|
|
72 |
|
73 |
// add a body class on this page
|
74 |
add_filter( 'body_class', array( $this, 'body_class' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
/**
|
@@ -153,16 +166,63 @@ class WooCommerce_Simple_Registration {
|
|
153 |
* @param array $classes
|
154 |
* @return array
|
155 |
*/
|
156 |
-
function body_class( $classes ) {
|
157 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
|
168 |
}
|
3 |
* Plugin Name: WooCommerce Simple Registration
|
4 |
* Plugin URI: https://astoundify.com/
|
5 |
* Description: A simple plugin to add a [woocommerce_simple_registration] shortcode to display the registration form on a separate page.
|
6 |
+
* Version: 1.3.0
|
7 |
* Author: Astoundify
|
8 |
* Author URI: https://astoundify.com/
|
9 |
* Text Domain: woocommerce-simple-registration
|
30 |
* @since 1.0.0
|
31 |
* @var string $version Plugin version number.
|
32 |
*/
|
33 |
+
public $version = '1.3.0';
|
34 |
|
35 |
|
36 |
/**
|
72 |
|
73 |
// add a body class on this page
|
74 |
add_filter( 'body_class', array( $this, 'body_class' ) );
|
75 |
+
|
76 |
+
// add first name and last name to register form
|
77 |
+
add_action( 'woocommerce_register_form_start', array( $this, 'add_name_input' ) );
|
78 |
+
add_action( 'woocommerce_created_customer', array( $this, 'save_name_input' ) );
|
79 |
+
|
80 |
+
/**
|
81 |
+
* WooCommerce Social Login Support
|
82 |
+
* @link http://www.woothemes.com/products/woocommerce-social-login/
|
83 |
+
* @since 1.3.0
|
84 |
+
*/
|
85 |
+
if( function_exists( 'init_woocommerce_social_login' ) ){
|
86 |
+
require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/wc-social-login.php' );
|
87 |
+
}
|
88 |
}
|
89 |
|
90 |
/**
|
166 |
* @param array $classes
|
167 |
* @return array
|
168 |
*/
|
169 |
+
public function body_class( $classes ) {
|
170 |
+
if( is_singular() && $post_data = get_post( get_queried_object_id() ) ){
|
171 |
+
if ( isset( $post_data->post_content ) && has_shortcode( $post_data->post_content, 'woocommerce_simple_registration' ) ) {
|
172 |
+
$classes[] = 'woocommerce-register';
|
173 |
+
$classes[] = 'woocommerce-account';
|
174 |
+
$classes[] = 'woocommerce-page';
|
175 |
+
}
|
176 |
+
}
|
177 |
+
return $classes;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Add First Name & Last Name
|
182 |
+
* To disable this simply use this code:
|
183 |
+
* `add_filter( 'woocommerce_simple_registration_name_fields', '__return_false' );`
|
184 |
+
* @since 1.3.0
|
185 |
+
*/
|
186 |
+
public function add_name_input(){
|
187 |
+
/* Filter to disable this feature. */
|
188 |
+
if( ! apply_filters( 'woocommerce_simple_registration_name_fields', true ) ){
|
189 |
+
return;
|
190 |
+
}
|
191 |
+
?>
|
192 |
+
<p class="woocommerce-FormRow woocommerce-FormRow--first form-row form-row-first">
|
193 |
+
<label for="reg_sr_firstname"><?php _e( 'First Name', 'woocommerce-simple-registration' ); ?></label>
|
194 |
+
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="sr_firstname" id="reg_sr_firstname" value="<?php if ( ! empty( $_POST['sr_firstname'] ) ) echo esc_attr( $_POST['sr_firstname'] ); ?>" />
|
195 |
+
</p>
|
196 |
+
|
197 |
+
<p class="woocommerce-FormRow woocommerce-FormRow--last form-row form-row-last">
|
198 |
+
<label for="reg_sr_lastname"><?php _e( 'Last Name', 'woocommerce-simple-registration' ); ?></label>
|
199 |
+
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text" name="sr_lastname" id="reg_sr_lastname" value="<?php if ( ! empty( $_POST['sr_lastname'] ) ) echo esc_attr( $_POST['sr_lastname'] ); ?>" />
|
200 |
+
</p>
|
201 |
+
<?php
|
202 |
+
}
|
203 |
|
204 |
+
/**
|
205 |
+
* Save First Name and Last Name
|
206 |
+
* @since 1.3.0
|
207 |
+
* @see WC/includes/wc-user-functions.php line 114
|
208 |
+
*/
|
209 |
+
public function save_name_input( $customer_id ){
|
210 |
+
/* Filter to disable this feature. */
|
211 |
+
if( ! apply_filters( 'woocommerce_simple_registration_name_fields', true ) ){
|
212 |
+
return;
|
213 |
}
|
214 |
|
215 |
+
/* Strip slash everything */
|
216 |
+
$request = stripslashes_deep( $_POST );
|
217 |
+
|
218 |
+
/* Save First Name */
|
219 |
+
if ( isset( $request['sr_firstname'] ) && !empty( $request['sr_firstname'] ) ) {
|
220 |
+
update_user_meta( $customer_id, 'first_name', sanitize_text_field( $request['sr_firstname'] ) );
|
221 |
+
}
|
222 |
+
/* Save Last Name */
|
223 |
+
if ( isset( $request['sr_lastname'] ) && !empty( $request['sr_lastname'] ) ) {
|
224 |
+
update_user_meta( $customer_id, 'last_name', sanitize_text_field( $request['sr_lastname'] ) );
|
225 |
+
}
|
226 |
}
|
227 |
|
228 |
}
|