Plugin Directory

Changeset 986028


Ignore:
Timestamp:
09/10/2014 04:01:44 AM (11 years ago)
Author:
buildcreate
Message:

Update to version 1.3.5, see read me for change log

Location:
agreeable/trunk
Files:
2 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • agreeable/trunk/agreeable.php

    r973537 r986028  
    33Plugin Name: Agreeable
    44Plugin URI: http://wordpress.org/extend/plugins/agreeable
    5 Description: Add a required "Agree to terms" checkbox to login and/or register forms.  Based on the I-Agree plugin by Michael Stursberg.
    6 Version: 1.3.4
     5Description: Add a required "Agree to terms" checkbox to login and/or register forms.
     6Version: 1.3.5
    77Author: kraftpress
    88Author URI: http://kraftpress.it
     
    1414//! Cleanup functions, make it smarter, faster, better.
    1515//==================================
    16 
    17 
    1816
    1917// If this file is called directly, abort.
     
    3735
    3836        /* Registration Validation Hooks  */
    39         add_filter('woocommerce_registration_errors', array($this, 'ag_woocommerce_reg_validation'), 10,3);
    4037        add_filter('registration_errors', array($this, 'ag_authenticate_user_acc'), 10, 2);
    4138        add_filter('bp_signup_validate', array($this, 'ag_authenticate_user_acc'), 10, 2);
    4239        add_filter('wpmu_validate_user_signup', array($this, 'ag_authenticate_user_acc'), 10, 3);
    4340
    44 
    4541        /* Login Validation Hooks */
    4642        add_filter('wp_authenticate_user', array($this, 'ag_authenticate_user_acc'), 10, 2);
    4743
    48 
    4944        /* Comment Validation Hooks */
    5045        add_action('pre_comment_on_post', array($this, 'ag_validate_comment'), 10, 2);
     
    5247        /* Output Hooks */
    5348        add_filter('login_form', array($this, 'ag_login_terms_accept') );
    54         add_filter('woocommerce_after_customer_login_form', array($this, 'ag_login_terms_accept'));
    5549        add_filter('register_form', array($this, 'ag_register_terms_accept'));
    5650        add_filter('comment_form_after_fields', array($this, 'ag_comment_terms_accept'));
     
    7367        return true;
    7468    }
    75    
     69
    7670    function update_options() {
     71
     72        if(isset($_POST['ag_hidden']) && $_POST['ag_hidden'] == 'Y') {
     73
     74            isset($_POST['ag_fail']) ? update_option('ag_fail', stripslashes($_POST['ag_fail'])) : update_option('ag_fail', '');
     75            isset($_POST['ag_termm']) ? update_option('ag_termm', $_POST['ag_termm']) : update_option('ag_termm', '');
     76            isset($_POST['ag_url']) ? update_option('ag_url', $_POST['ag_url']) : update_option('ag_url', '');
     77            isset($_POST['ag_hidden']) ? update_option('ag_colors', array('text-color' => $_POST['ag_text_color'], 'bg-color' => $_POST['ag_bg_color'])) : update_option('ag_colors', array('text-color' => '#333', 'bg-color' => '#fafafa'));
     78
     79            isset($_POST['ag_login']) ? update_option('ag_login', $_POST['ag_login']) : update_option('ag_login', '');
     80            isset($_POST['ag_register']) ? update_option('ag_register', $_POST['ag_register']) : update_option('ag_register', '');
     81            isset($_POST['ag_comments']) ? update_option('ag_comments', $_POST['ag_comments']) : update_option('ag_comments', '');
     82            isset($_POST['ag_lightbox']) ? update_option('ag_lightbox', $_POST['ag_lightbox']) : update_option('ag_lightbox', '');
     83            isset($_POST['ag_remember']) ? update_option('ag_remember', $_POST['ag_remember']) : update_option('ag_remember', '');
     84
     85        }
     86
    7787        $this->options = array(
    7888            'login' => get_option('ag_login'),
     
    92102        // Localization
    93103        load_plugin_textdomain('agreeable', false, basename( dirname( __FILE__ ) ) . '/languages' );
    94        
     104
    95105        if (is_multisite()) {
    96106            add_action( 'signup_extra_fields', array($this, 'ag_register_terms_accept'), 10, 3);
    97107            add_action( 'signup_blogform', array($this, 'ag_register_terms_accept'), 10, 3);
    98108        }
     109
     110        $this->update_options();
     111
    99112    }
    100113
    101114    function ag_admin() {
    102    
     115
    103116        /* Plugin Stylesheet */
    104117        wp_enqueue_style( 'agreeable-css', plugins_url('css/admin.css', __FILE__), '', '0.3.4', 'screen');
    105        
     118
    106119    }
    107120
    108121    function ag_front() {
    109    
     122
    110123        /* Only load lightbox code on the frontend, where we need it */
    111124        if ( $this->is_login_page() ) {
    112125            wp_enqueue_script('jquery');
    113126        }
    114        
     127
    115128        wp_enqueue_script( 'magnific', plugins_url('js/magnific.js', __FILE__),'', '', true);
    116129        wp_enqueue_script( 'agreeable-js', plugins_url('js/agreeable.js', __FILE__), '', '', true);
    117130        wp_enqueue_style( 'magnific', plugins_url('css/magnific.css', __FILE__));
    118131        wp_enqueue_style( 'agreeable-css', plugins_url('css/front.css', __FILE__));
    119        
    120     }
    121 
    122 
    123 
     132
     133    }
    124134
    125135    function ag_authenticate_user_acc($user) {
     
    128138        if(isset($_REQUEST['ag_type']) && $_REQUEST['ag_type'] == "login" && $this->options['login'] == 1 || isset($_REQUEST['ag_type']) && $_REQUEST['ag_type'] == 'register' && $this->options['register'] == 1) {
    129139
    130             // See if the checkbox #login_accept was checked
    131             if ( isset( $_REQUEST['login_accept'] ) && $_REQUEST['login_accept'] == 'on' ) {
     140            // See if the checkbox #ag_login_accept was checked
     141            if ( isset( $_REQUEST['ag_login_accept'] ) && $_REQUEST['ag_login_accept'] == 1) {
    132142
    133143                // Checkbox on, allow login, set the cookie if necessary
     
    136146                    setcookie( 'agreeable_terms', 'yes', strtotime('+30 days'), COOKIEPATH, COOKIE_DOMAIN, false );
    137147                }
     148
     149
     150                do_action('agreeable_validate_user', $user, $_REQUEST['ag_type']);
     151
     152                unset($_SESSION['ag_errors']);
     153
     154                return $user;
     155
     156            } else {
     157
     158                if($this->is_buddypress_registration()) {
     159
     160                    global $bp;
     161
     162                    $bp->signup->errors['ag_login_accept'] = $this->options['fail_text'];
     163
     164                    return;
     165
     166                }
     167
     168                $errors = new WP_Error();
    138169               
     170                $errors->add('ag_login_accept', $this->options['fail_text']);
    139171               
    140                 do_action('agreeable_validate_user', $user, $_REQUEST['ag_type']);
    141                
    142                 return $user;
    143                
    144             } else {
    145 
    146                 if($this->is_buddypress_registration()) {
    147                
    148                         global $bp;
    149                                            
    150                         $bp->signup->errors['login_accept'] = $this->options['fail_text'];
    151                        
    152                         return;
    153                        
    154                     }
    155                    
    156                
    157                
    158                 $errors = new WP_Error();
    159                 $errors->add('ag_did_not_accept', $this->options['fail_text']);
    160172
    161173                /* Incase it's a form that doesn't respect WordPress' error system */
     
    163175                $_SESSION['ag_errors'] = $this->options['fail_text'];
    164176
    165 
    166                 if(is_multisite()) {
     177                if(is_multisite() && $this->is_multisite_register() && !$this->is_login_page()) {                   
    167178                   
    168179                    $result = $user;
    169                     $result['errors'] = $errors;
    170180                   
    171181                    return $result;
    172182
    173                 } else {
    174 
    175                     return $errors;
    176 
    177183                }
    178184
     185                return $errors;
     186
    179187            }
    180188
     
    187195    }
    188196
     197    function is_woocommerce_page () {
     198
     199        if(  function_exists( "is_woocommerce" ) && is_woocommerce()){
     200            return true;
     201        }
     202
     203        $woocommerce_keys   =   array ( "woocommerce_shop_page_id" ,
     204            "woocommerce_terms_page_id" ,
     205            "woocommerce_cart_page_id" ,
     206            "woocommerce_checkout_page_id" ,
     207            "woocommerce_pay_page_id" ,
     208            "woocommerce_thanks_page_id" ,
     209            "woocommerce_myaccount_page_id" ,
     210            "woocommerce_edit_address_page_id" ,
     211            "woocommerce_view_order_page_id" ,
     212            "woocommerce_change_password_page_id" ,
     213            "woocommerce_logout_page_id" ,
     214            "woocommerce_lost_password_page_id" ) ;
     215        foreach ( $woocommerce_keys as $wc_page_id ) {
     216            if ( get_the_ID () == get_option ( $wc_page_id , 0 ) ) {
     217                return true ;
     218            }
     219        }
     220        return false;
     221    }
     222
    189223    function is_buddypress_registration() {
    190224
    191225        if(function_exists('bp_current_component')) {
    192                
     226
    193227            /* Lets make sure we're on the right page- Ie the buddypress register page */
    194228            $bp_pages = get_option('bp-pages');
    195229            $bp_page = get_post($bp_pages['register']);
    196            
     230
    197231            global $wp_query;
    198232            $current_page = isset($wp_query->query_vars['name']) ? $wp_query->query_vars['name'] : '';
    199                        
     233
    200234            return $bp_page->post_name == $current_page ?  true : false;
    201235
     
    203237    }
    204238
    205 
    206 
    207     function ag_woocommerce_reg_validation($reg_errors, $sanitized_user_login, $user_email) {
    208         global $woocommerce;
    209 
    210         if(!isset($_REQUEST['login_accept'])) {
    211 
    212             if ( !isset($_COOKIE['agreeable_terms'] ) && $this->options['remember_me'] == 1 || $this->options['remember_me'] == 0) {
    213                 return new WP_Error('registration-error', __($this->options['fail_text'], 'woocommerce'));
    214                 $woocommerce->add_error( __( $this->options['fail_text'], 'woocommerce' ) );
    215             } else {
    216 
    217             }
    218         }
    219 
    220         if ( !isset( $_COOKIE['agreeable_terms'] ) && $this->options['remember_me'] == 1 ) {
    221             setcookie( 'agreeable_terms', 'yes', strtotime('+30 days'), COOKIEPATH, COOKIE_DOMAIN, false );
    222         }
    223 
    224         return $reg_errors;
    225     }
    226 
    227239    function ag_validate_comment($comment) {
    228240
    229241        if($this->options['comments'] == 1) {
    230242
    231             // See if the checkbox #login_accept was checked
    232             if ( isset( $_REQUEST['login_accept'] ) && $_REQUEST['login_accept'] == 'on' ) {
     243            // See if the checkbox #ag_login_accept was checked
     244            if ( isset( $_REQUEST['ag_login_accept'] ) && $_REQUEST['ag_login_accept'] == 'on' ) {
    233245                // Checkbox on, allow comment
    234246                return $comment;
     
    251263    function ag_display_terms_form($type, $errors = '') {
    252264
     265        global $bp;
     266
    253267        if(isset($this->options['terms_page'])) {
    254268            $terms = get_post($this->options['terms_page']);
     
    271285        /*  Get our errors incase we need to display */
    272286
    273         $errors = new WP_Error();
    274 
    275         if(isset($_SESSION['ag_errors']) && $errors->get_error_message( 'ag_did_not_accept' ) == '' ) {
     287        $errors = new WP_Error;
     288
     289        if(isset($_SESSION['ag_errors']) && $errors->get_error_message( 'ag_login_accept' ) == '') {
    276290
    277291            $error = $_SESSION['ag_errors'];
    278292            unset($_SESSION['ag_errors']);
    279293
    280         } elseif (is_wp_error($errors)) {
    281 
    282             unset($error);
    283 
    284         }
    285 
    286         if ( !empty($error) ) {
    287 
    288             echo "<br><p class='error'>$error</p>";
     294        }
     295       
     296        if ( isset($error) && !$this->is_login_page()) {
     297
     298            echo '<br><p class="error">'.$error.'</p>';
    289299
    290300        }
     
    300310        echo '<div style="clear: both; padding: .25em 0;" id="terms-accept" class="terms-form">';
    301311
    302         if($this->is_buddypress_registration()){do_action( 'bp_login_accept_errors' );}
    303 
    304         echo '<label style="text-align: left;"><input type="checkbox" name="login_accept" id="login_accept" '.$remember.' />&nbsp;<a title="'.get_post($this->options['terms_page'])->post_title.'" class="open-popup-link" target="_BLANK" href="'.$term_link.'">'.$this->options['message'].'</a></label>';
     312        if($this->is_buddypress_registration()){do_action( 'bp_ag_login_accept_errors' );}
     313
     314        echo '<label style="text-align: left;"><input type="checkbox" value="1" name="ag_login_accept" id="ag_login_accept" '.$remember.' />&nbsp;<a title="'.get_post($this->options['terms_page'])->post_title.'" class="ag-open-popup-link" target="_BLANK" href="'.$term_link.'">'.$this->options['message'].'</a></label>';
    305315        echo '<input type="hidden" value="'.$type.'" name="ag_type" /></div>';
    306316        echo '<div id="terms" class="mfp-hide">'.$terms_content.'</div>';
     
    327337
    328338        if($this->options['register'] == 1) {
     339
    329340            $this->ag_display_terms_form('register', $errors);
    330            
    331             echo '<script>';
    332             echo '
    333                     jQuery(document).ready(function($){
    334                         if($("#theme-my-login")) {
    335                             $("#theme-my-login #terms-accept").insertBefore("#theme-my-login .submit");
    336                         }
    337                     });
    338                 ';
    339             echo '</script>';
    340            
     341
     342            if(class_exists('ThemeMyLogin')) {
     343                echo '<script>';
     344                echo '
     345                        jQuery(document).ready(function($){
     346                            if($("#theme-my-login")) {
     347                                $("#theme-my-login #terms-accept").insertBefore("#theme-my-login .submit");
     348                            }
     349                        });
     350                    ';
     351                echo '</script>';
     352            }
     353
    341354        }
    342355        return;
     
    360373    }
    361374
    362 
    363 
    364375    function agreeable_options() {
    365376        add_options_page('agreeable', 'Agreeable', 'manage_options', 'terms-options', array($this, 'agoptions'));
     
    367378
    368379    function agoptions() {
    369         include('agreeable-options.php');
     380        include_once('includes/settings.php');
    370381    }
    371382
     
    379390        return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
    380391    }
     392   
     393    function is_multisite_register() {
     394        return in_array($GLOBALS['pagenow'], array('wp-signup.php'));
     395    }
    381396
    382397}
  • agreeable/trunk/css/admin.css

    r970082 r986028  
    3333
    3434.agreeable-settings h3 {margin-top: 3em;}
     35.agreeable-settings h4 {margin: 2em 0 1em 0; padding-bottom: .5em; border-bottom: 1px dotted #ccc; font-size: 1.2em; color: #888; font-weight: 100; text-shadow: 0px 1px 1px #fff; text-transform: uppercase;}
    3536
    36 .kp-cross-promote-area {position: absolute; right: 10%; top: 16%; width: 20%; min-height: 200px; padding: 0 1em 1em; background: #fafafa; border: 1px solid #ccc; text-align: center; box-sizing: border-box;}
     37.kp-cross-promote-area {position: absolute; right: 10%; top: 0; width: 20%; min-height: 200px; padding: 0 1em 1em; background: #fafafa; border: 1px solid #ccc; text-align: center; box-sizing: border-box;}
    3738.kp-cross-promote-area #kp-logo {margin-bottom: 2em; margin-top: -1px; border-top: 1px #fff;}
    3839.kp-cross-promote-area h3 {margin-top: 0; font-weight: 100; text-transform: uppercase; color: #777; text-shadow: 0 1px 1px #fff; font-size: 1.4em; line-height: 1.4em; margin-bottom: .25em;}
  • agreeable/trunk/js/agreeable.js

    r953592 r986028  
    11jQuery(document).ready(function($) {
    2     $('.open-popup-link').magnificPopup({
    3       type:'inline',
    4       midClick: true
    5     });
     2
     3    $(document).on("DOMSubtreeModified", function(){
     4        $('.ag-open-popup-link').magnificPopup({
     5          type:'inline',
     6          midClick: true,
     7        });
     8    });
    69   
    710    if($('.woocommerce .login')) {
    8         $(".woocommerce>#terms-accept").insertBefore(".woocommerce .login #rememberme");
    9 
     11        $(".woocommerce>#agreeable_login_field").insertBefore(".woocommerce .login #rememberme");
    1012    }
    11    
     13           
    1214});
  • agreeable/trunk/readme.txt

    r973423 r986028  
    11=== Agreeable ===
    2 Contributors: kraftpress, buildcreate, thesturs
    3 Tags: agree, terms, conditions, require, terms, login, log in, admin, login page, admin, buddy press, page, policy, privacy, bbpress, theme my login, signup, register, widgets, comment terms, comments, multisite
     2Contributors: kraftpress, buildcreate
     3Tags: agree, terms, conditions, require, terms, login, log in, admin, login page, admin, buddy press, page, policy, privacy, bbpress, theme my login, signup, register, widgets, comment terms, comments, multisite, woocommerce
    44Requires at least: 3.5
    5 Tested up to: 3.9.1
     5Tested up to: 4.0
    66Stable tag: trunk
    77License:GPLv2 or later
     
    99
    1010== Description ==
    11 Add an "agree to terms" check box to your login, registration, or comment forms, requiring users to agree. Tested with BuddyPress and Multisite.  Based on the I-Agree plugin by thesturs.
    12 
    13 Use the form in the plugin settings page to contact us with feature requests, comments, or concerns.
     11Add an "agree to terms" check box to your login, registration, or comment forms, requiring users to agree. Tested with BuddyPress and Multisite.
    1412
    1513= Features =
     
    2018
    2119= Extensions =
    22 * Agreeable Records - Allows you to track user agreement by IP and username each time they log in. Learn more and purchase at: http://kraftpress.it/downloads/agreeable-records/
     20* Agreeable Login Records - Allows you to track user agreement by IP and username each time they log in. Learn more and purchase at: http://kraftpress.it/downloads/agreeable-records/
     21* WooCommerce Integration - Integrates Agreeable's terms & conditions fields into Woocommerce login, registration, and checkout. Learn more and purchase at: http://kraftpress.it/downloads/agreeable-woocommerce/
    2322
    2423= Translations =
     
    3837
    3938== Changelog ==
     39
     40= 1.3.5 =
     41* Resolved multisite registration issue
     42* Cleaned up code, renamed some functions
     43* Added a couple more hooks
     44* Added functions as needed for extensions
     45* Updated settings page
     46* Updated plugin banner
    4047
    4148= 1.3.3 =
Note: See TracChangeset for help on using the changeset viewer.