Developer guide
Developer guide
This guide is for anyone who wants to change or extend a PremiumPress theme in code. We'll show you how to do it without losing your work when the theme updates.
Before you write any code
Most changes don't need any code at all. Colours, fonts, the logo, homepage designs, the Site Generator, Elementor pages, custom fields, emails and every admin setting are saved in the database, and theme updates never touch them. Small CSS changes can go in Design → Custom code.
Code is the right choice when you need something the settings don't offer. When you do write code, keep it in a child theme or your own plugin, never in the theme folder. That's because the next update replaces every file in the theme folder, and your changes would be lost.
What's in this guide
- Child theme: how to set one up the right way, with the two lines PremiumPress needs.
- Page layouts: why copying a template into a child theme doesn't work, and what to do instead.
- Hooks and filters: the actions and filters the theme offers for your code, grouped by area.
- Adding your own features: extra listing-editor cards, listing-page sections, member-area tabs, homepage blocks, emails and SMS.
- Writing a payment gateway: how to connect a payment provider that the theme doesn't come with.
APIs
MCP server (AI agents). This lets an AI agent such as Claude look after the site through a set of tools: listings, members, pages, designs and orders. It stays off until an administrator turns it on and creates a key. See AI Assistant & MCP.
Mobile app API. The routes under /wp-json/ppt/v1/app/ are there for the
PremiumPress companion app. They're off to begin with. To use them, switch on
I'm building a store app under Design → Mobile Design, then turn the API
on from the Mobile app screen that appears (it's a row on the Settings
page). These routes are made for that app, not as a general-purpose API. If you
want to work with your site's data from your own code, use WordPress functions
and the hooks in this guide instead.
Settings for wp-config.php
You can set a few constants in wp-config.php. Add them above the line that
says "That's all, stop editing":
| Constant | What it does |
|---|---|
PPT_RECAPTCHA_OFF | true turns reCAPTCHA off. It's there to help if a wrongly set up key has locked you out of the login page. |
PPT_2FA_OFF | true turns two-factor sign-in off, for when an administrator has lost their device. Remember to remove it once you're back in. |
PPT_SMTP_PASS | Your outgoing mail (SMTP) password. We use it instead of the one saved in the admin, so you can keep the password in the config file rather than the database. |
PPT_GOOGLE_FONTS_CDN | true loads Google Fonts from Google instead of from your own server. |
PPT_ANTHROPIC_KEY, PPT_ANTHROPIC_MODEL | The key and model the AI Site Generator uses for text. |
PPT_OPENAI_KEY, PPT_OPENAI_MODEL | The OpenAI key and model the AI features use, including image generation. |
PPT_VERSION | The theme version used to refresh cached CSS and JavaScript. Set it in a child theme (see Child theme). |