Changeset 986028
- Timestamp:
- 09/10/2014 04:01:44 AM (11 years ago)
- Location:
- agreeable/trunk
- Files:
-
- 2 added
- 1 deleted
- 4 edited
-
agreeable-options.php (deleted)
-
agreeable.php (modified) (18 diffs)
-
css/admin.css (modified) (1 diff)
-
includes (added)
-
includes/settings.php (added)
-
js/agreeable.js (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
agreeable/trunk/agreeable.php
r973537 r986028 3 3 Plugin Name: Agreeable 4 4 Plugin 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. 45 Description: Add a required "Agree to terms" checkbox to login and/or register forms. 6 Version: 1.3.5 7 7 Author: kraftpress 8 8 Author URI: http://kraftpress.it … … 14 14 //! Cleanup functions, make it smarter, faster, better. 15 15 //================================== 16 17 18 16 19 17 // If this file is called directly, abort. … … 37 35 38 36 /* Registration Validation Hooks */ 39 add_filter('woocommerce_registration_errors', array($this, 'ag_woocommerce_reg_validation'), 10,3);40 37 add_filter('registration_errors', array($this, 'ag_authenticate_user_acc'), 10, 2); 41 38 add_filter('bp_signup_validate', array($this, 'ag_authenticate_user_acc'), 10, 2); 42 39 add_filter('wpmu_validate_user_signup', array($this, 'ag_authenticate_user_acc'), 10, 3); 43 40 44 45 41 /* Login Validation Hooks */ 46 42 add_filter('wp_authenticate_user', array($this, 'ag_authenticate_user_acc'), 10, 2); 47 43 48 49 44 /* Comment Validation Hooks */ 50 45 add_action('pre_comment_on_post', array($this, 'ag_validate_comment'), 10, 2); … … 52 47 /* Output Hooks */ 53 48 add_filter('login_form', array($this, 'ag_login_terms_accept') ); 54 add_filter('woocommerce_after_customer_login_form', array($this, 'ag_login_terms_accept'));55 49 add_filter('register_form', array($this, 'ag_register_terms_accept')); 56 50 add_filter('comment_form_after_fields', array($this, 'ag_comment_terms_accept')); … … 73 67 return true; 74 68 } 75 69 76 70 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 77 87 $this->options = array( 78 88 'login' => get_option('ag_login'), … … 92 102 // Localization 93 103 load_plugin_textdomain('agreeable', false, basename( dirname( __FILE__ ) ) . '/languages' ); 94 104 95 105 if (is_multisite()) { 96 106 add_action( 'signup_extra_fields', array($this, 'ag_register_terms_accept'), 10, 3); 97 107 add_action( 'signup_blogform', array($this, 'ag_register_terms_accept'), 10, 3); 98 108 } 109 110 $this->update_options(); 111 99 112 } 100 113 101 114 function ag_admin() { 102 115 103 116 /* Plugin Stylesheet */ 104 117 wp_enqueue_style( 'agreeable-css', plugins_url('css/admin.css', __FILE__), '', '0.3.4', 'screen'); 105 118 106 119 } 107 120 108 121 function ag_front() { 109 122 110 123 /* Only load lightbox code on the frontend, where we need it */ 111 124 if ( $this->is_login_page() ) { 112 125 wp_enqueue_script('jquery'); 113 126 } 114 127 115 128 wp_enqueue_script( 'magnific', plugins_url('js/magnific.js', __FILE__),'', '', true); 116 129 wp_enqueue_script( 'agreeable-js', plugins_url('js/agreeable.js', __FILE__), '', '', true); 117 130 wp_enqueue_style( 'magnific', plugins_url('css/magnific.css', __FILE__)); 118 131 wp_enqueue_style( 'agreeable-css', plugins_url('css/front.css', __FILE__)); 119 120 } 121 122 123 132 133 } 124 134 125 135 function ag_authenticate_user_acc($user) { … … 128 138 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) { 129 139 130 // See if the checkbox # login_accept was checked131 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) { 132 142 133 143 // Checkbox on, allow login, set the cookie if necessary … … 136 146 setcookie( 'agreeable_terms', 'yes', strtotime('+30 days'), COOKIEPATH, COOKIE_DOMAIN, false ); 137 147 } 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(); 138 169 170 $errors->add('ag_login_accept', $this->options['fail_text']); 139 171 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']);160 172 161 173 /* Incase it's a form that doesn't respect WordPress' error system */ … … 163 175 $_SESSION['ag_errors'] = $this->options['fail_text']; 164 176 165 166 if(is_multisite()) { 177 if(is_multisite() && $this->is_multisite_register() && !$this->is_login_page()) { 167 178 168 179 $result = $user; 169 $result['errors'] = $errors;170 180 171 181 return $result; 172 182 173 } else {174 175 return $errors;176 177 183 } 178 184 185 return $errors; 186 179 187 } 180 188 … … 187 195 } 188 196 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 189 223 function is_buddypress_registration() { 190 224 191 225 if(function_exists('bp_current_component')) { 192 226 193 227 /* Lets make sure we're on the right page- Ie the buddypress register page */ 194 228 $bp_pages = get_option('bp-pages'); 195 229 $bp_page = get_post($bp_pages['register']); 196 230 197 231 global $wp_query; 198 232 $current_page = isset($wp_query->query_vars['name']) ? $wp_query->query_vars['name'] : ''; 199 233 200 234 return $bp_page->post_name == $current_page ? true : false; 201 235 … … 203 237 } 204 238 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 227 239 function ag_validate_comment($comment) { 228 240 229 241 if($this->options['comments'] == 1) { 230 242 231 // See if the checkbox # login_accept was checked232 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' ) { 233 245 // Checkbox on, allow comment 234 246 return $comment; … … 251 263 function ag_display_terms_form($type, $errors = '') { 252 264 265 global $bp; 266 253 267 if(isset($this->options['terms_page'])) { 254 268 $terms = get_post($this->options['terms_page']); … … 271 285 /* Get our errors incase we need to display */ 272 286 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' ) == '') { 276 290 277 291 $error = $_SESSION['ag_errors']; 278 292 unset($_SESSION['ag_errors']); 279 293 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>'; 289 299 290 300 } … … 300 310 echo '<div style="clear: both; padding: .25em 0;" id="terms-accept" class="terms-form">'; 301 311 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.' /> <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.' /> <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>'; 305 315 echo '<input type="hidden" value="'.$type.'" name="ag_type" /></div>'; 306 316 echo '<div id="terms" class="mfp-hide">'.$terms_content.'</div>'; … … 327 337 328 338 if($this->options['register'] == 1) { 339 329 340 $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 341 354 } 342 355 return; … … 360 373 } 361 374 362 363 364 375 function agreeable_options() { 365 376 add_options_page('agreeable', 'Agreeable', 'manage_options', 'terms-options', array($this, 'agoptions')); … … 367 378 368 379 function agoptions() { 369 include ('agreeable-options.php');380 include_once('includes/settings.php'); 370 381 } 371 382 … … 379 390 return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')); 380 391 } 392 393 function is_multisite_register() { 394 return in_array($GLOBALS['pagenow'], array('wp-signup.php')); 395 } 381 396 382 397 } -
agreeable/trunk/css/admin.css
r970082 r986028 33 33 34 34 .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;} 35 36 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;} 37 38 .kp-cross-promote-area #kp-logo {margin-bottom: 2em; margin-top: -1px; border-top: 1px #fff;} 38 39 .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 1 1 jQuery(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 }); 6 9 7 10 if($('.woocommerce .login')) { 8 $(".woocommerce>#terms-accept").insertBefore(".woocommerce .login #rememberme"); 9 11 $(".woocommerce>#agreeable_login_field").insertBefore(".woocommerce .login #rememberme"); 10 12 } 11 13 12 14 }); -
agreeable/trunk/readme.txt
r973423 r986028 1 1 === Agreeable === 2 Contributors: kraftpress, buildcreate , thesturs3 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 2 Contributors: kraftpress, buildcreate 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, woocommerce 4 4 Requires at least: 3.5 5 Tested up to: 3.9.15 Tested up to: 4.0 6 6 Stable tag: trunk 7 7 License:GPLv2 or later … … 9 9 10 10 == 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. 11 Add an "agree to terms" check box to your login, registration, or comment forms, requiring users to agree. Tested with BuddyPress and Multisite. 14 12 15 13 = Features = … … 20 18 21 19 = 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/ 23 22 24 23 = Translations = … … 38 37 39 38 == 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 40 47 41 48 = 1.3.3 =
Note: See TracChangeset
for help on using the changeset viewer.