Skip to main content

Directory Theme class reference

16 min read

Car Dealer Theme — Class reference

The 25 classes that make _cd behave differently from the shared Directory core. Generated from the theme source.

← Back to Car Dealer Theme features

Compare Compare.php​

Car Dealer (_cd) — compare vehicles side by side. Several car designs promise it ("Compare specs" on the Ampere hero, "Add to compare" on Veloce, "compare in one place" in the how-it-works copy), and until 2026-09-29 nothing behind those words existed: the button dropped the visitor on the plain search page with no way to pick anything. This is the whole feature: - a Compare tick on every vehicle card on the search page (live AND showroom cards), on the Veloce inventory cards, and an "Add to compare" button in the single vehicle page's sidebar box — all the same control, toggle(); - a tray pinned to the bottom of every page once something is picked ("2 of 4 — Compare now"), drawn by assets/js/cd-compare.js; - /compare/ — the side-by-side table (photo, price, make, model, type, year, mileage, fuel, gearbox, location), also drawn by the script; - searchUrl() — the search page in "compare mode" (?compare=1), which prints the instructions above the results. The design CTAs that say "compare" link here. The picked list lives in the VISITOR'S BROWSER (localStorage), not in the database: no sign-in, nothing written server-side, and it works on a showroom install whose cards have no listing row behind them. So each control carries the vehicle's whole table row (payload()), built once here — the page and the tray never have to ask the server for anything, and there is only one renderer (the script). Registered in Theme.php's _cd service list, so it only exists on the Car Dealer theme.

API
register()url()searchUrl()ctaLink()isModeRequest()rewrite()queryVar()isCurrent()maybeRender()assets()banner()toggle()icon()payloadFromPost()payloadFromCard()specRows()
inc/_cd/Compare.php

DemoAccounts DemoAccounts.php​

Car Dealer — what the typed DEMO members walk into on top of the shared furnishing (Account\DemoFurnish: favourites, follow, inbox thread, review). the SELLER (AccountType::SOLO) three seeded vehicles (DemoLogin lends them — the count is raised here from one); the BUYER (AccountType::CLIENT) has favourited them, follows the seller and has an enquiry thread open — the shape a buyer's hub takes before a sale. Gated to the car dealer profile by Theme::boot()'s fork-gating (this is Ppt_cd*). Clone of Ppt_ct\DemoAccounts (2026-09-20).

API
register()lendCount()
inc/_cd/DemoAccounts.php

Expiry Expiry.php​

PPT — listing expiry / "Listing lifetime". The Settings ▸ Listings "Listing lifetime" (days) governs how long a listing stays live. 0 = never expires. A value > 0 stamps an expiry timestamp on each listing when it's published; a daily cron then runs the configured "On expiry" action (listings_expiry_action: nothing / draft / pending / trash) once the time is up. The expiry timestamp meta is SHARED with the pricing-plan expiry (PricingPlans::LISTING_EXPIRES_META). A listing that carries a pricing plan is governed by that plan's own duration (set in the editor / at checkout), so the global lifetime only applies to listings WITHOUT a plan. Either way, the cron here enforces whatever expiry timestamp a listing ends up with, and both editors show the time remaining.

API
register()metaKey()schedule()unschedule()onTransition()applyLifetime()runCheck()timestamp()remaining()dateLabel()
inc/_cd/Expiry.php

Single-listing gallery styles. The admin picks one of four layouts on the Design ▸ Listings tab (stored in the ppt_design option via Branding), and the single-listing template renders the chosen layout for the listing's images. standard — large hero photo + thumbnail strip (click to swap) [default] grid — all photos in a tiled grid (first one featured) carousel — a swipeable/scroll-snap slider with prev/next tall — full-width photos stacked vertically (good for portraits)

API
styles()locked()current()isFullSpan()render()css()
inc/_cd/Gallery.php

Geocoder Geocoder.php​

