Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions woocommerce/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

2026.nn.nn - version 6.2.5
* Fix - "event is not a function" error on My Payment Methods page
* Fix - Add additional nonce and permission checks

2026.08.19 - version 6.2.4
* Security - Hardened capability checks around the payment token editor's admin functionality
Expand Down
44 changes: 36 additions & 8 deletions woocommerce/class-sv-wc-admin-notice-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,30 @@ public function render_admin_notice( $message, $message_id, $params = array() )
}

echo sprintf(
'<div class="%1$s" data-plugin-id="%2$s" data-message-id="%3$s" %4$s><p>%5$s</p></div>',
'<div class="%1$s" data-plugin-id="%2$s" data-message-id="%3$s" data-nonce="%6$s" %4$s><p>%5$s</p></div>',
esc_attr( implode( ' ', $classes ) ),
esc_attr( $this->get_plugin()->get_id() ),
esc_attr( $message_id ),
( ! $params['is_visible'] ) ? 'style="display:none;"' : '',
wp_kses_post( $message )
wp_kses_post( $message ),
esc_attr( wp_create_nonce( $this->get_dismiss_notice_nonce_action() ) )
);
}


/**
* Gets the nonce action used to authorize dismissing notices for this plugin.
*
* @since 6.2.5
*
* @return string
*/
protected function get_dismiss_notice_nonce_action() : string {

return 'wc_plugin_framework_' . $this->get_plugin()->get_id() . '_dismiss_notice';
}


/**
* Render the javascript to handle the notice "dismiss" functionality
*
Expand Down Expand Up @@ -273,7 +287,8 @@ public function render_admin_notice_js() {

log_dismissed_notice(
$( $notice ).data( 'plugin-id' ),
$( $notice ).data( 'message-id' )
$( $notice ).data( 'message-id' ),
$( $notice ).data( 'nonce' )
);

} );
Expand All @@ -287,20 +302,22 @@ public function render_admin_notice_js() {

log_dismissed_notice(
$( $notice ).data( 'plugin-id' ),
$( $notice ).data( 'message-id' )
$( $notice ).data( 'message-id' ),
$( $notice ).data( 'nonce' )
);

$( $notice ).fadeOut();

} );

function log_dismissed_notice( pluginID, messageID ) {
function log_dismissed_notice( pluginID, messageID, nonce ) {

$.get(
$.post(
ajaxurl,
{
action: 'wc_plugin_framework_' + pluginID + '_dismiss_notice',
messageid: messageID
messageid: messageID,
nonce: nonce
}
);
}
Expand Down Expand Up @@ -419,8 +436,19 @@ public function get_dismissed_notices( $user_id = null ) {
*/
public function handle_dismiss_notice() {

$this->dismiss_notice( $_REQUEST['messageid'] );
check_ajax_referer( $this->get_dismiss_notice_nonce_action(), 'nonce' );

if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_send_json_error( null, 403 );
}

if ( empty( $_REQUEST['messageid'] ) || ! is_string( $_REQUEST['messageid'] ) ) {
wp_send_json_error( null, 400 );
}

$this->dismiss_notice( sanitize_text_field( wp_unslash( $_REQUEST['messageid'] ) ) );

wp_send_json_success();
}


Expand Down
23 changes: 23 additions & 0 deletions woocommerce/utilities/class-sv-wp-job-batch-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ protected function add_hooks() {
add_action( 'wp_ajax_' . $this->get_job_handler()->get_identifier() . '_cancel_job', array( $this, 'ajax_cancel_job' ) );
}

/**
* Gets the capability required to process or cancel jobs via AJAX.
*
* Child classes can override this to require a different capability.
*
* @since 6.2.5
*
* @return string
*/
protected function get_required_capability() : string {

return 'manage_woocommerce';
}


/**
* Gets the name of the script handle.
*
Expand Down Expand Up @@ -185,6 +200,10 @@ public function ajax_process_batch() {

check_ajax_referer( $this->get_job_handler()->get_identifier() . '_process_batch', 'security' );

if ( ! current_user_can( $this->get_required_capability() ) ) {
wp_send_json_error( null, 403 );
}

if ( empty( $_POST['job_id'] ) ) {
return;
}
Expand Down Expand Up @@ -219,6 +238,10 @@ public function ajax_cancel_job() {

check_ajax_referer( $this->get_job_handler()->get_identifier() . '_cancel_job', 'security' );

if ( ! current_user_can( $this->get_required_capability() ) ) {
wp_send_json_error( null, 403 );
}

if ( empty( $_POST['job_id'] ) ) {
return;
}
Expand Down
Loading