Plugin Directory

Changeset 948152


Ignore:
Timestamp:
07/14/2014 03:36:38 PM (12 years ago)
Author:
buildcreate
Message:

Version 0.3.1 Added localization and "remember agreement" feature

Location:
agreeable
Files:
16 added
4 edited

Legend:

Unmodified
Added
Removed
  • agreeable/trunk/agreeable-options.php

    r946511 r948152  
    3131          update_option('ag_colors', $dbcolors);
    3232         
     33          $dbremember = $_POST['ag_remember'];
     34          update_option('ag_remember', $dbremember);
     35         
    3336?>
    3437       
     
    4245          $dblogin = get_option('ag_login');
    4346          $dbregister = get_option('ag_register');
     47          $dbcomments = get_option('ag_comments');
    4448          $dblightbox = get_option('ag_lightbox');
    4549          $dbcolors = get_option('ag_colors');
     50          $dbremember = get_option('ag_remember');
    4651         
    4752          if(empty($dbcolors)) {
     
    5257        }
    5358    ?>
    54    
    55 <style>
    56     .mes {
    57         color: gray;
    58         font-style: italic;
    59         font-size:. 9em;
    60     }
    61     #ag-form {
    62         width: 50%;
    63     }
    64     textarea {
    65         clear: right;
    66         float: right;
    67     }
    68     input[type="submit"] {
    69         margin-top: 2em;
    70     }
    71     #ag-form label {display: block; margin-bottom: .25em; font-weight: 800;}
    72     #ag-form .checkboxes label {display: inline;}
    73    
    74     #ag-form h3 {border-bottom: 1px solid #ccc; margin-bottom: .5em; padding-bottom: .5em; color: #369; text-shadow: 0 1px 1px #fff;}
    75     #ag-form input[type="text"] {min-width: 400px;}
    76     #feedback-form input[type="email"], #feedback-form textarea {width: 100%; display: block;}
    77     #feedback-form textarea {min-height: 100px;}
    78     .checkboxes {padding-bottom: 1em;}
    79 </style>
    8059
    8160<?php $pages = get_pages('status=publish&numberposts=-1&posts_per_page=-1'); ?>
     
    8665            </div>
    8766            <div class="ag_feedback_form">
    88                 <?php feedback_form(); ?>
     67                <?php ag_feedback_form(); ?>
    8968            </div>
    9069           
     
    9372                <input type="hidden" name="ag_hidden" value="Y">
    9473               
    95                 <?php    echo "<h3>" . __( 'Settings', 'ag_trdom' ) . "</h3>"; ?>
     74                <?php    echo "<h3>" . __( 'Settings', 'agreeable' ) . "</h3>"; ?>
    9675               
    97                 <p><label for="ag_fail"><?php _e("Failed to agree error message: " ); ?></label><input type="text" name="ag_fail" value="<?php echo $dbfail; ?>" size="20"></br><?php _e("<span class='mes'>This is what shows up if they don't check the box</span>" ); ?></p>
     76                <p><label for="ag_fail"><?php _e("Failed to agree error message: ", 'agreeable' ); ?></label><input type="text" name="ag_fail" value="<?php echo $dbfail; ?>" size="20"></br><span class='mes'><?php _e("This is what shows up if they don't check the box", 'agreeable' ); ?></span></p>
    9877               
    9978                <p>
    100                     <label for="ag_url">Select your terms page</label>
     79                    <label for="ag_url"><?php _e("Select your terms page", 'agreeable'); ?></label>
    10180                    <select name="ag_url">
    10281                        <?php foreach ($pages as $p) { ?>
     
    10483                        <?php } ?>
    10584                    </select>
    106                     <br><?php _e("<span class='mes'>Create a page for your terms and conditions and select it here.</span>" ); ?>
     85                    <br><span class='mes'><?php _e("Create a page for your terms and conditions and select it here.", 'agreeable' ); ?></span>
    10786                </p>
    10887               
    109                 <p><label for="ag_termm"><?php _e("Message: " ); ?></label><input type="text"  name="ag_termm" size="40" value="<?php echo $dbtermm; ?>"><br><?php _e("<span class='mes'>This is the text that goes right after the checkbox</span>" ); ?></p>
     88                <p><label for="ag_termm"><?php _e("Message: ", 'agreeable' ); ?></label><input type="text"  name="ag_termm" size="40" value="<?php echo $dbtermm; ?>"><br><span class='mes'><?php _e("This is the text that goes right after the checkbox", 'agreeable' ); ?></span></p>
     89               
     90               
     91                <p class="ag-checkboxes">
     92                    <input type="checkbox" id="ag_remember" name="ag_remember" value="1" <?php if($dbremember == 1) {echo 'checked';} ?> />
     93                    <label for="ag_remember"><?php _e("Remember agreement for 30 days", 'agreeable'); ?></label>
     94                </p>
     95               
     96                <div class="ag-color-options ag-checkboxes">
     97                    <h3><?php _e("Lightbox Options", 'agreeable'); ?></h3>
     98                    <p class="ag-checkboxes">
     99                        <input type="checkbox" id="ag_lightbox" name="ag_lightbox" value="1" <?php if($dblightbox == 1) {echo 'checked';} ?> />
     100                        <label for="ag_lightbox"><?php _e("Active?", 'agreeable'); ?></label>
    110101                       
    111                
    112                 <div class="color-options checkboxes">
    113                     <h3>Lightbox options</h3>
    114                                     <p class="checkboxes">
    115                 <input type="checkbox" id="ag_lightbox" name="ag_lightbox" value="1" <?php if($dblightbox == 1) {echo 'checked';} ?> />
    116                     <label for="ag_lightbox">Active?</label>
    117                    
    118                     <br><?php _e("<span class='mes'>If checked, the terms will pop up in a responsive lightbox.  If unchecked the message will link to your terms page.</span>" ); ?></p>
    119                 </p>
     102                        <br><span class='mes'><?php _e("If checked, the terms will pop up in a responsive lightbox.  If unchecked the message will link to your terms page.", 'agreeable' ); ?></span></p>
     103                    </p>
    120104                   
    121105                    <input type="color" name="ag_text_color" id="ag_text_color" value="<?php echo $dbcolors['text-color']; ?>"/>
    122                     <label for="ag_text_color">Text color</label>
     106                    <label for="ag_text_color"><?php _e("Text color", 'agreeable'); ?></label>
    123107                    <br><br>
    124108                   
    125109                    <input type="color" name="ag_bg_color" id="ag_bg_color" value="<?php echo $dbcolors['bg-color']; ?>" />
    126                     <label for="ag_bg_color">Background color</label>
     110                    <label for="ag_bg_color"><?php _e("Background color", 'agreeable'); ?></label>
    127111                </div> 
    128112
    129                 <div class="checkboxes">
    130                                 <p>
    131                 <h3><?php _e("Where should it be displayed? " ); ?></h3>
    132                     <input type="checkbox" id="ag_login" name="ag_login" value="1" <?php if($dblogin == 1) {echo 'checked';} ?> /> <label for="ag_login"> Login form</label><br>
    133                     <input type="checkbox" id="ag_register" name="ag_register" value="1" <?php if($dbregister == 1) {echo 'checked';} ?> /> <label for="ag_register">Registration form</label>
    134                     <br>
    135                     <input type="checkbox" id="ag_comments" name="ag_comments" value="1" <?php if($dbcomments == 1) {echo 'checked';} ?> /> <label for="ag_comments">Comment form</label>
     113                <div class="ag-checkboxes">
     114                               
     115                <h3><?php _e("Where should it be displayed? ", 'agreeable' ); ?></h3>
     116                    <p>
     117                        <input type="checkbox" id="ag_login" name="ag_login" value="1" <?php if($dblogin == 1) {echo 'checked';} ?> /> <label for="ag_login"> <?php _e("Login form", 'agreeable'); ?></label><br>
     118                        <input type="checkbox" id="ag_register" name="ag_register" value="1" <?php if($dbregister == 1) {echo 'checked';} ?> /> <label for="ag_register"><?php _e("Registration form", 'agreeable'); ?></label>
     119                        <br>
     120                        <input type="checkbox" id="ag_comments" name="ag_comments" value="1" <?php if($dbcomments == 1) {echo 'checked';} ?> /> <label for="ag_comments"><?php _e("Comment form", 'agreeable'); ?></label>
     121                    </p>
    136122                </div>             
    137123           
    138124                <p class="submit">
    139                 <input type="submit" class="button button-large button-primary" name="Submit" value="<?php _e('Update Options', 'ag_trdom' ) ?>" />
     125                <input type="submit" class="button button-large button-primary" name="Submit" value="<?php _e('Update Options', 'agreeable' ) ?>" />
    140126                </p>
    141127            </form>
  • agreeable/trunk/agreeable.php

    r946511 r948152  
    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
     6Version: 0.3.1
    77Author: buildcreate
    88Author URI: http://buildcreate.com
    99*/
     10
     11function ag_action_init() {
     12    // Localization
     13    load_plugin_textdomain('agreeable', false, basename( dirname( __FILE__ ) ) . '/languages' );
     14}
     15
     16add_action('init', 'ag_action_init');
     17
    1018
    1119wp_enqueue_style( 'agreeable-css', plugins_url('css/agreeable.css', __FILE__));
     
    2028}
    2129
    22 function wp_authenticate_user_acc($user) {
     30function ag_authenticate_user_acc($user) {
    2331   
    2432    $dblogin = get_option('ag_login');
    2533    $dbregister = get_option('ag_register');
    2634    $dbfail = get_option('ag_fail');
     35    $dbremember = get_option('ag_remember');
    2736
    2837    global $bp;
     
    3342        if ( isset( $_REQUEST['login_accept'] ) && $_REQUEST['login_accept'] == 'on' ) {
    3443            // Checkbox on, allow login
     44           
     45                if ( !isset( $_COOKIE['agreeable_terms'] ) && $dbremember == 1 ) {
     46                    setcookie( 'agreeable_terms', 'yes', strtotime('+30 days'), COOKIEPATH, COOKIE_DOMAIN, false );
     47                }
     48           
    3549            return $user;
    3650        } else {
    37             // Did NOT check the box, do not allow login
    38            
    39             $error = new WP_Error();
    40             $error->add('did_not_accept', $dbfail);
    41              
    42               if(isset($bp->signup)) {
    43                     $bp->signup->errors['login_accept'] = '<div class="error">'.$dbfail.'</div>';
     51            // Did NOT check the box, lets see if the cookie is already set
     52           
     53            if ( !isset($_COOKIE['agreeable_terms'] ) && $dbremember == 1 || $dbremember == 0) {
     54                                   
     55                $error = new WP_Error();
     56                $error->add('did_not_accept', $dbfail);
     57                 
     58                  if(isset($bp->signup)) {
     59                        $bp->signup->errors['login_accept'] = '<div class="error">'.$dbfail.'</div>';
     60                }
     61               
     62                return $error;
     63               
     64            } else {
     65                return $user;
    4466            }
    45            
    46             return $error;
    4767        }
    4868    } else {
     
    81101
    82102// Add it to the appropriate hooks
    83 add_filter('wp_authenticate_user', 'wp_authenticate_user_acc', 99999, 2);
    84 add_filter('registration_errors', 'wp_authenticate_user_acc', 99999, 2);
    85 add_filter('bp_signup_validate', 'wp_authenticate_user_acc', 99999, 2);
     103add_filter('wp_authenticate_user', 'ag_authenticate_user_acc', 99999, 2);
     104add_filter('registration_errors', 'ag_authenticate_user_acc', 99999, 2);
     105add_filter('bp_signup_validate', 'ag_authenticate_user_acc', 99999, 2);
    86106add_action('pre_comment_on_post', 'ag_validate_comment', 99999, 2);
    87107
    88 function display_terms_form($type) {
     108function ag_display_terms_form($type) {
    89109    $dbtermm = get_option('ag_termm');
    90110    $dburl = get_option('ag_url');
    91111    $dblightbox = get_option('ag_lightbox');
    92112    $dbcolors = get_option('ag_colors');
    93  
    94    if(isset($dburl)) {$terms = get_post($dburl); $terms_content = '<h3>'.$terms->post_title.'</h3>'.apply_filters('the_content', $terms->post_content);}   
    95  
    96     // Add an element to the login form, which must be checked
    97    
    98     $term_link = get_post_permalink($terms);
    99    
    100     if($dblightbox == 1) {
    101    
    102         agreeable_lightbox();
    103         $term_link = '#terms';
    104        
    105         if($dbcolors) {
    106             echo '<style>#terms {background: '.$dbcolors['bg-color'].' !important; color: '.$dbcolors['text-color'].';}</style>';
    107         }       
     113    $dbremember = get_option('ag_remember');
     114   
     115    if ( !isset($_COOKIE['agreeable_terms'] ) && $dbremember == 1 || $dbremember == 0 ) {
     116       if(isset($dburl)) {$terms = get_post($dburl); $terms_content = '<h3>'.$terms->post_title.'</h3>'.apply_filters('the_content', $terms->post_content);}   
     117       
     118        // Add an element to the login form, which must be checked
     119       
     120        $term_link = get_post_permalink($terms);
     121       
     122        if($dblightbox == 1) {
     123       
     124            agreeable_lightbox();
     125            $term_link = '#terms';
     126           
     127            if($dbcolors) {
     128                echo '<style>#terms {background: '.$dbcolors['bg-color'].' !important; color: '.$dbcolors['text-color'].';}</style>';
     129            }       
     130        }
     131       
     132        echo '<div style="clear: both; padding: .25em 0;" id="terms-accept" class="terms-form">';
     133            if(isset($bp)){do_action( 'bp_login_accept_errors' );}
     134        echo '<label style="text-align: left;"><input type="checkbox" name="login_accept" id="login_accept" />&nbsp;<a title="'.get_post($dburl)->post_title.'" class="open-popup-link" target="_BLANK" href="'.$term_link.'">'.$dbtermm.'</a></label>';
     135        echo '<input type="hidden" value="'.$type.'" name="ag_type" /></div>';
     136        echo '<div id="terms" class="mfp-hide">'.$terms_content.'</div>';
     137        echo $type == 'comments' ? '<br>':'';
    108138    }
    109    
    110     echo '<div style="clear: both; padding: .25em 0;" id="terms-accept" class="terms-form">';
    111         if(isset($bp)){do_action( 'bp_login_accept_errors' );}
    112     echo '<label style="text-align: left;"><input type="checkbox" name="login_accept" id="login_accept" />&nbsp;<a title="'.get_post($dburl)->post_title.'" class="open-popup-link" target="_BLANK" href="'.$term_link.'">'.$dbtermm.'</a></label>';
    113     echo '<input type="hidden" value="'.$type.'" name="ag_type" /></div>';
    114     echo '<div id="terms" class="mfp-hide">'.$terms_content.'</div>';
    115     echo $type == 'comments' ? '<br>':'';
    116 }
    117 
    118 function login_terms_accept(){
     139}
     140
     141function ag_login_terms_accept(){
    119142    $dblogin = get_option('ag_login');
    120143   
    121144    if($dblogin == 1) {
    122         display_terms_form('login');
    123     }
    124 }
    125 
    126 function comment_terms_accept(){
     145        ag_display_terms_form('login');
     146    }
     147}
     148
     149function ag_comment_terms_accept(){
    127150    $dbcomments = get_option('ag_comments');
    128151   
    129152    if($dbcomments == 1) {
    130         display_terms_form('comments');
    131     }
    132 }
    133 
    134 function register_terms_accept() {
     153        ag_display_terms_form('comments');
     154    }
     155}
     156
     157function ag_register_terms_accept() {
    135158   
    136159    $dbregister = get_option('ag_register');
    137160   
    138161    if($dbregister == 1) {
    139         display_terms_form('register');
     162        ag_display_terms_form('register');
    140163    }
    141164   
     
    153176
    154177// As part of WP login form construction, call our function
    155 add_filter('login_form', 'login_terms_accept' );
    156 add_filter('register_form', 'register_terms_accept');
    157 add_filter('comment_form_after_fields', 'comment_terms_accept');
    158 
    159 add_action('bp_before_registration_submit_buttons', 'register_terms_accept');
     178add_filter('login_form', 'ag_login_terms_accept' );
     179add_filter('register_form', 'ag_register_terms_accept');
     180add_filter('comment_form_after_fields', 'ag_comment_terms_accept');
     181
     182add_action('bp_before_registration_submit_buttons', 'ag_register_terms_accept');
    160183
    161184
     
    165188   
    166189    if($dblogin == 1) {
    167         display_terms_form('login');
     190        ag_display_terms_form('login');
    168191    }
    169192   
     
    195218/* Plugin feedback form */
    196219
    197 function feedback_form() {
     220function ag_feedback_form() {
    198221   
    199222    if(!isset($_POST['feedback_email']) && !isset($_POST['feedback_content'])) {
    200223   
     224/*
    201225    $output = '<h3>We want your feedback.</h3>
    202226                <p><em>Have a feature idea, feedback, or question about the plugin?<br>We want to know- send it on over!</em></p>
    203                 <form id="feedback-form" name="feedback_form" method="post" action="'.str_replace( '%7E', '~', $_SERVER['REQUEST_URI']).'">
     227                <form id="ag-feedback-form" name="feedback_form" method="post" action="'.str_replace( '%7E', '~', $_SERVER['REQUEST_URI']).'">
    204228                <label for="feedback_email">Your email</label>
    205229                    <input type="email" name="feedback_email" placeholder="[email protected]" /><br>
     
    208232                    <input type="submit" class="button-primary button-large button" style="margin-top: 1em;" value="Send it!" />           
    209233                </form>';
    210     $output .= '<div style="padding: 1em; background: #eee; color: #333; margin-top: 2em;">
     234*/
     235    $output .= '<div style="padding: 1em; background: #eee; color: #333;">
    211236                    <h3 style="color: #369;">Buy me a cup of joe?</h3>
    212237                    <p>
     
    228253}
    229254
    230 function send_feedback() {
     255function ag_send_feedback() {
    231256    if(isset($_POST['feedback_email']) && isset($_POST['feedback_content'])) {
    232257       
     
    242267}
    243268
    244 add_action( 'plugins_loaded', 'send_feedback');
     269add_action( 'plugins_loaded', 'ag_send_feedback');
  • agreeable/trunk/css/agreeable.css

    r946511 r948152  
     1
     2/* Front end styles */
     3
    14.mfp-hide {display: none;}
     5
     6
     7/* Options page */
     8
     9.mes {
     10    color: gray;
     11    font-style: italic;
     12    font-size:. 9em;
     13}
     14#ag-form {
     15    width: 50%;
     16}
     17textarea {
     18    clear: right;
     19    float: right;
     20}
     21input[type="submit"] {
     22    margin-top: 2em;
     23}
     24
     25#ag-form label {display: block; margin-bottom: .25em; font-weight: 800; font-size: 1.1em;}
     26#ag-form .checkboxes label {display: inline;}
     27
     28#ag-form h3 {border-bottom: 1px solid #ccc; margin-bottom: .5em; padding-bottom: .5em; color: #369; text-shadow: 0 1px 1px #fff; font-size: 1.4em;}
     29#ag-form input[type="text"] {min-width: 400px;}
     30#ag-feedback-form input[type="email"], #ag-feedback-form textarea {width: 100%; display: block;}
     31#ag-feedback-form textarea {min-height: 100px;}
     32.ag-checkboxes {padding-bottom: 1em;}
     33
     34.ag-checkboxes input {float: left; margin-right: .5em;}
     35.ag-checkboxes label {line-height: 1em; margin-bottom: 0;}
     36
     37.ag-color-options input {margin-top: -.25em;}
    238
    339.ag-plugin-banner {border-bottom: 4px solid #5074bd; padding: 1em; background: #f4f4f4;}
  • agreeable/trunk/readme.txt

    r946511 r948152  
    3737
    3838== Changelog ==
     39
     40= 0.3.1 =
     41* Misc tweaks
     42* Added the ability to remember a user's agreement for 30 days
     43* Plugin is now localized and ready for translations- Spanish translation coming in 0.3.2
    3944
    4045= 0.3 =
Note: See TracChangeset for help on using the changeset viewer.