Skip to content

Conversation

@sbassah
Copy link
Contributor

@sbassah sbassah commented Oct 29, 2025

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.

@coderabbitai
Copy link

coderabbitai bot commented Oct 29, 2025

Walkthrough

Adds an optional 'excerpt' setting to post-update logic; when set, the plugin copies a mapped entry value into the post's post_excerpt during post updates.

Changes

Cohort / File(s) Change Summary
Post excerpt support
gravity-forms/gw-update-posts.php
Added 'excerpt' to constructor defaults and implemented logic to set post_excerpt from the entry when the option is enabled

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single-file change adding an optional parameter and following existing update pattern
  • Verify mapping/key names and ensure sanitization/escaping for post_excerpt update

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "gw-update-posts.php: Added support to update post excerpt" is concise, specific, and directly reflects the primary change described in the raw summary. It identifies the modified file and clearly communicates that support for updating post excerpts has been added, which aligns perfectly with the changeset modifications where an optional 'excerpt' argument was added to the constructor and the post_excerpt is updated when this argument is set.
Description Check ✅ Passed The PR description includes both required sections from the template: a Context section with a specific HelpScout ticket reference, and a Summary section that explains the motivation and change clearly. The description is not vague or generic—it explicitly states that the snippet previously lacked post excerpt update support and that this PR adds that functionality, which is directly confirmed by the changeset analysis.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sbassah-patch-1

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aca114f and 4e38e36.

📒 Files selected for processing (1)
  • gravity-forms/gw-update-posts.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • gravity-forms/gw-update-posts.php

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between fcf3ea9 and aca114f.

📒 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

Comment on lines 108 to 111

if ($this->_args['excerpt']) {
$post->post_excerpt = rgar($entry, $this->_args['excerpt']);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

@sbassah sbassah requested a review from saifsultanc October 29, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants