Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
We don't need to move this method.
  • Loading branch information
enejb authored and CGastrell committed Dec 10, 2025
commit d0b67b263d63f0846eba1040849924499a93f9bb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ protected function __construct() {
add_action( 'wp_ajax_feedback_export', array( $this, 'download_feedback_as_csv' ) );
add_action( 'wp_ajax_create_new_form', array( $this, 'create_new_form' ) );
add_action( 'wp_ajax_grunion_export_to_gdrive', array( $this, 'export_to_gdrive' ) );
add_action( 'wp_ajax_grunion_gdrive_connection', array( $this, 'test_gdrive_connection' ) );
}
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'current_screen', array( $this, 'unread_count' ) );
Expand Down Expand Up @@ -3731,40 +3730,4 @@ public function export_to_gdrive() {
)
);
}

/**
* Ajax handler. Sends a payload with connection status and html to replace
* the Connect button with the Export button using get_gdrive_export_button
*/
public function test_gdrive_connection() {
$post_data = wp_unslash( $_POST );
$user_id = (int) get_current_user_id();

if (
! $user_id ||
! current_user_can( 'export' ) ||
empty( sanitize_text_field( $post_data[ $this->export_nonce_field_gdrive ] ) ) ||
! wp_verify_nonce( sanitize_text_field( $post_data[ $this->export_nonce_field_gdrive ] ), 'feedback_export' )
) {
wp_send_json_error(
__( 'You aren\'t authorized to do that.', 'jetpack-forms' ),
403
);

return;
}

$has_valid_connection = Google_Drive::has_valid_connection();

$replacement_html = $has_valid_connection
? $this->get_gdrive_export_button_markup()
: '';

wp_send_json(
array(
'connection' => $has_valid_connection,
'html' => $replacement_html,
)
);
}
}