Add city-only Provider Listings meta box with JSON-safe persistence#2
Conversation
|
LGTM |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d8464a878
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $updated = $wpdb->update( | ||
| $wpdb->postmeta, | ||
| array( 'meta_value' => $json_string ), |
There was a problem hiding this comment.
Invalidate post-meta cache after direct writes
When a persistent object cache is enabled, this direct $wpdb->update() leaves WordPress' post_meta cache stale. The method already calls get_post_meta() for listing_type, which primes the meta cache for the whole post before this write, so later get_post_meta( $post_id, 'provider_listings', true ) calls (including WPGraphQL consumers) can keep returning the old JSON even though the database row changed. Please clear or update the post meta cache after both the update and insert paths while preserving the direct SQL write.
Useful? React with 👍 / 👎.
communityposts currently storeprovider_listingsas a raw JSON string consumed by WPGraphQL, but editors had no admin UI to maintain it. This change adds an editor-facing meta box for city pages and preserves JSON escape integrity by writing via$wpdbinstead of metadata APIs that unslash values.Admin UI (city-level only)
communityedit screens only whenlisting_type = city.normalcontext withhighpriority.JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) when parseable.Editor feedback in-box
Save path and data integrity
wp_create_nonce/wp_verify_nonce) andedit_postscapability gating.json_decode; invalid payloads are not persisted and surface an admin notice:Provider Listings not saved: invalid JSON.wp_postmetausing$wpdb->update()(with insert fallback when row is missing), avoidingupdate_post_meta()unslash corruption.Plugin wiring
ProviderListingsMetaBoxadmin component and registers it in plugin bootstrap.