Bulk geocoder — fills in lat/lng for existing listings that have an address but no coordinates (e.g. listings created before the editor's map picker existed), so they get a precise map marker and the "Distance from me" feature. Uses the site's Maps provider (Settings ▸ API keys): Google / Mapbox geocoding APIs (their key), or OpenStreetMap Nominatim (keyless, rate-limited to ~1 req/sec with an identifying UA). A small box on the PPT Listings screen runs it in batches over AJAX. Listings that can't be geocoded are flagged (_ppt_geo_failed) so they aren't retried forever.

API
register()geocode()pendingCount()ajaxBatch()assets()box()
inc/_cd/Geocoder.php

ListingActions ListingActions.php​

Per-listing visitor actions shown on the single-listing section nav: - Add to favorites — toggles the listing in the member's saved list (user meta ppt_favorites); the account page shows them. Logged-in only; guests are routed to sign-in. - Report — flags the listing to the site admin. The reason is stored as a comment on the listing (type ppt_report, a custom approval status so it stays hidden from the front-end and the normal comment-moderation tabs) and also emailed to the admin. Reports are reviewed in the admin Comments screen's dedicated "Reports" tab. Open to guests and members.

API
register()favIds()favHas()favToggle()favListingIds()ajaxFav()ajaxReport()assets()favButton()reportButton()
inc/_cd/ListingActions.php

ListingCard ListingCard.php​

The canonical listing card — the single, theme-wide way a business/listing is shown as a card. Every directory surface (search results, single-page "related", and the live listing-grid blocks) renders through here, so a listing looks the same everywhere and the demo-vs-live data split lives in ONE place. Data-source agnostic: fromPost() maps a real listing_type record and fromSample() maps a curated demo row into the same normalized shape, which render() draws. The markup is built on the theme design tokens, so the one card automatically adopts each design's colours/fonts. Its CSS is enqueued site-wide (assets/css/listing-card.css) — the card only emits markup. Normalized shape: name, link, img, cat, rating, desc, desc_long, price, city, dist, featured (bool), highlighted (bool), badge (string), id badge is an optional ribbon label (e.g. "New") for callers that need one; when empty it falls back to "Featured" if featured is set.

API
fromPost()fromSample()render()
inc/_cd/ListingCard.php

ListingEditor ListingEditor.php​

Listing editor — the shared brain behind the two listing-edit screens: - Admin : PPT-styled screen at ?page=ppt_listings&edit=<id> (Chrome shell), rendered by Admin\Listings when the edit param is present. - Member : front-end screen at /account/listing/<id>/ inside the Member Hub, rendered by Account\MembersPage for a listing the member owns. Both POST to admin-post.php (action ppt_listing_save) and run through the one save() below, so the field set, sanitising and persistence live in a single place. The mode (admin|member) decides which extras are honoured: admins get status, author, slug, featured/verified and the "edit only" custom fields; members get a friendly subset scoped to their own listing. Fields = core (title, description, category, tags, featured image, gallery, FAQ) + every field defined in the Custom Fields admin (Admin\Fields / option ppt_fields), stored as post meta keyed by the field key — which is what the single-listing template already reads.

API
register()newUrl()handleNew()submissionsOpen()memberCanAdd()canEdit()adminEditUrl()memberEditUrl()applicableFields()locationKeys()coordKeys()mapPickerReady()mapConfig()locationFields()socialNetworks()socialValue()socialIcon()hoursDays()hoursValue()normTime()bookingValue()bookingCapacity()bookingBlackout()bookingTz()
inc/_cd/ListingEditor.php

ListingFaq ListingFaq.php​

Single-listing FAQ. Reads per-listing FAQ items from the faq post meta (an array of ['q' => …, 'a' => …]). A live listing shows only its own saved FAQ — when it has none the section is omitted rather than filled with fabricated entries. Demo/preview mode supplies sample FAQ via DemoContent so a fresh design isn't empty. Populate a listing's own FAQ by saving faq meta, inject a site-wide default set via the ppt_listing_faq_default filter, or adjust the final list with the ppt_listing_faq filter.

API
items()
inc/_cd/ListingFaq.php

ListingHours ListingHours.php​

Business hours display for the single-listing sidebar. Reads the business_hours meta written by the listing editor (ListingEditor::HOURS_META) and renders a Google-Business-style day list with an "Open now / Closed now" badge computed in the site's timezone. Times are formatted with the site's time format.

API
has()isOpenNow()renderSidebar()
inc/_cd/ListingHours.php

ListingLocation ListingLocation.php​

Single-listing "Location" section — the richer location block: the full formatted address, an interactive map (ListingMap, precise when the listing has coordinates), a "Get directions" button, and a "Distance from you" control (browser geolocation → straight-line distance to the listing). Self-contained: it prints its own scoped CSS + JS once, so single.php just calls render().

API
address()coords()has()render()
inc/_cd/ListingLocation.php

ListingMap ListingMap.php​

The single-listing "Location" map. Uses the site's Maps provider setting (Settings ▸ API keys — the same ppt_maps_provider filter the search map reads). When the listing has stored coordinates (lat/lng, set by the editor's map picker) the map centres on them precisely and drops a named marker; otherwise it falls back to geocoding the address string: google / mapbox(fallback) → a keyless Google Maps embed osm → a Leaflet map (marker from coords, else Nominatim) Map libraries load from their CDNs — the owner-approved front-end map exception.

