Changeset 2817109
- Timestamp:
- 11/12/2022 10:07:36 PM (3 years ago)
- Location:
- gf-pushover-add-on/trunk
- Files:
-
- 4 edited
-
class-gf-pushover.php (modified) (4 diffs)
-
gf-pushover-add-on.js (modified) (1 diff)
-
gf-pushover-add-on.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gf-pushover-add-on/trunk/class-gf-pushover.php
r1869241 r2817109 27 27 parent::init(); 28 28 add_filter( 'gform_notification_services', array( $this, 'add_pushover_notification_service' ) ); 29 add_filter( 'gform_pre_send_email', array( $this, 'maybe_send_pushover_notification' ), 1 9, 3);29 add_filter( 'gform_pre_send_email', array( $this, 'maybe_send_pushover_notification' ), 10, 4 ); 30 30 add_action( 'admin_enqueue_scripts', array( $this, 'gform_pushover_ui_injector' ), 998 ); 31 add_filter( 'gform_notification_ui_settings', array( $this, 'gform_pushover_notification_setting'), 10, 3 ); 32 add_filter( 'gform_notification_validation', array( $this, 'gform_pushover_notification_validation'), 10, 3 ); 31 add_filter( 'gform_notification_settings_fields', array( $this, 'gform_pushover_notification_settings_fields'), 10, 3 ); 33 32 add_filter( 'gform_pre_notification_save', array( $this, 'gform_pushover_notification_setting_save'), 10, 2 ); 34 33 } … … 50 49 51 50 public function maybe_send_pushover_notification( $email, $message_format, $notification ) { 52 if ( rgar( $notification, 'service' ) !== 'pushover' || ! $this->initialize_api() ) {51 if ( rgar( $notification, 'service' ) !== 'pushover' || !$this->initialize_api() ) { 53 52 return $email; 54 53 } … … 102 101 } 103 102 104 public function gform_pushover_notification_setting( $ui_settings, $notification, $form ) { 105 $ui_settings['gform_pushover_user_token'] = ' 106 <tr> 107 <th> 108 <label for="gform_pushover_user_token">Pushover User Key<span class="gfield_required">*</span> <a href="#" onclick="return false;" onkeypress="return false;" class="gf_tooltip tooltip tooltip_notification_autoformat" title="<h6>Pushover User Key</h6>Get your Pushover User Key from <a href=\'https://pushover.net/\' target=\'_blank\'>https://pushover.net/</a>"><i class="fa fa-question-circle"></i></a></label> 109 </th> 110 <td> 111 <input value="' . rgar( $notification, 'gform_pushover_user_token' ) . '" name="gform_pushover_user_token" id="gform_pushover_user_token" class="fieldwidth-2"> 112 </td> 113 </tr> 114 <!-- / pushover user token -->'; 115 return $ui_settings; 103 public function gform_pushover_notification_settings_fields( $fields, $notification, $form ) { 104 $fields[0]['fields'][] = array( 105 'type' => 'text', 106 'name' => 'gform_pushover_user_token', 107 'label' => 'Pushover User Key', 108 'required' => true, 109 'tooltip' => 'Get your Pushover User Key from <a href=\'https://pushover.net/\' target=\'_blank\'>https://pushover.net/</a>', 110 'feedback_callback' => array( $this, 'gform_pushover_notification_validation' ), 111 ); 112 return $fields; 116 113 } 117 114 118 public function gform_pushover_notification_validation( $is_valid, $notification, $form ) { 119 if ( rgar( $notification, 'service' ) !== 'pushover' ) { 115 public function gform_pushover_notification_validation( $value ) { 116 if ( empty( $value ) ) { 117 $is_valid = true; 118 } elseif ( preg_match('/^\w{30}$/', $value ) ) { 120 119 $is_valid = true; 121 120 } else { 122 if ( rgempty( 'gform_pushover_user_token', $notification ) ) { 123 $is_valid = false; 124 GFCommon::add_error_message( esc_html( 'Please enter the Pushover User Key.' ) ); 125 } elseif ( preg_match('/^\w{30}$/', rgpost( 'gform_pushover_user_token' )) ) { 126 $is_valid = true; 127 } else { 128 $is_valid = false; 129 GFCommon::add_error_message( esc_html( 'Please enter a valid Pushover User Key.' ) ); 130 } 121 $is_valid = false; 122 GFCommon::add_error_message( esc_html( 'Please enter a valid Pushover User Key.' ) ); 131 123 } 132 124 return $is_valid; … … 134 126 135 127 public function gform_pushover_notification_setting_save( $notification, $form ) { 136 $notification['gform_pushover_user_token'] = rgpost( ' gform_pushover_user_token' );128 $notification['gform_pushover_user_token'] = rgpost( '_gform_setting_gform_pushover_user_token' ); 137 129 return $notification; 138 130 } -
gf-pushover-add-on/trunk/gf-pushover-add-on.js
r1869241 r2817109 1 1 jQuery(document).ready(function ($) { 2 if ( $("#tab_notification").length > 0 && $("#gform-notification-service-pushover").length > 0 ) { 3 if ( $("#gform_notification_service_pushover").is(":checked") ) { 4 $( "#gform_notification_to_type_email" ).attr('checked', 'checked'); 5 $( "#gform_notification_to_type_email" ).parent().parent().hide(); 6 $( "#gform_notification_to_email" ).val('{admin_email}'); 7 $( "#gform_notification_to_email_container" ).hide(); 8 $( "#gform_pushover_user_token" ).parent().parent().insertBefore( $( "#gform_notification_to_type_email" ).parent().parent() ); 9 $( "#gform_notification_from_name" ).parent().parent().hide(); 10 $( "#gform_notification_from" ).parent().parent().hide(); 11 $( "#gform_notification_reply_to" ).parent().parent().hide(); 12 $( "#gform_notification_bcc" ).parent().parent().hide(); 2 if ( $("#tab_notification").length > 0 && $("input[name=_gform_setting_service]").length > 0 ) { 3 console.log( $("input[name=_gform_setting_service]").val() ); 4 if ( $("input[name=_gform_setting_service][value=pushover]").is(":checked") ) { 5 console.log('test 3'); 6 $( "#_gform_setting_toType" ).val('email'); 7 $( "#gform_setting_toType" ).hide(); 8 $( "#_gform_setting_toEmail" ).val('{admin_email}'); 9 $( "#gform_setting_toEmail" ).hide(); 10 $( "#gform_setting_gform_pushover_user_token" ).insertBefore( $( "#gform_setting_toEmail" ) ); 11 $( "#gform_setting_fromName" ).hide(); 12 $( "#gform_setting_from" ).hide(); 13 $( "#gform_setting_replyTo" ).hide(); 14 $( "#gform_setting_bcc" ).hide(); 13 15 } else { 14 $( "#gform_ pushover_user_token" ).parent().parent().hide();16 $( "#gform_setting_gform_pushover_user_token" ).hide(); 15 17 } 16 18 } -
gf-pushover-add-on/trunk/gf-pushover-add-on.php
r2183110 r2817109 4 4 Plugin URI: https://wp2pgpmail.com/gravity-pushover/ 5 5 Description: Get Gravity Forms submissions as instant push notifications on your phone or tablet with Pushover. 6 Version: 1.0 36 Version: 1.04 7 7 Author: wp2pgpmail 8 8 Author URI: https://wp2pgpmail.com … … 10 10 */ 11 11 12 define( 'GF_PUSHOVER_VERSION', '1.0 3' );12 define( 'GF_PUSHOVER_VERSION', '1.04' ); 13 13 14 14 if ( is_plugin_active('gravityforms/gravityforms.php') ) { -
gf-pushover-add-on/trunk/readme.txt
r2809857 r2817109 6 6 Tested up to: 6.1 7 7 Requires PHP: 5.6 8 Stable tag: 1.0 38 Stable tag: 1.04 9 9 License: GPLv2 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 78 78 == Changelog == 79 79 80 = 1.04 = 81 * Adding the new filter gform_notification_settings_fields introduced with Gravity Forms v2.5 82 80 83 = 1.03 = 81 84 * Testing WordPress 5.3
Note: See TracChangeset
for help on using the changeset viewer.