Plugin Directory

Changeset 953592


Ignore:
Timestamp:
07/23/2014 04:45:54 PM (12 years ago)
Author:
buildcreate
Message:

Updating Woocommerce compatibility

Location:
agreeable/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • agreeable/trunk/agreeable.php

    r953516 r953592  
    44Plugin URI: http://wordpress.org/extend/plugins/agreeable
    55Description: Add a required "Agree to terms" checkbox to login and/or register forms.  Based on the I-Agree plugin by Michael Stursberg.
    6 Version: 0.3.4.1
     6Version: 0.3.4.2
    77Author: kraftpress
    88Author URI: http://kraftpress.it
     
    2121function ag_front() {
    2222    /* Only load lightbox code on the frontend, where we need it */
     23        if ( is_login_page() ) {
     24            wp_enqueue_script('jquery');
     25        }
    2326        wp_enqueue_script( 'magnific', plugins_url('js/magnific.js', __FILE__),'', '', true);
    2427        wp_enqueue_script( 'agreeable-js', plugins_url('js/agreeable.js', __FILE__), '', '', true);
    2528        wp_enqueue_style( 'magnific', plugins_url('css/magnific.css', __FILE__));
    26         wp_enqueue_style( 'magnific', plugins_url('css/front.css', __FILE__)); 
     29        wp_enqueue_style( 'agreeable-css', plugins_url('css/front.css', __FILE__));
    2730}
    2831
     
    3033add_action('admin_enqueue_scripts', 'ag_admin');
    3134add_action('wp_enqueue_scripts', 'ag_front');
     35add_action('login_enqueue_scripts', 'ag_front');
    3236
    3337function ag_authenticate_user_acc($user) {
     
    7377    }
    7478
     79}
     80
     81add_filter('woocommerce_registration_errors', 'ag_woocommerce_reg_validation', 10,3);
     82
     83function ag_woocommerce_reg_validation($reg_errors, $sanitized_user_login, $user_email) {
     84    global $woocommerce;
     85    $dbfail = get_option('ag_fail');
     86   
     87    if(!isset($_REQUEST['login_accept'])) {
     88   
     89        if ( !isset($_COOKIE['agreeable_terms'] ) && $dbremember == 1 || $dbremember == 0) {
     90                  return new WP_Error('registration-error', __($dbfail, 'woocommerce'));
     91                  $woocommerce->add_error( __( $dbfail, 'woocommerce' ) );
     92              } else {
     93
     94             }
     95    }
     96   
     97    if ( !isset( $_COOKIE['agreeable_terms'] ) && $dbremember == 1 ) {
     98        setcookie( 'agreeable_terms', 'yes', strtotime('+30 days'), COOKIEPATH, COOKIE_DOMAIN, false );
     99    }
     100   
     101   return $reg_errors;
    75102}
    76103
     
    177204}
    178205
     206
    179207// As part of WP login form construction, call our function
    180208add_filter('login_form', 'ag_login_terms_accept' );
     209add_filter('woocommerce_after_customer_login_form', 'ag_login_terms_accept');
    181210add_filter('register_form', 'ag_register_terms_accept');
    182211add_filter('comment_form_after_fields', 'ag_comment_terms_accept');
     
    270299
    271300add_action( 'plugins_loaded', 'ag_send_feedback');
     301
     302function is_login_page() {
     303    return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
     304}
  • agreeable/trunk/css/front.css

    r953516 r953592  
    22
    33.mfp-hide {display: none;}
     4
     5#terms {}
     6#terms h1, #terms h2 {margin-bottom: .5em; font-size: 2em;}
     7#terms h3, #terms h4 {margin-bottom: .5em; font-size: 1.3em;}
     8#terms ul, #terms ol {padding-left: 2em; margin-bottom: 1em;}
     9#terms p {margin-bottom: 1em;}
  • agreeable/trunk/js/agreeable.js

    r946511 r953592  
    44      midClick: true
    55    });
     6   
     7    if($('.woocommerce .login')) {
     8        $(".woocommerce>#terms-accept").insertBefore(".woocommerce .login #rememberme");
     9
     10    }
     11   
    612});
  • agreeable/trunk/readme.txt

    r953522 r953592  
    4141
    4242== Changelog ==
     43
     44= 3.4.2 =
     45* Fixed WooCommerce registration bug
    4346
    4447= 3.4.1 =
Note: See TracChangeset for help on using the changeset viewer.