API
render()
inc/_cd/ListingMap.php

ListingPricing ListingPricing.php​

Single-listing pricing plans. A listing owner enters one or more plans / packages on the submission form (a name, a price, and a short description); they're stored in the pricing_plans post meta as a list of ['name' => …, 'price' => float|null, 'desc' => …]. The LOWEST priced plan is mirrored into the searchable price meta (Ppt_cd\SearchPage::PRICE_META) by the editor on save, so the price range filter, the price sort, and the result-card price all work — that's the link between "enter your pricing" and "find listings by price". Prices are stored in the site's base currency; render() converts + formats via Ppt\Content\Currencies for the viewer's chosen currency.

API
plans()demoPlans()has()lowestPrice()normalise()render()
inc/_cd/ListingPricing.php

ListingSections ListingSections.php​

PPT — configurable single-listing sections. The admin (Design ▸ Listings ▸ "Listing page sections") gets a sortable list of on/off toggles for the optional feature blocks a listing page can carry — Booking, Business hours, Maps & Location, FAQ, Reviews. Turning one OFF removes it from BOTH the single listing page and the listing submission/edit form; the order of the list controls the order the (main-column) sections appear in. Config lives in the shared design option (Branding::OPTION = ppt_design) under the listing_sections key: { order:[keys…], enabled:{key:0|1} }. Anything not saved yet defaults to ON, in the catalog order — so existing sites are unchanged until the admin edits the list.

API
supported()catalog()config()order()enabled()orderedAmong()sanitize()
inc/_cd/ListingSections.php

ListingViews ListingViews.php​

PPT listing analytics — records a "hit" every time a single listing page is viewed, and serves that data back to the listing owner as a graph in the member area (/account ▸ My listings ▸ the analytics icon). Each view stores the listing id, the timestamp (UTC), and — when the visitor is logged in — their user id + display name, so an owner can see who has been looking. Bots/crawlers are skipped so counts reflect real visitors. The owner (and admins) can read the analytics for a listing over the AJAX endpoint, which returns a daily series (for the chart), rolling-window totals (7/30/60/90 days) and a list of recent named viewers. Storage: a custom table {prefix}ppt_listing_views (dbDelta on init).

API
register()table()install()maybeRecord()total()countSince()series()recentViewers()ajaxData()
inc/_cd/ListingViews.php

Media Media.php​

Listing images — the single, WordPress-native resolver for the PPT image system. A listing's photos are its WP featured image (primary) plus any image attachments parented to it (the gallery). No legacy ?imgid refs, no image-URL meta strings — everything flows through the media library.

API
primary()gallery()videos()media()counts()
inc/_cd/Media.php

Reviews Reviews.php​

