Changeset 948152
- Timestamp:
- 07/14/2014 03:36:38 PM (12 years ago)
- Location:
- agreeable
- Files:
-
- 16 added
- 4 edited
-
tags/0.3 (added)
-
tags/0.3/agreeable-options.php (added)
-
tags/0.3/agreeable.php (added)
-
tags/0.3/css (added)
-
tags/0.3/css/agreeable.css (added)
-
tags/0.3/css/magnific.css (added)
-
tags/0.3/images (added)
-
tags/0.3/images/banner.png (added)
-
tags/0.3/js (added)
-
tags/0.3/js/agreeable.js (added)
-
tags/0.3/js/magnific.js (added)
-
tags/0.3/readme.txt (added)
-
trunk/agreeable-options.php (modified) (6 diffs)
-
trunk/agreeable.php (modified) (10 diffs)
-
trunk/css/agreeable.css (modified) (1 diff)
-
trunk/languages (added)
-
trunk/languages/agreeable.pot (added)
-
trunk/languages/en.mo (added)
-
trunk/languages/en.po (added)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
agreeable/trunk/agreeable-options.php
r946511 r948152 31 31 update_option('ag_colors', $dbcolors); 32 32 33 $dbremember = $_POST['ag_remember']; 34 update_option('ag_remember', $dbremember); 35 33 36 ?> 34 37 … … 42 45 $dblogin = get_option('ag_login'); 43 46 $dbregister = get_option('ag_register'); 47 $dbcomments = get_option('ag_comments'); 44 48 $dblightbox = get_option('ag_lightbox'); 45 49 $dbcolors = get_option('ag_colors'); 50 $dbremember = get_option('ag_remember'); 46 51 47 52 if(empty($dbcolors)) { … … 52 57 } 53 58 ?> 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>80 59 81 60 <?php $pages = get_pages('status=publish&numberposts=-1&posts_per_page=-1'); ?> … … 86 65 </div> 87 66 <div class="ag_feedback_form"> 88 <?php feedback_form(); ?>67 <?php ag_feedback_form(); ?> 89 68 </div> 90 69 … … 93 72 <input type="hidden" name="ag_hidden" value="Y"> 94 73 95 <?php echo "<h3>" . __( 'Settings', 'ag _trdom' ) . "</h3>"; ?>74 <?php echo "<h3>" . __( 'Settings', 'agreeable' ) . "</h3>"; ?> 96 75 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> 98 77 99 78 <p> 100 <label for="ag_url"> Select your terms page</label>79 <label for="ag_url"><?php _e("Select your terms page", 'agreeable'); ?></label> 101 80 <select name="ag_url"> 102 81 <?php foreach ($pages as $p) { ?> … … 104 83 <?php } ?> 105 84 </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> 107 86 </p> 108 87 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> 110 101 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> 120 104 121 105 <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> 123 107 <br><br> 124 108 125 109 <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> 127 111 </div> 128 112 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> 136 122 </div> 137 123 138 124 <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' ) ?>" /> 140 126 </p> 141 127 </form> -
agreeable/trunk/agreeable.php
r946511 r948152 4 4 Plugin URI: http://wordpress.org/extend/plugins/agreeable 5 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: 0.3 6 Version: 0.3.1 7 7 Author: buildcreate 8 8 Author URI: http://buildcreate.com 9 9 */ 10 11 function ag_action_init() { 12 // Localization 13 load_plugin_textdomain('agreeable', false, basename( dirname( __FILE__ ) ) . '/languages' ); 14 } 15 16 add_action('init', 'ag_action_init'); 17 10 18 11 19 wp_enqueue_style( 'agreeable-css', plugins_url('css/agreeable.css', __FILE__)); … … 20 28 } 21 29 22 function wp_authenticate_user_acc($user) {30 function ag_authenticate_user_acc($user) { 23 31 24 32 $dblogin = get_option('ag_login'); 25 33 $dbregister = get_option('ag_register'); 26 34 $dbfail = get_option('ag_fail'); 35 $dbremember = get_option('ag_remember'); 27 36 28 37 global $bp; … … 33 42 if ( isset( $_REQUEST['login_accept'] ) && $_REQUEST['login_accept'] == 'on' ) { 34 43 // 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 35 49 return $user; 36 50 } 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; 44 66 } 45 46 return $error;47 67 } 48 68 } else { … … 81 101 82 102 // 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);103 add_filter('wp_authenticate_user', 'ag_authenticate_user_acc', 99999, 2); 104 add_filter('registration_errors', 'ag_authenticate_user_acc', 99999, 2); 105 add_filter('bp_signup_validate', 'ag_authenticate_user_acc', 99999, 2); 86 106 add_action('pre_comment_on_post', 'ag_validate_comment', 99999, 2); 87 107 88 function display_terms_form($type) {108 function ag_display_terms_form($type) { 89 109 $dbtermm = get_option('ag_termm'); 90 110 $dburl = get_option('ag_url'); 91 111 $dblightbox = get_option('ag_lightbox'); 92 112 $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" /> <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>':''; 108 138 } 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" /> <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 141 function ag_login_terms_accept(){ 119 142 $dblogin = get_option('ag_login'); 120 143 121 144 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 149 function ag_comment_terms_accept(){ 127 150 $dbcomments = get_option('ag_comments'); 128 151 129 152 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 157 function ag_register_terms_accept() { 135 158 136 159 $dbregister = get_option('ag_register'); 137 160 138 161 if($dbregister == 1) { 139 display_terms_form('register');162 ag_display_terms_form('register'); 140 163 } 141 164 … … 153 176 154 177 // 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');178 add_filter('login_form', 'ag_login_terms_accept' ); 179 add_filter('register_form', 'ag_register_terms_accept'); 180 add_filter('comment_form_after_fields', 'ag_comment_terms_accept'); 181 182 add_action('bp_before_registration_submit_buttons', 'ag_register_terms_accept'); 160 183 161 184 … … 165 188 166 189 if($dblogin == 1) { 167 display_terms_form('login');190 ag_display_terms_form('login'); 168 191 } 169 192 … … 195 218 /* Plugin feedback form */ 196 219 197 function feedback_form() {220 function ag_feedback_form() { 198 221 199 222 if(!isset($_POST['feedback_email']) && !isset($_POST['feedback_content'])) { 200 223 224 /* 201 225 $output = '<h3>We want your feedback.</h3> 202 226 <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']).'"> 204 228 <label for="feedback_email">Your email</label> 205 229 <input type="email" name="feedback_email" placeholder="[email protected]" /><br> … … 208 232 <input type="submit" class="button-primary button-large button" style="margin-top: 1em;" value="Send it!" /> 209 233 </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;"> 211 236 <h3 style="color: #369;">Buy me a cup of joe?</h3> 212 237 <p> … … 228 253 } 229 254 230 function send_feedback() {255 function ag_send_feedback() { 231 256 if(isset($_POST['feedback_email']) && isset($_POST['feedback_content'])) { 232 257 … … 242 267 } 243 268 244 add_action( 'plugins_loaded', ' send_feedback');269 add_action( 'plugins_loaded', 'ag_send_feedback'); -
agreeable/trunk/css/agreeable.css
r946511 r948152 1 2 /* Front end styles */ 3 1 4 .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 } 17 textarea { 18 clear: right; 19 float: right; 20 } 21 input[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;} 2 38 3 39 .ag-plugin-banner {border-bottom: 4px solid #5074bd; padding: 1em; background: #f4f4f4;} -
agreeable/trunk/readme.txt
r946511 r948152 37 37 38 38 == 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 39 44 40 45 = 0.3 =
Note: See TracChangeset
for help on using the changeset viewer.