diff --git a/changelog/fix-pluginscore-ratings b/changelog/fix-pluginscore-ratings
new file mode 100644
index 00000000000..ce2c1290a83
--- /dev/null
+++ b/changelog/fix-pluginscore-ratings
@@ -0,0 +1,4 @@
+Significance: patch
+Type: update
+
+update: usage of WP best practices
diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php
index 23d9c3ef388..b46a6e03cf2 100644
--- a/includes/class-wc-payment-gateway-wcpay.php
+++ b/includes/class-wc-payment-gateway-wcpay.php
@@ -1266,7 +1266,7 @@ public function process_payment( $order_id ) {
// This allows WC to check if WP_DEBUG mode is enabled before returning previous Exception and expose Exception class name to frontend.
add_filter( 'woocommerce_return_previous_exceptions', '__return_true' );
wc_add_notice( wp_strip_all_tags( WC_Payments_Utils::get_filtered_error_message( $e, $blocked_by_fraud_rules ) ), 'error' );
- do_action( 'update_payment_result_on_error', $e, $order );
+ do_action( 'wcpay_update_payment_result_on_error', $e, $order );
return [
'result' => 'fail',
@@ -1340,7 +1340,7 @@ public function update_customer_with_order_data( $order, $customer_id, $is_test_
/**
* Sets up a handler to add error details to the payment result.
- * Registers an action to handle 'update_payment_result_on_error',
+ * Registers an action to handle 'wcpay_update_payment_result_on_error',
* using the payment result object from 'woocommerce_rest_checkout_process_payment_with_context'.
*
* @param PaymentContext $context The payment context.
@@ -1348,7 +1348,7 @@ public function update_customer_with_order_data( $order, $customer_id, $is_test_
*/
public function setup_payment_error_handler( PaymentContext $context, PaymentResult &$result ) {
add_action(
- 'update_payment_result_on_error',
+ 'wcpay_update_payment_result_on_error',
function ( $error ) use ( &$result ) {
$result->set_payment_details(
array_merge(
diff --git a/includes/in-person-payments/templates/html-in-person-payment-receipt.php b/includes/in-person-payments/templates/html-in-person-payment-receipt.php
index e575e52fd03..0e1a9628553 100644
--- a/includes/in-person-payments/templates/html-in-person-payment-receipt.php
+++ b/includes/in-person-payments/templates/html-in-person-payment-receipt.php
@@ -12,7 +12,7 @@
* @param string $currency The currency to display.
* @return string
*/
-function format_price_helper( array $product, string $currency ): string {
+function wcpay_format_price_helper( array $product, string $currency ): string {
$active_price = $product['price'];
$regular_price = $product['regular_price'];
$has_discount = $active_price !== $regular_price;
@@ -139,7 +139,7 @@ function format_price_helper( array $product, string $currency ): string {
|
- @
+ @
|
$order['currency'] ] ), 'post' ); ?> |
diff --git a/includes/notes/class-wc-payments-remote-note-service.php b/includes/notes/class-wc-payments-remote-note-service.php
index cfd2d917950..3790884649e 100644
--- a/includes/notes/class-wc-payments-remote-note-service.php
+++ b/includes/notes/class-wc-payments-remote-note-service.php
@@ -113,11 +113,10 @@ private function create_note( array $note_data ) {
*/
public function delete_notes() {
global $wpdb;
- $prefix = self::NOTE_NAME_PREFIX;
- // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_admin_note_actions WHERE name LIKE '{$prefix}%'" );
- // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
- $wpdb->query( "DELETE FROM {$wpdb->prefix}wc_admin_notes WHERE name LIKE '{$prefix}%'" );
+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}wc_admin_note_actions WHERE name LIKE %s", $wpdb->esc_like( self::NOTE_NAME_PREFIX ) . '%' ) );
+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}wc_admin_notes WHERE name LIKE %s", $wpdb->esc_like( self::NOTE_NAME_PREFIX ) . '%' ) );
}
/**
diff --git a/includes/woopay/class-woopay-store-api-session-handler.php b/includes/woopay/class-woopay-store-api-session-handler.php
index 0871b715e32..7f922a7d171 100644
--- a/includes/woopay/class-woopay-store-api-session-handler.php
+++ b/includes/woopay/class-woopay-store-api-session-handler.php
@@ -112,7 +112,8 @@ public function save_data() {
$wpdb->query(
$wpdb->prepare(
- "INSERT INTO $this->table (`session_key`, `session_value`, `session_expiry`) VALUES (%s, %s, %d) ON DUPLICATE KEY UPDATE `session_value` = VALUES(`session_value`), `session_expiry` = VALUES(`session_expiry`)", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
+ "INSERT INTO $this->table (`session_key`, `session_value`, `session_expiry`) VALUES (%s, %s, %d) ON DUPLICATE KEY UPDATE `session_value` = VALUES(`session_value`), `session_expiry` = VALUES(`session_expiry`)",
$this->_customer_id,
maybe_serialize( $this->_data ),
$this->session_expiration
diff --git a/tests/unit/notes/test-class-wc-payments-remote-note-service.php b/tests/unit/notes/test-class-wc-payments-remote-note-service.php
index 79dfb42b6cb..ad8c3577c0f 100644
--- a/tests/unit/notes/test-class-wc-payments-remote-note-service.php
+++ b/tests/unit/notes/test-class-wc-payments-remote-note-service.php
@@ -140,4 +140,36 @@ public function test_throws_on_malformed_data() {
$this->expectException( Rest_Request_Exception::class );
$this->note_service->put_note( $note_data );
}
+
+ public function test_delete_notes() {
+ global $wpdb;
+
+ $real_data_store = WC_Data_Store::load( 'admin-note' );
+ $note_service = new WC_Payments_Remote_Note_Service( $real_data_store );
+
+ $note_data = [
+ 'title' => 'test',
+ 'content' => 'hello_world',
+ ];
+
+ $note_service->put_note( $note_data );
+
+ $notes_before = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT COUNT(*) FROM {$wpdb->prefix}wc_admin_notes WHERE name LIKE %s",
+ 'wc-payments-remote-notes-%'
+ )
+ );
+ $this->assertEquals( 1, $notes_before );
+
+ $note_service->delete_notes();
+
+ $notes_after = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT COUNT(*) FROM {$wpdb->prefix}wc_admin_notes WHERE name LIKE %s",
+ 'wc-payments-remote-notes-%'
+ )
+ );
+ $this->assertEquals( 0, $notes_after );
+ }
}