Listing reviews — built on native WordPress comments so they moderate and store like any comment, but stamped with the comment type "review" (the identifier that distinguishes them from ordinary blog comments in the admin) and a 1–5 star rating saved as comment meta. Reviews are always enabled on the listing CPT. Rendered in the single-listing "Reviews" (summary + breakdown + cards) and "Add Review" (star input + comment form) sections.

API
register()open()stampType()saveRating()onCommentChange()onStatusChange()syncPostRating()count()all()stats()stars()renderSummary()renderList()renderForm()
inc/_cd/Reviews.php

Roles Roles.php​

Buyer or Seller: who this member is on the car dealer profile. A car site has two sides. A SELLER lists vehicles; a BUYER browses, saves searches and messages sellers. Sign-up asks which in its role step ("browse" / "list") and stores the answer in ppt_signup_role; this bridges that answer onto the type Account\AccountType understands (buy → CLIENT, sell → SOLO) and supplies the words — the Classifieds bridge (Ppt_ct\Roles), cloned 2026-09-20 so the home-demo can offer a one-click "Buyer login" and "Seller login", the hub can show the badge, and a buyer's hub can drop the Selling half (hidesSelling(), the auction rule). Gated to the car dealer profile by Theme::boot()'s fork-gating (this is Ppt_cd*).

API
register()profiles()typeForUser()typeCurrent()toType()options()shortLabel()typeOf()isBuyer()hidesSelling()accountBadge()
inc/_cd/Roles.php

SearchPage SearchPage.php​

Server-rendered search / archive for the listing post type — the clean PPT rebuild of DT10's PPT\Custom\Search\SearchPage. Runs the normal WordPress main query (WP_Query) via official hooks (pre_get_posts + template_include) so it is SEO-friendly and every core filter applies. Contexts it owns: - keyword search (/?s=…) - the listing post-type archive (/listing/) - listing category / tag archives Filters (GET, all optional, combinable): s keyword tax-listing_category category term id price1 / price2 min / max price (numeric, price meta) sort featured | newest | oldest | rating | price_low | price_high | title paged pagination

API
register()shapeQuery()nearCoords()radiusKm()distanceFrom()distanceLabel()radiusClausesMain()radiusClauses()featuredOrderClauses()isListingContext()postType()isMapTakeover()categoryTax()terms()taxQueryFromRequest()listingTaxonomies()hasActiveFilters()matchingIds()termCounts()priceMetaQuery()ratingMetaQuery()activeMetaQuery()sortOptions()template()
inc/_cd/SearchPage.php

SingleListing SingleListing.php​

Single-listing page for the listing_type post type — the clean PPT rebuild of DT10's PPT\Custom\Single\SingleListing. Owns template_include for singular listings and renders its own token-styled template inside the normal main loop. No legacy $CORE / membership plumbing; standard WordPress access rules apply.

API
register()demoBookingProvider()template()related()
inc/_cd/SingleListing.php

TermMeta TermMeta.php​

Per-term IMAGE + ICON for the listing taxonomies. Adds two custom fields to the native WordPress term add/edit screens (Categories, Tags and any custom listing taxonomy): a media-library image picker and a swatch picker over the theme icon library. The values are stored as term meta and consumed by the live-category blocks (via Blocks\Support\Categories) so an admin can give each category a branded photo and icon instead of the auto-derived listing photo / fallback glyph. Admin-only UI; the read helpers (image()/imageId()/icon()) are safe to call anywhere. Taxonomies are resolved live from the listing post type, so new custom taxonomies get the fields automatically.

API
register()hookTaxonomies()taxonomies()imageId()image()icon()assets()addFields()editFields()save()
inc/_cd/TermMeta.php

Uploads Uploads.php​

Listing media uploads — the AJAX backend for the Uppy uploader on the listing editor (replacing the WordPress media frame). Uppy's XHRUpload posts one file per request to ppt_listing_upload; each becomes a normal WordPress attachment (so Media::gallery()/Media::videos() and the single-listing template keep working). Files are left unattached (post_parent = 0) until the listing form is saved, which parents the final set (ListingEditor::save()). A companion ppt_listing_media_remove deletes a freshly uploaded, not-yet- saved attachment when the user removes it in the editor, so abandoned uploads don't pile up in the media library.

