Skip to content

CGF Work Importer · 2026

A WordPress plugin that turns a live website into a draft portfolio case study.

The cgf work importer case study main ss

Project Brief

Writing up finished websites for a portfolio is slow. Every project needs the same things: a description, the goals, a handful of screenshots at the right sizes, and a consistent structure on the page.

The CGF Work Importer is a WordPress plugin I built to do that first pass. Given a live site’s address, it reads the site, saves its brand icon and colour, captures desktop, phone and full-length screenshots into the Media Library, and can ask the Claude API to draft the project story. Everything lands in a draft that I review and edit before it is published.

Client
Personal project, used on charlesgfrancis.com
My role
Product owner and developer: defined the workflow, built and tested it with an AI coding assistant, and maintain it.
Stack
WordPress, PHP, JavaScript, WordPress AJAX, Media Library, Claude API, screenshot APIs
Focus
Custom plugin, API integration, automation, admin UX
Industry
Software & Plugins
Services
WordPress plugin development, API integration, admin UX
Year
2026

The form

One screen: the site address, the client name and a few optional details. The importer finds the main pages from the site’s menu, and the screenshot service and AI writer are chosen here too.

The Import from website screen: URL, client name, pages to capture and screenshot service

Project Objectives

  1. One form, one click

    Enter a URL and a client name. Anything left blank is taken from the site where possible.

  2. Screenshots that just work

    Desktop, phone, grid-card and full-length captures through a choice of screenshot services, saved straight into the Media Library.

  3. A useful first draft

    Optional AI-written brief, objectives, direction and outcome in a fixed structure, based on the site’s own text and my notes.

  4. Humans stay in charge

    Imports are drafts by default, AI text is editable, and any screenshot can be re-taken later.

Review and fix

Every imported item can be edited by hand. “Write with AI” fills the story fields without saving, and the Screenshots box re-takes or adds any page, with an optional scroll-down offset.

The Project story box with the Write with AI button and the fields it fills The Screenshots box: re-take any image, scroll down before capturing, or add a new page

Settings

The Anthropic key can live in wp-config.php instead of the database. Once saved, the field only says it is saved; the key is never printed back into the page.

AI writer settings: the API key is never shown again once saved

Overview

  • Name: CGF Work Importer, part of the CGF Core plugin that runs this site
  • Type: WordPress plugin (admin tool)
  • Year: 2026
  • Stack: PHP, JavaScript, WordPress AJAX, the WordPress HTTP API and Media Library, the Claude Messages API, and mShots, Microlink or a custom screenshot service

How it works

  1. Start. The admin form posts the URL and options to admin-ajax.php. The URL is checked with wp_http_validate_url() and the homepage is fetched with wp_safe_remote_get().
  2. Read. PHP parses the HTML with DOMDocument for the title, description, theme colour, icons and main menu links, creates a draft Work item and saves the brand icon.
  3. Capture. The browser works through a queue of screenshot jobs, three at a time, and polls each one, because free services return a placeholder while they render. Images are saved to the Media Library; a scroll offset is applied by capturing a taller page and cropping it with wp_get_image_editor().
  4. Draft (optional). In parallel, PHP extracts readable text from the homepage and up to three linked pages and sends it, with my notes, to the Claude Messages API. The reply must match a JSON schema, so each part maps straight onto a field.
  5. Finish. A last step assigns the grid image, hero, wall screens, case-study sections and the scrolling full-length hero. The item stays a draft unless I chose to publish.
  6. Review. I edit the text, re-take any screenshot and publish when it is right.

Failure points handled: an invalid address is rejected before anything is created; if the site can’t be read, the import carries on with the details typed into the form; a failed or timed-out screenshot is skipped and marked; an exhausted screenshot quota stops the queue; API errors (bad key, rate limit, refusal, cut-off reply) are shown in plain words and the rest of the import still finishes.

Security and reliability

  • Every AJAX step checks a nonce and the user’s capabilities (upload_files, edit_posts, and edit_post for the item being changed). Saving the API key needs manage_options.
  • Client sites are fetched with wp_safe_remote_get(), which refuses local and private network addresses.
  • The API key is stored in a WordPress option, or in a CGF_ANTHROPIC_KEY constant in wp-config.php. It is never printed back into the page (the field only says it is saved); leaving the field blank keeps the saved key.
  • The prompt tells the model not to invent results, numbers or quotes, and the output is cleaned before saving. AI text is a draft, never published on its own.

Known gaps: without the constant, the key sits unencrypted in the database. Screenshot services are third parties and receive the page address. The free mShots service stops full-length captures at about 3,000 pixels. There is no automated test suite yet; it was tested by hand on real sites and a local WordPress copy.

Key decisions

  1. A browser-driven queue instead of one long request. Shared hosts kill long PHP requests. Splitting the import into small AJAX steps keeps each request short, shows live progress and lets one failed capture be skipped without losing the rest.
  2. Structured output from the model. Asking for JSON that matches a schema means the brief, objectives and outcome land in their own fields, not in one block of text that needs copying apart.
  3. Re-take in place. A re-taken screenshot replaces the file but keeps the same attachment ID, so every place that uses it updates at once.

Code excerpts

The guard every import step runs first:

function cgf_import_guard() {
	if ( ! check_ajax_referer( 'cgf_import', 'nonce', false )
		|| ! current_user_can( 'upload_files' )
		|| ! current_user_can( 'edit_posts' ) ) {
		wp_send_json_error( array( 'message' => __( 'You don’t have permission to import work.', 'cgf-core' ) ), 403 );
	}
}

The request body sent to the Claude Messages API (the key travels only in a request header):

$body = array(
	'model'         => $set['model'],
	'max_tokens'    => 8000,
	'system'        => $system,
	'messages'      => array( array( 'role' => 'user', 'content' => $user ) ),
	'output_config' => array(
		'effort' => 'low',
		'format' => array( 'type' => 'json_schema', 'schema' => $schema ),
	),
);

My contribution

I defined the product and the workflow, chose the services and the trade-offs, and tested each step against real client sites. The code was written with an AI coding assistant (Claude Code) working under my direction and review, and I maintain it as part of this site.

Outcome

The importer produced the first drafts of the case studies on this site. Time saved has not been measured, so no figures are given. The source is private; I’m happy to walk through it on a call.

Delivered

The plugin builds the first draft of the case studies on this site, starting with Smart Stays Rentals. Time savings have not been measured yet, so no numbers are claimed here.

More work

All work

Hiring?

Looking for a developer who can own the whole web experience?

I’m exploring full-time remote opportunities where I can contribute across development, UX and web operations.

Email Charles View Résumé Explore Work

Interested in a Project? Book a Consulting Call.

Looking for
Full-Time, Remote (U.S.)
Hiring page
Hire Me ↗