Documentation

Graphic_Data_Site_Checker
in package

Class Graphic_Data_Site_Checker.

Table of Contents

Constants

BATCH_SIZE  : mixed = 10
Number of URLs to check per AJAX batch request.
CAPABILITY  : mixed = 'edit_others_posts'
Capability required to access the Site Checker page and endpoints.
NONCE_ACTION  : mixed = 'graphic_data_site_checker'
Nonce action used for all Site Checker AJAX requests.
PAGE_SLUG  : mixed = 'graphic-data-site-checker'
This page's admin menu slug.
PARENT_SLUG  : mixed = 'graphic-data-search'
Parent admin menu slug that this page hangs off of.

Properties

$page_hook  : string
Full hook suffix for this page (populated once WP registers it).
$plugin_url  : string
Absolute URL to the plugin root (for asset URLs).
$version  : string
Version string used for asset cache-busting.

Methods

__construct()  : mixed
Constructor.
ajax_check_alt_text()  : mixed
Scan the instance/scene/modal/figure image fields, resolve each one that points at a Media Library attachment, and report the ones whose attachment has no alt text set.
ajax_check_content_structure()  : mixed
Run the instance, scene, and modal structural integrity checks and return their issues grouped by post type.
ajax_check_url_batch()  : mixed
Check a batch of URLs and return their reachability status.
ajax_gather_urls()  : mixed
Return the list of every URL found in Graphic Data postmeta, along with the post it belongs to and the meta key it came from.
enqueue_assets()  : mixed
Enqueue CSS and the ES module for the Site Checker page only.
print_inline_data()  : mixed
Print the configuration global consumed by the ES module.
register_submenu()  : mixed
Register the Site Checker submenu page.
render_page()  : mixed
Render the admin page markup.
build_issue()  : array<string, mixed>
Build a single {post_id, post_title, post_type, edit_link, message} issue row.
check_instance_overview_scenes()  : array<int, array<string, mixed>>
Verify every Instance post has an overview scene selected, and that the selected scene is published.
check_modal_tab_figures()  : array<int, array<string, mixed>>
For every Modal post, verify every tab from 1 through its configured tab count has at least one associated Figure post, and that a tab with exactly one Figure has that figure published.
check_scene_icon_associations()  : array<int, array<string, mixed>>
For every Scene post, verify the infographic SVG can be located and parsed, and that every clickable icon in it has exactly one associated (and published) Modal post.
check_url()  : array<string, mixed>
Probe a single URL and return {ok, status, error}.
extract_urls()  : array<string|int, string>
Recursively walk a meta value (scalar, array, or Exopite fieldset payload) and pull out every URL it references.
figure_meta_keys()  : array<string|int, string>
Meta keys to scan on figure posts.
gather_from_post_type()  : array<int, array<string, mixed>>
Iterate all posts of a given type and extract URLs from the named meta keys.
gather_image_urls_from_post_type()  : array<int, array<string, mixed>>
Iterate all posts of a given type and pull the Media Library image URL out of each configured image field.
human_label_for_meta_key()  : string
Return a human-readable label for a given meta key.
image_field_specs()  : array<int, array<string, string>>
Image field specs per post type: which meta key holds the image, and (for the Exopite fieldset fields) which sub-key inside that meta value holds the Media Library URL.
instance_meta_key_for_post_type()  : string
Meta key that links a given post type back to its owning instance, mirroring the "Instance" filter columns/dropdowns elsewhere in the plugin (see class-utility.php and includes/admin-{modal,figure}.php).
instance_scoped_query_args()  : array<string, mixed>
Build `get_posts()` args for a post type, optionally scoped to the posts belonging to a given instance. Shared by every gather routine (broken links and missing alt text) so the two checks stay scoped to the same set of posts for a given `target_instance` selection.
is_site_checker_screen()  : bool
Determine whether the given admin screen is the Site Checker page.
modal_meta_keys()  : array<string|int, string>
Meta keys to scan on modal posts.
normalize_url()  : string
Normalize a raw URL string into an absolute, checkable form.
resolve_attachment_id()  : int
Resolve an image URL to its Media Library attachment ID, if any.
scene_meta_keys()  : array<string|int, string>
Meta keys to scan on scene posts.

Constants

BATCH_SIZE

