-
Notifications
You must be signed in to change notification settings - Fork 92
gw-update-posts.php: Added support to update post excerpt.
#1183
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
base: master
Are you sure you want to change the base?
Conversation
WalkthroughAdds an optional 'excerpt' setting to post-update logic; when set, the plugin copies a mapped entry value into the post's Changes
Sequence Diagram(s)sequenceDiagram
participant Entry as Gravity Forms Entry
participant Updater as GW_Update_Posts
participant WP as WordPress (wp_update_post)
Entry->>Updater: trigger update_post_from_entry(entry)
note right of Updater #DDEBF7: existing mapping/field updates
Updater->>Updater: check if 'excerpt' option is enabled
alt excerpt enabled
Updater->>WP: set post_excerpt = mapped_entry_value
WP-->>Updater: update success
else excerpt disabled
Updater->>WP: update other fields only
WP-->>Updater: update success
end
Updater-->>Entry: return/update result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
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 (1)
gravity-forms/gw-update-posts.php (1)
6-6: Update documentation to include excerpt.The documentation comment should be updated to mention that excerpt can now be updated along with the other post fields.
Apply this diff:
- * Update existing post title, content, author and custom fields with values from Gravity Forms. + * Update existing post title, content, excerpt, author and custom fields with values from Gravity Forms.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gravity-forms/gw-update-posts.php(2 hunks)
🧰 Additional context used
🪛 GitHub Actions: PHP Lint (PR)
gravity-forms/gw-update-posts.php
[error] 28-28: PHPCS (Run thenabeel/action-phpcs@v8) failed: Spaces must be used for mid-line alignment; tabs are not allowed. (WordPress.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed).
🪛 GitHub Check: PHPCS (Files Changed)
gravity-forms/gw-update-posts.php
[failure] 28-28:
Spaces must be used for mid-line alignment; tabs are not allowed
[failure] 110-110:
Tabs must be used to indent lines; spaces are not allowed
[failure] 109-109:
No space before closing parenthesis is prohibited
[failure] 109-109:
No space after opening parenthesis is prohibited
[failure] 108-108:
Whitespace found at end of line
gravity-forms/gw-update-posts.php
Outdated
|
|
||
| if ($this->_args['excerpt']) { | ||
| $post->post_excerpt = rgar($entry, $this->_args['excerpt']); | ||
| } |
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.
Fix code formatting to match WordPress coding standards.
The excerpt update logic is correct and follows the same pattern as other field updates, but there are several formatting issues causing pipeline failures:
- Trailing whitespace on line 108
- Spaces inside parentheses on line 109
- Incorrect indentation (spaces instead of tabs) on line 110
Apply this diff:
-
- if ($this->_args['excerpt']) {
- $post->post_excerpt = rgar($entry, $this->_args['excerpt']);
- }
+
+ if ( $this->_args['excerpt'] ) {
+ $post->post_excerpt = rgar( $entry, $this->_args['excerpt'] );
+ }📝 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.
| if ($this->_args['excerpt']) { | |
| $post->post_excerpt = rgar($entry, $this->_args['excerpt']); | |
| } | |
| if ( $this->_args['excerpt'] ) { | |
| $post->post_excerpt = rgar( $entry, $this->_args['excerpt'] ); | |
| } |
🧰 Tools
🪛 GitHub Check: PHPCS (Files Changed)
[failure] 110-110:
Tabs must be used to indent lines; spaces are not allowed
[failure] 109-109:
No space before closing parenthesis is prohibited
[failure] 109-109:
No space after opening parenthesis is prohibited
[failure] 108-108:
Whitespace found at end of line
🤖 Prompt for AI Agents
In gravity-forms/gw-update-posts.php around lines 108 to 111, fix formatting to
match WordPress coding standards: remove the trailing whitespace on line 108,
remove the extra spaces inside the parentheses on line 109 so function calls
have no inner spaces (e.g., rgar($entry,$this->_args['excerpt'])), and replace
the spaces used for indentation on line 110 with a single tab to match the
surrounding file indentation; ensure the three lines align with the surrounding
field-update blocks.
Context
⛑️ Ticket(s): https://secure.helpscout.net/conversation/3122129973/91944?viewId=14960
Summary
The snippet doesn't support updating post excerpts. This PR is adding support to update the post excerpt.