Repository navigation
Lifecycle and Data
What PhotoPress does when it is activated, deactivated, updated and deleted, and every option, meta key and transient it stores. For developers and site owners who need to know what PhotoPress leaves in the database.
- WordPress 6.6 or later (
Requires at leastin README.txt). - Version 2.0.0 (photopress.php).
PHOTOPRESS_CORE_VERSIONis read from that header.
photopress_plugin::activate() deletes the option photopress_taxonomy_rewrites. On the next request the metadata module finds no record of the image taxonomies' rewrite rules and flushes the rules at wp_loaded, after every plugin has registered its post types and taxonomies (code).
PhotoPress's own code creates no database tables.
photopress_plugin::deactivate():
-
Scheduler::deactivate()unschedules every Action Scheduler action in the groupphotopress, deletesphotopress_scheduled, and, if no other plugin had loaded Action Scheduler, clears its every-minute WP-Cron eventaction_scheduler_run_queue. - Deletes
photopress_taxonomy_rewritesandrewrite_rules. WordPress builds the rules again on the next request, without the image taxonomies.
Unfinished jobs are kept. When PhotoPress is activated again they get a new batch from recovery. See Background Jobs.
PhotoPress has no upgrade routine and no stored schema version. Changes between versions are handled where the data is read:
| On | What happens | Code |
|---|---|---|
The first request after an update (wp_loaded) |
If photopress_version differs from the running version, it is updated and, while Proxy Cache Purge is active, the page cache is emptied. Pages cached by the earlier version do not then ask for scripts and styles this version lacks. |
PageCache.php#L334 |
init, while the Metadata settings lack description_enable
|
Sets description_enable to true where a description template is set, false otherwise. Before the switch existed, the template alone turned the description on. |
metadata.php#L319 |
| Reading settings in the admin or REST API | Keys that are no longer fields are dropped. Fields added since get their defaults. See Settings storage. | class-settings.php#L348 |
Each request, while photopress_scheduled is missing |
Counted as pending, so Action Scheduler loads and runs any queued work. | Scheduler.php#L85 |
| Regenerating an image |
_photopress_sizes_signature (1.9.0) is deleted. |
images.php#L445 |
Deleting PhotoPress from Plugins runs uninstall.php. On multisite it runs for every site of the network (get_sites() with no limit, then switch_to_blog()).
Deleted on each site:
- the options listed in
PHOTOPRESS_UNINSTALL_OPTIONSand the transients inPHOTOPRESS_UNINSTALL_TRANSIENTS; - every option starting with
photopress_core_(module settings),photopress_job_(jobs, their locks and start locks) orphotopress_cdn_job_(paths jobs rewrote); - the random-gallery transients
photopress_gallery_ids_*; - the post meta
_photopress_gallery_terms(delete_post_meta_by_key()); - Action Scheduler's WP-Cron event, unless another active plugin's copy of Action Scheduler is loaded.
Kept:
- images, their files, and image taxonomy terms;
- post meta:
_photopress_quality,_photopress_sizes_signature,_photopress_replaced_at,_photopress_replace_restore,_photopress_license_error; - metadata PhotoPress wrote into WordPress's own fields: alt text, captions, descriptions, and licensing written into image files;
- the
photopress-tmpfolder in uploads; - other PhotoPress plugins' settings (
photopress_seo_*,photopress_pro_*).
Every PHP file outside tests/ and vendor/ stops when loaded outside WordPress. The others check ABSPATH: all but src/init.php start with defined( 'ABSPATH' ) || exit;. photopress.php checks WPINC. uninstall.php checks WP_UNINSTALL_PLUGIN. The photopress-tmp folder gets an .htaccess with Require all denied. See Image Sizes.
| Hook | Type | Code | Purpose |
|---|---|---|---|
register_activation_hook |
function | photopress.php#L54 | Activation. |
register_deactivation_hook |
function | photopress.php#L55 | Deactivation. |
plugins_loaded |
action | photopress.php#L52 | Priority 1: builds the package and its modules (base, gallery, slideshow, metadata, search, images, media). |
init |
action | class-module.php#L50 | Priority 0: each module reads its option definitions and adds its hooks. |
admin_init, rest_api_init
|
action | class-module.php#L220 | Registers each module's setting. |
option_{$option} |
filter | class-settings.php#L336 |
asFields: the stored settings as exactly their fields. |
wp_loaded |
action | PageCache.php#L85 | Empties the page cache after an update. |
Each module's settings are one option, photopress_core_<module>, an array keyed by field (class-util.php). The settings tabs read and write them through core's /wp/v2/settings, which requires manage_options.
registerSettings() calls register_setting() with:
-
show_in_rest: an object schema with one property per field andadditionalProperties: false. The REST name is the option name. -
default: every field's default. -
sanitize_callback:sanitizeOptions().
Field types map to the schema and to sanitizing as follows (code):
| Field type | REST schema | Saved as |
|---|---|---|
boolean |
boolean |
(bool) |
integer |
integer, minimum 0 |
max( 0, (int) ) |
select |
string, enum of its options |
The value, if allowed. Otherwise the stored value is kept. |
url |
string |
esc_url_raw() |
none (image taxonomies list) |
array of objects |
Each entry cleaned: id by sanitize_key(), at most 32 characters, prefixed pp_ if it is a core taxonomy name, made unique with a suffix. |
| anything else (text, comma-separated list) | string |
sanitize_text_field() |
sanitizeOptions() also drops keys that are not fields, and keeps the stored value of a field the request leaves out.
asFields() filters the option on read wherever the setting is registered (admin and REST requests). It returns only current fields, with defaults for fields the stored value lacks. A stored key that is no longer a field would otherwise make the settings endpoint return null for the whole option.
On the front end, PhotoPress reads a setting as its stored value, or the module's default when the key is missing (pp_api::getOption()).
| Option | Purpose | Written by |
|---|---|---|
photopress_core_<module> |
A module's settings. | Settings tabs |
photopress_jobs |
IDs of the last 20 jobs. | Background Jobs |
photopress_job_<id> |
A job's state. | Background Jobs |
photopress_job_<id>_lock |
A job's batch lock. | Background Jobs |
photopress_job_start_<md5> |
A job type's start lock. | Background Jobs |
photopress_scheduled |
pending or idle: whether PhotoPress has Action Scheduler work. Autoloaded. |
Scheduler.php#L35 |
photopress_reprocess_queue |
metadata.reprocess runs waiting for the running one. |
metadata module |
photopress_search_term_changes |
Terms and images waiting for the running search.terms job. |
search module |
photopress_purge_after_jobs |
Jobs whose batches held back page cache purges. The cache is emptied when each ends. | PageCache.php#L65 |
photopress_version |
The version the page cache was last emptied for. Autoloaded. | PageCache.php#L53 |
photopress_taxonomy_rewrites |
Hash of the image taxonomies' rewrite rules last built. | metadata module |
photopress_flush_rewrite_rules |
Not written by 2.0.0. Deleted when the rules are rebuilt, and on uninstall. | metadata module |
photopress_old_people |
yes or no: whether the site has terms in photos_people, the People parent keyword of defaults before 2.0. |
metadata.php#L1166 |
photopress_images_assumed_quality |
The quality assumed for images without _photopress_quality. |
Image Sizes |
photopress_sitemap_seen |
When each sitemap was last built with PhotoPress's hooks, by name. | ImageSitemap.php#L31 |
photopress_cdn_pending |
Paths waiting for a CloudFront invalidation. | Offload Media and CDN |
photopress_cdn_last |
The last invalidation's result. | Offload Media and CDN |
photopress_cdn_job_<id> |
Paths a running job rewrote, to clear from CloudFront when it ends. | Offload Media and CDN |
photopress_gallery_upgrade |
The version of the gallery upgrade job started on this site. Autoloaded. | Child Pages Gallery |
| Transient | Lifetime | Purpose |
|---|---|---|
photopress_cdn_distribution |
1 day | The CloudFront distribution found for the delivery domain. |
photopress_aws_role_credentials |
Until 5 minutes before they expire, or 1 hour when there are none | The EC2 instance role's credentials. |
photopress_cdn_all_cleared |
10 minutes | Limits Clear the whole CDN. |
photopress_gallery_ids_<md5> |
10 minutes | The IDs a random-order gallery may show, shuffled per view (code). |
All on attachments, except _photopress_gallery_terms.
| Meta key | Purpose |
|---|---|
_photopress_gallery_terms |
On posts: one row per Taxonomy Gallery that chooses its images, <taxonomy>:<term ID> or latest, for page cache purges. See Taxonomy Gallery. Deleted on uninstall. |
_photopress_quality |
The quality the image's sizes were made at. See Image Sizes. |
_photopress_sizes_signature |
From 1.9.0. Not read. Deleted when the image is regenerated. |
_photopress_replaced_at |
When the image's file was last replaced. See Replacing Image Files. |
_photopress_replace_restore |
The restore record of a replacement under way. |
_photopress_license_error |
Why the license could not be written into the image's file: message, time. Deleted once it is written. |
PhotoPress also writes core fields: _wp_attachment_image_alt, the title, caption and description, image taxonomy terms, and _wp_attached_file / _wp_attachment_metadata when it remakes sizes or replaces a file.
Actions in the group photopress (photopress_job_batch, photopress_cdn_invalidate, photopress_offload_delete_objects, photopress_replace_settle, photopress_gallery_remove_retry) are stored in Action Scheduler's tables. Deactivation unschedules them. Uninstall does not touch Action Scheduler's tables, which other plugins may share.
Proxy Cache Purge. After an update, the page cache is emptied once through PhotoPress's photopress_purge_all event, registered with varnish_http_purge_events and varnish_http_purge_events_full. Without Proxy Cache Purge, photopress_version is still updated and nothing is purged.
Action Scheduler (bundled). See Background Jobs.
- Uninstall removes no post meta other than
_photopress_gallery_terms, and no terms or files. Their removal is left to you. - The
description_enablecheck runs oniniton every request. It writes only when saved Metadata settings lack the key. -
photopress_old_peopleis worked out once and not checked again. - Deactivation deletes
rewrite_rules, which every plugin's rules share. WordPress builds them all again on the next request.
Galleries
- Gallery Layouts
- Full-Screen Slideshow
- Gallery Slideshow Block
- Taxonomy Gallery
- Child Pages Gallery
- Gallery Images Added and Removed
- Image Templates and Blocks
Metadata
Pages and search
Media
Operation