Number of URLs to check per AJAX batch request.

public mixed BATCH_SIZE = 10

Kept low so no single request runs long enough to time out. The front-end fires batches sequentially and updates progress after each.

CAPABILITY

Capability required to access the Site Checker page and endpoints.

public mixed CAPABILITY = 'edit_others_posts'

edit_others_posts is held by the Editor role and above, so this gates the page at "editor or higher" without requiring full admin privileges.

Properties

Methods

__construct()

Constructor.

public __construct([string $plugin_url = '' ][, string $version = '1.0.0' ]) : mixed
Parameters
$plugin_url : string = ''

Absolute URL to the plugin root, with trailing slash. Defaults to one directory above this file.

$version : string = '1.0.0'

Version string for asset URLs.

ajax_check_alt_text()

Scan the instance/scene/modal/figure image fields, resolve each one that points at a Media Library attachment, and report the ones whose attachment has no alt text set.

public ajax_check_alt_text() : mixed

Unlike the broken-link check this needs no external HTTP requests — it's local postmeta lookups only — so it runs as a single request rather than a batched scan.

ajax_check_content_structure()

Run the instance, scene, and modal structural integrity checks and return their issues grouped by post type.

public ajax_check_content_structure() : mixed

ajax_gather_urls()

Return the list of every URL found in Graphic Data postmeta, along with the post it belongs to and the meta key it came from.

public ajax_gather_urls() : mixed

enqueue_assets()

Enqueue CSS and the ES module for the Site Checker page only.

public enqueue_assets(string $hook_suffix) : mixed
Parameters
$hook_suffix : string

Current admin page hook.

print_inline_data()

Print the configuration global consumed by the ES module.

public print_inline_data() : mixed

Script Modules load deferred, so this inline script (printed in the head) always runs before the module and can safely set globals.

build_issue()

Build a single {post_id, post_title, post_type, edit_link, message} issue row.

private build_issue(int $post_id, string $post_type, string $message) : array<string, mixed>
Parameters
$post_id : int

Post ID the issue is attached to.

$post_type : string

Post type slug.

$message : string

Human-readable description of the issue.

Return values
array<string, mixed>

check_instance_overview_scenes()

Verify every Instance post has an overview scene selected, and that the selected scene is published.

private check_instance_overview_scenes([int $target_instance = 0 ]) : array<int, array<string, mixed>>
Parameters
$target_instance : int = 0

Optional instance post ID to restrict results to. 0 means "all instances".

Return values
array<int, array<string, mixed>>

List of {post_id, post_title, post_type, edit_link, message}.

check_modal_tab_figures()

For every Modal post, verify every tab from 1 through its configured tab count has at least one associated Figure post, and that a tab with exactly one Figure has that figure published.

private check_modal_tab_figures([int $target_instance = 0 ]) : array<int, array<string, mixed>>
Parameters
$target_instance : int = 0

Optional instance post ID to restrict results to. 0 means "all instances".

Return values
array<int, array<string, mixed>>

List of {post_id, post_title, post_type, edit_link, message}.

check_scene_icon_associations()

For every Scene post, verify the infographic SVG can be located and parsed, and that every clickable icon in it has exactly one associated (and published) Modal post.

private check_scene_icon_associations([int $target_instance = 0 ]) : array<int, array<string, mixed>>
Parameters
$target_instance : int = 0

Optional instance post ID to restrict results to. 0 means "all instances".

Return values
array<int, array<string, mixed>>

List of {post_id, post_title, post_type, edit_link, message}.

check_url()

Probe a single URL and return {ok, status, error}.

private check_url(string $url) : array<string, mixed>

Tries HEAD first (cheap), falls back to GET when the server returns a client/server error or a WP_Error, since many hosts block HEAD.

Parameters
$url : string

Absolute URL.

Return values
array<string, mixed>

extract_urls()

Recursively walk a meta value (scalar, array, or Exopite fieldset payload) and pull out every URL it references.

private extract_urls(mixed $value) : array<string|int, string>

Handles href/src attributes from rich text, bare http(s):// URLs appearing in strings, and plain-URL scalar fields.

Parameters
$value : mixed

The value to scan.

Return values
array<string|int, string>

Unique list of absolute URLs.

figure_meta_keys()

Meta keys to scan on figure posts.

