-
Notifications
You must be signed in to change notification settings - Fork 151
[Fix] Ensure WPUF Profile Form Multistep Toggle Applies on Frontend #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] Ensure WPUF Profile Form Multistep Toggle Applies on Frontend #1687
Conversation
WalkthroughIntroduces toggle value normalization in post form settings, adjusts textarea field data handling by removing a type guard, updates repeat field rendering to support multiselect and removes prior preprocessing, switches WooCommerce review updates to a prepared statement, and refreshes POT metadata/source references. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
wpuf-functions.php (1)
1203-1212: Guard non-scalar repeat inner values to avoid “Array to string conversion”.If a repeat inner field (e.g., select with multiple, or unexpected array) slips through,
make_clickable( $inner_field_value )will emit notices. Coerce arrays to strings before rendering.Apply:
- } elseif ( 'radio' === $inner_field['input_type'] || 'select' === $inner_field['input_type'] ) { - // For radio and select fields, display single value - $repeat_html .= '<span>' . make_clickable( $inner_field_value ) . '</span>'; + } elseif ( 'radio' === $inner_field['input_type'] || 'select' === $inner_field['input_type'] ) { + // For radio and select fields, coerce arrays defensively + $val = is_array( $inner_field_value ) ? implode( ', ', $inner_field_value ) : $inner_field_value; + $repeat_html .= '<span>' . make_clickable( $val ) . '</span>'; } else { - // For text and other fields - $repeat_html .= '<span>' . make_clickable( $inner_field_value ) . '</span>'; + // For text and other fields + $val = is_array( $inner_field_value ) ? implode( ', ', $inner_field_value ) : $inner_field_value; + $repeat_html .= '<span>' . make_clickable( $val ) . '</span>'; }
🧹 Nitpick comments (2)
admin/form-builder/views/post-form-settings.php (2)
387-390: Good: normalize toggle truthy states before rendering.Ensures '1'/'yes'/'true' display as checked consistently.
You can make the state explicit:
- if ( wpuf_is_checkbox_or_toggle_on( $toggle_value ) ) { - $toggle_value = 'on'; - } + $toggle_value = wpuf_is_checkbox_or_toggle_on( $toggle_value ) ? 'on' : 'off';
301-337: Avoid double-fetching $value from $form_settings.
$valueis reassigned from$form_settingstwice (Lines 325–329 and 333–336). This can be simplified to one lookup to reduce branching and confusion.- // replace default value if already saved in DB - if ( ! empty( $field['name'] ) ) { - preg_match('/wpuf_settings\[(.*?)\]\[(.*?)\]/', $field['name'], $matches); - if (isset($matches[1]) && isset($matches[2])) { - $dynamic_key = $matches[1]; - $temp_key = $matches[2]; - $value = isset( $form_settings[ $dynamic_key ][ $temp_key ] ) ? $form_settings[ $dynamic_key ][ $temp_key ] : $value; - } - } else { - $value = isset( $form_settings[ $field_key ] ) ? $form_settings[ $field_key ] : $value; // checking with isset because saved value can be empty string - } - - // if the field is a pro fields preview, no need to load fields from db - if ( $is_pro_preview ) { - $value = ! empty( $field['value'] ) ? $field['value'] : $value; - } else { - $value = isset( $form_settings[ $field_key ] ) ? $form_settings[ $field_key ] : $value; // checking with isset because saved value can be empty string - } + // Resolve saved value once + if ( ! empty( $field['name'] ) && preg_match( '/wpuf_settings\[(.*?)\]\[(.*?)\]/', $field['name'], $m ) === 1 ) { + $value = isset( $form_settings[ $m[1] ][ $m[2] ] ) ? $form_settings[ $m[1] ][ $m[2] ] : $value; + } else { + $value = isset( $form_settings[ $field_key ] ) ? $form_settings[ $field_key ] : $value; + } + // For pro previews, prefer provided demo value + if ( $is_pro_preview && isset( $field['value'] ) ) { + $value = $field['value']; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
admin/form-builder/views/post-form-settings.php(1 hunks)includes/Fields/Form_Field_Textarea.php(0 hunks)wpuf-functions.php(1 hunks)
💤 Files with no reviewable changes (1)
- includes/Fields/Form_Field_Textarea.php
🧰 Additional context used
🧬 Code graph analysis (1)
admin/form-builder/views/post-form-settings.php (1)
wpuf-functions.php (1)
wpuf_is_checkbox_or_toggle_on(5592-5594)
🪛 GitHub Actions: Inspections
admin/form-builder/views/post-form-settings.php
[error] 1-1: PHP_CodeSniffer (phpcs) error: There must be one blank line after the namespace declaration. Command: vendor/bin/phpcs admin/form-builder/views/post-form-settings.php includes/Fields/Form_Field_Textarea.php wpuf-functions.php -q --report=checkstyle | cs2pr --graceful-warnings
🔇 Additional comments (2)
wpuf-functions.php (1)
1183-1183: Repeat field UL re-indent: OKNo functional change here; markup remains the same.
admin/form-builder/views/post-form-settings.php (1)
1-1: Namespace blank-line sniff not applicable
Nonamespacedeclarations exist in admin/form-builder/views/post-form-settings.php, includes/Fields/Form_Field_Textarea.php, or wpuf-functions.php; the “blank line after namespace” error must originate from a different file.Likely an incorrect or invalid review comment.
ab88de9 to
e34634e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php (2)
29-36: Silence unused parameter warnings by convention.Prefix unused args to satisfy analyzers without changing the hook signature.
- public function sync_product_gallery( $post_id, $form_id, $form_settings, $meta_vars = [] ) { + public function sync_product_gallery( $post_id, $_form_id, $_form_settings, $_meta_vars = [] ) {
7-7: Fix PHPCS: trailing whitespace.Trim trailing spaces on these lines to satisfy the PHPCS inspection.
Also applies to: 11-11, 16-16, 20-20, 34-34, 37-37, 46-46, 48-48, 52-52, 60-60
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php(0 hunks)includes/Integrations.php(1 hunks)includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php(1 hunks)
💤 Files with no reviewable changes (1)
- includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php
🧰 Additional context used
🧬 Code graph analysis (1)
includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php (3)
includes/Integrations.php (2)
Integrations(10-58)__construct(29-40)includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php (1)
__construct(12-253)includes/Traits/FieldableTrait.php (1)
update_post_meta(337-447)
🪛 PHPMD (2.15.0)
includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php
29-29: Avoid unused parameters such as '$form_id'. (Unused Code Rules)
(UnusedFormalParameter)
29-29: Avoid unused parameters such as '$form_settings'. (Unused Code Rules)
(UnusedFormalParameter)
29-29: Avoid unused parameters such as '$meta_vars'. (Unused Code Rules)
(UnusedFormalParameter)
🪛 GitHub Check: Run PHPCS inspection
includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php
[failure] 60-60:
Whitespace found at end of line
[failure] 52-52:
Whitespace found at end of line
[failure] 48-48:
Whitespace found at end of line
[failure] 46-46:
Whitespace found at end of line
[failure] 37-37:
Whitespace found at end of line
[failure] 34-34:
Whitespace found at end of line
[warning] 29-29:
The method parameter $meta_vars is never used
[warning] 29-29:
The method parameter $form_settings is never used
[warning] 29-29:
The method parameter $form_id is never used
[failure] 20-20:
Whitespace found at end of line
[failure] 16-16:
Whitespace found at end of line
[failure] 11-11:
Whitespace found at end of line
[failure] 7-7:
Whitespace found at end of line
🔇 Additional comments (3)
includes/Integrations.php (2)
26-26: WooCommerce integration wiring looks correct; confirm load order.If Integrations is constructed before WooCommerce loads,
class_exists('WooCommerce')will be false and the integration won’t initialize. Verify construction happens after plugins_loaded (or re-scan then).
26-26: Scope drift vs PR title.Title mentions “Profile Form Multistep Toggle,” but this adds a WooCommerce gallery sync integration. Confirm scope or split PR for clarity.
includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php (1)
12-19: Hooks look appropriate for when meta is available.Good choice of WPUF post insert/update and product save hooks.
| public function sync_gallery_on_save( $post_id ) { | ||
| // Avoid infinite loops | ||
| remove_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 ); | ||
|
|
||
| $this->sync_gallery_images( $post_id ); | ||
|
|
||
| // Re-add the action | ||
| add_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Guard autosaves/revisions and ensure hook is always restored.
Prevents unnecessary work and guarantees the hook is re-added even if something fails.
- public function sync_gallery_on_save( $post_id ) {
- // Avoid infinite loops
- remove_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 );
-
- $this->sync_gallery_images( $post_id );
-
- // Re-add the action
- add_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 );
- }
+ public function sync_gallery_on_save( $post_id ) {
+ if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
+ return;
+ }
+ // Avoid infinite loops
+ remove_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 );
+ try {
+ $this->sync_gallery_images( $post_id );
+ } finally {
+ // Re-add the action
+ add_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 );
+ }
+ }📝 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.
| public function sync_gallery_on_save( $post_id ) { | |
| // Avoid infinite loops | |
| remove_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 ); | |
| $this->sync_gallery_images( $post_id ); | |
| // Re-add the action | |
| add_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 ); | |
| } | |
| public function sync_gallery_on_save( $post_id ) { | |
| if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) { | |
| return; | |
| } | |
| // Avoid infinite loops | |
| remove_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 ); | |
| try { | |
| $this->sync_gallery_images( $post_id ); | |
| } finally { | |
| // Re-add the action | |
| add_action( 'save_post_product', [ $this, 'sync_gallery_on_save' ], 20 ); | |
| } | |
| } |
🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 48-48:
Whitespace found at end of line
[failure] 46-46:
Whitespace found at end of line
🤖 Prompt for AI Agents
In includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php around lines 43 to
51, the save_post handler does not guard against autosaves/revisions and can
fail to re-add the hook if an exception occurs; update sync_gallery_on_save to
early-return for autosaves and revisions (use wp_is_post_autosave and
wp_is_post_revision or check DOING_AUTOSAVE), optionally validate the post type
is 'product' and post ID is valid, then wrap the call to sync_gallery_images in
a try/finally so add_action is always executed to re-register the handler even
on error.
| private function sync_gallery_images( $post_id ) { | ||
| $images = get_post_meta( $post_id, '_product_image', true ); | ||
|
|
||
| if ( ! empty( $images ) ) { | ||
| // Handle serialized data | ||
| if ( is_string( $images ) && is_serialized( $images ) ) { | ||
| $images = maybe_unserialize( $images ); | ||
| } | ||
|
|
||
| // Ensure we have an array | ||
| if ( ! is_array( $images ) ) { | ||
| $images = [ $images ]; | ||
| } | ||
|
|
||
| // Filter out empty values | ||
| $images = array_filter( $images, function( $img ) { | ||
| return ! empty( $img ) && ( is_numeric( $img ) || is_string( $img ) ); | ||
| }); | ||
|
|
||
| // Update WooCommerce gallery meta | ||
| if ( ! empty( $images ) ) { | ||
| update_post_meta( $post_id, '_product_image_gallery', implode( ',', $images ) ); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Sanitize to numeric IDs only, dedupe, and clear gallery when empty.
Current filter permits arbitrary strings and never clears stale galleries.
- private function sync_gallery_images( $post_id ) {
- $images = get_post_meta( $post_id, '_product_image', true );
-
- if ( ! empty( $images ) ) {
- // Handle serialized data
- if ( is_string( $images ) && is_serialized( $images ) ) {
- $images = maybe_unserialize( $images );
- }
-
- // Ensure we have an array
- if ( ! is_array( $images ) ) {
- $images = [ $images ];
- }
-
- // Filter out empty values
- $images = array_filter( $images, function( $img ) {
- return ! empty( $img ) && ( is_numeric( $img ) || is_string( $img ) );
- });
-
- // Update WooCommerce gallery meta
- if ( ! empty( $images ) ) {
- update_post_meta( $post_id, '_product_image_gallery', implode( ',', $images ) );
- }
- }
- }
+ private function sync_gallery_images( $post_id ) {
+ $images = get_post_meta( $post_id, '_product_image', true );
+
+ // Normalize into a flat list of numeric IDs
+ if ( is_string( $images ) ) {
+ $images = wp_parse_id_list( $images );
+ } elseif ( is_array( $images ) ) {
+ $images = array_map(
+ static function ( $img ) {
+ if ( is_array( $img ) ) {
+ $img = $img['id'] ?? $img['attachment_id'] ?? null;
+ }
+ return absint( $img );
+ },
+ $images
+ );
+ } else {
+ $images = [];
+ }
+
+ // Dedupe and drop empties/invalids
+ $images = array_values( array_filter( array_unique( array_map( 'absint', $images ) ) ) );
+
+ if ( $images ) {
+ update_post_meta( $post_id, '_product_image_gallery', implode( ',', $images ) );
+ } else {
+ delete_post_meta( $post_id, '_product_image_gallery' );
+ }
+ }📝 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.
| private function sync_gallery_images( $post_id ) { | |
| $images = get_post_meta( $post_id, '_product_image', true ); | |
| if ( ! empty( $images ) ) { | |
| // Handle serialized data | |
| if ( is_string( $images ) && is_serialized( $images ) ) { | |
| $images = maybe_unserialize( $images ); | |
| } | |
| // Ensure we have an array | |
| if ( ! is_array( $images ) ) { | |
| $images = [ $images ]; | |
| } | |
| // Filter out empty values | |
| $images = array_filter( $images, function( $img ) { | |
| return ! empty( $img ) && ( is_numeric( $img ) || is_string( $img ) ); | |
| }); | |
| // Update WooCommerce gallery meta | |
| if ( ! empty( $images ) ) { | |
| update_post_meta( $post_id, '_product_image_gallery', implode( ',', $images ) ); | |
| } | |
| } | |
| private function sync_gallery_images( $post_id ) { | |
| $images = get_post_meta( $post_id, '_product_image', true ); | |
| // Normalize into a flat list of numeric IDs | |
| if ( is_string( $images ) ) { | |
| $images = wp_parse_id_list( $images ); | |
| } elseif ( is_array( $images ) ) { | |
| $images = array_map( | |
| static function ( $img ) { | |
| if ( is_array( $img ) ) { | |
| $img = $img['id'] ?? $img['attachment_id'] ?? null; | |
| } | |
| return absint( $img ); | |
| }, | |
| $images | |
| ); | |
| } else { | |
| $images = []; | |
| } | |
| // Dedupe and drop empties/invalids | |
| $images = array_values( array_filter( array_unique( array_map( 'absint', $images ) ) ) ); | |
| if ( $images ) { | |
| update_post_meta( $post_id, '_product_image_gallery', implode( ',', $images ) ); | |
| } else { | |
| delete_post_meta( $post_id, '_product_image_gallery' ); | |
| } | |
| } |
🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 60-60:
Whitespace found at end of line
🤖 Prompt for AI Agents
In includes/Integrations/WPUF_WooCommerce_Gallery_Sync.php around lines 58 to
81, the gallery sync accepts arbitrary strings and never clears stale galleries;
change the filter to accept only numeric attachment IDs (cast values to int),
remove non-positive IDs, deduplicate the list (preserve order), and then update
the _product_image_gallery meta with a comma-separated string of unique numeric
IDs; if the resulting array is empty, explicitly update_post_meta with an empty
string to clear the gallery.
…m/arifulhoque7/wp-user-frontend into fix/profile-form-multistep-toggle
This reverts commit e34634e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php (1)
304-311: Prefer WC CRUD or wp_update_post to keep caches and hooks consistent.Direct SQL bypasses WP/WC hooks and object cache. Use WooCommerce’s product API (preferred) or
wp_update_post(); both ensure proper invalidation and side effects.- public function update_reviews( $post_id ) { - global $wpdb; - $reviews = get_post_meta( $post_id, 'product_reviews', true ); - $status = ! empty( $reviews ) ? 'open' : 'closed'; - //$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 ) ); - } + public function update_reviews( $post_id ) { + $reviews = get_post_meta( $post_id, 'product_reviews', true ); + $status = ! empty( $reviews ) ? 'open' : 'closed'; + + // Prefer WC CRUD to update reviews (maintains hooks/cache). + if ( function_exists( 'wc_get_product' ) ) { + $product = wc_get_product( $post_id ); + if ( $product ) { + $product->set_reviews_allowed( 'open' === $status ); + $product->save(); + return; + } + } + + // Fallback to core API. + wp_update_post( array( 'ID' => $post_id, 'comment_status' => $status ) ); + }
🧹 Nitpick comments (1)
includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php (1)
309-309: Remove dead commented SQL.The commented
$comment_sqlline adds noise; drop it.- //$comment_sql = "UPDATE {$wpdb->prefix}posts SET comment_status='{$status}' WHERE ID={$post_id} AND post_status='publish' AND post_type='product'";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php(1 hunks)
🔇 Additional comments (1)
includes/Admin/Forms/Post/Templates/Post_Form_Template_WooCommerce.php (1)
310-311: Confirm WHERE constraints won’t block valid updates.Requiring
post_status='publish'andpost_type='product'is redundant withID=%dand may prevent toggling reviews for drafts/pending products. Verify intended behavior and drop extra predicates if unnecessary.
| $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 ) ); | ||
| } |
There was a problem hiding this comment.
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.
| $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.
Related PR in PRO
Close issue
Summary by CodeRabbit
New Features
Bug Fixes
Chores