Back to portfolio
WordPressClient work

Page Content Extractor

Operational WordPress tool for finding and bulk-updating localized pages, with Elementor/Gutenberg/Classic support, AI rewriting via Gemini, and image generation via Vertex AI Imagen.

Page Content Extractor

Core stack

PHP
WordPress Plugin API
WordPress Admin
WordPress HTTP API
WordPress Media LibraryWordPress TransientsWordPress Object CacheMySQL / wpdbElementorGutenberg Blocks APIJavaScriptjQueryCSSGoogle Gemini 2.0 Flash APIGoogle Vertex AI Imagen 3Google OAuth 2.0 Service Account JWTOpenSSLPHP GD

The challenge

The challenge was consistently updating a number of similar WordPress pages stored in different Elementor, Gutenberg, and classic editor formats. The operations had to find text or images even when the HTML structure differs, adapt content per locality, and avoid manual page-by-page intervention.

The solution

The solution is a WordPress plugin with a bulk-operation-oriented admin: it selects pages by slug conventions, normalizes and searches content per editor, extracts the locality, uses Gemini for text suggestions and Vertex AI Imagen for images, then applies changes through the WordPress/Elementor APIs or controlled DB fallbacks. Batches, visual progress, confirmations, and cache/debug utilities support the operational flow.

Notable complexity

Page Content Extractor is a WordPress plugin built to manage a set of service pages that follow slug conventions and include geographic variations. Instead of opening and editing each page by hand, the administrator enters a slug pattern and a text fragment or image name, and the plugin identifies the relevant pages and extracts the locality from the slug for the subsequent operations.

The text flow detects the editor used by each page — Elementor, Gutenberg, or the classic editor — and searches the content through a word-by-word normalization that removes differences in HTML, spacing, and capitalization. The algorithm also recognizes {{locality}}-style placeholders, and for Gutenberg it recursively walks the blocks. Matching pages are presented as cards in the admin, together with the editor type and the extracted locality.

For AI-assisted localization, the plugin sends the text to Gemini 2.0 Flash and asks for a rewrite that preserves meaning, introduces natural references to the locality, and limited HTML markup for emphasis. Suggestions can be generated individually or in batch; the interface processes batches of 10 pages and shows progress, and each suggestion can be applied separately or in bulk.

Applying content is editor-aware. For Elementor, the plugin reads _elementor_data, recursively traverses the elements, and saves the modified JSON to post meta, then clears the Elementor cache. For Gutenberg, it parses the blocks, modifies the blocks that contain the text, and serializes the structure back into post_content. For the classic editor it uses direct replacement in post_content. The snapshot does not implement transactions or explicit rollback, and the match-replacement logic can substitute the entire field/block in which the phrase was found, which is why destructive operations are preceded in the UI by confirmations.

The image flow searches for pages that use a given file and offers two strategies: traversing the editor structure or a direct database mode, introduced as a lower-memory-footprint variant. The DB mode searches post_content and _elementor_data, identifies the URL and attachment ID, then displays for each page the current image alongside a preview area for a new image.

Image generation uses Vertex AI Imagen 3. The plugin builds a JWT from the configured service account, obtains a Google OAuth access token, calls the Vertex AI endpoint, decodes the Base64 image, and saves it to the WordPress Media Library. PNG responses are converted to JPG via GD. The file name includes the locality and a timestamp, and the resulting image can be applied individually or in batch.

Replacing images updates both post_content and the Elementor data, including URLs and attachment IDs. The code includes several fallbacks for Gutenberg/media-text structures and a direct path via wpdb when the standard update doesn't produce the expected result. After changes, the plugin invalidates the post cache, the Elementor cache, and can clear caches for WP Super Cache, W3 Total Cache, WP Rocket, Autoptimize, and LiteSpeed.

The snapshot also keeps diagnostic tools for block structure, memory usage, and logs. There is also legacy or incomplete code: the shortcode file is not loaded by the bootstrap, a few old JavaScript handlers have no active PHP endpoints, and the Google Cloud library declared in Composer is unused because the autoloader is commented out. The repository does not contain automated tests, CI/CD workflows, or deploy configuration.

From a hardening perspective, the analyzed version would benefit from current_user_can checks on all destructive/AI AJAX endpoints, strict sanitization of the HTML returned by the model before preview and persistence, moving sensitive credentials out of wp_options into a secure secret store/config, and disabling debug being enabled by default. debug.log is included in the snapshot and contains information about the local environment, although no API keys, Bearer tokens, or private keys were identified in the analyzed file.

Key results

  • WordPress Admin interface for filtering pages by slug pattern and locality
  • Automatic detection of Elementor, Gutenberg, and Classic pages
  • Text search normalized independently of HTML, spacing, and capitalization
  • Support for locality placeholders in search expressions
  • Individual and bulk suggestions for localized content via Gemini 2.0 Flash
  • Applying content through Elementor-, Gutenberg-, and Classic-specific mechanisms
  • Image search in post_content and _elementor_data, including a low-memory DB mode
  • Localized image generation via Vertex AI Imagen 3 and saving to the Media Library
  • Individual and bulk image replacement, updating URLs and attachment IDs
  • WordPress/Elementor cache invalidation and integration with several popular caching plugins
  • Local rate limiting for AI calls via WordPress Transients
  • Admin tools for testing the Gemini connection, block debugging, and memory monitoring
  • Direct wpdb fallbacks for cases where the editor structures don't update reliably

Want something similar?

Start with the estimate wizard — answer a few questions and get a realistic price range and timeline.