Changeset 2129855
- Timestamp:
- 07/28/2019 08:36:38 PM (7 years ago)
- Location:
- xcoobee-form/trunk
- Files:
-
- 1 added
- 5 edited
-
CHANGELOG (modified) (1 diff)
-
includes/admin/views/settings-form.php (modified) (3 diffs)
-
includes/class-xcoobee-save-consent-shortcodes.php (added)
-
languages/xcoobee-form.pot (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
xcoobee-form.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
xcoobee-form/trunk/CHANGELOG
r2055947 r2129855 1 1 == Changelog == 2 3 = 1.2.1 - 2019-07-29 = 4 * fix bugs with Contact form 7 and XcooBee consent registration 5 6 = 1.2.0 - 2019-07-21 = 7 * Add Contact Form 7 Support. 2 8 3 9 = 1.0.0 - 2019-03-22 = -
xcoobee-form/trunk/includes/admin/views/settings-form.php
r2107044 r2129855 47 47 <nav class="tabs-nav"> 48 48 <a class="nav active" data-nav="xcoobee-form"><code>[xcoobee_form]</code><span><?php _e( 'Renders a safe form button.', 'xcoobee' ); ?></span></a> 49 <a class="nav" data-nav="xcoobee_save_consent"><code>[xcoobee_save_consent]</code><span><?php _e( 'This shortcode can be embedded in Contact Form 7. It will register corresponding consent for using of data with XcooBee. Users can then manage consent directly.', 'xcoobee' ); ?></span></a> 49 50 </nav> 50 51 <div class="tabs-content"> … … 116 117 </tbody> 117 118 </table> 118 <div class="example" id="shortcode-example-xcoobee-form"><span class="xbee-copy-text xbee-tooltip" data-tooltip="<?php _e('Copy', 'xcoobee'); ?>" data-copy="shortcode-example-xcoobee-form"></span><span class="headline"><?php _e( 'Example', 'xcoobee' ); ?></span><code>[xcoobee_form campaign_reference="xxx.xxxxxxxxxxx" button_size="medium" approve_redirect="https://example.com/thank-you/" decline_redirect="https://example.com/oops/" text="Use Safe Form" alt_text="Use the XcooBee secure network!" class="my-safe-form" id="xbee-safe-form"][/xcoobee_form]</code></div> 119 <div class="example"> 120 <span class="xbee-copy-text xbee-tooltip" data-clipboard-target="#xcoobee_form_all_attrs" data-tooltip="<?php esc_attr_e('Copy', 'xcoobee'); ?>"></span> 121 <span class="headline"><?php _e( 'XcooBee Form Example', 'xcoobee' ); ?></span> 122 <code id="xcoobee_form_all_attrs">[xcoobee_form campaign_reference="xxx.xxxxxxxxxxx" button_size="medium" approve_redirect="https://example.com/thank-you/" decline_redirect="https://example.com/oops/" text="Use Safe Form" alt_text="Use the XcooBee secure network!" class="my-safe-form" id="xbee-safe-form"][/xcoobee_form]</code> 123 </div> 124 </div> 125 <div class="content" data-nav="xcoobee_save_consent"> 126 <table class="shortcode-info"> 127 <thead> 128 <tr> 129 <th><?php _e( 'Attribute', 'xcoobee' ); ?></th> 130 <th><?php _e( 'Description', 'xcoobee' ); ?></th> 131 <th><?php _e( 'Default', 'xcoobee' ); ?></th> 132 <th><?php _e( 'Example', 'xcoobee' ); ?></th> 133 </tr> 134 </thead> 135 <tbody> 136 <tr> 137 <td><code>campaign_reference</code></td> 138 <td><?php _e( 'This is the XcooBee Campaign Reference. You can get this from your XcooBee campaign wizard screen.', 'xcoobee' ); ?></td> 139 <td>Default Campaign Reference</td> 140 <td><code>xxx.xxxxxxxxxx</code></td> 141 </tr> 142 <tr> 143 <td><code>xcoobee_id_field</code></td> 144 <td><?php _e( "This should be the name or ID of the form field of the form's field that contains the user's XcooBee ID. If both an email and XcooBee ID are present, we will process using XcooBee ID first.", 'xcoobee' ); ?></td> 145 <td>xcoobee_id</td> 146 <td><code>your-xcoobeeid</code></td> 147 </tr> 148 <tr> 149 <td><code>email_field</code></td> 150 <td><?php _e( "This should be the name or ID of the form field of the form's field that contains the user's email.", 'xcoobee' ); ?></td> 151 <td>email</td> 152 <td><code>your-email</code></td> 153 </tr> 154 </tbody> 155 </table> 156 <div class="example"> 157 <span class="xbee-copy-text xbee-tooltip" data-clipboard-target="#xcoobee_save_consent_all_defaults" data-tooltip="<?php esc_attr_e('Copy', 'xcoobee'); ?>"></span> 158 <span class="headline"><?php _e( 'XcooBee Save Consent', 'xcoobee' ); ?></span> 159 <code id="xcoobee_save_consent_all_defaults">[xcoobee_save_consent]</code> 160 </div> 161 <div class="example"> 162 <span class="xbee-copy-text xbee-tooltip" data-clipboard-target="#xcoobee_save_consent_no_defaults" data-tooltip="<?php esc_attr_e('Copy', 'xcoobee'); ?>"></span> 163 <span class="headline"><?php _e( 'XcooBee Save Consent', 'xcoobee' ); ?></span> 164 <code id="xcoobee_save_consent_no_defaults">[xcoobee_save_consent campaign_reference="xxx.xxxxxxxxxx" xcoobee_id_field="xcoobeeid-field" email_field="email-field"]</code> 165 </div> 119 166 </div> 120 167 </div> … … 124 171 125 172 <p class="actions"><?php submit_button( 'Save Changes', 'primary', 'submit', false ); ?></p> 173 174 <script> 175 (function ($) { 176 $(document).ready(function ($) { 177 new ClipboardJS('.xbee-copy-text'); 178 }); 179 })(jQuery); 180 </script> 181 182 <?php 183 unset( $default_campaign_reference ); -
xcoobee-form/trunk/languages/xcoobee-form.pot
r2107044 r2129855 50 50 msgstr "" 51 51 52 #: includes/admin/views/settings-form.php:55 52 #: includes/admin/views/settings-form.php:49 53 msgid "This shortcode can be embedded in Contact Form 7. It will register corresponding consent for using of data with XcooBee. Users can then manage consent directly." 54 msgstr "" 55 56 #: includes/admin/views/settings-form.php:56, includes/admin/views/settings-form.php:129 53 57 msgid "Attribute" 54 58 msgstr "" 55 59 56 #: includes/admin/views/settings-form.php:5 660 #: includes/admin/views/settings-form.php:57, includes/admin/views/settings-form.php:130 57 61 msgid "Description" 58 62 msgstr "" 59 63 60 #: includes/admin/views/settings-form.php:5 764 #: includes/admin/views/settings-form.php:58, includes/admin/views/settings-form.php:131 61 65 msgid "Default" 62 66 msgstr "" 63 67 64 #: includes/admin/views/settings-form.php:5 8, includes/admin/views/settings-form.php:11868 #: includes/admin/views/settings-form.php:59, includes/admin/views/settings-form.php:132 65 69 msgid "Example" 66 70 msgstr "" 67 71 68 #: includes/admin/views/settings-form.php:6 472 #: includes/admin/views/settings-form.php:65 69 73 msgid "Campaign reference." 70 74 msgstr "" 71 75 72 #: includes/admin/views/settings-form.php:7 076 #: includes/admin/views/settings-form.php:71 73 77 msgid "Size of the button (<code>small</code>, <code>medium</code> or <code>large</code>)." 74 78 msgstr "" 75 79 76 #: includes/admin/views/settings-form.php:7 680 #: includes/admin/views/settings-form.php:77 77 81 msgid "URL to redirect to when request is approved." 78 82 msgstr "" 79 83 80 #: includes/admin/views/settings-form.php:8 284 #: includes/admin/views/settings-form.php:83 81 85 msgid "URL to redirect to when request is declined." 82 86 msgstr "" 83 87 84 #: includes/admin/views/settings-form.php:8 888 #: includes/admin/views/settings-form.php:89 85 89 msgid "The <code>id</code> of the form. Leave this empty if the shortcode is placed inside the form." 86 90 msgstr "" 87 91 88 #: includes/admin/views/settings-form.php:9 492 #: includes/admin/views/settings-form.php:95 89 93 msgid "Alternate text for the button." 90 94 msgstr "" 91 95 92 #: includes/admin/views/settings-form.php:9 5, includes/class-xcoobee-form-shortcodes.php:4396 #: includes/admin/views/settings-form.php:96, includes/class-xcoobee-form-shortcodes.php:43 93 97 msgid "Safe Form" 94 98 msgstr "" 95 99 96 #: includes/admin/views/settings-form.php:9 6, includes/admin/views/settings-form.php:102100 #: includes/admin/views/settings-form.php:97, includes/admin/views/settings-form.php:103 97 101 msgid "Your text" 98 102 msgstr "" 99 103 100 #: includes/admin/views/settings-form.php:10 0104 #: includes/admin/views/settings-form.php:101 101 105 msgid "Alternate text for the button on hover." 102 106 msgstr "" 103 107 104 #: includes/admin/views/settings-form.php:10 1108 #: includes/admin/views/settings-form.php:102 105 109 msgid "Submit data securley via XcooBee!" 106 110 msgstr "" 107 111 108 #: includes/admin/views/settings-form.php:10 6112 #: includes/admin/views/settings-form.php:107 109 113 msgid "Additional CSS classes to button." 110 114 msgstr "" 111 115 112 #: includes/admin/views/settings-form.php:11 2116 #: includes/admin/views/settings-form.php:113 113 117 msgid "Custom HTML Id for the button." 114 118 msgstr "" 115 119 116 #: includes/admin/views/settings-form.php:1 18120 #: includes/admin/views/settings-form.php:120, includes/admin/views/settings-form.php:157, includes/admin/views/settings-form.php:162 117 121 msgid "Copy" 122 msgstr "" 123 124 #: includes/admin/views/settings-form.php:121 125 msgid "XcooBee Form Example" 126 msgstr "" 127 128 #: includes/admin/views/settings-form.php:138 129 msgid "This is the XcooBee Campaign Reference. You can get this from your XcooBee campaign wizard screen." 130 msgstr "" 131 132 #: includes/admin/views/settings-form.php:144 133 msgid "This should be the name or ID of the form field of the form's field that contains the user's XcooBee ID. If both an email and XcooBee ID are present, we will process using XcooBee ID first." 134 msgstr "" 135 136 #: includes/admin/views/settings-form.php:150 137 msgid "This should be the name or ID of the form field of the form's field that contains the user's email." 138 msgstr "" 139 140 #: includes/admin/views/settings-form.php:158, includes/admin/views/settings-form.php:163 141 msgid "XcooBee Save Consent" 118 142 msgstr "" 119 143 … … 122 146 msgstr "" 123 147 124 #: xcoobee-form.php: 99148 #: xcoobee-form.php:102 125 149 msgid "XcooBee Form requires XcooBee for WordPress to be installed and active. You can download %s here." 126 150 msgstr "" 127 151 128 #: xcoobee-form.php: 143152 #: xcoobee-form.php:250 129 153 msgid "View XcooBee Form settings" 130 154 msgstr "" 131 155 132 #: xcoobee-form.php: 143156 #: xcoobee-form.php:250 133 157 msgid "Settings" 134 158 msgstr "" -
xcoobee-form/trunk/readme.txt
r2107044 r2129855 3 3 Tags: xcoobee, privacy, consent, ccpa, gdpr, security, form 4 4 Requires at least: 4.4.0 5 Tested up to: 5.2. 16 Stable tag: 1. 1.15 Tested up to: 5.2.2 6 Stable tag: 1.2.1 7 7 License: GPLv3 8 8 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
xcoobee-form/trunk/xcoobee-form.php
r2107044 r2129855 5 5 * Author URI: https://www.xcoobee.com/ 6 6 * Description: Ask user for Data and Consent in GDPR compliant manner. Safely transfer the collected information to backend. 7 * Version: 1. 1.17 * Version: 1.2.1 8 8 * Author: XcooBee 9 9 * License: GPLv3 … … 14 14 * 15 15 * Requires at least: 4.4.0 16 * Tested up to: 5.2. 116 * Tested up to: 5.2.2 17 17 * 18 18 * @package XcooBee/Form … … 37 37 */ 38 38 class XcooBee_Form { 39 private static $default_email_field = 'email'; 40 private static $default_xcoobee_id_field = 'xcoobee_id'; 41 39 42 /** 40 43 * The singleton instance of XcooBee_Form. … … 105 108 * @since 1.0.0 106 109 */ 107 p ublicfunction includes() {110 private function includes() { 108 111 // Global includes. 109 112 include_once XBEE_FORM_ABSPATH . 'includes/functions.php'; 110 113 include_once XBEE_FORM_ABSPATH . 'includes/class-xcoobee-form-shortcodes.php'; 114 include_once XBEE_FORM_ABSPATH . 'includes/class-xcoobee-save-consent-shortcodes.php'; 111 115 112 116 // Back-end includes. … … 114 118 include_once XBEE_FORM_ABSPATH . 'includes/admin/class-xcoobee-form-admin.php'; 115 119 } 116 120 117 121 // Front-end includes. 118 122 if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { … … 126 130 * @since 1.0.0 127 131 */ 128 p ublicfunction hooks() {132 private function hooks() { 129 133 add_filter( 'plugin_action_links_' . XBEE_FORM_PLUGIN_BASENAME, [ $this, 'action_links' ], 10, 1 ); 130 134 add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] ); … … 132 136 add_action( 'wp_enqueue_scripts', [ $this, 'scripts' ] ); 133 137 add_action( 'wp_enqueue_scripts', [ $this, 'styles' ] ); 134 } 138 139 // Allows processing of our shortcodes in CF7. Without it, the embedded shortcode remains as text in the HTML. 140 add_filter( 'wpcf7_form_elements', 'do_shortcode' ); 141 add_action( 'wpcf7_submit', [ $this, 'handle_cf7_submit' ], 10, 2 ); 142 // add_action( 'wpcf7_validate', [ $this, 'handle_cf7_validate' ], 10, 2 ); // TODO: Revisit. 143 144 // Uncomment the following to test the CF7 form when the CF7 JavaScript has been disabled. 145 // That is, the form submission will do a regular form submission as opposed to using AJAX. 146 // add_filter( 'wpcf7_load_js', '__return_false' ); 147 } 148 149 /** 150 * @since 1.2.0 151 * 152 * @param WPCF7_ContactForm $cf7form 153 * @param Array $result 154 * @param number $result['contact_form_id'] 155 * @param string $result['message'] 156 * @param string $result['status'] 157 * @param string [$result['invalid_fields']] 158 */ 159 public function handle_cf7_submit( $cf7form, $result ) { 160 // error_log('XcooBee_Form->handle_cf7_submit'); 161 // error_log(print_r($_POST, true)); 162 // error_log(print_r($result, true)); 163 164 if ( $cf7form->in_demo_mode() ) { 165 return; 166 } 167 168 // $status may be: aborted, acceptance_missing, error, init, mail_failed, mail_sent, spam, validation_failed 169 $status = $result['status']; 170 if ( $status === 'mail_sent' || $status === 'mail_failed' || $status === 'init' ) { 171 $targets = []; 172 $xbee_action = isset( $_POST['xbee__action'] ) ? $_POST['xbee__action'] : ''; 173 if ( 'save_consent' === $xbee_action ) { 174 $campaign_reference = isset( $_POST['xbee__campaign_reference'] ) ? $_POST['xbee__campaign_reference'] : ''; 175 if ( empty( $campaign_reference ) ) { 176 $default_campaign_reference = get_option( 'xbee_form_default_campaign_reference', '' ); 177 $campaign_reference = $default_campaign_reference; 178 } 179 180 // error_log('$campaign_reference:' . print_r($campaign_reference, true)); 181 182 if ( ! empty( $campaign_reference) ) { 183 $xcoobee_id_field = isset( $_POST['xbee__xcoobee_id_field'] ) ? $_POST['xbee__xcoobee_id_field'] : ''; 184 if ( empty( $xcoobee_id_field ) ) { 185 $xcoobee_id_field = $default_xcoobee_id_field; 186 } 187 $xcoobee_id = isset( $_POST[$xcoobee_id_field] ) ? $_POST[$xcoobee_id_field] : ''; 188 // If appears to be a valid XcooBee ID, then ... 189 if ( ! empty( $xcoobee_id ) && xbee_validate_xid( $xcoobee_id ) ) { 190 $targets[] = array( 'target' => $xcoobee_id ); 191 } else { 192 $email_field = isset( $_POST['xbee__email_field'] ) ? $_POST['xbee__email_field'] : ''; 193 if ( empty( $email_field ) ) { 194 $email_field = $default_email_field; 195 } 196 $email = isset( $_POST[$email_field] ) ? $_POST[$email_field] : ''; 197 if ( ! empty( $email ) ) { 198 $targets[] = array( 'target' => $email ); 199 } 200 } 201 202 if ( count( $targets ) > 0 ) { 203 $xcoobee = XcooBee::get_xcoobee(); 204 $response = $xcoobee->consents->getCampaignIdByRef( $campaign_reference ); 205 206 // error_log('$response:' . print_r($response, true)); 207 if ( 200 === $response->code ) { 208 $campaign_id = $response->result; 209 // error_log('$targets:' . print_r($targets, true)); 210 // error_log('$campaign_id:' . print_r($campaign_id, true)); 211 $response = $xcoobee->consents->registerConsents( null, $targets, null, $campaign_id ); 212 if ( 200 !== $response->code || ! empty( $response->errors ) ) { 213 error_log( 'Failed to save consent. Error Code: ' . $response->code ); 214 if ( ! empty( $response->errors ) ) { 215 error_log( print_r( $response->errors, true ) ); 216 } 217 } 218 } else { 219 error_log( 'Failed to save consent. Unable to get campaign using "' . $campaign_reference . '".' ); 220 } 221 } 222 } else { 223 error_log( 'No campaign reference set. Unable to save consent.' ); 224 } 225 } 226 } 227 } 228 229 // /** 230 // * @since 1.2.0 231 // * 232 // * @param WPCF7_Validation $result 233 // * @param Array<WPCF7_FormTag> 234 // */ 235 // public function handle_cf7_validate( $result, $tags ) { 236 // error_log('XcooBee_Form->handle_cf7_validate'); 237 // error_log(print_r($result, true)); 238 // error_log(print_r($tags, true)); 239 240 // return $result; 241 // } 135 242 136 243 /** … … 155 262 // Back-end scripts. 156 263 if ( 'admin_enqueue_scripts' === current_action() ) { 157 wp_enqueue_script( 'xbee-form-admin-scripts', XBEE_FORM_DIR_URL . 'assets/dist/js/admin/scripts.min.js', [ ' jquery', 'xbee-admin-scripts' ], null, true );264 wp_enqueue_script( 'xbee-form-admin-scripts', XBEE_FORM_DIR_URL . 'assets/dist/js/admin/scripts.min.js', [ 'clipboard', 'jquery', 'xbee-admin-scripts' ], null, true ); 158 265 wp_localize_script( 'xbee-form-admin-scripts', 'xbeeFormAdminParams', [ 159 266 'ajaxURL' => admin_url( 'admin-ajax.php' ), … … 211 318 // Nothing to do for now. 212 319 } 213 320 214 321 /** 215 322 * Deactivation hooks. … … 234 341 XcooBee_Form::get_instance(); 235 342 } 236 237 343 add_action( 'plugins_loaded', 'init_xcoobee_form' ); 238 344
Note: See TracChangeset
for help on using the changeset viewer.