Advertising
Advertising
Shared across every PremiumPress product. 5 classes in inc/Advertising.
Ads Ads.php
PPT advertising — the advert store. A single custom table {prefix}ppt_ads holds every advert (both admin "house" ads and member-purchased ones). An advert is one placement in one zone: a BANNER (image + click-through URL), a TEXT ad (headline + a line of text on one of the textColors() backgrounds), or a CODE ad (raw HTML/AdSense, admin-only). Rotation, expiry and impression/click counting all read this table. This class owns: the schema (dbDelta on init), CRUD, the active-ads query used by the front-end renderer, impression/click counters, and the /?ppt_ad_click=
Expiry Expiry.php
PPT advertising — expiry reminders and renewals for member adverts. Reminders: an hourly check emails the advertiser (templates advert_expiring / advert_expired) and pushes a notification-bell item at each point in Settings ▸ Advertising ▸ "Send reminders this many days before the end" (default 3 and 1), then once more when the advert has ended — at which point it is marked Expired, so the member's card and the admin list say so instead of "Active". Which notice went last lives in the advert's notified column; a new end date clears it (Ads::update), so a renewed advert is reminded again for its new run. Renewals: the member's Renew button is the zone's normal checkout plus renew=
MemberArea MemberArea.php
PPT advertising — the members-area "Advertising" section (a panel inside the Member Hub at /account#advertising). Two parts: • My adverts — the member's purchased adverts, with status/views/clicks and a form to upload the banner + set the click-through URL (their "creative"). • Buy ad space — the enabled zones with pricing; "Buy" sends them to checkout (CheckoutFlow's advert branch), which returns them here to add their banner. The creative upload posts to admin-post (handleCreative); a member may only touch an advert they own.
Preroll Preroll.php
PPT advertising — the video pre-roll. A pre-roll is an ordinary advert (Ads) of type VIDEO sitting in the video_preroll zone: a short clip that plays before the video on the watch page. The viewer can skip it after a few seconds; when it ends, or is skipped, the real video starts on its own. The watch template asks this class whether a pre-roll will run BEFORE it prints the player (Preroll::willRun()), because a YouTube/Vimeo embed has to be held back — an <iframe> starts loading the moment it is parsed, and the viewer would hear the video under the advert. Uploaded videos need no such care: they are preload="metadata" and only play when told to. What plays, and how often, is decided in the browser (assets/js/ad-preroll.js); this class picks the advert, prints its settings, and counts the view when the clip actually starts — not when the page is built, which would count viewers who never saw it.
Zones Zones.php
PPT advertising — zones (ad positions) + the front-end renderer. Zones are a fixed catalog of positions in the theme (header, footer, search sidebar, between listings, single-listing, blog…). Each zone has a default IAB size and belongs to a page "group". The admin configures each zone (enable, price, run length, max concurrent ads, "Advertise here" placeholder, and an optional FALLBACK ad code — e.g. the site's own AdSense unit — shown whenever the zone has no live advert) — stored in the option ppt_ad_zones; global switches live in ppt_ad_settings. The fallback is deliberately NOT an advert row: it never counts towards a zone's "Max live adverts", so a zone showing it still reads as available to buyers. Zones::slot('header') is the single call templates use to output a zone: it rotates among the live adverts for that zone (counting an impression), renders a banner, text or code advert, or — when the zone is empty — its fallback code, else an "Advertise here" call-to-action when placeholders are on.