API
register()imageMimes()videoMimes()ajaxUpload()ajaxRemove()ajaxPoster()ajaxPersist()
inc/_cd/Uploads.php

VehicleSpecs VehicleSpecs.php​

Vehicle Type / Make / Model for the Car Dealer fork (_cd). Adds a three-step vehicle picker to the add/edit listing screen (Type → Make → Model, cascading) and a matching cascading search facet. Wiring is deliberately thin, mirroring _ll\CourseDetails: the editor prints VehicleSpecs::editorCard($pid), the save is VehicleSpecs::saveFromForm($pid, $in), search renders the same picker via ::searchFacet(); the single template / listing card can call ::chips($pid). Data model: - TYPE is a taxonomy (self::TAX_TYPE, 'listing_vehicle_type'), seeded with the eight default types below. Because it is a real listing taxonomy, the search query filters on it for free via SearchPage::taxQueryFromRequest() (the GET param tax-listing_vehicle_type). It is kept OUT of the generic taxonomy facet list (Admin\Search::taxonomyFilters) so the combined vehicle facet is the only Type control on the search page. - MAKE / MODEL are plain listing meta (self::MAKE_META / self::MODEL_META), their options driven by the bundled dataset (data/vehicles.json), keyed by type slug. Filtered on via self::vehicleMetaQuery().

API
register()isEnabled()isRequired()isVinEnabled()defaultTypes()registerTaxonomy()seedTypes()dataset()makesFor()typeSlug()typeLabel()make()model()price()salePrice()saveFromForm()savePriceFromForm()vehicleMetaQuery()searchUrl()icon()fuels()transmissions()fuel()transmission()
inc/_cd/VehicleSpecs.php

Vin Vin.php​

Offline VIN decoder for the Car Dealer fork. WHAT THIS CAN AND CANNOT DO. A 17-character VIN (ISO 3779) is three parts. The WMI (chars 1-3) identifies the manufacturer and is a finite, published table, so it can be bundled. The model year (char 10) and the country (char 1) are fixed codes. The check digit (char 9) is arithmetic. All of that decodes offline, with no API. The VDS (chars 4-8) — model, trim, engine, gearbox, body — is NOT standardised: every manufacturer invents its own scheme and publishes none of it. There is no offline way to turn those five characters into a model name, and anything that claims to do it for free is quietly querying a paid database. So this decoder fills Make and Year, narrows the Model dropdown to that make, and leaves the model to the seller. The UI is built around that limit rather than hiding it. A second honest limit: the check digit is only MANDATORY in North America. Plenty of legitimate European VINs do not carry a valid one, so a checksum mismatch is a soft warning here and never a rejection — otherwise the theme would refuse real cars. Pure static helpers with no hooks and no side effects, so the whole thing is testable without booting a request. The table lives in data/wmi.json and is read lazily, only when a decode actually runs.

API
typesWithoutVin()appliesToType()normalise()isWellFormed()isNorthAmerican()checkDigit()checksumValid()modelYear()yearAmbiguous()regions()country()wmiTable()manufacturer()makeAliases()matchMake()decode()get()saveFromForm()
inc/_cd/Vin.php

VinLookup VinLookup.php​

AJAX endpoint for the Car Dealer VIN decoder. Modelled on Account\AddressLookup, with one deliberate difference: there is no transient cache and no per-user throttle. Those exist there to stay inside a third party's usage policy — here Vin::decode() is a lookup in a bundled array with no upstream service to protect, so caching would add I/O and buy nothing. The omission is a decision, not an oversight. The decode runs server-side rather than in the browser because the WMI table is ~90 KB; sending it to every visitor who opens the listing form to save one request would be a bad trade. The browser does only the trivial 17-character format check, so an obvious typo never costs a round trip. Security posture is copied from AddressLookup: registered on wp_ajax_ ONLY (never the nopriv twin), nonce-checked, and gated per listing on ListingEditor::canEdit().

API
register()nonce()handle()placeName()summary()
inc/_cd/VinLookup.php