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
4 changes: 4 additions & 0 deletions admin/form-builder/views/post-form-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ function wpuf_render_settings_field( $field_key, $field, $form_settings, $post_t
if ( $is_pro_preview && strpos( $field_key, 'notification_' ) === 0 ) {
$toggle_value = 'off';
}
// Convert various "on" values to 'on' for the toggle
if ( wpuf_is_checkbox_or_toggle_on( $toggle_value ) ) {
$toggle_value = 'on';
}
?>
<label
for="<?php echo $field_key; ?>"
Expand Down
40 changes: 20 additions & 20 deletions assets/js/forms-list.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/forms-list.min.js.map

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions assets/js/subscriptions.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function update_reviews( $post_id ) {
$reviews = get_post_meta( $post_id, 'product_reviews', true );
$status = ! empty( $reviews ) ? 'open' : 'closed';
// wp_update_post( array( 'ID' => $post_id, 'comment_status' => $status ) );
$comment_sql = "UPDATE {$wpdb->prefix}posts SET comment_status='{$status}' WHERE ID={$post_id} AND post_status='publish' AND post_type='product'";
//$comment_sql = "UPDATE {$wpdb->prefix}posts SET comment_status='{$status}' WHERE ID={$post_id} AND post_status='publish' AND post_type='product'";
$wpdb->get_results( $wpdb->prepare( "UPDATE {$wpdb->prefix}posts SET comment_status=%s WHERE ID=%d AND post_status='publish' AND post_type='product'", $status, $post_id ) );
}
Comment on lines 310 to 311
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use $wpdb->query (or $wpdb->update) for UPDATE; get_results is the wrong API, and prefer $wpdb->posts over string interpolation.

get_results() is intended for SELECT-like queries; here it still executes but discards the affected-rows result and is semantically misleading. Also, reference the posts table via $wpdb->posts.

-        $wpdb->get_results( $wpdb->prepare( "UPDATE {$wpdb->prefix}posts SET comment_status=%s WHERE ID=%d AND post_status='publish' AND post_type='product'", $status, $post_id ) );
+        $wpdb->query(
+            $wpdb->prepare(
+                "UPDATE {$wpdb->posts} SET comment_status = %s WHERE ID = %d AND post_status = 'publish' AND post_type = 'product'",
+                $status,
+                $post_id
+            )
+        );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$wpdb->get_results( $wpdb->prepare( "UPDATE {$wpdb->prefix}posts SET comment_status=%s WHERE ID=%d AND post_status='publish' AND post_type='product'", $status, $post_id ) );
}
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->posts} SET comment_status = %s WHERE ID = %d AND post_status = 'publish' AND post_type = 'product'",
$status,
$post_id
)
);
}
🤖 Prompt for AI Agents
In includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php around
lines 310-311, the code uses $wpdb->get_results for an UPDATE and interpolates
the table name; replace this with the proper $wpdb API and table constant: call
$wpdb->update against $wpdb->posts (or use $wpdb->query with a prepared UPDATE)
so the function semantics match (returning affected rows) and avoid
string-interpolating {$wpdb->prefix}; pass the data array and where conditions
(ID => $post_id plus the post_status and post_type constraints) to $wpdb->update
or, if using $wpdb->query, use $wpdb->prepare with $wpdb->posts in the query
string.


Expand Down
4 changes: 0 additions & 4 deletions includes/Fields/Form_Field_Textarea.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace WeDevs\Wpuf\Fields;

Check failure on line 3 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

There must be one blank line after the namespace declaration


/**
* Textarea Field Class

Check warning on line 7 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
*/

Check warning on line 8 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
class Form_Field_Textarea extends Field_Contract {

public function __construct() {
Expand All @@ -14,14 +14,14 @@
$this->icon = 'menu-alt-2';
}

/**

Check warning on line 17 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
* Render the Textarea field

Check warning on line 18 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
*

Check warning on line 19 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
* @param array $field_settings

Check warning on line 20 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
* @param int $form_id

Check warning on line 21 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
* @param string $type

Check warning on line 22 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
* @param int $post_id

Check warning on line 23 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
*

Check warning on line 24 in includes/Fields/Form_Field_Textarea.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
* @return void
*/
public function render( $field_settings, $form_id, $type = 'post', $post_id = null ) {
Expand Down Expand Up @@ -172,10 +172,6 @@
* @return string
*/
public function render_field_data( $data, $field ) {
if ( ! is_string( $data ) ) {
return '';
}

$data = implode( ',', $data );
$hide_label = isset( $field['hide_field_label'] )
? wpuf_validate_boolean( $field['hide_field_label'] )
Expand Down
Loading
Loading