Changeset 2903367
- Timestamp:
- 04/24/2023 02:50:30 PM (3 years ago)
- Location:
- wired-impact-volunteer-management/trunk
- Files:
-
- 4 edited
-
README.txt (modified) (2 diffs)
-
frontend/js/wi-volunteer-management-public.js (modified) (7 diffs)
-
includes/class-wi-volunteer-management.php (modified) (1 diff)
-
wivm.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wired-impact-volunteer-management/trunk/README.txt
r2826554 r2903367 5 5 Tested up to: 6.1 6 6 Requires PHP: 5.2.4 7 Stable tag: 1. 4.97 Stable tag: 1.5 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 110 110 == Changelog == 111 111 112 = 1.5 = 113 * Upgraded Google Analytics tracking to work with Google Analytics 4. 114 112 115 = 1.4.9 = 113 116 * Tested up to WordPress 6.1. -
wired-impact-volunteer-management/trunk/frontend/js/wi-volunteer-management-public.js
r1578967 r2903367 1 (function( $ ) { 1 ( function( $ ) { 2 2 3 'use strict'; 3 4 4 // Document ready5 $( function() {5 // Document ready. 6 $( function() { 6 7 7 8 /** 8 * Handle submission of volunteer opportunity sign up form inclding validation and AJAX processing. 9 * Handle submission of volunteer opportunity sign up form including 10 * validation and AJAX processing. 9 11 */ 10 $( '#wivm-sign-up-form input[type=submit]' ).click(function(e){ 12 $( '#wivm-sign-up-form input[type=submit]' ).click( function( e ) { 13 11 14 e.preventDefault(); 12 15 var $this = $( this ), … … 16 19 17 20 form_valid = validate_sign_up_form(); 18 if( form_valid === true ){ 21 if ( form_valid === true ) { 22 19 23 submit_sign_up_form( $this ); 20 } 21 else { //Allow submission again if there were errors 24 25 } else { // Allow submission again if there were errors. 26 22 27 $this.prop( "disabled", false ); 23 28 } 24 } );29 } ); 25 30 26 31 }); … … 28 33 /** 29 34 * Validate the volunteer opportunity sign up form. 35 * 30 36 * @return {bool} Whether the form is valid. 31 37 */ 32 38 function validate_sign_up_form(){ 39 33 40 var has_errors = false; 34 41 35 // Show an error and don't submit if the honeypot exists and is filled in42 // Show an error and don't submit if the honeypot exists and is filled in. 36 43 var hp = $( '#wivm_hp' ); 37 if( hp.length && hp.val() !== '' ){ 44 if ( hp.length && hp.val() !== '' ) { 45 38 46 has_errors = true; 39 47 } 40 48 41 //Make sure each field is filled in and that email addresses are valid 42 $( '#wivm-sign-up-form input[type=text]:not(#wivm_hp), #wivm-sign-up-form input[type=email]' ).each(function() { 43 if( this.value === '' ) { 44 $( this ).addClass( 'field-error' ); 45 has_errors = true; 46 } 47 else if ( this.type === 'email' && !validate_email( this.value ) ){ 48 $( this ).addClass( 'field-error' ); 49 has_errors = true; 50 } 51 else { 52 $( this ).removeClass( 'field-error' ); 53 } 54 }); 49 // Make sure each field is filled in and that email addresses are valid. 50 $( '#wivm-sign-up-form input[type=text]:not(#wivm_hp), #wivm-sign-up-form input[type=email]' ).each( function() { 55 51 56 //If not valid return false. 57 if( has_errors === true ){ 58 $( '.volunteer-opp-message.loading, .volunteer-opp-message.success' ).slideUp(); 59 $( '.volunteer-opp-message.error' ).slideDown(); 60 return false; 61 } 62 else { 63 $( '.volunteer-opp-message' ).slideUp(); 64 return true; 65 } 52 if ( this.value === '' ) { 53 54 $( this ).addClass( 'field-error' ); 55 has_errors = true; 56 57 } else if ( this.type === 'email' && ! validate_email( this.value ) ) { 58 59 $( this ).addClass( 'field-error' ); 60 has_errors = true; 61 62 } else { 63 64 $( this ).removeClass( 'field-error' ); 65 } 66 } ); 67 68 // If not valid return false. 69 if ( has_errors === true ) { 70 71 $( '.volunteer-opp-message.loading, .volunteer-opp-message.success' ).slideUp(); 72 $( '.volunteer-opp-message.error' ).slideDown(); 73 74 return false; 75 76 } else { 77 78 $( '.volunteer-opp-message' ).slideUp(); 79 80 return true; 81 } 66 82 } 67 83 … … 73 89 */ 74 90 function validate_email( email ){ 91 75 92 var email_regex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 76 93 77 if( email_regex.test( email ) ){ 78 return true; 79 } 80 else { 81 return false; 82 } 94 if ( email_regex.test( email ) ) { 95 96 return true; 97 98 } else { 99 100 return false; 101 } 83 102 } 84 103 … … 87 106 */ 88 107 function submit_sign_up_form( submit_button ){ 89 //Show messages to user 108 109 // Show messages to user. 90 110 $( '.volunteer-opp-message.error' ).slideUp(); 91 111 $( '.volunteer-opp-message.loading' ).slideDown(); … … 100 120 $( '.volunteer-opp-message.loading' ).slideUp(); 101 121 102 //If submitter was RSVPed successfully103 if( response === 'rsvped' ){ 122 if ( response === 'rsvped' ) { // If submitter was RSVPed successfully. 123 104 124 $( '.volunteer-opp-message.success' ).slideDown(); 105 125 submit_button.prop( "disabled", false ); 106 track_google_analytics( ' RSVPSuccess' );107 } 108 //If submitter had already RSVPed109 else if( response === 'already_rsvped'){ 126 track_google_analytics( 'Success' ); 127 128 } else if ( response === 'already_rsvped') { // If submitter had already RSVPed. 129 110 130 $( '.volunteer-opp-message.already-rsvped' ).slideDown(); 111 131 submit_button.prop( "disabled", false ); 112 track_google_analytics( ' RSVP Failure: Already RSVPed' );113 } 114 //If submitter tried to sign up, but there are no spots left.115 else if( response === 'rsvp_closed' ){ 132 track_google_analytics( 'Failure: Already Signed Up' ); 133 134 } else if ( response === 'rsvp_closed' ) { // If submitter tried to sign up, but there are no spots left. 135 116 136 $( '.volunteer-opp-message.rsvp-closed' ).slideDown(); 117 137 $( '#wivm-sign-up-form' ).slideUp(); 118 track_google_analytics( ' RSVPFailure: No More Open Spots' );138 track_google_analytics( 'Failure: No More Open Spots' ); 119 139 } 120 140 } … … 123 143 124 144 /** 125 * Track volunteer opportunity action as an event within Google Analytics.145 * Track an event within Google Analytics when volunteers sign up. 126 146 * 127 * This only works in Universal Analytics, and does not in Classic Analytics. 128 * 129 * @param {string} action The action that was completed (i.e. "Successful RSVP") 147 * @param {string} sign_up_result The result of the sign up attempt. 130 148 */ 131 function track_google_analytics( action ){ 132 //Determine global analytics object name 133 var ga = window[window['GoogleAnalyticsObject'] || 'ga']; 134 if( typeof ga == 'function' ){ 135 //Track as an event 136 ga( 'send', { 137 hitType: 'event', 138 eventCategory: 'Volunteer Opportunity', 139 eventAction: action 140 }); 149 function track_google_analytics( sign_up_result ){ 150 151 if ( typeof gtag === 'function' ) { 152 153 gtag( 'event', 'volunteer_opportunity_submit', { 154 'sign_up_result': sign_up_result, 155 } ); 141 156 } 142 157 } 143 158 144 145 159 })( jQuery ); -
wired-impact-volunteer-management/trunk/includes/class-wi-volunteer-management.php
r2826554 r2903367 69 69 70 70 $this->plugin_name = 'wired-impact-volunteer-management'; 71 $this->version = '1. 4.9';71 $this->version = '1.5'; 72 72 73 73 $this->load_dependencies(); -
wired-impact-volunteer-management/trunk/wivm.php
r2826554 r2903367 17 17 * Plugin URI: https://wiredimpact.com/wordpress-plugins-for-nonprofits/volunteer-management/ 18 18 * Description: A simple, free way to keep track of your nonprofit’s volunteers and opportunities. 19 * Version: 1. 4.919 * Version: 1.5 20 20 * Author: Wired Impact 21 21 * Author URI: https://wiredimpact.com
Note: See TracChangeset
for help on using the changeset viewer.