Changeset 3448270
- Timestamp:
- 01/27/2026 11:25:42 PM (6 weeks ago)
- Location:
- workzen-connector/trunk
- Files:
-
- 1 deleted
- 5 edited
-
.svnignore (deleted)
-
assets/admin.js (modified) (1 diff)
-
includes/class-admin-pages.php (modified) (2 diffs)
-
includes/class-ajax-handlers.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
workzen-connector.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
workzen-connector/trunk/assets/admin.js
r3447338 r3448270 323 323 }); 324 324 325 // API Testing - Send Test Booking 326 $('#wzc-send-test-booking').on('click', function() { 327 const $btn = $(this); 328 const $result = $('#wzc-test-result'); 329 330 $btn.prop('disabled', true).html('<span class="dashicons dashicons-update-alt" style="margin-top: 3px; animation: spin 1s linear infinite;"></span> ' + wzconnectorAjax.i18n.sending); 331 $result.hide(); 332 333 $.ajax({ 334 url: wzconnectorAjax.ajax_url, 335 type: 'POST', 336 data: { 337 action: 'wzconnector_send_test_booking', 338 nonce: wzconnectorAjax.nonce 339 }, 340 success: function(response) { 341 if (response.success) { 342 $result.html(` 343 <div style="padding: 12px; background: #ecfdf5; border: 1px solid #10b981; border-radius: 8px; color: #065f46;"> 344 <strong>${wzconnectorAjax.i18n.success}</strong><br> 345 ${escapeHtml(response.data && response.data.message ? response.data.message : '')} 346 ${(response.data && response.data.booking) ? '<br><small>Booking: ' + escapeHtml(response.data.booking) + '</small>' : ''} 347 ${(response.data && response.data.lead_guid) ? '<br><small>Lead GUID: ' + escapeHtml(response.data.lead_guid) + '</small>' : ''} 348 </div> 349 `).show(); 350 } else { 351 $result.html(` 352 <div style="padding: 12px; background: #fef2f2; border: 1px solid #dc2626; border-radius: 8px; color: #b91c1c;"> 353 <strong>${wzconnectorAjax.i18n.error}</strong><br> 354 ${escapeHtml(response.data && response.data.message ? response.data.message : '')} 355 ${(response.data && response.data.details) ? '<br><small>' + escapeHtml(response.data.details) + '</small>' : ''} 356 </div> 357 `).show(); 358 } 359 }, 360 error: function() { 361 $result.html(` 362 <div style="padding: 12px; background: #fef2f2; border: 1px solid #dc2626; border-radius: 8px; color: #b91c1c;"> 363 <strong>${wzconnectorAjax.i18n.error}</strong><br> 364 ${wzconnectorAjax.i18n.unexpectedError} 365 </div> 366 `).show(); 367 }, 368 complete: function() { 369 $btn.prop('disabled', false).html('<span class="dashicons dashicons-calendar-alt" style="margin-top: 3px;"></span> ' + wzconnectorAjax.i18n.sendTestBooking); 370 } 371 }); 372 }); 373 325 374 // Retry failed log entry 326 375 $(document).on('click', '.wzc-retry-btn', function() { -
workzen-connector/trunk/includes/class-admin-pages.php
r3447338 r3448270 142 142 'testing' => __( 'Testing...', 'workzen-connector' ), 143 143 'sendTestLead' => __( 'Send Test Lead', 'workzen-connector' ), 144 'sendTestBooking' => __( 'Send Test Booking', 'workzen-connector' ), 144 145 'sending' => __( 'Sending...', 'workzen-connector' ), 145 146 'retry' => __( '↻ Retry', 'workzen-connector' ), … … 606 607 <?php esc_html_e( 'Send Test Lead', 'workzen-connector' ); ?> 607 608 </button> 609 <button type="button" id="wzc-send-test-booking" class="button button-secondary"> 610 <span class="dashicons dashicons-calendar-alt" style="margin-top: 3px;"></span> 611 <?php esc_html_e( 'Send Test Booking', 'workzen-connector' ); ?> 612 </button> 608 613 </div> 609 614 <div id="wzc-test-result" style="margin-top: 16px; display: none;"></div> -
workzen-connector/trunk/includes/class-ajax-handlers.php
r3447338 r3448270 30 30 add_action( 'wp_ajax_wzconnector_test_connection', array( $this, 'ajax_test_connection' ) ); 31 31 add_action( 'wp_ajax_wzconnector_send_test_lead', array( $this, 'ajax_send_test_lead' ) ); 32 add_action( 'wp_ajax_wzconnector_send_test_booking', array( $this, 'ajax_send_test_booking' ) ); 32 33 add_action( 'wp_ajax_wzconnector_submit_floating_form', array( $this, 'ajax_submit_floating_form' ) ); 33 34 add_action( 'wp_ajax_nopriv_wzconnector_submit_floating_form', array( $this, 'ajax_submit_floating_form' ) ); … … 392 393 if ( $status_code === 201 || $status_code === 200 ) { 393 394 // Verify this is actually a WorkZen API response with lead data 394 if ( isset( $decoded_body['lead_id'] ) || isset( $decoded_body['lead_guid'] ) ) { 395 $lead_guid = isset( $decoded_body['data']['lead_guid'] ) ? $decoded_body['data']['lead_guid'] : ( isset( $decoded_body['lead_guid'] ) ? $decoded_body['lead_guid'] : null ); 396 $lead_id = isset( $decoded_body['data']['lead_id'] ) ? $decoded_body['data']['lead_id'] : ( isset( $decoded_body['lead_id'] ) ? $decoded_body['lead_id'] : null ); 397 398 if ( isset( $decoded_body['success'] ) || $lead_guid || $lead_id ) { 395 399 wp_send_json_success( array( 396 'message' => __( 'Test lead sent successfully! Check your WorkZen dashboard.', 'workzen-connector' ),397 'lead_id' => isset( $decoded_body['lead_id'] ) ? $decoded_body['lead_id'] : null,398 'lead_guid' => isset( $decoded_body['lead_guid'] ) ? $decoded_body['lead_guid'] : null,400 'message' => __( 'Test lead sent successfully! Check your WorkZen dashboard.', 'workzen-connector' ), 401 'lead_id' => $lead_id, 402 'lead_guid' => $lead_guid, 399 403 ) ); 400 404 } else { … … 419 423 420 424 /** 421 * Enqueue frontend tracking assets425 * AJAX: Send a test booking to verify the API works with booking data 422 426 */ 427 public function ajax_send_test_booking() { 428 check_ajax_referer( 'wzconnector_nonce', 'nonce' ); 429 430 if ( ! current_user_can( 'manage_options' ) ) { 431 wp_send_json_error( array( 'message' => 'Unauthorized' ) ); 432 } 433 434 $endpoint = get_option( WZC_Constants::OPTION_ENDPOINT ); 435 $integration_key = get_option( WZC_Constants::OPTION_INTEGRATION_KEY ); 436 437 if ( empty( $endpoint ) || empty( $integration_key ) ) { 438 wp_send_json_error( array( 439 'message' => __( 'Please configure your Integration Key and API Endpoint first.', 'workzen-connector' ), 440 ) ); 441 } 442 443 // Build a test booking for tomorrow at 9:00 AM, 1 hour 444 $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day' ) ); 445 446 $body = array( 447 'website_name' => get_option( WZC_Constants::OPTION_WEBSITE_NAME ), 448 'integration' => 'test-plugin', 449 'fields' => array( 450 'first_name' => 'Jane', 451 'last_name' => 'Doe', 452 'email' => 'jane.doe@test.workzen.io', 453 'phone' => '+1 (555) 987-6543', 454 'message' => __( 'This is a test booking from the WordPress connector plugin.', 'workzen-connector' ), 455 ), 456 'meta' => array( 457 'test' => true, 458 'source' => 'Test Booking Button', 459 'form_type' => 'booking', 460 'booking_date' => $tomorrow, 461 'booking_time' => '09:00', 462 'timestamp' => current_time( 'mysql' ), 463 ), 464 'visit_request_start_time' => $tomorrow . ' 09:00:00', 465 'visit_request_time_frame' => '60', 466 ); 467 468 $args = array( 469 'body' => wp_json_encode( $body ), 470 'headers' => array( 471 'Content-Type' => 'application/json', 472 'X-Integration-Key' => $integration_key, 473 ), 474 'timeout' => 10, 475 ); 476 477 if ( defined( 'WORKZEN_DEV' ) && WORKZEN_DEV ) { 478 $args['sslverify'] = false; 479 } 480 481 $response = wp_remote_post( $endpoint, $args ); 482 483 if ( is_wp_error( $response ) ) { 484 wp_send_json_error( array( 485 'message' => 'Failed to send test booking: ' . $response->get_error_message(), 486 ) ); 487 } 488 489 $status_code = wp_remote_retrieve_response_code( $response ); 490 $response_body = wp_remote_retrieve_body( $response ); 491 $decoded_body = json_decode( $response_body, true ); 492 493 if ( $status_code === 201 || $status_code === 200 ) { 494 $lead_guid = isset( $decoded_body['data']['lead_guid'] ) ? $decoded_body['data']['lead_guid'] : ( isset( $decoded_body['lead_guid'] ) ? $decoded_body['lead_guid'] : null ); 495 496 if ( isset( $decoded_body['success'] ) || $lead_guid ) { 497 wp_send_json_success( array( 498 'message' => __( 'Test booking sent successfully! Check your WorkZen dashboard.', 'workzen-connector' ), 499 'lead_guid' => $lead_guid, 500 'booking' => $tomorrow . ' at 09:00 AM (1 hour)', 501 ) ); 502 } else { 503 wp_send_json_error( array( 504 'message' => 'Unexpected API response format.', 505 'details' => 'The endpoint returned a ' . $status_code . ' response but not in the expected WorkZen format.', 506 ) ); 507 } 508 } elseif ( $status_code === 401 ) { 509 $error_message = isset( $decoded_body['message'] ) ? $decoded_body['message'] : 'Authentication failed'; 510 wp_send_json_error( array( 511 'message' => 'Authentication failed. ' . $error_message, 512 ) ); 513 } else { 514 wp_send_json_error( array( 515 'message' => 'Failed to create booking. Status code: ' . $status_code, 516 'details' => isset( $decoded_body['message'] ) ? $decoded_body['message'] : $response_body, 517 ) ); 518 } 519 } 423 520 424 521 /** -
workzen-connector/trunk/readme.txt
r3447338 r3448270 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.12. 07 Stable tag: 1.12.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 102 102 103 103 == Changelog == 104 105 = 1.12.1 = 106 * Fix: Test lead response now correctly handles nested API response format 107 * Feature: Added "Send Test Booking" button for testing booking submissions 104 108 105 109 = 1.12.0 = … … 227 231 == Upgrade Notice == 228 232 233 = 1.12.1 = 234 Fix test lead response handling and add test booking button. 235 229 236 = 1.12.0 = 230 237 Security and reliability update! Fixed race conditions, improved error handling, added input validation, and extended booking date range. Update recommended. -
workzen-connector/trunk/workzen-connector.php
r3447338 r3448270 3 3 * Plugin Name: WorkZen Connector 4 4 * Description: Connects WordPress forms to WorkZen CRM. Captures leads from Contact Form 7, WPForms, Gravity Forms, and other popular form plugins, sending them securely to your WorkZen account via the WorkZen API (https://api.workzen.io). Includes floating buttons with online booking functionality. 5 * Version: 1.12. 05 * Version: 1.12.1 6 6 * Author: Ika Balzam 7 7 * Author URI: https://workzen.io … … 20 20 21 21 // Define plugin constants 22 define( 'WZC_VERSION', '1.12. 0' );22 define( 'WZC_VERSION', '1.12.1' ); 23 23 define( 'WZC_PLUGIN_FILE', __FILE__ ); 24 24 define( 'WZC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.