private figure_meta_keys() : array<string|int, string>
Return values
array<string|int, string>

gather_from_post_type()

Iterate all posts of a given type and extract URLs from the named meta keys.

private gather_from_post_type(string $post_type, array<string|int, string> $meta_keys[, int $target_instance = 0 ]) : array<int, array<string, mixed>>
Parameters
$post_type : string

Post type slug.

$meta_keys : array<string|int, string>

Meta keys to inspect.

$target_instance : int = 0

Optional instance post ID to restrict results to. 0 (the default) means "all instances".

Return values
array<int, array<string, mixed>>

Flat list of {post_id, post_title, post_type, edit_link, meta_key, url}.

gather_image_urls_from_post_type()

Iterate all posts of a given type and pull the Media Library image URL out of each configured image field.

private gather_image_urls_from_post_type(string $post_type[, int $target_instance = 0 ]) : array<int, array<string, mixed>>
Parameters
$post_type : string

Post type slug.

$target_instance : int = 0

Optional instance post ID to restrict results to. 0 means "all instances".

Return values
array<int, array<string, mixed>>

Flat list of {post_id, post_title, post_type, edit_link, field_label, url}.

human_label_for_meta_key()

Return a human-readable label for a given meta key.

private human_label_for_meta_key(string $meta_key) : string

Used in the broken-links report so operators see field names as they appear in the editor UI rather than raw meta keys.

Parameters
$meta_key : string

Meta key.

Return values
string

Human-readable label.

image_field_specs()

Image field specs per post type: which meta key holds the image, and (for the Exopite fieldset fields) which sub-key inside that meta value holds the Media Library URL.

private image_field_specs(string $post_type) : array<int, array<string, string>>
Parameters
$post_type : string

Post type slug.

Return values
array<int, array<string, string>>

List of {meta_key, sub_key, label}. sub_key is '' for flat (non-fieldset) fields.

instance_meta_key_for_post_type()

Meta key that links a given post type back to its owning instance, mirroring the "Instance" filter columns/dropdowns elsewhere in the plugin (see class-utility.php and includes/admin-{modal,figure}.php).

private instance_meta_key_for_post_type(string $post_type) : string
Parameters
$post_type : string

Post type slug.

Return values
string

Meta key, or empty string if the post type has no such link.

instance_scoped_query_args()

Build `get_posts()` args for a post type, optionally scoped to the posts belonging to a given instance. Shared by every gather routine (broken links and missing alt text) so the two checks stay scoped to the same set of posts for a given `target_instance` selection.

private instance_scoped_query_args(string $post_type[, int $target_instance = 0 ]) : array<string, mixed>
Parameters
$post_type : string

Post type slug.

$target_instance : int = 0

Optional instance post ID to restrict results to. 0 means "all instances".

Return values
array<string, mixed>

get_posts() args.

is_site_checker_screen()

Determine whether the given admin screen is the Site Checker page.

private is_site_checker_screen(string $screen_id) : bool
Parameters
$screen_id : string

Screen ID / hook suffix.

Return values
bool

modal_meta_keys()

Meta keys to scan on modal posts.

private modal_meta_keys() : array<string|int, string>
Return values
array<string|int, string>

normalize_url()

Normalize a raw URL string into an absolute, checkable form.

private normalize_url(string $url) : string

Rejects mailto:/tel:/javascript: schemes and pure anchors. Turns protocol-relative and site-root-relative URLs into absolute ones.

Parameters
$url : string

Raw URL.

Return values
string

Absolute URL, or empty string if not checkable.

resolve_attachment_id()

Resolve an image URL to its Media Library attachment ID, if any.

private resolve_attachment_id(string $url) : int

Falls back to stripping a -WIDTHxHEIGHT resize suffix (e.g. image-300x200.jpg -> image.jpg) before retrying, since stored field values sometimes point at a generated intermediate size rather than the original upload that attachment_url_to_postid() indexes. Mirrors the same fallback in class-validation.php's media linking.

Parameters
$url : string

Image URL.

Return values
int

Attachment post ID, or 0 if it doesn't resolve to one.

scene_meta_keys()

Meta keys to scan on scene posts.

private scene_meta_keys() : array<string|int, string>
Return values
array<string|int, string>
On this page

Search results