# Poly Community
> Poly Community is a WordPress plugin by WordPlus that turns a site into a member site, built from blocks: a community with profiles, spaces, a feed, a forum and questions with answers, and components for events, courses, jobs, listings, bookings, paid membership and more, on one core of accounts, members, payments, moderation, notifications and search. The community is one component among them and can be switched off.
Facts to rely on, as of version 1.0.0-beta.1:
- **Status:** in preview, not out for download yet and not on WordPress.org yet. The name may still change. It runs on https://www.wordplus.org/, and its release is announced in https://www.wordplus.org/groups/poly-community/.
- **What it needs:** WordPress 7.2 or later, PHP 8.1 or later, MySQL or MariaDB. No other plugin.
- **What it costs:** the plugin is free with every component in it. Instant live updates and push notifications come with a WordPlus Cloud subscription (https://www.wordplus.cloud) through the WordPlus Cloud plugin. Without it, pages stay live by asking the site every few seconds.
- **Apps:** 21, all in the plugin, each switched on under Settings → Components. Of them, Knowledge base needs Evo Support, Live needs WordPlus Live Stream. The start page knows 90 kinds of site and switches on what each needs.
- **Themes:** block themes (every page a Site Editor template), classic themes, or a full-page portal. Poly Theme, an optional block theme in its look, is to be a free download from WordPlus Cloud.
- **Better Messages:** with Better Messages active, private messages and a chat for each space come into the community (https://www.better-messages.com/).
- **Data:** in tables of its own on the site, never sent anywhere. Members download their data and delete their account.
- **For developers:** `Poly_Community()` with stable parts, hooks prefixed `poly_community_`, REST under `poly-community/v1`, blocks `poly-community/*`, and apps as folders with a `kit.json` manifest, registered with `poly_community_register_kits`.
- **Help:** questions at https://www.wordplus.org/questions/poly-community-help/, contact at https://www.wordplus.org/contact/. Docs at https://www.poly-community.com/docs/.
---
# What Poly Community is
Address: https://www.poly-community.com/docs/
Poly Community is a WordPress plugin that turns a site into a member site. It starts with a community: members with profiles, spaces they gather in, a feed, a forum and questions with answers. Its components add events, courses, job boards, listings, bookings, paid membership and more, all on the same core of accounts, members, payments, moderation, notifications and search.
The community itself is one component among them. Keep it on for a social site, or switch it off and run a directory, a job board or a school on the rest.
**Preview**
Poly Community is in preview and not out for download yet. The name may still change. It runs every day on [wordplus.org](https://www.wordplus.org/), where you can see it and [follow how it goes](https://www.wordplus.org/groups/poly-community/).
## What it is made of
- **The core.** Accounts and joining, members and their profiles, permissions, pages that change without a reload, payments, files, notifications, moderation, search and the admin.
- **The Community component.** Profiles, follows or friends, spaces (called spaces or groups), a feed of posts with pictures, video, voice notes, polls and reactions, a forum with boards, and questions with answers and votes.
- **The components.** Events, courses, jobs, listings, bookings, paid membership and more, each switched on when you need it.
- **Blocks.** Every page is made of blocks you move, remove or restyle in the Site Editor, down to each post and member card. Edit a card once and every list follows.
## Who it is for
The start page knows many kinds of site, from a hobby club to a professional association, a dating site, a creator with paying fans, a neighborhood, a course academy or a marketplace. Picking one sets the components, fields, spaces and words that fit it, and everything stays yours to change.
## What it needs
- WordPress 7.2 or later and PHP 8.1 or later.
- MySQL or MariaDB.
- Any theme. It looks its best in a block theme, works in classic themes, and can run as a full-page portal of its own. See [Themes and layouts](https://www.poly-community.com/docs/themes-and-layouts/).
Nothing else is required. Live updates work on any host by asking the site every few seconds, and a [WordPlus Cloud](https://www.wordplus.cloud) connection makes them instant. See [Live updates](https://www.poly-community.com/docs/live-updates/).
## Where to go next
- [Getting started](https://www.poly-community.com/docs/getting-started/): installing it and the start page.
- [The settings](https://www.poly-community.com/docs/settings/): every page of the admin, in the order it has them.
- [For developers](https://www.poly-community.com/docs/developers/): building a component or adding to one.
---
# Getting started
Address: https://www.poly-community.com/docs/getting-started/
**Not out yet**
Poly Community is in preview, so there is no zip to download yet. This page describes the plugin as it runs on [wordplus.org](https://www.wordplus.org/) today. To hear when it is out, [join the Poly Community group](https://www.wordplus.org/groups/poly-community/).
## What you need
- WordPress 7.2 or later.
- PHP 8.1 or later.
- MySQL or MariaDB. Poly Community keeps its data in tables of its own with indexes made for large communities, never in post meta or user meta.
- Pretty permalinks, for addresses such as `/members/ana/`. With plain permalinks the community still works, with addresses that carry their query.
Any host that runs WordPress runs it on its own.
## Install it
Once it is out: in WordPress, go to **Plugins → Add New Plugin**, upload the zip or search for Poly Community, install it and activate it.
Activating it opens the start page. The site changes only once you finish it, and the start page stays under **Poly Community → Settings → Start** if you leave it for later.
## The start page
Five steps, and only the first one needs an answer. Once you have picked what you are building, **Set it up now** sits beside **Continue** on every step and sets the site up with what that kind of site needs and whatever you changed so far. Every choice can be changed later in Settings, and the column **Your site** keeps a line of what you picked, with **See every change** for the whole list of what will be written.
### 1. What are you building?
Pick the goal closest to your site: a community, an organization, a directory, a job board, a shop or marketplace, a school, bookings, events, creators and memberships, dating, or a site for adults. Or find a kind of site by name, such as a forum, a coaching business or the plugin you are moving from. **Start blank** is the core alone: accounts and joining, members and their profiles, notifications and moderation.
(Screenshot: What are you building, with twelve goals in a grid: Community, Organization, Directory, Job board, Shop or marketplace, School or courses, Bookings, Events, Creators and memberships, Dating and matching, For adults and Start blank. The first step of the start page.)
A goal holds several kinds of site, and you pick the one that fits best. The kind you pick says what it sets up today and what it gets in later updates, and the kinds it resembles.
(Screenshot: Which kind, with the kinds of community in columns and General community picked, saying what it sets up. Community has more than thirty kinds, from a neighborhood to a running club.)
### 2. What can members do?
The components the kind of site needs are on already: courses, events, jobs, listings, bookings, paid membership and the rest, each a switch with a line saying what it does. Switch on more, or off what you do not need. The **Community** component is the feed, spaces and connections between members: a site without it runs on its other components alone.
### 3. Who it is for
Who can see the site (everyone, or members only), who can join (anyone, anyone once you approve them, or only people you add), the sign-up form on one page or in steps, whether email addresses are confirmed, how members connect, and whether there are spaces and who makes them. Then, if you like, what the site is about: topics that add the choices members pick from in their Interests field.
### 4. How it looks
Whether the community is a portal with its own top bar or sits inside your theme, how the login and sign-up pages look, the colors, the arrangement of columns, the name, and where the community lives: at `/community/`, or the whole site.
With the community at its own address and a block theme, **In your site menu** adds a link to the community to the menu at the top of your site, so a visitor on your home page finds it. It is an ordinary link of that menu, which you change in **Appearance → Editor → Navigation**.
(Screenshot: The community name, Where the community lives with At /community/ picked, and In your site menu switched on. Where the community lives, and its link in your menu.)
### 5. Finish
**Add sample content** adds a few members and posts written for the kind of site you picked, so you can look around before anyone joins. Each is marked Sample, none is ever emailed, and **Settings → Start** removes them all in one click, leaving your own posts and spaces. Then press **Set up the site**.
## After setting it up
**Settings → Start** says the site is set up and lists the steps that come next, in groups: people joining (inviting your first members, the sign-up form, how login and sign-up look, approving new members), how it looks, and staying in touch (email that arrives, the app members install). Each has its button, and the ones that do not apply to your site can be dismissed.
(Screenshot: Settings, Start: Your site is set up, Get started with Poly Community with its count of steps done, the site type, and the next steps in groups. Settings → Start after the start page.)
On the site itself, visitors find the community from your menu, and **Log in** and **Join** sit at the end of your theme header.
(Screenshot: The header of the site, with Sample Page and Community in the menu, then search, light or dark, Log in and Join. The site header after setting it up.)
## Usage data
The Plugins screen asks once whether to share some data about your site with WordPlus Cloud, which makes the plugin, so it works better with sites like yours. Its screen lists each thing and lets you leave any out: your name and email, for news of security and feature updates, the site address with its WordPress and PHP versions, the components in use, and the plugins and themes on the site. It shares only what you allow, and **Skip** keeps everything on your site.
## How the pages move
Moving between community pages loads no page whole. Each kind of page is one file the browser keeps, the same for every reader, and a move asks the site for one small answer with what that page shows: on a test site with the sample content, the next page is drawn within about 50 to 180 ms of a click and filled from 2 to 6 KB of data, where loading the same page whole sends 175 to 240 KB and starts every script again.
To change what a page shows, start with **Settings → Appearance** and the page templates in the Site Editor. A developer or a coding agent who changes a component or builds a new one keeps it drawn this way: [Pages drawn from data](https://www.poly-community.com/docs/developers/data-driven-pages/) has the rules, the API and a recipe.
## Live updates, and making them instant
Pages update while they are open, with no reload: an open page asks your site what is new every 10 seconds, every 60 in a tab out of sight. [Live updates](https://www.poly-community.com/docs/live-updates/) says what updates and how often. **Poly Community → Upgrade** shows what WordPlus Cloud adds: every update at once, who is online right now and push notifications.
Next: [the settings, page by page](https://www.poly-community.com/docs/settings/).
---
# The feed and posts
Address: https://www.poly-community.com/docs/features/feed/
The feed is where members talk to everyone. The **Activity** page holds the feed of the whole community, each profile the posts of its member, each space the posts written in it, and each tag page the posts that name the tag. A post is written once and shows in every feed it belongs to.
Everything on this page is set in **Poly Community → Settings → Posts**, in six tabs: Writing, Feed and comments, Pictures and files, Reactions and polls, Tags and links, Sharing and more. The feed and posts are part of the Community component: switched off in **Settings → Components**, the Activity page, the feeds and the posts are hidden everywhere, and nothing is deleted.
## Reading the feed
Over the feed, one row says what it shows.
- **Everyone** or **Following**, at its start. Everyone is every post the member may see. Following is the posts of the people, spaces and tags they follow. A member who follows nobody yet is not offered the choice, and neither is a visitor.
- **Filters**, where components add their own kinds of post (events, albums, listings and the rest): **Show** narrows the feed to one kind, or All kinds.
- **Sort**, at its end, with the order of the feed.
(Screenshot: The Sort menu of the feed: Latest, Last active, Trending today, Trending this week, Trending this month and Unread, each with a line saying what it does. The order of the feed.)
**Unread**, offered to members, shows only the posts they have not seen yet. A post counts as seen once it has stayed on the screen a moment, so there is no Mark all as read.
Each choice is a link: the Back button and a shared address keep it. A feed of a profile or a space has the order and the filters, without Everyone and Following.
On a phone the order is in the sheet of **Filters** too, so the row is Everyone or Following and **Filters**. On a profile or a space, **Filters** stands at the end of the tabs.
**The feed opens on** (Feed and comments tab) sets where the Activity feed starts for a member who has not chosen: **Everyone** (the default) or **Following**. Once a member picks one, it is kept for them. **In the order** sets its order the same way: **Latest** (the default) or **Last active**.
New posts by others do not push the feed down while someone reads it. They wait behind a button at its top, such as **3 new posts**. Likes, replies, edits and deleted posts change in place on every open page. See [Live updates](https://www.poly-community.com/docs/live-updates/).
**Dates and times** are written in the forms of the site language (Settings → General → Site Language), in the time zone of the browser of each reader: **3 h** for a recent post, **Oct 2, 2025** for an older one, and **October 2, 2025 at 9:30 AM** when the pointer rests on it. A German site writes **2. Oktober 2025 um 09:30**, whatever the language of the browser. Settings → General → Date Format and Time Format change nothing in the community, as they would write one form for every reader. A day with no time, such as a birthday, is the same day for everyone, and an email is written in the time zone the member saved, or else the time zone of the site.
**The activity feed shows** ticks the kinds of post the Activity feed shows beside the posts of members: blog posts brought in from the site (see [Blog posts in the feed](#blog-posts-in-the-feed)), and the kinds components add, such as events, albums and petitions. All are ticked by default. A kind left out still shows on its own page, on the profile of its author and in its space.
## Writing a post
The composer sits at the top of the Activity feed, of the profile of its member and of every space they may post in. It opens in place: the field grows, the formatting bar shows over the tools, and **Post** wakes up once something is written. On a phone it is one line, the picture of the member and the prompt, and a tap anywhere on it opens the composer as a sheet over the whole screen, whose paperclip adds pictures and files.
(Screenshot: The composer open: the title line, a post written with its first words in bold, the formatting bar, then the tools for files, a voice note, emoji and a poll, Everyone as the audience, and Post with its arrow. The composer, open.)
### Who sees a post
The button beside Post says who a post outside spaces is for, and the member changes it for each post:
- **Everyone**: anyone who can see the community.
- **Members**: only people who are logged in.
- **Friends** or **Followers**: the friends of the member, or the people who follow them, where members connect that way (Settings → Members).
- **Only me**: a note to themselves.
**Post in a space…** at the end of the list moves the post into one of the spaces of the member. A post in a space is seen by whoever may see that space.
**New posts are visible to** (Writing tab) is where the button starts: **Everyone** (the default) or **Members**.
**Who posts outside spaces** decides who writes in the Activity feed and on profiles: **Every member** (the default) or **Moderators and staff**, for a community led by announcements or by its spaces, where members post in spaces alone.
### Formatting
With **Formatting** on (the default), members format their words from the formatting bar, from its keyboard shortcuts, or by typing Markdown, which turns into formatting as it is typed: `**bold**`, `_italic_`, `- ` for a list, `> ` for a quote. Off, posts are plain text.
**What members can format** picks the buttons of the bar, each with its shortcut and its Markdown: Bold, Italic, Strikethrough, Link, Heading, Quote, Bulleted list, Numbered list and Code, all of them by default. The site draws only what is ticked, whatever a post sends. Replies never have headings.
### Titles, mentions and tags
**Titles** decides whether a post has one:
- **When the member wants one** (the default): an optional title line shows over the text once the composer is open. A titled post shows it above its text, and its page is called by it.
- **Always**: every post needs a title before it can be posted, as on a forum.
- **None**: posts are their text, as in a feed.
Typing `@` and a letter suggests members: in a space its members first, then the people the writer follows or is friends with, then everyone else. The member mentioned is told. Typing `#` suggests tags: each tag links to a page of every post that names it, and the most used show as trending.
On the **Tags and links** tab, **Hashtags** turns tags on for posts, topics and questions, in any language (on by default). **Members can follow tags** (on by default) adds the posts of a followed tag to the Following feed of the member. **Hidden tags**, with a comma between them, are tags that get no page and are never suggested or trending: they show as plain text.
### Long posts
**A long post starts at** 30,000 characters by default. **A post longer than that** either **Waits for a moderator** (the default: it shows once approved, and its author is told so before posting) or **Is not accepted** (the composer stops at that length and says so).
**Longest post** (200,000 characters) is a guard for the server against texts nobody writes, not a limit for writers: keep it far above a long post. **Longest reply** (5,000) is the limit of a reply.
### Drafts and scheduled posts
The arrow beside **Post** holds **Save draft** and **Schedule…**. A scheduled post goes out at the time its author picks, from 5 minutes to a year ahead. **Drafts** and **Scheduled** in the same menu list them, to open, post now, change the time of, or delete. A member keeps up to 50 drafts.
Whatever is being written is kept in the browser too: after a reload, or a closed tab, the composer brings it back with **Restored what you were writing** and a **Discard** button.
**Drafts** turns saved drafts on or off (on by default). **Scheduled posts** is for **Every member** (the default), **Administrators** alone, for announcements planned ahead, or **Nobody**. Posts already scheduled still go out at their time.
## What a post carries
Besides its words, a post carries what the tools of the composer add. Each is set on the **Pictures and files**, **Reactions and polls** and **Tags and links** tabs.
(Screenshot: A post by Zoë Fischer with two photos side by side, a meadow and birds over a marsh, a tag, eight reactions, and two comments under it. A post with photos, reactions and comments.)
**Pictures.** Up to 10 in a post (**Pictures in a post**, 20 at most) and 4 in a reply (**Pictures in a reply**), shown as a gallery in the order the member puts them. In the composer each one can be dragged to another place (Alt and the arrow keys from the keyboard), cropped or turned, and given alt text, read aloud in its place and shown under it in the picture viewer.
**Files.** Up to 4 in a post (**Files in a post**, 10 at most) and 2 in a reply. The type of a file decides where it goes: a picture to the gallery, a video to the video, an audio file to the clip, anything else to the files. Which types are allowed and how large each may be are set in **Settings → Files**.
**Video.** One video a post. **Videos** is **Uploaded** (the default: attached from the device), **Recorded or uploaded** (recorded with the camera in the composer too), **Recorded only**, or **Off** (a video file then goes with the files, and plays there as it came). **Longest video** is 600 seconds by default. Videos are made to stream to any screen, by the browser of the member who uploads them unless Settings → Files says otherwise.
**Audio clips.** One clip a post or a reply, played with its waveform, seeking and speed. **Audio clips** is **Voice notes or uploaded** (the default: recorded with the microphone in the composer, or an audio file), **Uploaded**, **Voice notes only** or **Off**. **Longest audio clip** is 300 seconds by default. A recording stays on the device until it is posted.
**Polls and quizzes.** A question with up to twelve options. Its author chooses whether members pick one or several, whether the vote is anonymous, and when it ends. A quiz has a right answer, shown with an explanation once a member has answered. After voting, members see the bars and the counts, and who voted where the poll is not anonymous. Its author or an administrator can end it early.
(Screenshot: A poll of Leo Martins with three options, the bars filled after voting, Saturday morning leading, and the faces of who voted. A poll after voting.)
**Polls** and **Quizzes** are on by default. **Who adds polls** is **Every member**, or **Administrators, and the admins of a space and moderators in it**. Everyone votes either way.
**GIFs and stickers.** A post or a reply may be a GIF or a sticker, alone or with words. GIFs come from the service chosen in **Settings → Services → GIFs**, straight to the browser of each member. Stickers are the packs kept on the site, managed under **Sticker packs** on the same tab.
**Places.** A post may say where its author is, or the place it is about. **Places on posts** is off until a map service is set up in **Settings → Services → Maps and places**. An exact spot is kept only when the member chooses it.
**Links.** With **Link previews** on, a link in a post shows a card with its picture, title and site. The site fetches the page once, when the post is written, and keeps its picture as its own, so readers never contact the other site. **Video and audio players** play a video or a song from a service WordPress knows right in the post, after a member presses play. **Players from** picks those services: a link to one left out shows as a card.
## Reactions
Every post and reply has **Like**. Its button shows the first reaction, the emoji of Like, grey until it is given. Hovering over it, a long press or its arrow shows the other reactions, and a member gives one reaction to a post: the button then shows that reaction, and tapping it again takes it back. The post shows its three most given reactions and how many there are in all, and a tap there lists who reacted, a tab for each reaction.
(Screenshot: A post with its reactions open from Like: Like, Love, Haha, Wow and Sad. The reactions, open from Like.)
**Reactions offered** (Reactions and polls tab) holds Like and up to five more: Love, Haha, Wow and Sad by default, with Angry to add. Like is always first. Pick the emoji of each one, and order them with the arrows. With Like alone, there is nothing to choose from, and its button shows the icon picked as **Like button** in **Settings → Appearance → Feed**: Heart, Thumbs up or Star.
(Screenshot: Settings, Posts, Reactions: Reactions offered, with Like, Love, Haha, Wow and Sad, each with its emoji. Settings → Posts → Reactions and polls.)
## Comments
Members reply under a post, and reply to a reply, three levels deep. A reply to the deepest one stays beside it and says whom it answers. In a feed, a post shows its latest comments and how many more there are, and the rest open in place.
**Comments open with** (Feed and comments tab) sets their order: **Oldest first** (the default, a conversation in the order it was had), **Top first** (the most liked first) or **Newest first**. On the page of a post, members can switch.
A reply carries formatted words without headings, up to 4 pictures, 2 files, one audio clip, one link preview and one GIF or sticker. **Turn off notifications** in the menu of a post stops what it would tell that member, and **Turn on notifications** brings it back.
(Screenshot: Settings, Posts, Feed and comments: The feed opens on Everyone, In the order Latest, Comments open with Oldest first, and The activity feed shows with Blog post ticked. Settings → Posts → Feed and comments.)
## Editing a post
**Edit post** in the menu of a post opens it in the composer, and a reply has its own **Edit**. Members can change the words, the title, pictures and files, the clip and the video, the link preview, the GIF, the place, and who sees a post outside spaces. A poll changes only while nobody has voted. The space of a post and what a share points at stay as they are.
An edit in the first two minutes after posting leaves no mark, so a typo fixed at once is just fixed. After that the post says **Edited**, and **Edited by an administrator** when an administrator changed it.
- **Members can edit their posts** (on by default) covers posts and replies. Administrators can always edit any post.
- **For how long**: minutes after posting, 0 for any time (the default).
- **Earlier versions**: **Kept for the author and administrators** (the default, which helps when a report is about words since changed), **Kept for everyone**, who open them from Edited, or **Not kept**.
## Sharing, saving and pinning
**Share** under a post opens **Copy link**, **Share to your profile**, **Share in a space…** and, where the device has one, **Share via…** with its own share sheet. Sharing opens the composer with the post under a few words of the member. Only posts open to everyone or to members, or in a public or members-only space, can be shared, and a share never shows its post to someone who may not see it.
(Screenshot: The Share menu of a post: Copy link, Share to your profile, Share in a space. Share.)
The menu of a post (its three dots) holds what a member does with it: **Save**, pinning, **Turn off notifications**, **Copy link**, and for their own post **Edit post** and **Delete post**. On the posts of others they find **Report post**, and moderators **Hide for review**.
(Screenshot: The menu of a post of Maya Chen: Edit post, Pin to your profile, Save, Copy link, Turn off notifications and Delete post. The menu of a post, on a post of your own.)
On a phone this menu, like every menu of the community, opens as a sheet from the foot of the screen, each row a
finger tall, and a tap above it closes it. **Delete post** then asks in a small box in the middle of the screen.
(Screenshot: The feed on a phone, dimmed, with the menu of a post as a sheet at the foot of the screen: Edit post, Pin to your profile, Save, Copy link, Turn off notifications and Delete post. The same menu on a phone.)
**Saving.** **Save** keeps a post on a **Saved** page that only its member sees, to read later.
**Pinning.** A pinned post leads its feed, marked **Pinned**.
- **Pin to your profile**: a member pins up to 3 of their own posts.
- **Pin in** a space: its admins and moderators pin up to 5, and up to 10 in a board of the forum.
- **Pin for everyone**: administrators pin up to 5, shown as announcements above the composer of the Activity page. A member can hide one they have read.
On the **Sharing and more** tab, **Sharing**, **Saved posts** and **Pinned posts** are each on by default. **Sharing posts some cannot open** decides about posts behind **Show** (a rating or a warning) or behind a paid plan:
- **None of them**: neither can be shared.
- **Posts behind Show** (the default): shared by those who opened them. Others see **A post behind Show** and its reasons in the share. Posts behind a plan cannot be shared.
- **Those behind a plan too**: members of a plan may share its posts, and everyone else sees the invitation of the plan in the share, never the post.
## Views
A post counts a view when it is opened or read in a feed: once a day for each reader, never by its author. **Views** (Feed and comments tab) chooses who sees the number, for each kind of post: **Everyone**, **Its author** (with whoever posts for them, and the administrators) or **Nobody**, where views are still counted. Posts show it to their author by default, topics and questions to everyone.
## Blog posts in the feed
Under **WordPress posts** (Sharing and more tab), **Bring in** picks the post types of the site whose new posts join the community feeds, by their author: **Posts**, **Pages** or both. None is chosen by default. Members reply to them and react there. They stay edited where they are written, and leave the feed when unpublished. **Who sees them** is **Everyone** (as on the site) or **Members**.
## Changing the feed and posts
The feed and its posts change in the ways every component does, set out in full in [Changing a component](https://www.poly-community.com/docs/developers/changing-components/). Take the first that does what you need: each one after it is more of your own to keep up when Poly Community changes.
### In the admin
Everything above: **Settings → Posts** for what posts carry and what members may do with them, **Settings → Appearance → Feed** for how the feed looks, and [Settings → Words](https://www.poly-community.com/docs/settings/words/) for any of its texts in words of your own.
### In the Site Editor
With a block theme, open **Appearance → Editor**:
- **Community: Activity** is the feed page. It holds **Welcome for visitors**, **Post composer**, **Announcements** (the posts pinned for everyone), **Feed bar** and **Activity feed**, in that order. Move them, take one out, or put blocks of your own around them. As on the page, **Welcome for visitors** takes no room in the editor while you are signed in, and **Announcements** none while nothing is pinned: select them in the List View to see them.
- **Community: Single post** is a post on its own page.
- **Community post**, a template part, is each post wherever it shows: in every feed, on profiles and spaces, and on its own page. It holds **Post author** and **Post menu** in a row, then **Post text**, a block for each thing a post carries (**Post images**, **Post video**, **Post poll** and the others), **Post actions** (the buttons under it) and **Post replies**. Change it once and every list follows.
An **Activity feed** block may hold blocks of its own in place of the part, for that feed alone.
### A copy of a view
The markup inside each block comes from a view, which a copy in your theme replaces, as [A view in your theme](https://www.poly-community.com/docs/developers/changing-components/#a-view-in-your-theme) shows. Each piece of a post has two views:
| Piece | A card | A post by itself |
|---|---|---|
| The post around its pieces | `parts/card` | `parts/post` |
| Post author | `parts/card-author` | `parts/post-author` |
| Post menu | `parts/card-menu` | `parts/post-menu` |
| Post poll | `parts/card-poll` | `parts/post-poll` |
| Post actions | `parts/card-actions` | `parts/post-actions` |
| Post replies | `parts/card-replies` | `parts/post-replies` |
- **A card** is how a post shows almost everywhere: in every feed, on profiles and spaces, on the page of a tag and on its own page, on a whole load, after a move between pages and when it arrives live. It is a template drawn once for every post of the page, over the row of each, so its view reads the post from the row (`context.item` and the `state.card…` values the view already uses), never in PHP.
- **A post by itself** is drawn where a page cannot draw it from its row.
Copy the card view for what you want to change, and the post view with it, changed alike, so the post looks the same wherever it is drawn:
```bash
wp poly-community view copy parts/card-author
wp poly-community view copy parts/post-author
```
### In code
A plugin of your own changes the blocks of every post with `poly_community_post_layout`, which gives the blocks of **Community post** as Poly Community starts it. A classic theme draws posts with them, and a block theme starts from them until the part is saved in the Site Editor. This one shows each author without the picture beside the name:
```php
function my_site_post_layout( $layout ) {
return str_replace(
'',
'',
$layout
);
}
add_filter( 'poly_community_post_layout', 'my_site_post_layout' );
```
The ⋯ menu of a post and the buttons under it are places of the registry, `post.menu` and `post.actions`, which a plugin adds to, moves and takes from on `poly_community_register_ui`: see [Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/).
---
# Profiles
Address: https://www.poly-community.com/docs/features/profiles/
Every member has a profile: a page of their own with a cover, a picture, their name and a line about them, and tabs with their posts, what they tell about themselves and who they are connected to. Their name and picture lead there wherever they show, and the members directory lists them all.
Members fill in their profile on **Edit profile**. What a profile asks beyond the name and the headline is set under **Settings → Members → Profile fields** (see [Profile fields](https://www.poly-community.com/docs/features/profile-fields/)), and the buttons and tabs for following and friends under **Settings → Members → Connections**.
## A profile page
(Screenshot: The head of the profile of Zoë Fischer: a cover of a yellow flower, her picture, her name, @zoe-fischer and Illustrator, 7 followers, 9 following and 2 posts, the Follow, Message and ⋯ buttons, then the tabs Posts, About, Followers and Following. A profile, as another member sees it.)
The head of a profile holds:
- **The cover and the picture.** A member without a picture shows their initials on a color of their own, or their Gravatar (see [Settings → Members → Profiles](#settings--members--profiles)).
- **The name, the handle and the headline.** The handle (`@zoe-fischer`) is in the address of the profile, `members/zoe-fischer/` under the community. The headline is one line the member writes, shown under their name everywhere.
- **Online.** On a site served by WordPlus Cloud, a member who is here now shows as online, or with the status they picked. Without it nobody is called online, and cards say when each member was last active. See [Live updates](https://www.poly-community.com/docs/live-updates/).
- **The numbers.** Followers, following or friends, and posts. Followers, following and friends each open their list.
- **The buttons.** Follow, Add friend or both, as the site connects members ([Following and friends](https://www.poly-community.com/docs/features/connections/)). Message, with Better Messages, and its video and audio call buttons where it offers calls. On their own profile a member has **Edit profile** instead.
- **The ⋯ menu,** below.
On a phone the head is short, so the posts start on the first screen. The cover is lower, the picture sits over its left edge with one button beside it, the main one for the reader (Follow, Add friend, Message, or Edit profile on their own), and the ⋯ menu holds the other buttons. Under them come the name, with the rank of the member after it where the site gives ranks (a long name is cut to keep it there, and the badges stay on Achievements), one line (the headline, or the handle where the member wrote none) and the numbers on one line. On any tab but the first the head folds to a bar with the picture, the name and ⋯, so the tab starts near the top of the screen.
(Screenshot: The profile of Zoë Fischer on a phone, twice: on Posts a low cover, her picture over it with Follow and ⋯ beside it, her name with the rank Regular after it, Illustrator, her numbers on one line, the tabs and her first post, and on About a bar with her picture, her name, her rank and ⋯, then the tabs and what she tells about herself. A profile on a phone, on Posts and on About.)
Under the head come the tabs: **Posts** (while the feed is on), **About**, **Friends** (while members become friends), **Followers** and **Following** (while members follow each other), **Achievements** once the site gives badges, and the tabs the components add, such as Reviews. A tab shows its count beside it, and keeps it current as it changes.
### The ⋯ menu
(Screenshot: The ⋯ menu of a profile: Copy profile link, Report Zoë, Mute notifications from Zoë and Block Zoë in red. The ⋯ menu of a profile.)
- **Copy profile link.**
- **Report,** into the moderation queue of the team.
- **Mute notifications from** the member: no notifications from them, and they do not know.
- **Block,** after a question: the two members no longer see each other anywhere in the community, and any follow or friendship between them ends.
Administrators find more there: **Suspend**, which hides the profile and posts of the member from everyone and stops them posting until it is lifted, **Lift the suspension**, **Edit on the Members screen** and **Open in WordPress**. Another administrator is never suspended from it.
### About
(Screenshot: The About tab of Zoë Fischer: About, Location, Website, Pronouns and Member since, each with its icon and her answer. The About tab.)
The About tab shows the answers of the member to the [profile fields](https://www.poly-community.com/docs/features/profile-fields/), by section, each to those its member allows to see it, and when they joined. On their own profile a member finds **Edit profile** here too. Answers whose field has an icon are also listed beside the profile, as the icon and the answer.
### The card over a name
(Screenshot: The card over the name of a member: picture, the Following and Message buttons, name, headline and handle, Follows you, a line about them, and their numbers of followers, following and posts. The card over a name.)
Resting the pointer on the name or the picture of a member for a moment opens a card over it: their cover and picture, their buttons, name, headline and handle, whether they follow you, a few words about them, their numbers, and the spaces you share. The keyboard opens it too, by moving to the link. It closes when the pointer leaves it, on Escape, and on a scroll. Touch screens have none: a tap opens the profile.
## Editing a profile
(Screenshot: Edit profile: the cover and the picture with their buttons, then Name, Headline and the profile fields, each with who sees the answer, and Save profile. Edit profile.)
A member opens **Edit profile** from their account menu, or from their own profile. The **Profile** tab holds:
- **The cover and the picture.** Dropped on their place, or picked with **Change cover** and **Change your picture**. Each is cropped before it is uploaded: the picture round, the cover three times as wide as it is high.
- **Name** and **Headline,** "one line under your name everywhere".
- **The profile fields,** each with who sees the answer, as the member chooses unless the field fixes it.
**Save profile** keeps it all at once. Edit profile also holds **Notifications**, **Privacy** and **Account**, and **Verification** where the site verifies members.
### Privacy
(Screenshot: Edit profile, Privacy: Muted with one member and Unmute, then Blocked with one member and Unblock. Edit profile → Privacy.)
- **Your memberships,** where the site lets members hide which spaces they are in (the Sensitive component does): **Hide my memberships in spaces I join**, and the spaces they hid. A hidden membership is left out of the member list of the space, their profile and every list of people. The team of the space and administrators still see it, and the member still counts in its number. The menu of each space hides or shows one at any time.
- **Distance,** where members are found by how far they are: **Do not show how far I am** keeps them out of searches near a place. Their place still shows on their profile to whoever its field allows.
- **Muted:** the members and posts they get no notifications from, each with **Unmute**.
- **Blocked:** the members they blocked, each with **Unblock**.
## Who can open profiles
(Screenshot: Settings, Joining, Who can see it: Who can see the community, Who can see the rest of the site, Profile pages and Members directory. Settings → Joining → Who can see it.)
Under **Settings → Joining → Who can see it**:
- **Profile pages.** **Public** (the default): each member has a page anyone can open, and their name links to it wherever it shows. **Members only**: logged-in members open the pages of each other, and visitors see names and pictures without links. **Off**: members see only their own page, the team every page, and names and pictures still show beside what members write, without links.
- **Members directory.** **On** (the default), **Members only**, or **Off**: no Members page, no people in search and no member widgets. It is off while profile pages are.
A profile shows to a visitor only while the community itself does: **Who can see the community** set to **Members only** shows visitors a login prompt everywhere.
## The members directory
(Screenshot: The Members page: the tabs Discover and Following, Search by name and Sort: Recently active, then six member cards, each with a cover, a picture, a name, a handle, a headline, followers, when they were last active, and Follow, Following or Edit profile. The members directory.)
The **Members** page lists every member the reader may see:
- **Tabs,** for a member: **Discover** (everyone), **Following** and **Friends**, as the site connects members.
- **Search by name.**
- **Sort:** **Recently active** (the default), **Newest**, **Name**, and **Nearest** where members give a place.
- **Filters:** the profile fields marked as a directory filter, **Verified** where the site verifies members, and **Near** a place, the place of the reader or where they are now, within the distance they pick.
On a phone the row is **Search by name** and **Filters**, its number on it: the order and every filter are in its sheet, with **Clear**. Tabs that don't fit the width are under **More**.
Each card shows the cover, the picture, the name, the handle and the headline, the answers to fields marked to show on cards, the followers or friends of the member, when they were last active (or Online, on a site served by WordPlus Cloud), and their button.
## Settings → Members → Profiles
(Screenshot: Settings, Members, Profiles, Pictures and places: Members without a picture, Pictures across the site, A member place for others, and Distances in. Settings → Members → Profiles: Pictures and places.)
**Pictures and places:**
- **Members without a picture:** **Initials** (the default), on a color of their own, or **Gravatar** where they have one, else their initials. Gravatar then gets the email address of each such member, hashed.
- **Pictures across the site:** **Community picture** (the default): where WordPress shows an avatar (comments, forums, messages), the community picture of the member. **From WordPress**: WordPress shows its own avatars outside the community.
- **A member place, for others:** how far a place is rounded before others see it: **About 1.2 km** (the default), **About 5 km** or **About 40 km** across. Everyone in an area is at one distance and one spot on a map, never their own.
- **Distances in:** **Kilometres** (the default) or **Miles**, in the directory and in lists of posts with a place.
(Screenshot: Settings, Members, Profiles, Deleting an account: When an account is deleted and Members deleting their account. Settings → Members → Profiles: Deleting an account.)
**Deleting an account:**
- **When an account is deleted:** **Keep their posts** (the default), under "Deleted member", so threads still read correctly, or **Delete their posts** with the account.
- **Members deleting their account:** **Not offered** (members ask the team, and an administrator deletes the account in Users), **Ask an administrator** (the default: Edit profile → Account files a WordPress erasure request, the member confirms it by email, and an administrator carries it out in Tools → Erase Personal Data), or **At once** (after the member types their password). Administrator accounts are never deleted this way.
## Changing profiles
Profiles change in the ways every component does, set out in full in [Changing a component](https://www.poly-community.com/docs/developers/changing-components/).
### In the admin
The settings above, the profile fields and connections under **Settings → Members**, **Settings → Appearance → Members** for how member cards look, and [Settings → Words](https://www.poly-community.com/docs/settings/words/) for any of their texts.
### In the Site Editor
With a block theme, open **Appearance → Editor**:
- **Community: Member profile** is the profile page. Its **Profile header** holds **Member cover**, **Member picture**, **Member name**, **Member handle**, **Online status**, **Member headline** and **Member stats**, the buttons (**Edit profile button**, **Connect button**, **Message button** and two **Call button** blocks), **Profile menu** and **Profile tabs**. Under it, **Profile tab content** draws the tab open.
- **Community member card**, a template part, is each member card: in the members directory and in the member lists of a profile, such as its followers. Change it once and every card follows.
- **Community member row**, a template part, is each member in the short lists, such as **Who to follow**.
### A copy of a view
The markup inside the blocks comes from views, which a copy in your theme replaces, as [A view in your theme](https://www.poly-community.com/docs/developers/changing-components/#a-view-in-your-theme) shows. The About tab is the view `parts/profile-about`: a copy of it draws the About tab of every member, also after a move from one member page to another.
```bash
wp poly-community view copy parts/profile-about
```
### In code
A plugin of your own changes the blocks of every member card with `poly_community_member_card_layout`, which gives the blocks of **Community member card** as Poly Community starts it. A classic theme draws the cards with them, and a block theme starts from them until the part is saved in the Site Editor. This one adds a line under each headline:
```php
function my_site_member_card( $layout ) {
return str_replace(
'',
'
';
return array(
'ids' => $ids,
'type' => 'room',
'more' => false,
'page' => (int) ( $args['page'] ?? 1 ),
'args' => $args,
// The events it follows, and those that change one of its rows (Lists: whose events ask it again).
'events' => 'room.created room.deleted',
'reads' => array( 'room.updated' ),
'empty' => Poly_Community()->live_data->html( 'rooms', 0, 'empty', abs( crc32( $empty ) ), $empty ),
);
}
```
The [Lists](https://www.poly-community.com/docs/developers/lists/) page has the shape of a list and how its events are written.
### 4. Draw the block from the state
The block puts its list on a whole load and only names it while a page file is drawn. Its template draws the rows from the state either way. A component block named `poly-community/example-rooms` is drawn by its component class `render_example_rooms()`:
```php
public function render_example_rooms( $attributes, $content, $block ) {
$lists = Poly_Community_Address_Lists();
$slot = $lists->new_slot();
$key = 'rooms:1';
if ( ! $lists->is_skeleton() ) {
Poly_Community()->live_data->put_list( $key, $this->rooms_list( array( 'page' => 1 ) ) );
}
$lists->state();
wp_interactivity_state( 'poly-community', array( 'tileKeys' => array( $slot => $key ) ) );
return Poly_Community()->blocks->kit_block( $block, $this->view( 'rooms', array( 'slot' => $slot ) ) );
}
```
Its view, `views/rooms.php`, is plain Interactivity API markup: [`data-wp-each`](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/api-reference/#wp-each) draws a list from its ids, [`data-wp-bind`](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/api-reference/#wp-bind) sets attributes from the state, [`data-wp-context`](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/api-reference/#wp-context) holds the slot of the list, and [`data-wp-html`](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/api-reference/#wp-html) draws the trusted HTML of each row:
```html
```
These getters are the community own (`state.partRows`, `state.rowPart`, `state.tilesEmpty`), [derived state](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/understanding-global-state-local-context-derived-state-and-config/) of the `poly-community` store, so the list draws before any script of yours has loaded, as it has not yet after a move. Showing the rooms needs no script at all. Teaching in the courses component is drawn the same way (`kits/courses/views/teaching-tiles.php`).
A part that is not a list (a number, a short summary) is named the same way with `Poly_Community_Parts`: `unread()` while a file is drawn, `put()` otherwise. See [Parts: name them unread](https://www.poly-community.com/docs/developers/page-moves/#parts-name-them-unread).
### 5. List the block for page files
```php
public function move_blocks( $blocks ) {
$blocks[] = 'example-rooms'; // without poly-community/
return $blocks;
}
```
A page holding a block that is not listed has no file, and moves to it load its HTML. That is safe, only slower. Listing a block is a promise that it draws nothing of the moment and nothing of its reader in a file, on every page that holds it.
### 6. Say what the reader may do as a fact
```php
public function facts( $facts, $context ) {
if ( ! empty( $context['logged_in'] ) ) {
$facts['exampleRoomsCanEdit'] = ! empty( $context['is_admin'] );
}
return $facts;
}
```
The form of step 4 is in every drawing, so every file of a kind is the same, and it shows for the readers it is for (`state.reader.exampleRoomsCanEdit`). The browser reads the facts again when the access of its reader changes (the `access.changed` event).
A row is the same for every reader too, as an event takes it to all of them. So the Rename and Remove buttons of a room are in its HTML for everyone, and its styles show them where the list holding it says its reader may change rooms (`data-can-edit`, bound to the same fact):
```css
.example-room-tools { display: none; }
.example-rooms[data-can-edit="true"] .example-room-tools { display: flex; }
```
The server never takes the fact on trust: each route asks the capability itself (step 8).
(Screenshot: The Rooms page as a member sees it: the same four rooms, with no field and no buttons. The same page, as a member.)
### 7. Tell each change as an event
```php
public function save( $id, $name ) {
global $wpdb;
$now = (int) floor( microtime( true ) * 1000000 ); // its version, in microseconds
if ( $id && self::get( $id ) ) {
$wpdb->update( $wpdb->poly_example_rooms, array( 'name' => (string) $name, 'updated_us' => $now ), array( 'id' => (int) $id ) );
Poly_Community()->events->emit( array( 'site' ), 'room.updated', array( 'id' => (int) $id ) );
return (int) $id;
}
$wpdb->insert( $wpdb->poly_example_rooms, array( 'name' => (string) $name, 'updated_us' => $now, 'created_at' => current_time( 'mysql', true ) ) );
$id = (int) $wpdb->insert_id;
Poly_Community()->events->emit( array( 'site' ), 'room.created', array( 'id' => $id ) );
return $id;
}
```
Name the object `id` in the payload, as a list reads a row again by it. Emit after the change is saved, on the channels of those who may see the object: `site` for everyone, `members` for members, `user:{id}` for one account, or the core helpers `Poly_Community()->access->item_channels( $item )`, `space_channels( $space )` and `profile_channels( $profile )`. Every member page showing the list hears it. `room.updated` carries the room row (the row type `events` in step 2), so each page writes it in place and asks nothing (the list `reads`). `room.deleted` takes the room out of the list at once. `room.created` shows on the next move of each reader, so the list never shifts while it is read (its `events`). A payload that names the profile id of the member who made the change, as `author`, `by` or `profile`, makes their own other tabs ask the list again (a user id there matches nobody). It follows with no reload, and with no code of yours in the browser.
### 8. Your routes and your script, where you need them
What a reader changes goes through a REST route of the community API (`poly-community/v1`), which the component adds and which asks the capability itself, whatever a page shows. A route that changes a room answers with the room row, as a pack, so the page that asked draws it at once:
```php
public function routes() {
register_rest_route( Poly_Community_Rest_Api::NAMESPACE_V1, '/example-rooms', array(
'methods' => 'POST',
'callback' => array( $this, 'rest_save' ),
'permission_callback' => array( $this, 'can_edit' ),
'args' => array( 'name' => array( 'type' => 'string', 'required' => true, 'sanitize_callback' => 'sanitize_text_field' ) ),
) );
// … and /example-rooms/(?P\d+), POST to rename and DELETE to remove, with the same check.
}
public function can_edit() {
return current_user_can( 'manage_options' );
}
public function rest_save( WP_REST_Request $request ) {
// … the name checked, a WP_Error with a status for one refused …
$id = $this->save( (int) $request->get_param( 'id' ), $name );
// Built by build_row(), the row of its type, kept out of the page's state: the answer carries it.
return rest_ensure_response( array( 'id' => $id, 'data' => Poly_Community()->live_data->row_pack( 'room', self::get( $id ) ) ) );
}
```
`row_pack( $type, $object )` builds the row of an object of a registered type as a pack. For anything else a write answers with, `pack( $build, false, false, $args )` calls `$build` with `$args` and packs what it puts.
A component script is a [script module](https://developer.wordpress.org/reference/functions/wp_register_script_module/) that imports from the core module `poly-community`, and from `@wordpress/interactivity` where it needs [`store()` or `getContext()`](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/api-reference/#store-client-methods). A file at `assets/.js` is registered as `@poly-community/kit-` by itself. Without `script` in `kit.json` it loads on every community page. With `script: drawn`, as here, it loads only on a page that draws the component: on its first load, and on a move to it, from its page file or its HTML alike, as the WordPress router [brings the modules of a page it shows](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/client-side-navigation/#ensuring-script-modules-load-during-navigation). Its `import … from 'poly-community'` then gets the one copy of the core already running. The components of Poly Community build theirs from `src/index.ts`. The example is a plain module with no build:
```js
const KEY = 'rooms:1'; // the list this page draws
// The answer drawn: its row put into the state, the list told of a new id or one gone.
function drawn( answer, removed = 0 ) {
mergePack( answer?.data );
const list = listOf( KEY );
if ( ! list ) {
return;
}
const ids = ( list.ids || [] ).map( Number );
if ( removed ) {
const at = ids.indexOf( removed );
if ( at > -1 ) {
ids.splice( at, 1 );
list.ids = ids;
}
} else if ( answer?.id && ! ids.includes( Number( answer.id ) ) ) {
list.ids = [ ...ids, Number( answer.id ) ];
}
}
async function send( path, options, removed = 0 ) {
try {
drawn( await api( path, options ), removed );
return true;
} catch ( error ) {
toast( errorMessage( error ), true ); // the message of the WP_Error the route answered
return false;
}
}
// A room added from the form above the list.
async function addRoom( event ) {
const form = event.target instanceof Element ? event.target.closest( '.example-rooms-add' ) : null;
if ( ! form ) {
return;
}
event.preventDefault();
const field = form.elements.namedItem( 'name' );
if ( await send( 'example-rooms', { method: 'POST', body: { name: field.value.trim() } } ) ) {
field.value = '';
}
}
// … and changeRoom(), a click on Rename or Remove in a room, sent the same way (assets/example-rooms.js).
// On the document, so it holds on every page a move brings: the module runs once a page load. Named handlers, so
// they can be taken off again with removeEventListener().
document.addEventListener( 'submit', addRoom );
document.addEventListener( 'click', changeRoom );
```
`api()` calls a route under `poly-community/v1/` with the reader session, so `example-rooms` is `/wp-json/poly-community/v1/example-rooms`. Every other page showing the rooms follows the event the save told, with no code of yours: a row the event carries is written in place, a room deleted leaves at once, and a new one shows on the next move of the reader. The page that made the change draws it from the answer, and the event that comes after finds the list as it is. Write state through rows, parts and lists like this, never into the page HTML, as a page drawn again from its file or an event draws over it.
An event of your own, beside what the lists do with theirs, is handled with `onLive( type, listener )`, as [Live updates in code](https://www.poly-community.com/docs/developers/live/#in-a-component-script) shows.
### 9. Check it
- **Its page file is made.** As an administrator, open `/?poly_moves_made=1` on the site: every page, its kinds, and why a kind has no file (a block not listed, something of the moment read, two readers drawn otherwise, with where they part).
- **A move uses it.** After a move, `document.documentElement.dataset.polyMove` is `file` where it came from the page file, and says why where it did not.
- **It stays current.** Add a room as an administrator in one browser, and watch the page of a member in another follow with no reload.
- **Its tests.** The specs of Poly Community check a page against a whole load of it with `movesFromFile()` (`tests/fixtures/moves.ts`), as `tests/specs/instant-and-live.spec.ts` does for this example: a file for each kind of reader, its script brought by a move from the file or from the HTML with the core loaded once, a member page following rooms changed on the server with no page asked, and an administrator page drawing its own writes while it hears none of their events.
## Changing an existing part
- **Its template in the Site Editor, or a view override in your theme:** both are part of the page key, so the page files are made again from them. Keep the rules of this page in what you add: a block of your own listed, its data named and not read.
- **What a post row holds:** a component adds its own values to the rows of its kinds with `poly_community_item_row_data` (under `kit`: a job pay, a listing price, an event date). It is told the form the row is built in (`reader`, `shared`, `known`), so nothing of one reader goes into a shared one. The row version moves at each change of the post. For a row of a core table you change yourself, call `Poly_Community()->live_data->touch( $type, $id )` after the change.
- **A part of a post card:** `poly_community_card_part_html` filters the HTML of each part of a card as it is drawn (`$html`, the part name, the block). Draw from the row, never from the reader.
- **The widgets beside a page type:** `poly_community_sidebar_blocks` lists them (block names, attributes as JSON after a space). Each must be a block a file may hold.
- **A page that draws by something of your own** (a setting of your plugin, a file it reads): add it to the page key with `poly_community_json_move_key`, so a change of it makes the files again. It is given the page id and, as a third argument, the tab page id (`kit-events-calendar`, whose key holds the month, so a new month draws its file again).
- **A link that draws the page again with another address** (a tab, a sort): mark it `data-poly-file`, and it becomes a page file of its own. Its address must be the same for every reader. See [Tabs that draw the page again](https://www.poly-community.com/docs/developers/page-moves/#tabs-that-draw-the-page-again).
- **Something only some readers see:** a fact of the reader, as in step 6, not a test in the view.
- **A list that should follow more events:** add them to its `events`, with what their payload must hold (`room.deleted:space=12`).
What stops a page file: a block not listed, a block that reads rows or parts while a file is drawn, another plugin that prints into the page or hooks an action its page type runs, and a classic widget in the widget area. Each is said on `/?poly_moves_made=1`, and the page still works, moved to by its HTML.
## What is stable
`poly_community_register_kits`, `poly_community_register_row_types`, `poly_community_register_lists`, `poly_community_sidebar_blocks`, `register_type()` and `register_list()` are on the [stable list](https://www.poly-community.com/docs/reference/). The rest of this page is not on it yet: the events and their names, `Poly_Community()->events->emit()`, the `poly-community` script module and its functions, `poly_community_viewer_facts`, `poly_community_item_row_data`, `poly_community_card_part_html`, `poly_community_json_move_blocks`, `poly_community_json_move_key` and the page file rules.
See also [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/), [Moving between pages](https://www.poly-community.com/docs/developers/page-moves/), [Lists](https://www.poly-community.com/docs/developers/lists/), [Live updates in code](https://www.poly-community.com/docs/developers/live/) and [Building a component](https://www.poly-community.com/docs/developers/components/).
---
# Changing a component
Address: https://www.poly-community.com/docs/developers/changing-components/
A component of Poly Community (Events, Courses, Jobs, or one a plugin adds) can be changed in four ways. Take the first that does what you need: each one after it is more of your own to keep up when Poly Community changes.
| Way | What it changes | Through updates |
|---|---|---|
| [In the admin](#in-the-admin) | What it does, its fields, its words (Settings → Words), its look | Kept, nothing to do |
| [In the Site Editor](#in-the-site-editor) | Which blocks its pages and cards hold, and where | Kept by WordPress, the block names are stable |
| [A view in your theme](#a-view-in-your-theme) | The markup of one view | Settings says when the view you copied changes |
| [Hooks in a plugin](#hooks-in-a-plugin) | Values, parts of cards, sorts, rules | Kept when on the [stable list](https://www.poly-community.com/docs/reference/) |
Whichever you choose, a page keeps moving without a reload and stays current: each way below says what it takes. It is the [WordPress Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/) all through.
## In the admin
- **On or off:** Settings → Components, one switch each.
- **What it does:** its own page under Settings → Components, with its settings.
- **Its fields:** the fields of its kinds of item, added and ordered under Settings → Components → Forms and fields, drawn on its forms and cards.
- **Its words:** any of its texts in words of the site own under [Settings → Words](https://www.poly-community.com/docs/settings/words/), with the choices of words a site makes (what spaces and friends are called).
- **Its look:** Settings → Appearance, the design tokens every component draws with.
## In the Site Editor
Every page of the community is a block template, the pages of the components among them ("Community: Events"), and every card a component declares for its lists (`cards` in its `kit.json`) is a template part (`community-{name}`). With a block theme, open them in **Appearance → Editor**: move, add and remove blocks, or put the blocks of a component on another page. WordPress keeps what you save, and block names are on the [stable list](https://www.poly-community.com/docs/reference/).
Page files follow: the templates and parts the Site Editor saved are part of their key, so a change makes them again.
## A view in your theme
The markup inside a block comes from a view: a PHP file of the community (`views/members.php`) or of a component (`kits/events/views/card.php`). A copy of it in your theme, under `poly-community/` and laid out as the plugin lays out its own, is drawn in its place:
```
wp-content/themes/your-child-theme/poly-community/
views/members.php in place of the community view members
views/parts/community-footer.php in place of the community view parts/community-footer
kits/events/views/card.php in place of the view card of Events, the event under a post in the feed
kits/example-rooms/views/room.php in place of the view room of a component a plugin adds
```
The child theme is looked at first, then its parent. Keep your copies in a child theme: an update of a theme replaces its folder, and the copies in it with it, so Settings and `view copy` warn when your theme is not a child theme. Make the copy with WP-CLI, which also stamps it:
```bash
wp poly-community view copy members
wp poly-community view copy card --component=events
wp poly-community view list
```
`view copy` writes the view into the child theme with one line added at its top, its stamp, and never writes over a copy that is there:
```php
name ); ?>
Ask at the desk for the key.
…the buttons of the view, kept as they are…
```
## A view in a plugin
A plugin changes a view through `poly_community_view_file`, which has the last word over the theme copy:
```php
function my_plugin_view_file( $file, $name ) {
// A community view is named by its path under views/, a component view as kits/{folder}/{name}.
if ( 'kits/events/card' === $name ) {
return __DIR__ . '/views/event-card.php';
}
return $file;
}
add_filter( 'poly_community_view_file', 'my_plugin_view_file', 10, 2 );
```
The file gets the same `$args` as the view, and `$kit` for a component view. Page files count it once a page is drawn with it.
The file may draw the view itself around what it adds. **[The example plugin](pathname:///downloads/poly-community-tweaks.zip)** of [Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/) draws a line above the members directory this way:
```php
function poly_community_tweaks_view_file( $file, $name ) {
return 'members' === $name ? __DIR__ . '/views/members.php' : $file;
}
add_filter( 'poly_community_view_file', 'poly_community_tweaks_view_file', 10, 2 );
```
```php
Say hello to a neighbour: everyone here lives within a walk of the river.
path . 'views/members.php';
```
## Hooks in a plugin
Most changes need no copy of a view at all. Each common one has its place in the core, for every component alike:
| To change | Use |
|---|---|
| What a card shows | `poly_community_item_row_data` adds values to the row of an item (under `kit`), and `poly_community_card_part_html` changes the HTML of each part of a card as it is drawn. |
| The fields of a form | The fields of a kind, under Settings → Components → Forms and fields, or in code with `Poly_Community()->thing_fields`. |
| How a list is sorted | `poly_community_item_sorts` adds sorts of your own to the lists of a kind: a label, and an `ORDER BY` on its rows. |
| The tabs of profiles and spaces, and the menus | The places `profile.tabs`, `space.tabs`, `nav` and `account` of the registry, on `poly_community_register_ui`, shown in [Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/). |
| The buttons of a profile, a space and a post, and their ⋯ menus | Block Hooks for a button in a head, and the places `profile.menu`, `space.menu`, `post.menu` and `post.actions` of the registry, shown in [Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/). |
| Who may do what | Access rules (`poly_community_register_access_rules`), what a member must do first (`poly_community_requirements`), and the actions of a component, which approval, profile requirements and verification hold back. |
The components have hooks of their own besides, each listed with where it runs in [Hooks of the components](https://www.poly-community.com/docs/reference/component-hooks/).
## Why not copy a component
A component cannot run twice under two names by copying its folder. Its class, its blocks (`poly-community/…`), its kinds of item, its rows, lists and routes and its tables are all named, and a second component with any of those names is refused or clashes with the first. A copy that renames all of them is a fork of its own, with none of the updates of the component and none of its data.
Change it in one of the ways above, or add a component of your own beside it that does what it lacks, as [Building a component](https://www.poly-community.com/docs/developers/components/) shows: it can need the component (`needs.kits` in its `kit.json`), use its hooks, and put its blocks on its pages.
See also [What you can build](https://www.poly-community.com/docs/developers/what-you-can-build/) and [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/).
---
# Tabs and menus
Address: https://www.poly-community.com/docs/developers/tabs-and-menus/
A profile and a space each have a bar of tabs under their head, and the community has two menus: the community menu beside or above every page, and the member menu under the picture of the member. A plugin adds to the tab bars through the registry of buttons, menus and tabs, `poly_community_register_ui` ([Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/)), and to the two menus with a filter. A [component](https://www.poly-community.com/docs/developers/components/) declares its tabs in its `kit.json`.
**[Download the example plugin](pathname:///downloads/poly-community-tweaks.zip)** (Tweaks for Poly Community, a zip to upload under Plugins → Add New Plugin → Upload Plugin). The code for profiles, spaces and the two menus on this page is in it, and the tests of Poly Community run it as a site owner installs it. In each picture, a red box marks the change it shows. Changes the example makes elsewhere on the same screen, such as its buttons, are left unboxed.
(Screenshot: The head of a member profile with its tabs: Posts, Info and Projects boxed in red, then Followers. A Projects tab added after About, About renamed Info, and Following taken out of the bar.)
## One rule for all of it
A page of the community is drawn once and kept as a page file, which pages move to without a reload, one file serving every reader of a kind. The tabs and menu items are part of it. So a tab says who sees it with a rule, `who`, which Poly Community settles in every file and in the browser ([Who sees it](https://www.poly-community.com/docs/developers/buttons-and-menus/#who-sees-it)), and what it is for a profile or a space (its count, whether it is there) is worked out from the profile or the space alone.
Each hook below takes a named function, prefixed with the name of your plugin, never an anonymous function: another plugin or a theme can then take it off again with `remove_action( 'poly_community_register_ui', 'my_plugin_projects_tab' )`, and an error names it.
## A tab on every profile
One registration puts the tab in the bar and gives it its page:
```php
// After About, its page the blocks a function answers for the profile.
function my_plugin_projects_tab( $ui ) {
$ui->add( 'profile.tabs', 'my-plugin-projects', array(
'label' => __( 'Projects', 'my-plugin' ),
'slug' => 'projects',
'after' => 'about',
'page' => array( 'render' => 'my_plugin_projects_page' ),
) );
}
add_action( 'poly_community_register_ui', 'my_plugin_projects_tab' );
// Its page: blocks, as a template holds them.
function my_plugin_projects_page( $profile ) {
return '
Projects
'
. '
What this member is working on shows here.
';
}
```
A tab takes the keys of an item ([An item in a ⋯ menu](https://www.poly-community.com/docs/developers/buttons-and-menus/#an-item-in-a--menu)), and these:
| Key | What |
|---|---|
| `slug` | The last part of its address, `/members/{handle}/projects/`. Its id when left out. |
| `page` | Its page: `template`, the path of a file of block markup, or `render`, a named function given the profile or the space that answers block markup. |
| `count` | A named function given the profile or the space: a number shown after the label, none at 0. |
The page is blocks: any blocks of WordPress, of Poly Community, or of your plugin, written as a template holds them. Pressed in the bar, the tab draws its page without a reload: the [Interactivity Router](https://www.poly-community.com/docs/developers/interactivity-api/) brings its page as HTML, as it does every page whose blocks are not among those listed for page files ([Page moves](https://www.poly-community.com/docs/developers/page-moves/)).
The tabs of Poly Community on a profile are `posts`, `about`, `friends` (whose slug is the word the site chose, `friends` or `connections`), `followers` and `following`, then those of the components by their slug, such as `reviews` and `achievements`. In a tab bar, where a tab stands is worked out from the tabs that profile or space has: a tab after one it does not have stands with the rest.
## Changing the tabs there
`change()` renames a tab of Poly Community, moves it, or keeps it from some readers (`who`) or some profiles (`when`), and `remove()` takes it out of the bar:
```php
// About called Info, and Following out of the bar.
function my_plugin_profile_tab_changes( $ui ) {
$ui->change( 'profile.tabs', 'about', array( 'label' => __( 'Info', 'my-plugin' ) ) );
$ui->remove( 'profile.tabs', 'following' );
}
add_action( 'poly_community_register_ui', 'my_plugin_profile_tab_changes' );
```
A tab of the community taken out of the bar is hidden, not closed: its page still answers at its address. What a page shows and to whom is set in Settings and by the privacy choices of each member. To rename a tab without code, [Settings → Words](https://www.poly-community.com/docs/settings/words/) gives any text of Poly Community words of the site own.
## A tab for some readers alone
`who` keeps a tab from the readers its rule leaves out, its page too: for them the bar leaves it out and its address is not found, from the one registration.
```php
// A Drafts tab for the member on their own profile alone.
function my_plugin_drafts_tab( $ui ) {
$ui->add( 'profile.tabs', 'my-plugin-drafts', array(
'label' => __( 'Drafts', 'my-plugin' ),
'slug' => 'drafts',
'who' => 'own',
'page' => array( 'render' => 'my_plugin_drafts_page' ),
) );
}
add_action( 'poly_community_register_ui', 'my_plugin_drafts_tab' );
function my_plugin_drafts_page( $profile ) {
return '
What you have not published yet, seen by you alone.
';
}
```
`own` is the member on their own profile and no one else. A tab for the team of the community is `array( 'roles' => array( 'moderator', 'staff' ) )`, and [Who sees it](https://www.poly-community.com/docs/developers/buttons-and-menus/#who-sees-it) lists every rule. A tab whose rule a page file cannot settle for all its readers keeps its page out of the file, drawn for each reader instead.
(Screenshot: A member on their own profile: Edit profile, then Add a project boxed in red, and a Drafts tab boxed in red. A member on their own profile: a Drafts tab and an Add a project button, which no one else sees.)
## A tab on every space
The place `space.tabs` the same way, and its page is shown to those who may see what the space holds, as the other tabs of a space are:
```php
function my_plugin_resources_tab( $ui ) {
$ui->add( 'space.tabs', 'my-plugin-resources', array(
'label' => __( 'Resources', 'my-plugin' ),
'slug' => 'resources',
'page' => array( 'render' => 'my_plugin_resources_page' ),
) );
}
add_action( 'poly_community_register_ui', 'my_plugin_resources_tab' );
function my_plugin_resources_page( $space ) {
return '
Links and files the space keeps for its members.
';
}
```
The tabs of Poly Community on a space are `posts`, `members` and `about` (About first for a space without its feed), then those of the components by their slug, such as `leaderboard`.
`poly_community_profile_tabs`, the filter before the registry, still works after it, with a deprecation notice, for at least two releases. `poly_community_space_tabs` and the two page filters, `poly_community_space_tab_markup` and `poly_community_profile_tab_markup`, are still supported with no notice: the registry is the way for new code, and they will be deprecated in a later release, once Better Messages has moved to it. A space is a group in other plugins, and every kind of space a component adds (a course, an organization) has the same bar.
(Screenshot: The head of a space, Trail Runners, with its tabs: Posts, Members, About and Resources (shown), Resources boxed in red. A Resources tab added to every space.)
## A tab from a component
A [component](https://www.poly-community.com/docs/developers/components/) declares its tabs in its `kit.json`, each a tab of the registry by its slug, standing `after` or `before` the tab it names or with the rest, shown to whom its `who` says, and keeps its page as a template of its own, `templates/profile-{slug}.html` or `templates/space-{slug}.html`:
```json
"tabs": {
"profile": [ { "slug": "learning", "label": "Learning", "after": "about" } ],
"space": []
}
```
The tab shows while the component is on. A method `kit_tab( $tab, $where, $object )` on the component class changes its tab as drawn: it is given `array( slug, label, url )` and answers it with a count or other words, or null to leave it out there. To show it on some profiles or spaces only (spaces of one type, members of one type), use `poly_community_kit_tab_shown` too:
```php
function my_plugin_kit_tab_shown( $shown, $kit, $where, $tab, $object ) {
// $where is profile or space, $object the profile or the space.
return $shown;
}
add_filter( 'poly_community_kit_tab_shown', 'my_plugin_kit_tab_shown', 10, 5 );
```
A tab that only the member whose page it is sees (Listings, for a member who may list and has none out) is drawn in the page file for every reader, so the member page moves from its file for them as for anyone. Show it in a file (`Poly_Community_Json_Moves::for_all()`) where its member would see it, and answer it from `kit_tab()` with the readers it is for, `for`, as [`for_readers()`](https://www.poly-community.com/docs/developers/page-moves/) takes them:
```php
public function kit_tab( $tab, $where, $profile ) {
if ( 'profile' === $where && $this->only_its_member_sees( $profile ) ) {
$tab['for'] = 'own:' . Poly_Community_Json_Moves()->subject_mark( 'profile', (int) $profile->id );
}
return $tab;
}
```
A tab with `for` is left out of what makes member pages alike. A tab shown to some readers without it makes their member pages move by their HTML.
A slug of the community (`posts`, `about`, `members`, `followers`, `following`, `friends`, `connections`) is never taken by a component.
## Other tab bars
Two more tab bars are places of the registry, a tab there taking the same keys:
| Place | Tabs | Ids of Poly Community |
|---|---|---|
| `space.settings` | The settings of a space, for whoever runs it | `general` (the page itself), `privacy`, `posts`, then those of the components (`place`, `auto`) |
| `settings.tabs` | Edit profile, of the reader | `profile` (the page itself), `notifications`, `privacy`, `account`, then those of the components (`billing`, `requests` and the others). Unlike a profile tab, one taken out is closed: its address answers 404. |
The tabs of the members directory are links that narrow it, with no page of their own: the place `members.tabs`. Its ids of Poly Community are `discover`, `friends` and `following`, then a tab for each member type that has one (`type-{slug}`). A tab of yours gives its `url`, `count` a number beside it, and it is the tab of the page where the address asked has every part of the query of its `url`:
```php
function my_plugin_members_tabs( $ui ) {
$ui->add( 'members.tabs', 'my-plugin-nearby', array(
'label' => __( 'Nearby', 'my-plugin' ),
'url' => Poly_Community()->routes->members_url( array( 'show' => 'nearby' ) ),
'after' => 'discover',
'who' => 'members',
) );
}
add_action( 'poly_community_register_ui', 'my_plugin_members_tabs' );
```
`poly_community_members_tabs`, the filter before the registry, still works after it, with a deprecation notice, for at least two releases.
Two more each have a filter of their own, not on the [stable list](https://www.poly-community.com/docs/reference/):
| Tabs | Filter | Each tab |
|---|---|---|
| My items, for a kind of item | `poly_community_my_items_tabs( $tabs, $kind )` | key ⇒ `label`, `where` and `order` (SQL on the items `i`), `none`, `empty` |
| A tag | `poly_community_tag_tabs( $tabs, $tag )` | slug ⇒ `label`, `kinds` (type ids), `look` (`posts`, `topics` or `questions`) |
## An item in the community menu
The place `nav` of the registry is the default community menu:
```php
function my_plugin_nav_items( $ui ) {
$ui->add( 'nav', 'my-plugin-help', array(
'label' => __( 'Help', 'my-plugin' ),
'icon' => 'question',
'url' => home_url( '/help/' ),
) );
}
add_action( 'poly_community_register_ui', 'my_plugin_nav_items' );
```
The menu shows it while the site keeps the default menu. Once the owner saves a menu of their own under **Settings → Appearance → Menus**, that menu is what shows, and the item is one of the pages offered there to add. It is the item of the page shown where its address is the address of that page.
The ids of Poly Community there are `home` (or `activity` where the home is the feed), `activity`, `members`, `spaces` and `profile`, then the pages of the components: `forum`, `questions`, `help`, and `kit-{view}` for each page a component names in its `nav`. An item there takes the keys of an item ([An item in a ⋯ menu](https://www.poly-community.com/docs/developers/buttons-and-menus/#an-item-in-a--menu)), and `count` gives it a number.
## An item in the member menu
The place `account` is the menu under the picture of the member. A visitor has no picture there, and sees the items of that menu as links beside Log in, so an item for members alone says so with `who`:
```php
function my_plugin_account_items( $ui ) {
$ui->add( 'account', 'my-plugin-billing', array(
'label' => __( 'Billing', 'my-plugin' ),
'icon' => 'wallet',
'url' => home_url( '/billing/' ),
'who' => 'members',
) );
}
add_action( 'poly_community_register_ui', 'my_plugin_account_items' );
```
The ids of Poly Community there are `profile`, `settings`, `my-spaces` and `saved`, then the pages of the components whose place is that menu. These two menus are drawn for their reader, never from a page file, so `who` there may use any rule, and `note` puts a second line under the label.
An icon is the name of one of the icons of Poly Community: `question`, `wallet`, `calendar`, `star`, `users`, `globe` and the others the community uses. A page of a component goes in the menus by its `nav` in `kit.json` instead ([Building a component](https://www.poly-community.com/docs/developers/components/)).
`poly_community_account_items`, the filter before the registry, still works after it, with a deprecation notice, for at least two releases. `poly_community_nav_items` is still supported with no notice: the registry is the way for new code, and it will be deprecated in a later release, once Better Messages has moved to it.
The buttons at the foot of the community menu, where it is a column (Live chat of Live Support), are the place `nav.foot`: an item there runs its `action` on a press, with its `data`.
For the buttons of a profile, a space and a post, and the items of their ⋯ menus, see [Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/).
See also [Changing a component](https://www.poly-community.com/docs/developers/changing-components/), [Page moves](https://www.poly-community.com/docs/developers/page-moves/) and [Hooks of the components](https://www.poly-community.com/docs/reference/component-hooks/).
---
# Buttons and menus
Address: https://www.poly-community.com/docs/developers/buttons-and-menus/
A profile and a space each have buttons in their head (Follow, Message, Join, Share) and a ⋯ menu beside them. A post has a ⋯ menu beside its author and a row of buttons under it (Like, Reply, Share). A plugin adds its own to each of them, moves those of Poly Community and takes them out.
**[Download the example plugin](pathname:///downloads/poly-community-tweaks.zip)** (Tweaks for Poly Community, the plugin of [Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/)). Everything on this page is in it, and the tests of Poly Community run it as a site owner installs it. In each picture, a red box marks the change it shows. Changes the example makes elsewhere on the same screen, such as its tabs, are left unboxed.
(Screenshot: The head of a member profile with a Projects button, boxed in red, before its ⋯ menu. A Projects button added to the head of every profile.)
## One rule for all of it
A profile page and the cards of a list are drawn once and kept as a page file, which pages move to without a reload. A file serves every reader of a kind. So an item of a menu says who sees it with a rule, `who`, which Poly Community settles wherever the item is drawn, and a button of your own in a head checks its reader only as [Who sees it](#who-sees-it) says.
- **Name the member by their address.** In an item, `{url}` is the address of the profile, the space or the post it is for, and `{url:enc}` the same address encoded for the query of a link. In a block of your own, `Poly_Community()->routes->profile_url( $profile )`. The file the member pages share holds those for each member in turn. A number of your own in an attribute or a query would carry the first member to all the others.
- **Never name the reader in a label.** A page whose file names its reader is not kept as a file (many an administrator is called admin), and it moves by its HTML.
Each hook below takes a named function, never an anonymous function, so another plugin can take it off again with `remove_action()` or `remove_filter()`.
## A button in the head of a profile or a space
The buttons of a head are blocks of its template:
| Head | Its blocks, in their order |
|---|---|
| A profile | `edit-profile-button`, `follow-button`, `message-button`, `call-button` (video, then audio), `profile-menu` (the ⋯) |
| A space | `join-button`, `space-invite-button`, `space-manage-button`, `space-chat-button`, `share-button`, `space-menu` (the ⋯) |
Each is `poly-community/` and its name. With a block theme, a site owner moves or removes them in **Appearance → Editor**, in the templates of the community.
A plugin adds a button as a block of its own, and puts it next to one of these with [Block Hooks](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#block-hooks), `blockHooks` in its `block.json`. It lands there under a block theme and under a classic theme alike:
```json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "poly-community-tweaks/projects-button",
"title": "Projects button",
"category": "widgets",
"supports": { "html": false },
"blockHooks": { "poly-community/profile-menu": "before" },
"textdomain": "poly-community-tweaks",
"render": "file:./render.php"
}
```
```php
routes->current()['profile'] ?? null;
if ( ! $poly_tweaks_profile ) {
return;
}
?>
```
```php
function poly_community_tweaks_blocks() {
register_block_type( __DIR__ . '/blocks/projects-button' );
}
add_action( 'init', 'poly_community_tweaks_blocks' );
```
`Poly_Community()->routes->current()` gives the page shown, its `profile` or its `space`. The classes `poly-btn` and `poly-btn-secondary` draw it as the buttons beside it.
**List it for page files.** A block another plugin draws with its own code keeps a page out of its file, and the page moves by its HTML, still without a reload but slower. A block that draws only from the profile or the space shown, the same for every reader, says so:
```php
function poly_community_tweaks_move_blocks( $blocks ) {
$blocks[] = 'poly-community-tweaks/projects-button';
return $blocks;
}
add_filter( 'poly_community_json_move_blocks', 'poly_community_tweaks_move_blocks' );
```
**Take one out** by drawing its block as nothing:
```php
// The Share button of a space head, whose link the ⋯ menu copies instead.
function poly_community_tweaks_no_share_button( $html, $block ) {
return '';
}
add_filter( 'render_block_poly-community/share-button', 'poly_community_tweaks_no_share_button', 10, 2 );
```
## An item in a ⋯ menu
Every ⋯ menu and every row of buttons is a place of one registry. A plugin adds its items there, and moves or takes out those of Poly Community, on `poly_community_register_ui`:
| Place | Where | Ids of Poly Community, in their order |
|---|---|---|
| `profile.menu` | The ⋯ of a profile | `copy-link`, `report`, `mute`, `block`, and under Moderation (the group `moderation`) `suspend`, `edit-member`, `wordpress-user` |
| `space.menu` | The ⋯ of a space | `invite`, `members`, `delete`, `leave`, each where its reader may |
| `post.menu` | The ⋯ of a post | `edit`, `pin`, `save`, `hide-pin`, the items of the components (below), `copy-link`, `mute`, `report`, `hold`, `delete` |
| `post.actions` | The buttons under a post | `like`, `quote`, `reply-to`, `reply`, `share`, `solution`, `reactions` (who reacted), `views`. `quote`, `reply-to` and `solution` are in a topic of the forum. |
```php
// Projects after Copy profile link, Report moved to the end, Mute taken out.
function poly_community_tweaks_profile_menu( $ui ) {
$ui->add( 'profile.menu', 'tweaks-projects', array(
'label' => __( 'Projects', 'poly-community-tweaks' ),
'icon' => 'grid',
'url' => '{url}projects/',
'after' => 'copy-link',
) );
$ui->change( 'profile.menu', 'report', array( 'last' => true ) );
$ui->remove( 'profile.menu', 'mute' );
}
add_action( 'poly_community_register_ui', 'poly_community_tweaks_profile_menu' );
```
(Screenshot: The ⋯ menu of a profile: Copy profile link, Projects, Block, Report, with Projects and Report boxed in red. The ⋯ of a profile: Projects added, Report moved to the end, Mute taken out.)
| Method | What it does |
|---|---|
| `$ui->add( $place, $id, $item )` | Adds an item. Prefix its id with your plugin, as hooks are. An id there already is refused: change it instead. |
| `$ui->change( $place, $id, $keys )` | Changes keys of an item, yours or one of another plugin. Of an item of Poly Community: where it stands, its group, and `who`, which can hide it from more readers and never shows it to readers Poly Community leaves out. |
| `$ui->remove( $place, $id )` | Takes an item out. |
| `$ui->get( $place, $id )` | The item as registered, or null. |
The components of Poly Community register theirs first, so a plugin at the default priority finds every item. A key an item does not have, an id there already or an item with no label is refused with a notice.
An item says what it is:
| Key | What |
|---|---|
| `label` | Its words. |
| `icon` | A name from [Icons](https://www.poly-community.com/docs/reference/icons/) (`link`, `grid`, `external` and the others), a name of your own, or a whole SVG ([Icons](#icons) below). |
| `url` | A link, which may hold the address of the profile, space or post it is for, `{url}`, and its `{id}`, `{handle}` (a profile) or `{slug}` (a space), each with `:enc` for the query of a link (`{url:enc}`). |
| `for` | A named function given the profile, space or post, where those are not enough: it answers what the item is for it, an array of `label`, `url`, and `data` values for the names the item has. |
| `target` | `_blank` opens the link in a new tab. |
| `action` | An [Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/) action of your own store run on a press, `my-plugin::actions.open`. The item says what it is for in `data-poly-subject` (`profile:12`, `space:4`, `item:310`), `data-poly-place` and `data-poly-ui` (its id), and a menu closes as it is pressed. |
| `command` | A command of Poly Community by its name: `copy-link` copies the `url` of the item and says so. |
| `data` | Its `data-` attributes, name ⇒ a string, which may hold the same as `url`. |
| `first`, `last`, `after`, `before` | Where it stands: first, last, or next to another by its id. |
| `group` | `moderation` puts it under Moderation in the ⋯ of a profile. |
| `who` | Who sees it ([Who sees it](#who-sees-it)). Everyone when left out. |
| `when` | A named function given the profile, space or post: whether the item is there for it (a post with a price, a space of a type). It reads that alone, never the reader. |
| `danger` | Drawn in red, for what cannot be undone. |
Where an item stands is worked out once for every reader, before any item is left out, so it stays next to the one it names even where that one is not shown. `first` and `last` work as if each item were put there in turn: a `first` added later stands before one added earlier. An id that is not there (its plugin turned off) counts as none given.
The example copies the address of a space with a command of Poly Community, first in the menu, with an icon of its own ([Icons](#icons)):
```php
function poly_community_tweaks_space_menu( $ui ) {
$ui->add( 'space.menu', 'tweaks-copy-link', array(
'label' => __( 'Copy space link', 'poly-community-tweaks' ),
'icon' => poly_community_tweaks_link_svg(),
'command' => 'copy-link',
'url' => '{url}',
'first' => true,
) );
}
add_action( 'poly_community_register_ui', 'poly_community_tweaks_space_menu' );
```
The items the components add to the ⋯ of a post stand after `hide-pin`, each by its id: `life` (Renew and End now), `feature`, `close` (a question), `tip`, `live-end`, `writer` (a post of an organization), `album-edit` and `rating`. Move or take out any of them as one of Poly Community.
## Icons
The `icon` of an item or of a button under a post is one of three, each drawn 18 px in the colour of its words:
**A name of Poly Community.** [Icons](https://www.poly-community.com/docs/reference/icons/) shows every one with its name. Most come from the icons file every page keeps, so they cost a page nothing.
**A name of your own**, added on `poly_community_register_icons` with `$icons->add()`: the shapes of an icon on a grid of 24 by 24, drawn as lines, with a label and a group of the icon pickers of Settings. A shape drawn filled takes `fill="currentColor"`. It joins the icons file, and every item and button takes it by its name. A whole SVG may have a name too:
```php
function poly_community_tweaks_icons( $icons ) {
$icons->add( 'tweaks-notes', '', array(
'label' => __( 'Notes', 'poly-community-tweaks' ),
'group' => 'work',
) );
$icons->add( 'tweaks-link', poly_community_tweaks_link_svg(), array( 'label' => __( 'Link', 'poly-community-tweaks' ) ) );
}
add_action( 'poly_community_register_icons', 'poly_community_tweaks_icons' );
```
**A whole SVG**, as an icon set gives it, any `viewBox`. It is drawn in place, its shapes kept (`path`, `circle`, `ellipse`, `rect`, `line`, `polyline`, `polygon` and `g`) and anything else taken out, such as a script, a style or a link. It fills in the colour of the words unless it says otherwise:
```php
function poly_community_tweaks_link_svg() {
return '';
}
```
A name of your own is the lighter choice for an icon shown on many items at once, a whole SVG the quicker one for an icon from another set. A name there is none of draws no icon. In a block of your own, such as a button in a head, write the SVG in its markup, or print a name with `poly_the_icon( 'tweaks-notes', 18 )`. [Icons](https://www.poly-community.com/docs/reference/icons/#add-your-own) says what a name of your own may hold.
## The ⋯ of a post, and the buttons under it
A post is drawn by itself on its page, and from its row in the cards of a list (the feed, a space, a profile), where the menu and the buttons are a template drawn once for every post of the page. One registration serves both. A `url` with `{url}`, and what `for` and `when` answer, are worked out for each post on the server and travel with its row. `who` is settled for each reader in the browser.
```php
// Copy link first, then Open in a new tab, for members alone.
function poly_community_tweaks_post_menu( $ui ) {
$ui->change( 'post.menu', 'copy-link', array( 'first' => true ) );
$ui->add( 'post.menu', 'tweaks-open', array(
'label' => __( 'Open in a new tab', 'poly-community-tweaks' ),
'icon' => 'external',
'url' => '{url}',
'target' => '_blank',
'who' => 'members',
'after' => 'copy-link',
) );
}
add_action( 'poly_community_register_ui', 'poly_community_tweaks_post_menu' );
```
(Screenshot: The ⋯ menu of a post: Copy link and Open in a new tab boxed in red, then Edit post, the pins, Save, Turn off notifications and Delete post. The ⋯ of a post in a card: Copy link moved to the top, Open in a new tab added for members.)
A function given the post (`for`, `when`) reads the post alone. What it answers is the same for every reader, so it travels with the row to all of them.
The buttons under a post are the place `post.actions`, and an item there is drawn as the buttons beside it:
```php
// Share before Reply, an Open button after Reply, and the views taken out.
function poly_community_tweaks_post_actions( $ui ) {
$ui->change( 'post.actions', 'share', array( 'before' => 'reply' ) );
$ui->remove( 'post.actions', 'views' );
$ui->add( 'post.actions', 'tweaks-open', array(
'label' => __( 'Open', 'poly-community-tweaks' ),
'icon' => 'external',
'url' => '{url}',
'after' => 'reply',
) );
}
add_action( 'poly_community_register_ui', 'poly_community_tweaks_post_actions' );
```
(Screenshot: A post in the feed with Like, Share, Reply and Open under it, Share and Open boxed in red. The buttons under a post: Share moved before Reply, Open added, the views taken out.)
## Who sees it
`who` says who sees an item, and Poly Community settles it wherever the item is drawn: in PHP for a page drawn for its reader, when a page file is made for what all its readers answer alike, and in the browser, from the facts of the reader and the row of the post, for the rest. So an item holds in every page file and every list without a check of your own.
| `who` | Who sees it |
|---|---|
| `everyone` | Everyone, as when it is left out. |
| `visitors` | Those not logged in. |
| `members` | Those logged in. |
| `own` | The member on their own profile or their own post, and no one else. |
| `type:{slug}` | The members of a member type, as Menus saves it. |
| A rule, `array( 'roles' => array( 'moderator', 'staff' ) )` | The rule the "Who may" settings of Poly Community save, below. |
A rule lets the reader in by any of these:
| Key | Lets in |
|---|---|
| `roles` | Members with any of the roles: `member` (any member), `moderator` (the team of the community), `staff` (its staff), `admin`. With no key of this table given, `roles` is `member`. |
| `spaceRoles` | The `admin` or `moderator` of the space the post is in. |
| `own` | `true`: the member on their own profile or post. |
| `can` | Who has a right on it, below. |
Then it must meet each restriction it names: `trust` (a trust level at least, while the Trust levels component runs), `verified` (`identity`, `age`), and the parts the components add, `memberTypes` (slugs) and `plans` (ids). A part whose component is off lets no one through. **An administrator passes any rule written this way.** The word `own` alone lets in no one else, so an item with `'who' => 'own'` is the member alone, and `array( 'own' => true )` the member and the administrators.
`can` names a right on the post or the profile the item is for, the check its route runs:
| `can` | On | Who has it |
|---|---|---|
| `edit` | a post | Its author within the edit window, an administrator |
| `delete` | a post | Its author, whoever may act as its profile, an administrator, the team of its space |
| `hold` | a post | The team of its space, on a shown post another wrote |
| `report` | a post | A member, on what is neither theirs nor theirs to keep in order |
| `moderate` | a post | An administrator, or the team of its space on a post another wrote |
| `moderate` | a profile | An administrator, on a member who is not one |
A right on a post belongs to each reader alone, so a post page that holds an item with one is drawn for its reader rather than kept as a file: never wrong, a little slower. In the cards of a list the browser settles it from the row.
An item for the team of the community, under Moderation in the ⋯ of a profile:
```php
function poly_community_tweaks_team_item( $ui ) {
$ui->add( 'profile.menu', 'tweaks-notes', array(
'label' => __( 'Notes on this member', 'poly-community-tweaks' ),
'icon' => 'tweaks-notes',
'url' => home_url( '/team-notes/?member={url:enc}' ),
'who' => array( 'roles' => array( 'moderator', 'staff' ) ),
'group' => 'moderation',
) );
}
add_action( 'poly_community_register_ui', 'poly_community_tweaks_team_item' );
```
(Screenshot: The ⋯ menu of a profile as a moderator sees it, with Notes on this member under Moderation boxed in red. The ⋯ of a profile for the team: Notes on this member added under Moderation.)
An item settled in the browser is in the page of every reader of the page file or the list, hidden for those its rule leaves out. Its words, its link and its data must hold nothing for some readers alone: a secret belongs on the page the item opens.
**Showing is not a permission.** An item only shows. What it opens or does checks again on the server: a page of yours with `current_user_can()`, a REST route with its `permission_callback`.
### A button of your own for some readers alone: Shown to
A button in a head is a block of yours. Who sees it is its "Shown to": a block that asks for it in its block.json (`"supports": { "poly-community/who": true }`) takes the attribute `polyWho`, a `who` as an item takes it, which an owner sets in the editor, in the panel "Shown to". Poly Community settles it wherever the block is drawn: for the reader of the page, and in the browser where a page file serves many readers. `own` and the roles of a space read the profile or the space of the page. It never shows a block where the block itself draws nothing. The header buttons of Poly Community take it too.
A button in the head of a profile for its member alone is a block put after Edit profile (`"blockHooks": { "poly-community/edit-profile-button": "after" }`), which gives `polyWho` the default `own`:
```json
{
"name": "poly-community-tweaks/add-project-button",
"attributes": {
"polyWho": { "type": [ "string", "object" ], "default": "own" }
},
"supports": { "html": false, "poly-community/who": true },
"blockHooks": { "poly-community/edit-profile-button": "after" },
"render": "file:./render.php"
}
```
Its `render.php` draws from the profile shown, and leaves the reader to the rule:
```php
routes->current()['profile'] ?? null;
if ( ! $poly_tweaks_profile ) {
return;
}
?>
```
List it for page files as the Projects button is: drawn as nothing in the file every other reader shares, it keeps their moves fast. A tab for the member alone is one registration with `'who' => 'own'`, its address not found for others ([Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/#a-tab-for-some-readers-alone)).
(Screenshot: A member on their own profile: Edit profile, then Add a project boxed in red, and a Drafts tab boxed in red. A member on their own profile: Add a project and a Drafts tab added, which no one else sees.)
## Other buttons and menus
The rest are places of the same registry, each with the ids of Poly Community in it:
| Place | Where | Its own ids |
|---|---|---|
| `reply.menu` | The ⋯ of a reply, on its own and over every comment of a tree | `report`, `hold`, `delete` |
| `reply.actions` | The buttons of a reply | `like`, `reply`, `edit`, and of the components `writer` and `votes` |
| `topic.menu` | The ⋯ of a topic of the forum, its group `moderation` first | `pin`, `lock`, `move`, `copy-link`, `mute`, `report`, `delete` |
| `space.member` | The ⋯ of a member in the member list of a space, for those who may act on them. Its subject is the member, in the space of the list | `roles`, `owner`, `remove`, `ban` |
| `nav.foot` | The buttons at the foot of the navigation column, each opening something on the page with its `action` and its `data` | `live-chat` (Live Support) |
The actions `poly_community_reply_actions`, `poly_community_comment_template`, `poly_community_space_member_menu` and `poly_community_space_person_menu` of before still print, deprecated, for at least two releases.
Two are not places of the registry. Each takes what a plugin adds, and none moves or takes out what Poly Community draws there:
| Where | How a plugin adds to it |
|---|---|
| Join, in the head of a space and on its card | `poly_community_join_button( null, $space, $state, $card )` answers the HTML drawn in its place. |
| Message and the calls, in the head of a profile | Drawn by the messaging plugin (Better Messages) through `poly_community_messaging_message_button` and `poly_community_messaging_call_button`. |
In a head, any of these blocks is taken out with its `render_block_` filter, as above, or shown to some readers alone with its Shown to.
## What is stable
The registry is on the [stable list](https://www.poly-community.com/docs/reference/): `poly_community_register_ui` and its methods, the places and the ids of Poly Community in them, the keys of an item, the words and keys of `who`, the rights of `can`, the commands, the three attributes the browser reads, Shown to (`poly-community/who`, `polyWho`) and the icons ([What is stable](https://www.poly-community.com/docs/developers/#what-is-stable)). A change keeps the old way working and is written in the changelog. Block Hooks are of WordPress, and the blocks of Poly Community keep their names.
See also [Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/), [Changing a component](https://www.poly-community.com/docs/developers/changing-components/), [Page moves](https://www.poly-community.com/docs/developers/page-moves/) and [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/).
---
# Building a component
Address: https://www.poly-community.com/docs/developers/components/
A component is a folder with a manifest, `kit.json`, and a class in `kit.php`. Its pages, menu items, tabs on profiles and spaces, kinds of item, tables, blocks and settings are all declared there. Switched off, the whole component is gone from the site, and its data waits in its tables until it is switched on again. The components of Poly Community itself are made this way, in `kits/` of the plugin, and a plugin adds its own the same way.
The example here is a small one, Recipes: a page of its own, an item in the community menu, a tab on every profile, an item in the menu under the picture of each member, and a setting on its own page under Settings. From there, the last section says where each next step is.
**[Download the starter plugin](pathname:///downloads/poly-community-recipes.zip)** (Recipes for Poly Community, a zip to upload under Plugins → Add New Plugin → Upload Plugin). The code on this page is all of it. The plugin tests install it as a site owner would and check each step of this page on it (`examples/poly-community-recipes` in the plugin, checked by `tests/specs/component-guide.spec.ts`).
## Drawn from data, from the start
Every page of Poly Community is one static file of its type, the same for every reader, and one JSON answer a move asks for. The browser draws the page from the two, which is what keeps a site fast as it grows. A component keeps it page by page:
- What every reader sees is blocks, in its templates, the same in the file for everyone.
- What one reader sees or may do comes as data with the move, a part or a fact, never as HTML the server draws for that reader and never as a test of the reader in PHP. [Pages drawn from data](https://www.poly-community.com/docs/developers/data-driven-pages/) has the rules, the API and a recipe.
- `wp poly-community page-data check ` says for a visitor, a member and an administrator whether the page is one drawing, or the first reason it is not and what to change ([Checking a page](https://www.poly-community.com/docs/developers/data-driven-pages/#checking-a-page)).
Recipes is drawn from data as it is: its page and its tab are blocks, and its menu items are items of the registry with a `who` rule. The plugin tests check its page and a profile with its tab:
```bash
wp poly-community page-data check kit-example-recipes # kit-example-recipes: one drawing for every reader
wp poly-community page-data check profile # profile: one drawing for every reader
```
Run the check on every page you add or change, as each step below does.
## 1. The plugin
A plugin adds its component on `poly_community_register_kits`, by the folder that holds it:
```php
add( __DIR__ . '/example-recipes' );
}
add_action( 'poly_community_register_kits', 'poly_community_recipes_register' );
```
`Requires Plugins` makes WordPress ask for Poly Community first. Every hook and callback of a component is a named function or a public method of its class (`array( $this, 'ui' )`). Poly Community calls it from outside the class, an error names it, and another plugin can take a hook off again with `remove_action()` only when its callback has a name.
The folder ends up like this:
```
poly-community-recipes/
poly-community-recipes.php the plugin
example-recipes/
kit.json the manifest
kit.php its class, extending Poly_Community_Kit
templates/example-recipes.html its page, as blocks
templates/profile-recipes.html its tab on every profile, as blocks
```
A bigger component adds `schema.php` (its `CREATE TABLE` statements), `blocks//block.json` (one folder a block), `views/*.php` (printed with `$this->view()` and `$this->the_view()`) and `templates/card-.html` (the default blocks of each of its cards).
## 2. The manifest
```json
{
"slug": "example-recipes",
"title": "Recipes",
"description": "A page of recipes, an item in the community menu and a Recipes tab on every profile.",
"summary": "A page of recipes",
"icon": "book",
"group": "content",
"defaultOn": true,
"textDomain": "poly-community-recipes",
"needs": { "kits": [], "foundations": [], "sdk": [], "plugins": [], "cloud": false },
"views": {
"example-recipes": { "path": "recipes", "width": "list", "title": "Recipes" }
},
"nav": [ { "view": "example-recipes", "label": "Recipes", "icon": "book", "after": "members" } ],
"tabs": {
"profile": [ { "slug": "recipes", "label": "Recipes", "after": "about" } ],
"space": []
}
}
```
- `slug` names the component everywhere. `title`, `description`, `summary`, `icon` and `group` are how it shows under **Settings → Components**: `group` is `content`, `people`, `money`, `spaces` or `safety`, and `icon` a name from [Icons](https://www.poly-community.com/docs/reference/icons/).
- `defaultOn` switches it on once the plugin is active. Without it, the owner switches it on.
- `textDomain` is the text domain the words of the manifest are translated with: the title, the description and the labels of its pages, menu items and tabs. Without it they are looked up in that of Poly Community.
- `needs` names the components that come on with it, the parts of Poly Community and of the WordPlus SDK it uses, and the plugins it works with.
- `views` are its pages under the community home. `path` may hold `{id}` (an item of the kind `item` names, checked to be visible) or `{name}`. `width` is how wide the page is drawn (`list`, `feed` and the others its views use).
- `nav` puts its pages in the community menu, here after Members. `tabs` adds a tab to every profile or space ([A tab from a component](https://www.poly-community.com/docs/developers/tabs-and-menus/#a-tab-from-a-component)).
- `kinds`, `spaceTypes`, `notifications` and `trees` list what goes away with the component when it is off, and `tables` the tables it keeps.
- `actions` names its own actions, each held back like one of the community (`post`, `reply`, `react`, `join`, `upload`), so approval, profile requirements and verification hold them too.
## 3. Its pages and its tab
A page of a component is a block template, `templates/{view}.html`. `` puts the head of the page there, its title from the manifest:
```html
Recipes the members of this community cook and share.
```
A tab on every profile is a template of its own, `templates/profile-{slug}.html` (`space-{slug}.html` for a space):
```html
The recipes of this member show here.
```
Any block goes in them: those of WordPress, of Poly Community, or of your plugin. With a block theme, the site owner can change them in **Appearance → Editor** like any other page of the community. Pages of core blocks are kept as page files too, so a move to the page from anywhere in the community draws it with no page asked of the server.
## 4. The class
The class is named after the slug (`Poly_Community_Kit_` and the slug in words), or named by `class` in the manifest. `boot()` adds its hooks once a request, only while the component is on. Here it adds a setting of its own and puts one item in the member menu, under the picture of the member, through the registry of buttons, menus and tabs:
```php
final class Poly_Community_Kit_Example_Recipes extends Poly_Community_Kit {
public function boot() {
add_action( 'poly_community_register_settings_rows', array( $this, 'settings' ) );
add_action( 'poly_community_register_ui', array( $this, 'ui' ) );
}
// An item in the member menu, linking to the page of the component. A visitor sees the items of that menu as links
// beside Log in, so it says it is for members.
public function ui( $ui ) {
if ( ! $this->setting( 'memberMenu' ) ) {
return;
}
$ui->add( 'account', 'example-recipes-add', array(
'label' => __( 'Add a recipe', 'poly-community-recipes' ),
'icon' => 'book',
'url' => Poly_Community()->kits->view_url( 'example-recipes', 'example-recipes' ),
'who' => 'members',
) );
}
}
```
`boot()` runs before `init`, so anything that translates a text or reads a setting goes in a hook that runs later, as `ui()` does here, or in `after_init()`. Every component gets `setting()`, `view()`, `the_view()`, `register_job()` and `item_of()` from `Poly_Community_Kit`.
The address of the page comes from `Poly_Community()->kits->view_url()`. A site may run the community at its root, and the owner may give a page another word under **Settings → Pages and addresses**, so an address written by hand breaks. Who sees the item is its `who` rule, which Poly Community settles for each reader, as a page is kept as a file for every reader of a kind ([Who sees it](https://www.poly-community.com/docs/developers/buttons-and-menus/#who-sees-it)). A test of the reader in PHP would draw the file for the first reader only.
## 5. Its settings
A component keeps its settings on its own page under **Settings → Components**, `features/{slug}`. It adds them on `poly_community_register_settings_rows`, a card with `add_section()` and its rows with `add()`, and reads each with `$this->setting( $key )`, which gives the default until the owner saves another:
```php
// Its settings: a card on its own page under Settings, Components, whose values $this->setting() reads.
public function settings( $rows ) {
$rows->add_section( array(
'id' => 'example-recipes-menu',
'page' => 'features/example-recipes',
'owner' => 'example-recipes',
'title' => __( 'The member menu', 'poly-community-recipes' ),
) );
$rows->add( array(
'key' => 'memberMenu',
'page' => 'features/example-recipes',
'section' => 'example-recipes-menu',
'owner' => 'example-recipes',
'type' => 'toggle',
'label' => __( 'Add a recipe in the member menu', 'poly-community-recipes' ),
'description' => __( 'An item under the picture of each member that opens the page of recipes.', 'poly-community-recipes' ),
'default' => true,
) );
}
```
(Screenshot: Settings, Components, Recipes: its switch under On this site, then the card The member menu with the switch Add a recipe in the member menu. Settings → Components → Recipes.)
`owner` is the slug of the component, so the row shows and saves only while the component is on, and its value is kept with the component. [Settings rows](https://www.poly-community.com/docs/developers/settings-rows/) has every type of row and how to put one on another page of Settings.
## 6. Trying it
Activate the plugin on a copy of your site. Recipes is then under **Settings → Components** with the others, switched on, with its switch and its card of settings on its page there. On the site:
- **Recipes** is in the community menu after Members, and its page answers at `/community/recipes/` (or wherever the community and the word for the page are).
- Every profile has a **Recipes** tab after About.
- A member finds **Add a recipe** in the menu under their picture. A visitor does not see it among the links beside Log in. With **Add a recipe in the member menu** switched off on its page, the item is gone from the menu.
- Switched off under Settings → Components, its page answers 404, and its menu item and tab are gone.
The same with WP-CLI:
```bash
wp plugin activate poly-community-recipes
wp eval 'echo Poly_Community()->kits->view_url( "example-recipes", "example-recipes" );'
curl -s -o /dev/null -w '%{http_code}\n' "$(wp eval 'echo Poly_Community()->kits->view_url( "example-recipes", "example-recipes" );')"
```
The first `wp eval` prints the address of its page, and `curl` answers 200 while the component is on, 404 once it is off. Then the check of [Drawn from data, from the start](#drawn-from-data-from-the-start) on its page and on a profile.
## Where to go from here
| Next | Where |
|---|---|
| A kind of item with fields of its own, as events and jobs have | [Kinds of item](https://www.poly-community.com/docs/developers/kinds/) |
| What one reader sees, as a part or a fact | [Pages drawn from data](https://www.poly-community.com/docs/developers/data-driven-pages/) |
| Its own table and blocks, drawn from data and updated live | [Building for instant pages and live updates](https://www.poly-community.com/docs/developers/instant-and-live/), with the Rooms example plugin |
| More tabs, buttons and menu items, for some readers alone | [Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/), [Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/) |
| Who may do what | [What you can build](https://www.poly-community.com/docs/developers/what-you-can-build/), item 3 |
| How wide its pages are drawn and the widgets beside them | [Templates and themes](https://www.poly-community.com/docs/developers/templates/) |
| Its words in other languages | [Translating](https://www.poly-community.com/docs/developers/translating/) |
| Changing a component that is there | [Changing a component](https://www.poly-community.com/docs/developers/changing-components/) |
A block of a component is a WordPress block: a [block.json](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/) with `"supports": { "interactivity": true }`, its markup drawn with the directives of the [Interactivity API](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/), and its script a [script module](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#view-script-module). See [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/).
See also [What you can build](https://www.poly-community.com/docs/developers/what-you-can-build/) and the [Reference](https://www.poly-community.com/docs/reference/).
---
# Kinds of item
Address: https://www.poly-community.com/docs/developers/kinds/
Everything members write is an item, and every item has a kind: a post, a reply, a forum topic, a question and its answers, an event, a job, a listing. The components register their kinds the same way your plugin does, on `poly_community_register_post_kinds`:
```php
function my_plugin_post_kinds( $kinds ) {
$kinds->register( 'recipe', array(
'label' => _x( 'Recipe', 'Post kind', 'my-plugin' ),
'plural' => _x( 'Recipes', 'Post kind', 'my-plugin' ),
'icon' => 'book',
'title' => array( 'mode' => 'required', 'min' => 3, 'max' => 120 ),
'carries' => array( 'pictures' ),
'feeds' => array( 'home', 'all', 'space', 'profile' ),
'replies' => 'comment',
) );
}
add_action( 'poly_community_register_post_kinds', 'my_plugin_post_kinds' );
```
A kind is kept as a row of its own the first time it is registered, so posts of it keep their kind while the code that registered it is away.
## Its arguments
These arguments are stable:
| Argument | Meaning |
|---|---|
| `label`, `plural`, `icon` | Its names and its icon. |
| `title`, `body` | Whether it has a title (`none`, `optional`, `required`, or a rule with `mode`, `min` and `max`) and words. |
| `carries` | The attachments it may carry, or `*` for all of them. |
| `fields` | Its fields, kept with the profile fields and edited under Settings. |
| `replies` | The kind of its replies, or `false` for none. |
| `feeds` | The feeds it shows in (`home`, `all`, `space`, `profile`), read while the Community component runs. An empty list for none. |
| `written` | Where it is written: `composer`, `own` (its own form) or `elsewhere`. |
| `can` | The action its writing needs, which access rules and requirements hold back. |
| `space_types` | The space types it may be posted in. |
| `grants` | Whether it may be shared with chosen members. |
| `counted` | Whether it counts among the posts of its author and its space. |
| `grants_told` | Whether members it is shared with are told. |
| `votes`, `lifetime`, `review`, `sells`, `contact`, `stats`, `alerts` | What a component turns on for it: votes, a life with an end, approval before publishing, paid posting, ways to reach its owner, views, saved searches. |
## Writing and reading items
`Poly_Community()->items` writes and reads items of every kind: `create()`, `get_item()`, `update()`, `delete()` and `data()`. The composer reaches them through the REST route `poly-community/v1/items`, which first asks whether the member may write there. Code that calls `create()` itself asks `Poly_Community()->access` first.
Whether someone may see an item is `Poly_Community()->access->can_see_item()`. Ask it rather than reading an item visibility yourself: spaces, blocks between members, plans and the components all have a say.
---
# Lists
Address: https://www.poly-community.com/docs/developers/lists/
A list is the ids a part of a page draws, in order, with what the browser needs to draw more of it and to place a new one. It lives in the page state by its key (`state.lists['rooms:1']`), beside the rows it names (`state.rows.room[12]`). The server puts it there on a whole load. The browser asks it as JSON after a move from a page file, after an event that changes it, and for its next page. One kind of list is registered once, and every list of it is named by a key.
For the whole path of a part drawn from data, see [Building for instant pages and live updates](https://www.poly-community.com/docs/developers/instant-and-live/).
## Registering a kind
```php
function my_rooms_lists( $live ) {
$live->register_list( 'rooms', array(
'args' => array(
'space' => array( 'type' => 'integer', 'minimum' => 0, 'default' => 0 ),
'page' => array( 'type' => 'integer', 'minimum' => 1, 'maximum' => 50, 'default' => 1 ),
),
'list' => 'my_rooms_list',
'key' => 'my_rooms_key',
'rows' => 'my_rooms_rows',
) );
}
add_action( 'poly_community_register_lists', 'my_rooms_lists' );
function my_rooms_key( $rest ) {
$bits = explode( ':', (string) $rest );
return array( 'space' => absint( $bits[0] ?? 0 ), 'page' => max( 1, absint( $bits[1] ?? 1 ) ) );
}
function my_rooms_rows( $ids, $request ) {
foreach ( $ids as $id ) {
my_rooms_build_row( my_rooms_get( (int) $id ) ); // the row type builder, as Live updates in code has it
}
}
```
- **`list( $args )`** puts the rows of the list for its reader and returns its shape (below), null for nothing there, or a `WP_Error`. It is the same function the block calls on a whole load, so both draw alike.
- **`args`** are its query arguments as REST schemas. What is not in them is not passed on.
- **`key( $rest )`** turns what follows `rooms:` in a key into its arguments, or null for a key it does not know. A page file names its lists by key, and the browser asks them by key.
- **`rows( $ids, $request )`** puts the rows of those ids, for a row read again after an event or a press. A kind may have `rows` alone, as the core `members` kind does.
The kind is read at `GET /wp-json/poly-community/v1/lists/rooms` with its arguments, `GET lists/rooms?ids=1,2` for rows, and many lists at once with `GET lists?keys=rooms:0:1,rooms:12:1`, as a page from its file asks them in its one request. Each answer holds the list and its rows (`data`), in the shape of the page state.
## The shape of a list
```php
array(
'ids' => array( 12, 7, 3 ), // in the order drawn
'type' => 'room', // the row type its ids are of
'more' => true, // whether a next page exists
'page' => 1,
'args' => $args, // what it was read with, asked again with
// Optional:
'events' => 'room.created room.deleted:space=12',
'reads' => array( 'room.updated' ),
'min' => 30,
)
```
- **`events`** names the events the list follows (a room added, one gone). An event about the reader asks the whole list again: their own change, made on this page or in another tab, or a kind told to them alone. A change by anyone else asks nothing. The list stays as drawn under the reader, so it never shifts while they read it, and shows the change on their next move. A `.deleted` event of a row the list shows is the one exception: the row leaves at once.
- **`reads`** names the events that change one of its rows, the one whose id the event names as `id`. When the event carries that row in the type of the list (the row type `events`, see [Instant and live](https://www.poly-community.com/docs/developers/instant-and-live/)), the row is written in place and nothing is asked. Otherwise an event about the reader reads the row again through the kind `rows`, batched, one request at a time for a page, and a change by anyone else shows on the next move of the reader.
- **`min`** is how often at most, in seconds, an event about the reader asks the list again.
A list follows the realtime connection where the site has one and the poll where it has not. Either way, only the events of the reader make it ask, so a page open for hours costs the server nothing for the changes of others.
### How events are named
A declaration is tokens separated by spaces. A token is an event type (`room.created`), or a type and what its payload must hold: `key=value` pairs separated by commas (`room.deleted:space=12`), or a word alone for the payload `change` or `kind` (`item.changed:pinned`). Where the payload holds a list, a value matches when one of its entries is that value.
## Drawing a list
On a whole load the block puts the list. While a page file is drawn, it names it alone. The same markup draws it either way, from the state:
```php
$lists = Poly_Community_Address_Lists();
$slot = $lists->new_slot();
$key = 'rooms:' . (int) $space . ':1';
if ( ! $lists->is_skeleton() ) {
$list = my_rooms_list( array( 'space' => (int) $space, 'page' => 1 ) );
if ( $list ) {
Poly_Community()->live_data->put_list( $key, $list );
}
}
$lists->state();
wp_interactivity_state( 'poly-community', array( 'tileKeys' => array( $slot => $key ) ) );
```
A list is named by its slot in `tileKeys`, which a page file and its one request read. A list whose every row is one part of trusted HTML (`html.row` in its row) draws with the core getters, before any script of yours has loaded:
```html
```
Read nothing else of the moment while a file is drawn: a row, a part or a list put then refuses the drawing, and the page moves by its HTML. `/?poly_moves_made=1` says what it read.
## A list of posts through a component card
A list of posts drawn through a component own card (a roadmap column, an events list) does not register a kind: it goes through the core item list, which names itself in a page file. The component answers which posts it holds:
```php
function my_rooms_news_list( $found, $source, $args ) {
if ( 'my-rooms-news' !== $source ) {
return $found;
}
return array(
'ids' => my_news_ids( $args ),
'more' => false,
'total' => my_news_total( $args ),
'events' => 'item.created:room_news item.deleted',
);
}
add_filter( 'poly_community_item_list', 'my_rooms_news_list', 10, 3 );
```
It may also say `ids_only` (of its `events`, those that count only for a post it shows), `min`, `words` (its words by name, drawn with it) and `heads` (a heading before a card, by its id).
## What is stable
`poly_community_register_lists` and `register_list()` are on the stable list ([What is stable](https://www.poly-community.com/docs/developers/#what-is-stable)). The shape of a list, its event declarations, `tileKeys`, the core getters and `poly_community_item_list` are not on it yet.
See also [Live updates in code](https://www.poly-community.com/docs/developers/live/), [Moving between pages](https://www.poly-community.com/docs/developers/page-moves/) and [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/).
---
# Payment gateways
Address: https://www.poly-community.com/docs/developers/payment-gateways/
Poly Community takes payments through the payments part of the WordPlus SDK, which carries Stripe, PayPal, Mollie, CCBill and bank transfer. Any other gateway is a plugin of its own that adds a **provider** to the part. Once added, it shows under **Settings → Services → Payments** beside the others, with its own settings, check and test payment, and every component that sells (plans, tickets, courses, the items of members) can sell through it. Nothing of Poly Community changes for it.
The money goes to the account of the site owner at the gateway. The part never reads what the gateway sends: your provider turns it into a few **normalized changes** (paid, failed, renewed, refunded…), and the part applies them once, checked against what it fixed for the order.
## Registering
```php
function mypay_payment_providers( $providers ) {
$pay = function_exists( 'wordplus_payments' ) ? wordplus_payments() : null;
if ( ! $pay || $pay->api() < 4 ) {
return $providers; // a part older than this provider: leave it out
}
require_once __DIR__ . '/class-mypay.php';
$providers['mypay'] = new MyPay_Provider(); // the id: [a-z0-9_-]{1,40}, stored on every row, never changed
return $providers;
}
add_filter( 'wordplus_payment_providers', 'mypay_payment_providers' );
```
- **Require the class inside the filter.** The part loads its base class, `WordPlus_SDK_Payment_Provider`, just before it runs the filter. A file that extends it at the top of your plugin would fail on a site where the part is not loaded yet.
- **Say the level you were written for** from `needs()` (4 today). On a site whose part is older, your provider is listed as waiting for an update and never called half.
- **The id is for good.** It is kept on every order and subscription.
## The class
```php
class MyPay_Provider extends WordPlus_SDK_Payment_Provider {
public function needs() { return 4; }
public function label() { return 'MyPay'; }
public function fields( $mode ) {
return array(
'api_key' => array( 'label' => 'API key', 'type' => 'secret' ),
'public_key' => array( 'label' => 'Public key', 'type' => 'text' ),
);
}
public function ready( array $settings, $mode ) {
return '' !== (string) ( $settings['api_key'] ?? '' );
}
public function capabilities() {
return array( 'one_time' => true, 'recurring' => true, 'refunds' => true, 'on_site' => true );
}
public function start( array $order, array $product, array $price, array $buyer, array $urls, array $settings ) { /* … */ }
public function verify_webhook( WP_REST_Request $request, array $settings, $endpoint = '' ) { /* … */ }
public function notices( WP_REST_Request $request ) { /* … */ }
public function resolve( array $notice, array $settings ) { /* … */ }
public function fetch_order( array $order, array $settings ) { /* … */ }
}
```
| Method | What it does |
|---|---|
| `fields( $mode )` | The settings of each mode (test and live). A `secret` field is sealed on the site and never shown again. |
| `validate( $name, $value, $mode )` | Refuses a value with words for the owner, such as a live key under test mode. |
| `ready( $settings, $mode )` | Whether the keys of a mode are there. No request. |
| `check( $settings, $mode )` | Rows for **Check**: what works and what is missing, in the words of your gateway. |
| `capabilities()` | What you can do (below). Everything you do not say is off. |
| `prepare( $product, $price, $settings )` | Makes a price at your gateway where it needs one first (plans for subscriptions). |
| `start( $order, $product, $price, $buyer, $urls, $settings )` | Begins a checkout: `url` (your page) or `mount` (your form on the site), with `session`. |
| `accepts( $price, $amount, $currency )` | Whether you can charge this amount in your own units (some gateways take whole units only for some currencies). Asked before you are offered at all. |
| `verify_webhook()`, `notices()` | Believes a notice (its signature, or by asking your API) and names the events in it. |
| `resolve( $notice, $settings )` | Asks your API for the object as it is now and answers **changes**. |
| `fetch_order()`, `fetch_subscription()` | The same, when the member comes back and on a schedule, so a lost notice changes nothing. |
| `refund()`, `cancel()` | Money given back, and a subscription cancelled (at the end of its period, or at once). |
| `pause()`, `resume()`, `undo_cancel()` | A subscription stopped for now and started again, and a cancel taken back, where you can. |
| `switch_plan( $subscription, $price, $timing, $urls, $settings )` | A member moves to another plan from **Billing** (below). |
| `dashboard( $kind, $ref, $mode )` | Your page of a payment or a subscription, for the **Open in** link an administrator sees. Never shown to members. |
| `unsupported()` | (Protected) the error to answer for something you cannot do, in the words of the site. |
## Capabilities
What you can do. Each one you leave out keeps its default, which is what every gateway did before it existed, so a gateway written earlier never has to say more.
| Capability | Default | Say it when |
|---|---|---|
| `one_time`, `recurring`, `custom` | off | You take one-off payments, subscriptions, an amount the buyer chooses. |
| `trials`, `refunds`, `partial_refunds`, `tax`, `promo_codes` | `refunds` on, the rest off | You do them by API. `refunds` off shows **Refund in the dashboard of your gateway** in place of Refund. |
| `currencies` | every one | A list of the currencies you take, in upper case. |
| `adult` | off | You accept adult content, for an 18+ site. |
| `portal` | off | You have a page where a buyer manages what they pay. Billing in the community never sends members there: it is for plugins that choose to. |
| `sellers` | off | Members sell on accounts of their own at your gateway, set up on its own pages. |
| `cancel_at_period_end` | on | Off where cancelling ends billing at once: give the subscription as `active` with `cancel_at_period_end` and its paid `period_end` until then. |
| `subscription_objects` | on | Off where renewals are payments and you have no subscription object to ask: you build each `subscription` change yourself from the payments you saw. |
| `verify` | `signature` | `fetch` where your notices carry no signature: a notice is then believed only by asking your API for every object it names. |
| `events` | off | You can list the events since a time, so the reconcile catches what a lost notice would have brought. |
| `choice_on_page` | off | The buyer picks the plan on your page: `start()` gets the other prices of the product, and your `order_paid` names the `price_id` taken. |
| `country_first` | off | You need the country of the buyer before a price (tax, local prices). |
| `portal_customer` | on | Off where your portal needs no customer kept on the site. |
| `manual` | off | An administrator confirms your payments (`mark_paid()`, `instructions()`). |
| `pause`, `undo_cancel` | off | You can stop charging for now, and take back a cancel at the end of the period. |
| `on_site` | off | The buyer can pay in your form on the payment page of the site (below). |
| `change_method` | off | A member can give a subscription another card from Billing (below). |
| `switch_plan` | none | A list of when a plan can change: `renewal`, `now`, or both (below). |
The **Ways to pay** screen, the choice of how to pay and Billing all follow them: a member is offered only what your gateway can do, and reads plainly what it cannot, with no way to your own pages.
## Changes
A change is an array with a `type` and the facts of it:
| Type | When |
|---|---|
| `order_paid` | Money taken, or nothing due (a free trial). Names the order, the amount, the currency and your references. |
| `order_processing` | A payment on its way (a bank debit that takes days). |
| `order_failed`, `order_expired` | Not paid. |
| `subscription` | The whole current state of a subscription: status, paid period, set to end or not. |
| `renewal_paid`, `renewal_failed` | A renewal. |
| `refund`, `dispute`, `dispute_closed` | Money given back or questioned. |
Give only what your gateway said, never a guess. The part applies each change once, in any order, and ignores one whose amounts are not what it fixed.
## Paying on the site
With `on_site`, the member pays in your form on the payment page of the site, never leaving it.
1. `on_site_ready( $settings )` says whether the keys of a mode can draw the form (a public key is there). The owner can still keep your gateway on its own page with **Pay on this site**.
2. `start()` is then given `$urls['on_site']`. Answer `mount` in place of `url`:
```php
return array(
'session' => $session_id,
'url' => '',
'mount' => array(
'scripts' => array( 'https://js.mypay.example/v2/pay.js', plugins_url( 'on-site.js', __FILE__ ) ),
'data' => array( 'key' => $settings['public_key'], 'token' => $client_token ),
),
);
```
The scripts load on the payment page alone, in order. `data` reaches the browser as it is: public values only.
3. Your script registers the form:
```js
window.wordplusPaymentsOnSite.register( 'mypay', {
async mount( element, data, { failed, done, submit } ) {
if ( typeof window.MyPay !== 'function' ) return failed();
const form = await window.MyPay( data.key ).form( data.token );
return form.mount( element );
},
} );
```
End it the way your form ends: by itself on the return address (Stripe), with `done()` (a form that ends in the page, as the buttons of PayPal), or with `await submit( { token } )` (a form that ends with a token the server charges with). `submit` calls your `on_site_submit( $order, $payload, $settings )`, which charges and answers `url`, where the member goes next. Words you mark `'buyer' => true` in a WP_Error reach the member (a card declined). Any other error reaches them as plain words of the site.
Where the form cannot open, the page says nothing was charged and offers your own page: the part closes the session and calls `start()` again without `on_site`. Where your gateway cannot close a session (PayPal voids no order), answer `url` beside `mount` in the same answer: your own page for the same session, which the part keeps and sends the member to instead, with nothing closed or made twice. Nothing is believed from the browser: the part asks your API, as after your page.
## Notices you must ask about
Where your gateway signs its notices, `verify_webhook()` checks the signature with the secret the owner saved, before anything of the request is read. Where it does not sign them (some send only an id), say `'verify' => 'fetch'`: `verify_webhook()` may then answer a mode without a signature, and `resolve()` asks your API for every object a notice names, so a forged notice changes nothing. The conformance suite sends one to make sure.
## A card change from Billing
With `change_method`, a member gives a running subscription another card from **Billing**, on the payment page of the site:
- `change_method( $subscription, $urls, $settings )` begins it, answering `url` or `mount` as `start()` does. Nothing is charged.
- `change_method_done( $subscription, $session, $settings )` makes the saved card the one the subscription is charged to, once your gateway says it was saved, and a WP_Error `payments_waiting` until then. Your notice of it should finish it too, for a member who closed the page.
- On a subscription whose renewal failed, the new card should pay that renewal at once, not at your next retry days later. Stripe pays its open invoice with it. Your notices tell the part, as of any renewal.
Without it, Billing says plainly what to do instead, and nothing leads to the pages of your gateway.
## Another plan from Billing
With `switch_plan`, a member moves a running subscription to another plan of the same group (another plan of the site, another tier of the same creator) from the **Plans** page and Billing. List the timings you can do:
- `renewal`: nothing is charged now, and the next renewal takes the new price. The part keeps the member on the plan they paid for until then, whatever price your gateway already names, and makes the new plan theirs once a paid period past it is heard.
- `now`: the new plan at once, the difference charged (or credited) as your gateway reckons it, and the change made only once that charge went through.
The administrator chooses, per gateway, under **When a member switches plan**: at the next renewal (the default where you can), at once, dearer plans at once and cheaper ones at the renewal (where you list both), or not at all. `switch_plan( $subscription, $price, $timing, $urls, $settings )` is given the new price prepared for you as for a checkout, and answers the changes you made (a `subscription` change naming the new price), or `url` with `session` where the member must approve at your gateway first (for a switch at once only, for now), or an error whose words marked `'buyer' => true` reach the member, nothing changed. The price they pay now, asked again, takes back a switch kept for the renewal.
Without it, the member reads plainly that plans cannot be switched with your gateway: cancel, and join the other plan once theirs ends.
## A pause from Billing
With `pause`, the administrator may let members pause and resume their own plan from **Billing** (**Members can pause**, off at first). `pause()` stops charging for now and `resume()` starts it again, each answering the `subscription` changes it made. The part keeps the access to the end of the time paid for, whatever period your notices name while you skip or void the bills. Resume so that no paused time is free and none is charged twice. Within the time paid for, charge nothing more. After it, charge a period from that day, at once.
## The check
```bash
wp wordplus payments check mypay
```
On a site, it checks what can be checked without a sale: your provider loads for the level of the part, its capabilities are well formed, its fields and its `check()` answer in test mode (no live key is ever used), and a forged notice is refused. It writes nothing.
The full checks with money (a purchase paid however its notices come, a whole subscription life, refunds, a reconcile that finds what a lost notice would have brought) are the conformance suite of the SDK, `tests/payments/ProviderConformance.php`, run over a stand-in for your API. Its complete example provider, `example-pay`, is written by these rules and passes both.
## What stays stable
A gateway you write today keeps working after every update. The WordPlus SDK holds it by tests on every change:
- **The public surface is written down and checked.** Every method of the base class and its arguments, every capability and its default, the change types and their keys, the hooks, the routes and the calls of the script are kept in one file, and a test fails when any of them is removed or changed in a way that would break a gateway: a method of the base class keeps its arguments exactly (your class declares the same ones), no method becomes one you must write, and a capability keeps its default.
- **An old gateway runs on every update.** A gateway written for level 3 and frozen, never edited again, goes through the whole conformance suite on every change of the SDK. A change that would make it fail is undone or made to work with it.
- **The level only grows.** A new level adds optional methods and capabilities whose defaults are what every gateway did before. A gateway written for an older level runs unchanged, and is never called for what it did not declare.
- **Nothing you rely on is renamed or removed** without a release that announces it first and keeps the old name working.
- **Ask the level, not the version:** `wordplus_payments()->api()`.
---
# Login providers
Address: https://www.poly-community.com/docs/developers/login-providers/
Poly Community logs members in with Google, Microsoft, Apple, Facebook and GitHub, and with any provider an owner adds over OpenID Connect without code (see [Your own OpenID Connect provider](https://www.poly-community.com/docs/services/sso/openid-connect/)). Any other provider, one that speaks plain OAuth 2 such as Discord, or an OpenID Connect provider you want ready-made with its own name and button, is a plugin of its own that adds a **provider** to the single sign-on part of the WordPlus SDK.
Facebook and GitHub are written this way too, with nothing your plugin cannot use.
Once added, the provider is a row under **Settings → Services → Single sign-on** with its mark, set up in its own dialog, and off until the owner turns it on under **Settings → Joining → Logging in**. Its button then shows on the login forms of the community and on the WordPress login screen, and on the sign-up forms while **Let new people join with it** is on.
## What the part does for you
Your provider says where its endpoints are and who the member is. Everything else belongs to the part and never reaches your code:
- the start, with its state bound to the browser and PKCE,
- the way back to `/wp-json/wordplus/v1/sso/back` and the exchange of the code for an access token,
- finding the member by their account at the provider, or by an email address the provider vouched for and the member confirmed here, or handing someone new to the sign-up form,
- Connected accounts on the account settings of a member and in wp-admin, and disconnecting,
- the refusals and the words the login page shows for them,
- the dialog of the owner with the redirect address, and the client secret kept sealed.
## Registering
```php
function my_plugin_sso_providers( $providers ) {
if ( ! class_exists( 'WordPlus_SDK_SSO_Providers', false ) || WordPlus_SDK_SSO_Providers::API < 1 ) {
return $providers; // a copy of the SDK older than this provider: leave it out
}
require_once __DIR__ . '/class-discord-provider.php';
$providers['discord'] = new My_Discord_Provider(); // the id: [a-z0-9-], up to 40 characters, never changed
return $providers;
}
add_filter( 'wordplus_sso_providers', 'my_plugin_sso_providers' );
```
- **Require the class inside the filter.** The part loads its base class, `WordPlus_SDK_SSO_Provider`, just before it runs the filter. A file that extends it at the top of your plugin would fail on a site where the part is not loaded yet.
- **The id is for good.** The link between an account here and the account at the provider is kept under it (`wordplus_sso_discord` in user meta), and so are the keys the owner enters.
- **Several plugins may add providers.** Each adds its own id to the array and returns the array.
## The class
A whole provider for Discord:
:::note[Written from the docs of Discord]
The endpoints, scopes and fields below follow the OAuth2 and user docs of Discord. The example has not been run against Discord itself. The same class, with a stand-in server, is what the tests of Poly Community log in through.
```php
class My_Discord_Provider extends WordPlus_SDK_SSO_Provider {
public function label() {
return 'Discord';
}
public function authorize_url() {
return 'https://discord.com/oauth2/authorize';
}
public function token_url() {
return 'https://discord.com/api/oauth2/token';
}
public function scopes() {
return 'identify email';
}
public function console() {
return 'https://discord.com/developers/applications';
}
public function mark() {
// Its logo as the brand gives it, from its press kit: one SVG with a viewBox.
return '';
}
public function colors() {
return array( 'background' => '#5865F2', 'border' => '#5865F2', 'text' => '#ffffff' );
}
public function dialog() {
return array(
'app' => 'Make an application in the Discord Developer Portal, add the redirect below under OAuth2, then copy its keys here',
'addresses' => array(
array( 'label' => 'Redirect', 'description' => 'Add it under OAuth2, exactly as here' ),
),
'client' => array( 'label' => 'Client ID', 'description' => 'Under OAuth2 in the Developer Portal' ),
'secret' => array( 'label' => 'Client Secret', 'description' => 'Under OAuth2: reset it and copy it at once' ),
);
}
public function identity( $token, array $tokens, $secret ) {
$me = $this->read( 'https://discord.com/api/users/@me', array( 'Authorization' => 'Bearer ' . $token ) );
if ( ! $me || empty( $me['id'] ) ) {
return new WP_Error( 'sso_profile', 'Discord did not say who you are.' );
}
$avatar = ! empty( $me['avatar'] )
? 'https://cdn.discordapp.com/avatars/' . $me['id'] . '/' . $me['avatar'] . '.png?size=512'
: '';
return array(
'sub' => $me['id'],
'email' => $me['email'] ?? '',
'verified' => true === ( $me['verified'] ?? null ),
'name' => $me['global_name'] ?? $me['username'] ?? '',
'username' => $me['username'] ?? '',
'picture' => $avatar,
);
}
}
```
The owner then makes the application at Discord, enters the redirect address the dialog shows, copies its client ID and secret into the dialog, and turns Discord on.
## What each method says
| Method | What it returns |
|---|---|
| `label()` | Its name, on its button (**Continue with** and the name) and in the list of providers. Required. |
| `kind()` | `oauth2` (the default), or `oidc` for a provider that speaks OpenID Connect at a fixed issuer. |
| `authorize_url()`, `token_url()` | OAuth 2: where the member logs in, and where the code is exchanged. Both https. |
| `issuer()` | OpenID Connect: the issuer, whose `/.well-known/openid-configuration` names the rest. https. |
| `scopes()` | The scopes asked for, separated by spaces. `openid email profile` for OpenID Connect unless you say otherwise. |
| `pkce()` | Whether the start carries PKCE (S256). True by default: leave it on unless the provider refuses it. |
| `token_by_get()` | True for a provider that exchanges the code by GET with its fields in the address, as Facebook does. False by default. |
| `console()` | Where the owner makes the app: the **Make the app** button of the dialog. |
| `mark()` | An SVG with a `viewBox`, drawn at 18 px on the button and in the list. The part keeps its shapes alone: no script, style, link or event. |
| `colors()` | `background`, `border` and `text` of its button, each `#rgb` or `#rrggbb`. Any one missing or wrong, and the button looks like that of a provider an owner adds. |
| `dialog()` | The dialog in the words of the console of the provider: `app`, the line beside **Make the app**. `addresses`, each a `label`, a `description` and a `value` to copy: the redirect address when `value` is left out, `home` for the address of the site, or an address of your own. `client` and `secret`, each a `label` and a `description`. Anything left out reads as for any provider. |
| `identity()` | OAuth 2: who the member is, read with the access token (below). |
| `needs()` | The level of the API it was written for, `1` today. |
## Who the member is
`identity( $token, $tokens, $secret )` gets the access token, the whole answer of the token endpoint (a refresh token or an id it carries, for example) and the client secret, for a provider that signs its calls with it. `$this->read( $url, $headers )` reads a JSON object by GET and answers null when it cannot. Answer an array, or a `WP_Error` when the profile cannot be read:
- **`sub`**: the id of the account at the provider, the same at every login and never an email address. Required: without it there is no login.
- **`email`**: the address the provider gives, if any.
- **`verified`**: `true` only when the provider vouches that the address belongs to the account. Anything else, a string `'true'` included, counts as not verified.
- **`name`**, **`given`**, **`family`**: the names, as plain text.
- **`picture`**: an https address of their picture.
- **`username`**: offered as their username here, unless a member already has it.
The part cleans each before anything reads it. An address that is not verified never links an existing account: the member logs in another way once and connects the provider in their account settings. Someone new confirms such an address with a code on the sign-up form.
## A provider over OpenID Connect
A provider that publishes `/.well-known/openid-configuration` needs no `identity()`. The part reads its ID token and checks its signature (RS256), issuer, audience, time and nonce, asks its UserInfo when the ID token leaves the address out, offers its `preferred_username` as the username (the part before the @ when it is an address), and sends the client secret as the provider takes it:
```php
class My_GitLab_Provider extends WordPlus_SDK_SSO_Provider {
public function label() { return 'GitLab'; }
public function kind() { return 'oidc'; }
public function issuer() { return 'https://gitlab.com'; }
public function console() { return 'https://gitlab.com/-/user_settings/applications'; }
// mark(), colors() and dialog() as above
}
```
## The rules it is checked by
A provider is left out, and why is kept, when:
- **reserved**: its id is one of the five the part carries (`google`, `microsoft`, `apple`, `facebook`, `github`).
- **taken**: an owner already added an OpenID Connect provider with that id. The links of its members are kept by the id, so the id stays with that provider.
- **needs**: its `needs()` is higher than `WordPlus_SDK_SSO_Providers::API` on this site.
- **invalid**: its id is not letters, numbers and hyphens, it is not a `WordPlus_SDK_SSO_Provider`, it has no name, or an endpoint or issuer is not https.
`WordPlus_SDK_SSO_Providers::refused()` lists them while you build, by id.
When your plugin is switched off, its provider leaves the list and its button goes, and a login started at its address goes back to the login page. The keys the owner entered are kept, and switched on again, the provider is as it was.
## What stays stable
The filter `wordplus_sso_providers`, the methods of `WordPlus_SDK_SSO_Provider` above and what `identity()` answers. A change to them comes with a new level of `WordPlus_SDK_SSO_Providers::API`, and a provider that asks for a level the site does not have waits for its update rather than half working.
---
# Settings rows
Address: https://www.poly-community.com/docs/developers/settings-rows/
Every setting of Poly Community is a row on a page of Settings, in a card, with its owner: the core, the Community component, or a component by its slug. A row shows, saves and is found by the search of Settings only while its owner runs, so the settings of a component that is switched off are hidden with it and kept for when it is on again.
A component adds its own on `poly_community_register_settings_rows`. The callback is given the registry, and adds a card with `add_section()` and each row with `add()`. Both are stable.
## Settings and pages drawn from data
Every page of Poly Community is one static file of its type for every reader, drawn by the browser from data ([Pages drawn from data](https://www.poly-community.com/docs/developers/data-driven-pages/)). A setting is the same for every reader, so reading one keeps a page that way: read it where the component registers what it draws, its blocks, its items and their `who` rules, as the starter reads its switch where it adds its menu item. Never read a setting together with a test of the reader to draw something for one reader in PHP. What depends on the reader is a fact the page shows its part by.
After a change, `wp poly-community page-data check ` on each page the setting changes says whether the page is still one drawing for every reader.
## A card and a row
The starter of [Building a component](https://www.poly-community.com/docs/developers/components/) adds one card with one switch to its page, `features/example-recipes`, and reads the switch where it draws its menu item:
```php
public function boot() {
add_action( 'poly_community_register_settings_rows', array( $this, 'settings' ) );
add_action( 'poly_community_register_ui', array( $this, 'ui' ) );
}
// Its settings: a card on its own page under Settings, Components, whose values $this->setting() reads.
public function settings( $rows ) {
$rows->add_section( array(
'id' => 'example-recipes-menu',
'page' => 'features/example-recipes',
'owner' => 'example-recipes',
'title' => __( 'The member menu', 'poly-community-recipes' ),
) );
$rows->add( array(
'key' => 'memberMenu',
'page' => 'features/example-recipes',
'section' => 'example-recipes-menu',
'owner' => 'example-recipes',
'type' => 'toggle',
'label' => __( 'Add a recipe in the member menu', 'poly-community-recipes' ),
'description' => __( 'An item under the picture of each member that opens the page of recipes.', 'poly-community-recipes' ),
'default' => true,
) );
}
```
(Screenshot: Settings, Components, Recipes: its switch under On this site, then the card The member menu with the switch Add a recipe in the member menu. Settings → Components → Recipes, with the card the starter adds.)
`$this->setting( 'memberMenu' )` then gives the value the owner saved, or the `default` until they save one. The plugin tests switch it off and check that the item leaves the menu (`tests/specs/component-guide.spec.ts`).
The rows of a component on its own page are kept with the component. They are saved with the rest of Settings, so a row needs no code to save it, and the value is cleaned by its type before it is kept.
## A card
| Key | What |
|---|---|
| `id` | Its id, prefixed with your component or plugin. Rows name it in their `section`. |
| `page` | The page it is on: `features/{slug}` for the page of a component under Settings → Components. |
| `owner` | The slug of the component, so the card shows while it is on. |
| `title`, `description` | Its heading and the line under it. |
| `after` | The id of the card it follows on that page. Without it, it goes last. |
## A row
| Key | What |
|---|---|
| `key` | Its name, which `$this->setting()` reads, each key once in a component. |
| `page`, `section` | Its page and its card. |
| `owner` | The slug of the component. |
| `type` | How it is set, below. A switch when left out. |
| `label`, `description` | Its words, and the line under them. |
| `default` | Its value until the owner saves one. |
| `options` | For a choice: a list of `array( 'value' => …, 'label' => … )`. |
| `min`, `max`, `step`, `unit` | For a number: its bounds, its step (a step of `0.01` keeps two decimals) and the unit shown after it. For words, `max` is how many characters they keep (200 when left out). |
| `placeholder` | What an empty field shows. |
| `when` | The other rows of its page that must hold a value for this one to show: `array( 'memberMenu' => true )` shows it only while that switch is on, and a list of values allows any of them. |
| `sanitize` | A named function given the cleaned value and the value sent, answering the value to keep, for a rule of your own on top of its type. |
## The types of row
| `type` | Shows | Its value |
|---|---|---|
| `toggle` | A switch | `true` or `false` |
| `number` | A number field | A whole number, or one with the decimals of its `step`, held between `min` and `max` |
| `text` | A line of words | The words, as plain text, at most `max` characters |
| `select` | A dropdown of its `options` | The value chosen, or its default when the value is none of them |
| `choice` | A radio button for each of its `options` | The same as `select` |
| `chips` | A button for each of its `options`, any of them pressed | The list of values chosen |
| `ticks` | A tick box for each of its `options` | The list of the options set off, so an option added later is on |
| `whocan` | Who may do something, as the other "who can" rows of Poly Community | A rule of roles and member types |
## The hook after a save
`poly_community_kit_settings_saved` runs after a save that changed the settings of one or more components, with the list of their slugs. A component that keeps something worked out from its settings forgets it there.
See also [Building a component](https://www.poly-community.com/docs/developers/components/) and [What you can build](https://www.poly-community.com/docs/developers/what-you-can-build/).
---
# Pages drawn from data
Address: https://www.poly-community.com/docs/developers/data-driven-pages/
Every page of Poly Community is one static file of its type, the same for every reader, and one JSON answer that a move asks for. The browser draws the page from the two. This page is for a developer, or a coding agent, adding pages or blocks to Poly Community that work the same way. [Moving between pages](https://www.poly-community.com/docs/developers/page-moves/) explains the mechanics underneath, and [Building for instant pages and live updates](https://www.poly-community.com/docs/developers/instant-and-live/) the rows, lists and events.
## The rules
1. **A page type is one file.** The page of every member, of every group, of every event is drawn once and kept as a static file, named by a hash of what it is drawn from. It holds templates and marks. It holds nothing of one reader and nothing of one subject.
2. **A move is the file and one answer.** The answer brings the rows, lists, parts and facts the page shows. Nothing else is asked, and nothing PHP draws is fetched after a page has loaded.
3. **The browser draws everything.** The only HTML inside the data is text members wrote (a post, a comment, a bio), already made safe. A section that shows an item, such as a title, its facts or its about, is a template in the file over the data of the item.
4. **The reader is data too.** What a reader may do and what they are (logged in, the owner, a moderator) are facts the answer brings. The file shows a part by them.
5. **A page loaded whole shows the same.** The server still draws a page loaded whole, for a first visit and for search engines. It must show what the file and its data show, and the tests compare the two.
## The API
Say once what the pages of your plugin show, on the `poly_community_register_page_data` action. It passes the registry, `Poly_Community_Page_Data`.
```php
add_action( 'poly_community_register_page_data', 'my_rooms_page_data' );
function my_rooms_page_data( $data ) {
$data->block( 'my-rooms/room-head' );
$data->part( 'myRoomBooking', array(
'of' => 'post',
'answer' => 'my_rooms_booking_of',
) );
$data->fact( 'myRoomsCanBook', 'my_rooms_can_book' );
$data->owner_block( 'my-rooms/room-manage', array( 'kinds' => array( 'room' ) ) );
$data->mark( 'post', '~(data-my-room=")%d(?=")~' );
}
```
### block
`$data->block( $name )` lists a block a page file may hold. List it once it draws what every reader sees, and takes what some readers alone see from parts and facts. A block that is not listed keeps its page from having a file, and the [check command](#checking-a-page) says which block it is.
### part
`$data->part( $name, $args )` is data each reader gets with the move, and on a page loaded whole. A template in the file binds it as `state.partHere`.
| Option | What it is |
|---|---|
| `of` | What its key is the id of: `post` (a post, or the item of a component page), `profile`, `space`, or `page`. |
| `answer` | A function `( $subject, $context, $args )` that returns the data for the reader: an array, never HTML. `$subject` is the post, member or group, already checked to be one the reader may open. `$context` is the reader, from `Poly_Community()->access->viewer()`. |
| `route` | Instead of `answer`, a route of your own under `poly-community/v1`, with `{id}` where the subject goes. |
| `teaser` | `true` where `answer` is also given a post the reader sees only as its teaser, and returns what the teaser shows. By default a part answers a reader who may open the post. |
A part with an `answer` needs no route of its own. The registry answers it at `page-data/parts/{name}/{id}`, and the move asks it inside its one answer.
A block draws its part with one template, on a page loaded whole and in a file alike. `here()` gives the context of the template: on a page loaded whole it puts the data for the reader, and in a file it names the part, so the move brings it.
```php
```
```php
function my_rooms_booking_of( $item, $context, $args ) {
$booking = my_rooms_booking_for( $item->id, $context['user_id'] );
return array(
'status' => $booking ? $booking['when_words'] : '',
'url' => $context['logged_in'] ? my_rooms_book_url( $item->id ) : '',
);
}
```
Give `here()` a third argument for a part that a block draws in more than one way, such as a short and a long look. It is kept in the key of the part and passed to `answer` as `$args`. A fourth argument adds keys of your own to the context of the template, such as the id your actions read.
A template draws what every item could show, each section hidden by its data: a room with no booking has the booking line hidden, not left out. One file then serves a room with a booking and a room without.
### fact
`$data->fact( $name, $callback )` is a fact of the reader the move brings, worked out once a move. A file shows a part by it with `Poly_Community_Json_Moves::for_readers( $html, 'myRoomsCanBook' )`, and a template reads it from the reader. The callback takes the reader context and returns a boolean, a string or a list.
### owner_block
`$data->owner_block( $name, array( 'kinds' => array( 'room' ) ) )` is a block drawn for those who may change the item alone, such as a bar to edit or end it. A file of the page draws none of it, and is drawn for readers who may not change the item. Whoever may change it moves to the page by its HTML, so they still see the bar. Administrators may change every item, so they load such a page whole, and the check says so.
Where more readers use the bar than may edit the item, such as the co-hosts of an event or the moderators of its group, give `can`: a function `( $item, $context )` that says whether the reader is one the bar is drawn for.
```php
$data->owner_block( 'my-rooms/room-manage', array(
'kinds' => array( 'room' ),
'can' => 'my_rooms_can_manage',
) );
```
### managed
`$data->managed( $kind, $can )` says that those who manage an item of the kind see its page otherwise, with no bar of their own: a course team sees Edit course where a student sees Start. As with an owner block, no file is drawn as one of them, and they move to the page by its HTML. Those who may change the item count by default, and `$can` adds others: a function `( $item, $context )`.
### drawn_whole_for
`$data->drawn_whole_for( $kind, $callback )` names readers an item page is drawn whole for, because a part of it shows them something that is not data yet, such as their own review to change. Use `*` as the kind for every kind. The callback takes the item and the reader context and returns whether the page is drawn whole for them. No file is drawn as one of them, and the check never picks one of them to draw it as.
### drawn_whole
`$data->drawn_whole( $kind, $callback )` names items of a kind whose page the server still draws whole, because a part of it is not drawn from data yet. The callback takes the item and returns why, or an empty string where its page is drawn from data. The page file serves the other items, and a reader moves to one of these by its HTML. Use it while you convert a page piece by piece, and take it away once the last piece is data.
```php
$data->drawn_whole( 'room', 'my_rooms_drawn_whole' );
function my_rooms_drawn_whole( $item ) {
return my_rooms_takes_deposits( $item->id ) ? 'deposits' : '';
}
```
### mark
`$data->mark( $kind, $pattern, $replacement )` says where a block writes the id of the subject of a page of many subjects, so one file serves every member, group or post. `$pattern` is a pattern for `preg_replace()` with `%d` where the id stands. The default replacement keeps the first group and puts `{{s}}` for the id. Where a block writes the account of the member or of the writer of the post, put `%u` in the pattern and `{{s:user}}` in the replacement. For the profile of the writer of a post, put `%b` and `{{s:by}}`. A pattern with `%u` or `%b` is left out for a subject that has none, such as a post written as no one. The ids in the routes of your parts are marked for you.
## A recipe: the page of one item
A component page of one item, such as the page of a room, is one file for every room of its kind. To get it there:
1. **Run the check.** `wp poly-community page-data check kit-room` says, for each kind of reader, the first reason the page has no file. Fix them in order.
2. **Draw the item from its row.** Each section that shows the room (its name, its facts, its about) binds the row of the item in the store, `state.rows.item[ id ]`, and the data your kind adds to it with `poly_community_item_row_data`. The context of the section names the row: `data-wp-context='{"rowKey":"item","item":{"id":…}}'`.
3. **Put what the reader alone sees in parts.** Their booking, their review, whether they may book: a part with an `answer`, drawn with `here()`.
4. **Show by facts what a reader may do.** A Book button for a reader who may book is drawn for every reader and shown by a fact.
5. **List the owner blocks.** The bar its owner uses to change the room is an owner block.
6. **List the blocks.** Each block of the page, once it draws so, with `block()`.
7. **Mark the ids.** Where a block writes the id of the room in an attribute of its own, a mark.
8. **Check again**, until every kind says it is drawn, then test it: move to the page from a list and compare what it shows with a page loaded whole, for a visitor, a member and the owner.
### Items in a group
A room posted in a group has a page type of its own beside the one for rooms outside groups: `kit-room-space`, as a post in a group has `space-post`. Its file is drawn for two rooms in two groups named otherwise, so whatever the page draws of one group differs between the drawings and nothing of a group stays in the file. Check it with `wp poly-community page-data check kit-room-space`.
- **The name of the group** in the trail of the page is marked for you (`{{s:place}}`, from the row of the room).
- **Anything else of the group**, such as its rules or its own widgets beside the page, comes from your part. Put it in the answer, bind the widget to it, and bind any attribute that names the group, such as `data-poly-room-space`, from the part too.
- **A move to the page** reads the row of the room in the list it was pressed in. That row says its group (`space`, `place` with a name and an address), as `Item_Rows::move_fields()` writes it.
A forum topic is always in a board and has the page type `forum-topic`. A question in a Q&A topic has `qa-question`. The topic page and the question page are the worked examples of a page in a group: `inc/forum-page-data.php` and `inc/question-page-data.php`. A key your page names in its state that the browser reads after a move, such as the key of a list it draws, must be one the file brings: add it with the filter `poly_community_json_move_own`.
### Your block on a page of ours
A block your plugin adds to a page of ours, such as a button on the question page, keeps that page from a file until it draws from data too. Register a part of your own for it, and draw the block from it in a file:
- **Draw every shape of it.** A block that shows otherwise to a moderator and to a member draws both in the file, each hidden until the part says it is theirs.
- **Take the context from the part.** The ids your actions read, such as the question the vote is for, come in the part under a key with `context`, taken with `partContextOf` and `data-wp-watch---part="callbacks.partContext"`. A callback that has to run once the id is known is a `data-wp-watch`, not a `data-wp-init`.
- **Mark the rest.** An id the block writes in an attribute, such as the name of a radio group, is a mark of yours.
- **Bring data in the part.** A grid of photos takes its first tiles from the answer, so the move asks nothing more.
Vote to close of the reputation kit is a worked example (`kits/reputation/inc/trait-page-data.php`, the part `closeVote`), and so is the gallery of an event in the photo albums kit (`kits/photo-albums/inc/trait-page-data.php`, the part `albumGrid`).
## Templates in the browser
- Bind a part with `state.partHere`, a row with the row named by the context, a list with `data-wp-each`.
- Hide with `data-wp-bind--hidden`, and draw the element hidden on the server where it starts hidden, so a page loaded whole shows the same.
- Work out what a template shows from data where it is shown: a date in the reader zone, a count in words. Write it as a getter in the store of your plugin, and the same rule in the server pass.
- Text members wrote is the only HTML a template puts in place, with `data-wp-html`.
- A template whose own context comes from the reader, such as a Watch button that holds whether they watch, takes it from the part. Put it under a key of the answer as `context` (`'watch' => array( 'context' => array( 'watching' => true ) )`). On the element, name that key in its context as `partContextOf` and add `data-wp-watch---part="callbacks.partContext"`. Each answer of the part is taken once, so what the reader changes after stays until the part is answered again.
- A list your page holds is named in its file by its key in one of the list slots of the state (`tileKeys`, `feedKeys`, `reviewKeys`, `treeKeys`, `threadKeys`), never put, and asked with the move. Register its kind with `register_list()` so the move can answer it: the posts of a topic are the list kind `thread`.
## Checking a page
| How | What it says |
|---|---|
| `wp poly-community page-data check ` | Makes the file of the page now and says, for a visitor, a member and an administrator, whether it is drawn and what to change. |
| `wp poly-community page-data list` | Every page and whether it is one drawing, as last made. |
| `/?poly_moves_made=1`, as an administrator | The same in a browser, with each kind and why. |
| `data-poly-move` on `` | After a move: `file` where it was drawn from its file, else `html:` and why. |
## Why a page has no file
Each reason the check command gives, by how it begins, and what to change.
| The reason begins | What to change |
|---|---|
| `its block` | A block draws something of one reader or one moment. Draw what every reader sees, put what some readers alone see in a part or behind a fact, then list the block with `block()`. |
| `it read` | The drawing read rows, lists or parts of the moment. Name lists unread, draw parts with `here()`, and keep reads of one reader out of what the file draws. |
| `two readers drawn otherwise` | Two readers of one kind got different HTML at the place shown. Something of the reader is drawn there: make it a part, or mark it with a fact. |
| `parts otherwise for some readers` | A part was drawn for some readers and not others. Draw its holder for every reader and let its data or a fact hide it. |
| `a moderator drawn otherwise` | A moderator saw more than a member. Draw the moderator parts for every reader, each shown by a fact. |
| `a member of another fit` | Members of different fits got different drawings. Show the difference by a fact. |
| `no two readers of the kind` | There are not two readers of this kind who reach the page. Nothing to change in code. |
| `no two` | There are not two members, posts or items to draw the page for. Nothing to change: it is made again an hour after, once the site has two. |
| `no menu links to` | Only pages a menu links to, their tabs and pages of many subjects get a file. Link the page from a menu. |
| `its address answers` | The page answers this reader with an error or the login. Those readers load it whole. |
| `its address asks` | The address carries a query only a tab page may carry. Make the view a tab of its page. |
| `asked for another key` | What the page is drawn from changed while it was made. Make it again: it settles. |
| `its reader may change the post` | The page has an owner block. Its file serves the others. Expected for administrators. |
| `its reader is of no kind` | A suspended or blocked reader loads pages whole. |
| `its widget area holds the widget` | A classic widget draws by its own code. Use a block that draws from data, or take it out. |
| `retry` | The site was busy. It is made again later. |
## For coding agents
An agent follows the recipe above with the check command as its test: it changes one block, runs the check, and goes on while a kind still gives a reason. The guide to coding agents, out once its skills have a home, has the instructions to give it and the prompts that work.
---
# Moving between pages
Address: https://www.poly-community.com/docs/developers/page-moves/
A member who taps a link in the community does not load a new page. The page they are on stays, and the part that changes is drawn in place, the way an app moves between its screens. This page says how that works and what a block, a widget or a kit has to do to keep it working. For the whole path of a new part, its rows, lists and events too, see [Building for instant pages and live updates](https://www.poly-community.com/docs/developers/instant-and-live/).
## Three ways a page is shown
1. **A whole load.** The first page a browser opens, or one opened by its address, is drawn by the server as any WordPress page is.
2. **From its file.** Every page of the menu has a file of its own, a static script in the uploads folder, and so do a member page and a post page (below). A tap on its link builds the page from that file, asks one request for what is in it now, and shows it. The document then has `data-poly-move="file"`.
3. **From its HTML.** Any other address (a post of a kit kind, a page with a query, a page that has no file yet) is fetched as HTML and drawn in place by the router of the WordPress Interactivity API.
Both moves are a [client-side navigation](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/client-side-navigation/) of the [Interactivity Router](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-interactivity-router/), in one router region, `poly-community/app`. A move from a file hands the router the page through the `html` parameter of [`navigate()`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-interactivity-router/#navigate-parameters) instead of having it fetched, so the router diffs it, keeps elements by their [`data-wp-key`](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/client-side-navigation/#preserving-elements-with-data-wp-key) and brings its styles and script modules as it does for any page. Every block of Poly Community declares that it works this way (`"supports": { "interactivity": true }`, [Client-side navigation compatibility](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/client-side-navigation-compatibility/)).
The second is the one to keep. After a page has loaded, the browser fetches only static files in the background (the page files, their templates), never a page, and a tap costs one request for data.
## The page file
Each page type has one file for every reader:
```
wp-content/uploads/poly-community/pages/members.07cd5154.js
wp-content/uploads/poly-community/pages/activity.e922f13f.js
wp-content/uploads/poly-community/pages/events.eab76af6.js
```
The name is the page and a hash of what the file holds, so a file never changes: a new one is written and the old one goes an hour later. It is served with a cache of a year. The file holds no key, so a page that draws as it did keeps its file and its name after a change, and browsers keep it too.
A page of many addresses has one file for all of them, its subject filled in by the browser from the row the page holds: a member page (each member, and each of their tabs), and a post page, one file for posts outside spaces and one for posts in a space. A post page file serves posts of the plain kind with no title of their own, by someone other than the reader. For a post in a space, the way back and the trail take the space name and address from the post row, and the reply box is in the file for every member, shown where the comments answer says the reader may reply, so a member of the space and a member outside it read the same file. The file in a space is drawn for two posts of two spaces of one type, with other names, that a visitor may open: whatever the page draws of one space differs between the two drawings, which refuses the file, so it never holds anything of one space. Each post file is drawn for posts with a title of their own or for posts without one, as most of the newest posts of the site are, and serves that kind alone. A post in a space of another type (a course space when the file is for groups), in a space inside another space, written as the space, or in a space whose replies take other tools moves by its HTML, as does any other post.
A space page has one file for every group of its shape, for a visitor so far (a member still moves by HTML, as where they stand in the space is drawn by the server). The browser finds the space from a card of it on the page or a post row that names it, and fills its name, address and the colour of its pictures. Its header data (`spaceHead`), its About data (`spaceAbout`) and its numbers come with the move, and so does what its widgets show (Who runs it, Rules, the faces of a few members in its header), as `GET spaces/{id}/widgets` answers it. A summary is drawn either way and shown by its data, so a space with none moves from the same file. A space of another type, with fields of its type filled in, inside another space, or with other tabs moves by its HTML.
What it holds:
- **The page as every reader sees it**: one drawing for all, each part some readers alone see marked with whom it is for (below). Where a page still draws otherwise for a visitor, a member and an administrator, each kind: the first whole, the others written as they differ from it, and the browser builds the reader kind again from them.
- **The page drawn as a skeleton**: every list named and none read, every part named and none read. Nothing in it is of the moment or of any reader.
- **What the head of the page needs**: its scripts and styles, by reference.
- **The templates its lists draw from**, once.
The file is made for a key. The key holds what the page is drawn from: the plugin version and its build, its scripts and styles, the saved templates and template parts, the settings, the locale, the theme and plugins, the page and its address. A change to any of them gives the page a new key, and a new file is made.
### One drawing for every reader
Where the kinds of a page come out the same, the file holds one drawing (`all`) and is named for every reader: a visitor, a member, a moderator and an administrator read the same bytes. The made record says `one: ''` for such a page, or why its kinds still differ. Most pages are one drawing: the feed, Members, member pages and their tabs, posts, a group page and its About tab, Spaces, Courses, Listings and the Events tabs.
A page is drawn as one when each block draws, in a file, what any reader may see, and marks each part only some readers see with the readers it is for. `Poly_Community_Json_Moves::for_all()` says the page drawn is a file. `for_readers()` marks a part:
```php
function my_plugin_render_button( $attributes, $content, $block ) {
if ( Poly_Community_Json_Moves::for_all() ) {
// In a file: drawn for every reader, shown to members alone.
return Poly_Community_Json_Moves::for_readers( my_plugin_button_html(), 'loggedIn' );
}
// A page loaded whole: drawn for its reader alone, as ever.
return is_user_logged_in() ? my_plugin_button_html() : '';
}
```
The part is one element. Its first tag gets `data-poly-for` with the facts, and the browser hides it (`.poly-not-for`) for any reader the facts do not fit. The facts:
- groups separated by spaces, any of which fits (`can:{{s}}:invite can:{{s}}:inviteMenu`),
- facts in a group separated by commas, all of which must fit (`loggedIn,!admin`),
- `!` before a fact for readers who lack it,
- a fact of `state.reader` by its name (`loggedIn`, `admin`, `createSpace`, `startTopic`, or one of your own),
- a fact of the page subject: `own:{id}` (the member page is the reader own), `joined:{id}` and `mod:{id}` (the reader is in the space, runs it), `can:{id}:{right}` (a right of the reader in the space, from the move answer), with the subject id written as its mark (`Poly_Community_Json_Moves()->subject_mark( 'space', $space_id )`) in a file of many subjects.
Two parts for two kinds of reader are two marked parts side by side: Join and Manage on a space page are both drawn, each shown by where the reader stands.
### A member own page
A member page file serves the member it belongs to on the page itself and the tabs the core knows draw everything only that member sees with `own:{id}` (Posts, About, Followers, Following). On any other tab the member moves to their own page by its HTML. Once every part of your tab that only its member sees is drawn for them in the file, add its slug, and the member moves to it from the file too:
```php
function my_plugin_own_tabs( $tabs ) {
$tabs[] = 'portfolio';
return $tabs;
}
add_filter( 'poly_community_json_move_own_tabs', 'my_plugin_own_tabs' );
```
A site administrator own page always moves by its HTML: their menu is drawn otherwise.
A right of your own in a space (may make an event there) is added to the reader rights the move answer brings, and a part marked with it:
```php
function my_plugin_space_rights( $can, $space, $context ) {
if ( my_plugin_can_make_in( $space, $context ) ) {
$can[] = 'myThings';
}
return $can;
}
add_filter( 'poly_community_space_reader_rights', 'my_plugin_space_rights', 10, 3 );
```
```php
$mark = Poly_Community_Json_Moves()->subject_mark( 'space', (int) $space->id );
echo Poly_Community_Json_Moves::for_readers( $new_thing_link, 'can:' . $mark . ':myThings' );
```
### Where your block writes the subject id
A file of many subjects (member pages, space pages, posts) has the subject id written as a mark the browser fills. The core marks where its own blocks write it. Where your block writes it elsewhere (a key of a list, an attribute of your own), say where, or the drawings for two subjects differ and the page has no file:
```php
function my_plugin_subject_ids( $ids, $kind, $id ) {
if ( 'profile' === $kind ) {
$ids[ '~(data-my-plugin-member=")' . (int) $id . '(?=")~' ] = '${1}{{s}}';
}
return $ids;
}
add_filter( 'poly_community_json_move_subject_ids', 'my_plugin_subject_ids', 10, 3 );
```
`$kind` is `profile`, `space` or `post`. Mark only what is the subject id: a number marked that is not makes two drawings differ, which refuses the file. Photo albums marks its albums list of a member this way, Events its list and New event of a space, Live its Go live address and who is live in a space.
On a space page, the key of a part named unread is marked for you where the space id is one of its segments, between `-` or `:` (`4-{id}`, `now:{id}:24`). The REST path you named it with, and the key where your block writes it into the page, are yours to mark.
### Facts a move brings
Facts of every page come with each page (`poly_community_viewer_facts`, above). Facts only a page drawn from its file needs come with the move answer instead, worked out once a move, never in the page or the file: what the reader may post and with which tools, whether they may make a space or start a topic, what holds them back. Add your own:
```php
function my_plugin_move_facts( $facts, $context ) {
$facts['myCanCreate'] = my_can_create( $context );
return $facts;
}
add_filter( 'poly_community_move_facts', 'my_plugin_move_facts', 10, 2 );
```
and mark the part with `myCanCreate`. A visitor gets none. A page loaded whole draws its reader own and asks no facts.
### A part another plugin draws for members alone
A part another plugin draws only when someone is logged in (a Message button) is drawn in a file as a stand-in member, then marked for the readers it is for:
```php
$html = Poly_Community_Json_Moves::as_a_member( $profile_user_id, 'my_plugin_message_button_html' );
return Poly_Community_Json_Moves::for_readers( $html, 'loggedIn,!own:{{s}}' );
```
The first argument is a user the stand-in must not be (the member whose page it is). With `true` as the third argument the stand-in is an administrator, for a part drawn for the widest rights and shown by the reader own (the composer tools).
### Who a file is for
A page whose kinds still differ is served by kind. A file serves a reader whose **fit** it was drawn for. The fit is:
- the reader shape (a visitor, a member, an administrator),
- whether the reader is held back (a member whose posts wait for review),
- for a page with a gated block of the core (the composer, the feed, pinned posts), what the reader chose there,
- for a page with a fitted block, what that block says of the reader (below),
- for the only administrator of a site, that administrator alone.
A moderator reads the member kind of a page where a drawing of that page as a moderator came out the same as the member kind. A moderator is one of the site team, or a member on the team of a space or a course. Each of the two kinds of moderator is checked on its own, the first time one of them reads the page (`mods` in the made record), so a page made for members waits for no moderator drawing. Where a page draws more for them, they move by HTML on that page alone. A moderator is never one of the readers a member kind is drawn as.
### How a file is made
After a page is shown, the server checks whether each page of the menu has a file for the reader fit. Where one is missing, it draws the page in the background, each kind as two readers of that fit who were active last, and keeps the file only where both drawings are the same and neither read anything of the moment. The tabs of a page are made with it.
All the pages wanted go to one background request, which draws them one after another, so the site draws one page at a time. After three minutes it hands the pages left to a request of its own. A drawing that finds the site busy (a time out, an error) stops it, and those pages are asked for again ten minutes later.
After a change that gives every page a new key (a deploy, a setting), each kind drawn and checked for the older key is drawn once for the new one. It is kept where it draws the same as before, apart from the versions of scripts, styles and icons. Only a kind that draws otherwise gets the whole check with two readers. So a deploy that changes nothing a page draws costs one drawing a kind.
A drawing is refused when:
- a block of the page is not one a file may hold,
- a block read something of the moment while drawing (a row of a member, a list, a part with data),
- a block of another plugin draws with its own code,
- no menu links to the page, or its address answers with something else (a login page).
An administrator reads why at `/?poly_moves_made=1`, or by `GET poly-community/v1/moves/made`. A refused kind is drawn again a day later, or as soon as its key changes.
## The move
1. The browser loads the page files when it is idle.
2. A tap on a link to a page with a file builds the reader kind of it, keeps the parts of the page that are the reader own (the menu, their spaces), and asks **one request**: the lists, parts and numbers the file names, with `move={page}:{key}:{kind}:{fit}` so the server checks that the file is for that reader.
3. The router shows the page. Its lists, parts and numbers come in that one answer.
Styles and script modules the page needs and the page shown lacks are added as the file names them. A module comes as the WordPress router brings the modules of any page it shows, with the mark WordPress gives a module that loads on a move (`data-wp-router-options`, which Poly Community asks for every component script). Every community page names `poly-community` in its import map, so a module that imports the core gets the one copy already running, whatever page the move came from.
A page of the menu moves from its file at its plain address. Its tabs move from files of their own (below). A member page moves from the one file of every member, the member it is about filled in from the rows the page already holds, and so does each tab of a member page (About, Followers). Any other address with a query is fetched as HTML.
### Tabs that draw the page again
A tab that only narrows or sorts a list of the page asks that list again as JSON, in place. A tab that draws the page again (Events Past and Going, the Questions orders, the Forum tabs, the tabs of a member page) gets a page file of its own. Mark its link:
```html
Past
```
As the page is drawn for its file, its links marked `data-poly-file` become pages of their own, up to eight a page, named after the page and what the address adds (`events-past.3f9a2b1c.js`, `questions-active.…`). Each is drawn and checked like any page. Its file is read when its page, or another of its tabs, is shown. The sort menu part does this for its orders with `'files' => true`.
A link marked `data-poly-file` must be the same for every reader: its address is kept and named in the page state of every reader, a visitor included. Never mark a link whose address holds something of its reader (their handle, a key, an id only they have).
## Building a block that works this way
A block works in a page file when, drawn as a skeleton, it draws nothing of the moment and nothing of the reader beyond their shape. The check is `Poly_Community_Address_Lists()->is_skeleton()`: true while a file is drawn.
### List the block
The core lists its own blocks. A kit or another plugin lists its own with a filter:
```php
function my_plugin_move_blocks( $blocks ) {
$blocks[] = 'my-block'; // a block of a component, poly-community/my-block, without poly-community/
$blocks[] = 'my-plugin/projects-button'; // a block of a plugin of its own, by its whole name
return $blocks;
}
add_filter( 'poly_community_json_move_blocks', 'my_plugin_move_blocks' );
```
A page whose template holds a block not listed has no file. Listing a block is a promise for every page that holds it, so a block that cannot keep it somewhere says so (below).
### Rows and lists: name them, do not read them
A list drawn from data (a list registered with `Poly_Community()->live_data->register_list()`) is named in a skeleton by its key in the slot it is drawn in, with no rows:
```php
$lists = Poly_Community_Address_Lists();
$slot = $lists->new_slot();
if ( $lists->is_skeleton() ) {
$list = array( 'ids' => array(), 'type' => 'my_row', 'more' => false, 'page' => 1, 'args' => $args );
} else {
$list = $this->my_list( $args ); // its rows put for the reader
Poly_Community()->live_data->put_list( $key, $list );
}
wp_interactivity_state( 'poly-community', array( 'tileKeys' => array( $slot => $key ) ) );
```
The template draws the rows from the state (`data-wp-each`), so the same markup is drawn by the server on a whole load and by the browser after a move. The move asks the list by its key in its one request. The forum topics (`inc/forum-lists.php`) and the questions (`inc/question-lists.php`) are lists like that, each row a part of trusted HTML drawn for its reader. A kit list of posts through its own card goes through the core item list (`poly_community_item_list`), which names itself in a skeleton.
A list whose every row is one part of trusted HTML (its row holds the key of that part as `html.row`) is drawn by the getters of the core, so it draws before a kit script has loaded, as it has not after a move from a file:
```html
```
Teaching is drawn this way (`kits/courses/views/teaching-tiles.php`). Give the list a `rows` callback beside its `list`, so a row is read again by its id (`GET lists/{kind}?ids=`) after a press or an event.
### Parts: name them unread
A part is data a template draws from by name and key (`Poly_Community_Parts`). In a skeleton, `put()` of a part refuses the drawing. Name it instead, with the REST path the browser asks it by:
```php
$parts = Poly_Community_Parts::instance();
if ( $parts->unread( 'myWidget', $count, 'my-plugin/widget?count=' . $count ) ) {
return $this->view( 'widget', array( 'count' => $count ) ); // drawn empty, its data asked at the move
}
$parts->put( 'myWidget', $count, $this->widget_shown( $count ) );
```
The path answers the same data `put()` would hold. The template reads `state.partHere`. A widget that hides itself when empty says so in its data (`'any' => (bool) $rows`) and binds `data-wp-bind--hidden="!state.partHere.any"`, so a file draws it hidden until its data comes. Waiting for an answer, Trending tags and the leaderboard work this way.
### A part of the post a page shows
A post page, and a component page of one item (an event, a course, a petition), is one file for every post of its kind. A block of yours on it that shows something of that post to some readers alone (its numbers to its author, a list to its team) puts it as a part keyed by the post id and names it unread with its route under the community REST namespace, `{id}` where the post id goes (`items/{id}/my-notes`, or `petitions/{id}/signers?part=1` of Votes). Add the route to the post parts, and the move answer brings each reader their own:
```php
function my_plugin_post_parts( $parts ) {
$parts['myPetitionNotes'] = 'items/{id}/my-notes';
return $parts;
}
add_filter( 'poly_community_json_move_post_parts', 'my_plugin_post_parts' );
```
```php
if ( Poly_Community_Json_Moves::for_all() ) {
Poly_Community_Parts::instance()->unread( 'myPetitionNotes', (int) $item->id, 'items/' . (int) $item->id . '/my-notes' );
return $this->view( 'notes-part', array( 'id' => (int) $item->id ) ); // a holder bound to state.partHere
}
```
The route answers what the reader may see, nothing for another, and the holder hides itself on that. The post id in a route of the post parts is marked for you where `{id}` stands, an attribute of your own with it is yours to mark (`poly_community_json_move_subject_ids`, above). The core block Views and contacts works this way (`itemStats`, `items/{id}/stats`), and so do the blocks Ended (`itemEnded`, `items/{id}/ended`), Category path (`termCrumbs`, `items/{id}/crumbs`) and Contact the owner (`contactOwner`, `items/{id}/contact`), and the signers of a petition (`petitionSigners`). The Message button of Contact the owner is drawn as a member has it, the account of the writer of the post marked as `{{s:user}}`, and shown where the part says the reader gets it.
A kind with fields shows those for cards in a list and all of them on its own page: the row of a post holds both as two parts, as it holds the start and the whole of a long text, so a move to its page shows all of them.
### What the reader may do: a fact, not a drawing
What differs by reader but fits in the same markup is drawn for every member and shown by a fact of the reader:
```php
function my_plugin_viewer_facts( $facts, $context ) {
if ( ! empty( $context['logged_in'] ) ) {
$facts['myCanCreate'] = my_can_create( $context );
}
return $facts;
}
add_filter( 'poly_community_viewer_facts', 'my_plugin_viewer_facts', 10, 2 );
```
```html
New thing
```
The facts are the reader own and are never kept in a file. New event on the Events page is shown this way, as are Post in a space in the composer and Following in the feed bar.
### Every kind of a file is public
A page file is a static file: anyone can download it, a visitor included, and every kind in it, the administrator kind too. The fit only decides who is shown a kind, never who can read it. So no kind may hold anything a visitor must not read: no member name of a private space, no hidden topic, no address with a key. Such a block names it unread (a list, a part), asks it when it is used, or refuses the drawing (below). The filters of Questions refuse it when the reader sees other Q&A topics than a visitor does, so a members-only topic is never named in the file.
### What a fact cannot say: a fitted block
Some blocks draw something of their reader that changes the page around them, such as whether they may make a course, which puts New course in the head of Teaching. Such a block is fitted: a page that holds it is drawn for readers alike in that, and served only to them.
```php
function my_plugin_fitted_blocks( $blocks ) {
$blocks[] = 'my-list';
return $blocks;
}
add_filter( 'poly_community_json_move_fitted_blocks', 'my_plugin_fitted_blocks' );
function my_plugin_move_fit( $fit, $blocks, $user_id ) {
if ( in_array( 'my-list', $blocks, true ) ) {
$fit['my-list'] = my_can_create( $user_id ); // for that member, never the current user
}
return $fit;
}
add_filter( 'poly_community_json_move_fit', 'my_plugin_move_fit', 10, 3 );
```
Keep the value the same for most members: each different value is a reader group of its own, and only the largest group gets a file. The value may differ by reader, but what it draws is still public, as every kind is.
### A page only some members reach
A page that only some members have in their navigation (Teaching, for those who build courses) is drawn as those who do. Say who reaches it:
```php
function my_plugin_move_reaches( $reaches, $page, $user_id ) {
return 'kit-my-page' === $page ? $reaches && my_reaches( $user_id ) : $reaches;
}
add_filter( 'poly_community_json_move_reaches', 'my_plugin_move_reaches', 10, 3 );
```
Otherwise the page is drawn as members who have no link to it, and refused.
### A block on the page of a space
A space page file serves every space of its shape. A block a component puts on that page (above its posts, beside them) is drawn into the file once, so it must draw the same for every space of that shape, or say what it draws differently. Name the data of one space in a part keyed by the space, even as one segment of the key (`4-{space id}`): the file holds the key with a mark the browser fills. Where the block draws something of the space or of its reader by the server, put it in the shape of the space, and a space or reader of another shape moves to that page by its HTML:
```php
function my_plugin_space_shape( $shape, $space, $context ) {
$level = my_plugin_space_level( $space );
if ( $level ) {
$shape['my-plugin'] = array( $level, my_plugin_reader_level( $context ) );
}
return $shape;
}
add_filter( 'poly_community_json_move_space_shape', 'my_plugin_space_shape', 10, 3 );
```
Leave the shape alone for the spaces where the block draws nothing, so those keep the file most spaces share. Ratings does this for its gate above the posts of a space rated for grown-ups.
### What can never be in a file
A block that sometimes draws what a file cannot hold (a space own rules, whether the reader watches something) says so as it draws it. The drawing is refused, and the page moves by HTML there:
```php
Poly_Community_Json_Moves::not_in_file( 'my-block' );
```
### Secrets are asked for when they are needed
A page in a file is the same for every reader of its fit, so it holds no secret of a reader, and neither should a page drawn whole. Ask for it when it is used. Subscribe on the Events page asks its menu, with the member calendar address and its key, as it is pressed (`GET poly-community/v1/events/subscribe`).
### Buttons inside rows drawn as parts
A row drawn as a part of trusted HTML is not run by the Interactivity API. A button in a tile of a list (`data-poly-tile`, inside the list `data-poly-tiles`) names its action as usual (`data-wp-on--click="actions.myAction"`), and the action is registered for parts in the script module:
```js
async function myAction( { button, context, id, post } ) {
const answer = await post( `my-plugin/things/${ id }/do`, {} );
return { done: true }; // the card new context, or nothing to read the card again
}
registerPress( 'myAction', myAction );
```
Links in parts move as any link does.
### Classic themes
Under a classic theme the community is on its pages, one for each section (the home, Members, Spaces), and the Community block of that page is its layout. A file is drawn from that block, with the Page type block of that page type in its main column. A move uses the file only inside the section it was drawn in: what the page has around the block (its title, the menu of the theme) belongs to that page, so a move to another section is fetched as HTML. A widget in the widget area of the Widgets screen keeps the page from a file unless it is a block widget whose blocks can be held in a file.
### Times and places of the reader
A page file is drawn in the site time zone. A block that writes times in the reader zone names no zone in a skeleton and lets the browser write its own, as the events list does, rather than asking the page again.
## Checking a page
- `/?poly_moves_made=1` as an administrator: each page, its file and why any kind of it was refused.
- In the browser, the document has `data-poly-move="file"` after a move from a file.
- In the tests, `movesFromFile( page, cli, id )` of `tests/fixtures/moves.ts` waits for the page file, loads the page whole, moves to it from the feed and checks that it shows the same and that no page was fetched. The specs of Events (`kits/events/tests/specs/moves.spec.ts`), Questions (`tests/specs/questions-moves.spec.ts`) and Teaching (`kits/courses/tests/specs/moves.spec.ts`) use it.
---
# Templates and themes
Address: https://www.poly-community.com/docs/developers/templates/
Every page of Poly Community is a block template, with the community navigation at one side, the main column in the middle and widgets at the other side. With a block theme, a site owner changes each one in **Appearance → Editor**, as [Themes and layouts](https://www.poly-community.com/docs/themes-and-layouts/) shows. What a page holds before anyone edits it, how wide it is drawn and what goes beside it is set by Poly Community, and a plugin changes each of those with a filter. The four on this page are stable.
The examples on this page are run by the plugin tests in a must-use plugin, as printed here (`tests/specs/templates-guide.spec.ts`), on the members directory. With them in place the directory is still one drawing for every reader, as `wp poly-community page-data check members` says, which is what every change to a page must leave it ([Pages drawn from data](https://www.poly-community.com/docs/developers/data-driven-pages/)). The blocks a filter here adds follow the same rule: what every reader sees in their markup, what one reader sees as a part or a fact.
## How wide a page is drawn
`poly_community_content_width` is given the width of a page and its view, and answers one of these:
| Width | What |
|---|---|
| `feed` | The width of a feed, with widgets beside it. The activity, a post, notifications and search. |
| `list` | Wider, for lists and pages with tabs, with widgets. The forum, questions, a profile and a space. |
| `form` | A form and little else. Logging in, joining, a new space. |
| `grid` | As wide as the layout allows, with widgets. A page that names none. |
| `full` | The whole room, with no widgets. Messages. |
```php
// The members directory as wide as a list.
function my_plugin_content_width( $width, $view ) {
return 'members' === $view ? 'list' : $width;
}
add_filter( 'poly_community_content_width', 'my_plugin_content_width', 10, 2 );
```
The main column then carries the class `poly-main-list` in place of `poly-main-grid`. A page of a component takes its width from `width` in its `kit.json` ([Building a component](https://www.poly-community.com/docs/developers/components/#2-the-manifest)).
## The widgets beside a page
`poly_community_sidebar_blocks` is given the widgets beside a page, in order, and its view. Each widget is the name of a block, those of Poly Community without `poly-community/`, followed by its attributes as JSON after a space where it has some, such as `popular-spaces {"sort":"newest"}`:
```php
// Beside the members directory: Popular spaces, then the footer of the community.
function my_plugin_sidebar_blocks( $blocks, $view ) {
return 'members' === $view ? array( 'popular-spaces', 'community-footer' ) : $blocks;
}
add_filter( 'poly_community_sidebar_blocks', 'my_plugin_sidebar_blocks', 10, 2 );
```
A widget of a part that is switched off (Popular spaces without spaces) is left out, and a page whose widgets all show nothing has no widgets column at all. By default the members directory has Online now, Who to follow and the footer, a profile has its details, Who to follow and the footer, and a page of a component without widgets of its own has those of its width. A component names the widgets of each of its pages with `widgets` in its `kit.json`, and an empty list for none.
## The default blocks of a page
`poly_community_main_markup` is given the block markup of the main column of a page of Poly Community and its view, before anyone has edited it in the Site Editor, and answers the markup to use:
```php
// A line above the members directory, in its default blocks.
function my_plugin_main_markup( $markup, $view ) {
if ( 'members' !== $view ) {
return $markup;
}
return '
Everyone here lives within a walk of the river.
' . "\n" . $markup;
}
add_filter( 'poly_community_main_markup', 'my_plugin_main_markup', 10, 2 );
```
It changes the default only. A template the owner saved in the Site Editor is drawn as they saved it, and their change wins. To change the markup inside a block instead, see [Changing a component](https://www.poly-community.com/docs/developers/changing-components/#a-view-in-a-plugin). A page of a component takes its default blocks from its own template, `templates/{view}.html`.
## What is drawn around a page
`poly_community_page_kind` is given what is drawn around the main column of a page, and the route of the page (its `view`, `section` and `status`), and answers one of these:
| Kind | What |
|---|---|
| `app` | The navigation, the main column and the widgets. Every page by default. |
| `account` | The form alone, for logging in and joining. |
| `account-nav` | The form with the navigation and no widgets, where the site chose to show the navigation on those pages. |
| `gate` | Its login alone, for a visitor of a community open to members only. |
| `not-found` | The navigation and the main column, no widgets. |
| `bleed` | The whole column, no widgets. Messages. |
Any other answer is taken as `app`.
See also [Building a component](https://www.poly-community.com/docs/developers/components/), [Changing a component](https://www.poly-community.com/docs/developers/changing-components/) and [Themes and layouts](https://www.poly-community.com/docs/themes-and-layouts/).
---
# Live updates in code
Address: https://www.poly-community.com/docs/developers/live/
A page of Poly Community draws what it shows from rows in its state. When something changes on the server, an event tells it, on the channels of those who may see it. The event carries the changed rows, or says which to read again, and every member page showing them draws them new. Nothing reloads, and no page is fetched.
For the whole path of a part drawn from data, see [Building for instant pages and live updates](https://www.poly-community.com/docs/developers/instant-and-live/).
## Rows
A row is an object as the browser draws it: its `id`, its version `v`, the values its template reads, and in `html` the keys of the trusted HTML it shows. Rows live in the state by type and id (`state.rows.room[12]`), in one shape in the page state, a REST answer and an event:
```json
{ "rows": { "room": { "12": { "id": 12, "v": 1795959816000000, "name": "The vault", "html": { "row": "room:12:row:1795959816000000" } } } },
"html": { "room:12:row:1795959816000000": "…" } }
```
### Registering a row type
```php
function my_rooms_row_types( $live ) {
$live->register_type( 'room', array(
'find' => 'my_rooms_get',
'row' => 'my_rooms_build_row',
'version' => 'my_rooms_version',
'events' => array(
'room.updated' => 'my_rooms_of_event',
),
'exact' => 'my_rooms_is_public',
'named' => 'my_rooms_named',
) );
}
add_action( 'poly_community_register_row_types', 'my_rooms_row_types' );
function my_rooms_of_event( $payload ) {
return (int) ( $payload['id'] ?? 0 );
}
function my_rooms_named( $room ) {
return array( (int) $room->owner_user_id );
}
```
Each callback is the name of a function, or `array( $this, 'method' )` in a class, never an anonymous function: an error names it, and the function that hooks the registration can be taken off again with `remove_action()`.
- **`find( $id )`** returns the object as it is now, or null.
- **`row( $object, $form )`** builds the row, puts it with `$live->put( 'room', $row )` and returns it, or returns null where the object is not drawn from data. `$form` says for whom: `reader` (the reader of this request, what they may do included), `shared` (everyone an event reaches: nothing of one reader in it) or `known` (shared, with the real author of an anonymous object).
- **`version( $object )`** is the row `v`. A newer version always wins in the browser, and a row of an older one never draws over a newer. A row at the same version as the one a page holds is not taken, so the version must grow with every change. Rows of the core tables are versioned by their `rev`, which `$live->touch( $type, $id )` moves at each change. A row of your own table takes the time of its last change in microseconds, kept when it is saved (`(int) floor( microtime( true ) * 1000000 )`): a time in seconds gives two changes in one second the same version, and the second is lost.
- **`events`** are the event types about the object, each answering its id, or 0 for an event about something else. Such an event moves the object version and carries its row (below).
- **`exact( $object )`** says whether the channels of its events are exactly those who may see it. Where they are not, its events go as references, and each page reads the row again for its own reader.
- **`named( $object )`** returns the accounts the row names. A reader in a block with one of them is never sent it.
- **`table`** names the core table that versions it (`items`, `profiles` or `spaces`) for a row type over one of them.
- **`anon( $object )`** and **`known`** are for a row whose real author only some may know: where `anon` says so, the shared row is built without them, and those who may know get a second event of the type `known` names, carrying the `known` row.
The HTML a row shows is drawn by the server and kept by key: `$live->html( 'room', $id, 'row', $v, $html )` returns its key, which the row holds in `html`. The browser draws it only from the page state, a REST answer or an event the server sent, never from what another browser published.
## Events
```php
Poly_Community()->events->emit( $channels, 'room.updated', array( 'id' => (int) $room->id, 'space' => (int) $room->space_id ) );
```
Emit an event after the change is saved, with what it is about. Name the object `id`, as lists read a row again by it. Keep the payload small, its ids and what a list declaration matches on (`space` above): the row type that names the event adds the row itself.
### Channels
An event goes to channels, and a reader hears these:
| Channel | Who hears it |
|---|---|
| `site` | everyone who may see the community |
| `members` | every member logged in |
| `user:{id}` | one account, on every page they have open |
| `profile:{id}` | the member of that profile, and those who write as it |
| `followers:{id}`, `friends:{id}` | the followers or friends of that profile |
| `mod` | the administrators, for the moderation queue |
Spaces, profiles and posts have the channels of exactly those who may see them, from `Poly_Community()->access->space_channels( $space )`, `profile_channels( $profile )` and `item_channels( $item )`. Use those for what belongs to one of them, so an event of a hidden space never reaches someone outside it.
### What an event carries
`emit()` asks the row type naming the event for its row, built as `shared`, and adds it to the event. An event goes as a reference instead, with the ids alone, when its row type is not `exact` for that object, or when the event would be over 60 KB.
A page then reads the rows again for its own reader.
Which parts take the rows an event carries: the lists of the core (posts, members, comments, forum topics, questions) each take those of their own types. A list of yours follows its events by its declarations ([Lists](https://www.poly-community.com/docs/developers/lists/)): the events in its `events` ask it again, and those in its `reads` read the row they name again for each reader, in one request a batch. That works whether the event carried the row or came as a reference.
### How pages hear them
The pages of members hear events: a visitor page asks for none, and a visitor sees what changed on the next page they open. A member page hears them over the realtime connection where the site has one (WordPlus Cloud), and otherwise by asking `GET /wp-json/poly-community/v1/events?since=` every few seconds, less often in a hidden tab (Settings sets how often). Both bring the same events, each once. A page that has not asked for over an hour (a laptop asleep) is told to draw what it shows again from fresh data, as the log keeps an hour.
## In a component script
A component script is a script module at `assets/.js`, registered as `@poly-community/kit-` by itself, that imports from the core module `poly-community`. It may be built (the components of Poly Community build theirs from `src/index.ts`) or written as it is, as the [example plugin](https://www.poly-community.com/docs/developers/instant-and-live/#building-a-new-part-step-by-step) does:
```js
// A handler for one type of event, polled or pushed alike.
function roomFull( payload, event ) {
setPart( 'roomSeats', payload.id, { full: true } );
}
const stop = onLive( 'room.full', roomFull );
// A part asked again from its route, its answer written where the page reads it.
askPart( 'roomSeats', 12, 'my-rooms/12/seats' );
```
- **`onLive( type, listener )`** adds a handler and returns a function that takes it off. The payload is what the event carries, its rows in `data` where it carries any.
- **`api( path, options )`** calls a route under `poly-community/v1/` with the reader session (`api( 'example-rooms', { method: 'POST', body: { name } } )`). Register the routes of your component there, each with its own permission check. Its errors reject, and `errorMessage( error )` gives the message to show with `toast( message, true )`.
- **`mergePack( data )`, `listOf( key )`** put rows a route answered into the state and give a list of the page by its key, so the page that made a change draws it at once ([step 8 of the guide](https://www.poly-community.com/docs/developers/instant-and-live/#8-your-routes-and-your-script-where-you-need-them)).
- **`setPart()`, `askPart()`, `partOf()`** write, ask again and read the parts of a page ([Parts](https://www.poly-community.com/docs/developers/page-moves/#parts-name-them-unread)).
- **`followServer( name )`** keeps a key of the state taken from each page a move brings, whole. Use it for state of your own that differs by page: a move keeps the state of the page before and adds only keys it has not.
- **`markPageChanged()`** says something the page shows changed elsewhere, where no part of it can be drawn again from data: the page shows its pill, which draws it again.
What an event changes is drawn from the state. Never write into the HTML of a page by hand: a move or an event draws over it.
### A widget drawn again
A widget the server draws with no data of its own may name the events that draw it again: `data-poly-refresh="room.created room.deleted"` on its wrapper, with `data-poly-refresh-min` (seconds at most between two) and `data-poly-refresh-every` (again on a timer). It is drawn again by asking the page, so prefer a list or a part that follows its events, as above, for anything new.
## What is stable
`poly_community_register_row_types` and `register_type()` are on the stable list ([What is stable](https://www.poly-community.com/docs/developers/#what-is-stable)). The events and their names, `Poly_Community()->events->emit()`, the channels and the `poly-community` script module are not on it yet.
See also [Lists](https://www.poly-community.com/docs/developers/lists/), [Moving between pages](https://www.poly-community.com/docs/developers/page-moves/) and [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/).
---
# Translating
Address: https://www.poly-community.com/docs/developers/translating/
A component is translated as any WordPress plugin is, with one step of its own for the words of its `kit.json`. The plugin tests take the starter of [Building a component](https://www.poly-community.com/docs/developers/components/) through every step on this page and check it in German (`tests/specs/component-guide.spec.ts`).
## The words in PHP
Every word the code of a component shows goes through the functions of WordPress with the text domain of its plugin, the name of its folder: `__()`, `_x()`, `esc_html__()` and the rest. The starter labels its item in the member menu so:
```php
'label' => __( 'Add a recipe', 'poly-community-recipes' ),
```
## The words of its manifest
The title, description and summary in `kit.json`, and the labels of its pages, menu items and tabs, are translated by Poly Community with the text domain the manifest names in `textDomain`, and the context `Kit`. Without `textDomain`, they are looked up in the text domain of Poly Community, where they are not found.
`wp i18n make-pot` reads PHP and JavaScript but not `kit.json`. So list those words in a PHP file of their own, which nothing loads, as Poly Community does for its own components:
```php
items->create( … )`. These methods are stable. The other public methods of a part are not.
| Part | Methods |
|---|---|
| `kinds` | `register()`, `get()`, `of()`, `id()`, `counts()` |
| `attachments` | `register()` |
| `access` | `register_rule()`, `register_who_can()`, `who_can()`, `can_see_item()`, `can_open_item()`, `viewer()` |
| `live_data` | `register_type()`, `register_list()` |
| `settings_rows` | `add()`, `add_section()` |
| `routes` | `item_url()`, `profile_url()`, `space_url()`, `home_url()`, `view_url()` |
| `kits` | `get()`, `view_url()` |
| `items` | `create()`, `get_item()`, `update()`, `delete()`, `data()` |
| `thing_fields` | `of_kind()`, `values()`, `set_visibility()` |
| `terms` | `register_tree()` |
| `relationships` | `register_type()` |
| `icons` | `add()`, `add_group()`, `has()`, `names()` |
| `ui` | `add()`, `change()`, `remove()`, `get()`, `items()`, `places()` |
Functions: `poly_icon()`, `poly_the_icon()`. [Icons](https://www.poly-community.com/docs/reference/icons/) says what they draw.
## The places of buttons, menus and tabs
The places of `Poly_Community()->ui` and the ids of Poly Community in each, which [Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/) and [Tabs and menus](https://www.poly-community.com/docs/developers/tabs-and-menus/) show. An item takes the keys `label`, `icon`, `url`, `action`, `command`, `target`, `after`, `before`, `first`, `last`, `group`, `who`, `when`, `for`, `danger`, `data`, `slug`, `count`, `page`, `note`, and `who` the words `everyone`, `visitors`, `members`, `own`, `type:{slug}` or a rule with `roles`, `spaceRoles`, `own`, `can`, `trust`, `verified`.
| Place | Subject | Its own ids |
|---|---|---|
| `profile.menu` | profile | `copy-link`, `report`, `mute`, `block`, `suspend`, `edit-member`, `wordpress-user` |
| `space.menu` | space | `invite`, `members`, `delete`, `leave` |
| `post.menu` | item | `edit`, `pin`, `save`, `hide-pin`, `copy-link`, `mute`, `report`, `hold`, `delete` |
| `post.actions` | item | `like`, `quote`, `reply-to`, `reply`, `share`, `solution`, `reactions`, `views` |
| `reply.menu` | item | `report`, `hold`, `delete` |
| `reply.actions` | item | `like`, `reply`, `edit` |
| `topic.menu` | item | `pin`, `lock`, `move`, `copy-link`, `mute`, `report`, `delete` |
| `space.member` | member | `roles`, `owner`, `remove`, `ban` |
| `members.tabs` | none | `discover`, `friends`, `following` |
| `nav.foot` | none | none |
| `profile.tabs` | profile | `posts`, `about`, `friends`, `followers`, `following` |
| `space.tabs` | space | `posts`, `members`, `about` |
| `space.settings` | space | `general`, `privacy`, `posts` |
| `settings.tabs` | none | `profile`, `notifications`, `privacy`, `account` |
| `nav` | none | `home`, `activity`, `members`, `spaces`, `profile` |
| `account` | none | `profile`, `settings`, `my-spaces`, `saved` |
## A component
Every component extends `Poly_Community_Kit`, which gives it `setting()`, `view()`, `the_view()`, `register_job()`, `item_of()`. See [Building a component](https://www.poly-community.com/docs/developers/components/).
---
# Actions
Address: https://www.poly-community.com/docs/reference/php-actions/
The 24 stable actions of Poly Community, read from the code. The plugin runs 559 hooks named `poly_community_` in all, and only these are kept from one release to the next. Each says where it runs and what it is given.
## poly_community_item_created
```php
function my_plugin_item_created( $item_id, $item ) {
// …
}
add_action( 'poly_community_item_created', 'my_plugin_item_created', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$item_id` | `(int) $item->id` |
| `$item` | `$item` |
Runs in `inc/activity.php:2365`, `inc/wp-posts.php:351`.
## poly_community_item_deleted
```php
function my_plugin_item_deleted( $item_id, $item ) {
// …
}
add_action( 'poly_community_item_deleted', 'my_plugin_item_deleted', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$item_id` | `(int) $item_id` |
| `$item` | `$item` |
Runs in `inc/activity.php:3627`, `inc/activity.php:3685`, `inc/activity.php:3725` and 4 more.
## poly_community_item_updated
```php
function my_plugin_item_updated( $item_id, $item, $before ) {
// …
}
add_action( 'poly_community_item_updated', 'my_plugin_item_updated', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$item_id` | `(int) $item->id` |
| `$item` | `$item` |
| `$before` | `$before` |
Runs in `inc/activity.php:3088`, `inc/lifetimes.php:757`, `inc/wp-posts.php:374` and 5 more.
## poly_community_kit_settings_saved
```php
function my_plugin_kit_settings_saved( $saved ) {
// …
}
add_action( 'poly_community_kit_settings_saved', 'my_plugin_kit_settings_saved' );
```
Runs in `inc/kits.php:1271`.
## poly_community_kits_changed
```php
function my_plugin_kits_changed( $changed ) {
// …
}
add_action( 'poly_community_kits_changed', 'my_plugin_kits_changed' );
```
Runs in `inc/kits.php:1288`.
## poly_community_register_access_rules
```php
function my_plugin_register_access_rules( $access ) {
// …
}
add_action( 'poly_community_register_access_rules', 'my_plugin_register_access_rules' );
```
| Argument | As the plugin passes it |
|---|---|
| `$access` | `$this` |
Runs in `inc/access.php:176`.
## poly_community_register_attachments
```php
function my_plugin_register_attachments( $attachments ) {
// …
}
add_action( 'poly_community_register_attachments', 'my_plugin_register_attachments' );
```
| Argument | As the plugin passes it |
|---|---|
| `$attachments` | `$this` |
Runs in `inc/attachments.php:105`.
## poly_community_register_catalogs
```php
function my_plugin_register_catalogs( $catalogs ) {
// …
}
add_action( 'poly_community_register_catalogs', 'my_plugin_register_catalogs' );
```
| Argument | As the plugin passes it |
|---|---|
| `$catalogs` | `$this` |
Runs in `inc/catalogs.php:146`.
## poly_community_register_data_kinds
```php
function my_plugin_register_data_kinds( $data_admin ) {
// …
}
add_action( 'poly_community_register_data_kinds', 'my_plugin_register_data_kinds' );
```
| Argument | As the plugin passes it |
|---|---|
| `$data_admin` | `$this` |
Runs in `inc/data-admin.php:107`.
## poly_community_register_forms
```php
function my_plugin_register_forms( $forms ) {
// …
}
add_action( 'poly_community_register_forms', 'my_plugin_register_forms' );
```
| Argument | As the plugin passes it |
|---|---|
| `$forms` | `$this` |
Runs in `inc/forms.php:348`.
## poly_community_register_icons
```php
function my_plugin_register_icons( $icons ) {
// …
}
add_action( 'poly_community_register_icons', 'my_plugin_register_icons' );
```
| Argument | As the plugin passes it |
|---|---|
| `$icons` | `$this` |
Runs in `inc/icons.php:182`.
## poly_community_register_jobs
```php
function my_plugin_register_jobs( $queue ) {
// …
}
add_action( 'poly_community_register_jobs', 'my_plugin_register_jobs' );
```
| Argument | As the plugin passes it |
|---|---|
| `$queue` | `$this` |
Runs in `inc/queue.php:144`.
## poly_community_register_kits
```php
function my_plugin_register_kits( $kits ) {
// …
}
add_action( 'poly_community_register_kits', 'my_plugin_register_kits' );
```
| Argument | As the plugin passes it |
|---|---|
| `$kits` | `$this` |
Runs in `inc/kits.php:163`.
## poly_community_register_lists
```php
function my_plugin_register_lists( $live_data ) {
// …
}
add_action( 'poly_community_register_lists', 'my_plugin_register_lists' );
```
| Argument | As the plugin passes it |
|---|---|
| `$live_data` | `$this` |
Runs in `inc/live-data.php:1522`.
## poly_community_register_post_kinds
```php
function my_plugin_register_post_kinds( $post_kinds ) {
// …
}
add_action( 'poly_community_register_post_kinds', 'my_plugin_register_post_kinds' );
```
| Argument | As the plugin passes it |
|---|---|
| `$post_kinds` | `$this` |
Runs in `inc/post-kinds.php:69`.
## poly_community_register_relationship_types
```php
function my_plugin_register_relationship_types( $relationships ) {
// …
}
add_action( 'poly_community_register_relationship_types', 'my_plugin_register_relationship_types' );
```
| Argument | As the plugin passes it |
|---|---|
| `$relationships` | `$this` |
Runs in `inc/relationships.php:111`.
## poly_community_register_review_targets
```php
function my_plugin_register_review_targets( $reviews ) {
// …
}
add_action( 'poly_community_register_review_targets', 'my_plugin_register_review_targets' );
```
| Argument | As the plugin passes it |
|---|---|
| `$reviews` | `$this` |
Runs in `inc/reviews.php:264`.
## poly_community_register_row_types
```php
function my_plugin_register_row_types( $live_data ) {
// …
}
add_action( 'poly_community_register_row_types', 'my_plugin_register_row_types' );
```
| Argument | As the plugin passes it |
|---|---|
| `$live_data` | `$this` |
Runs in `inc/live-data.php:430`.
## poly_community_register_search_kinds
```php
function my_plugin_register_search_kinds( $search ) {
// …
}
add_action( 'poly_community_register_search_kinds', 'my_plugin_register_search_kinds' );
```
| Argument | As the plugin passes it |
|---|---|
| `$search` | `$this` |
Runs in `inc/search.php:267`.
## poly_community_register_seller_kinds
```php
function my_plugin_register_seller_kinds( $earnings ) {
// …
}
add_action( 'poly_community_register_seller_kinds', 'my_plugin_register_seller_kinds' );
```
| Argument | As the plugin passes it |
|---|---|
| `$earnings` | `$this` |
Runs in `inc/earnings.php:153`.
## poly_community_register_settings_rows
```php
function my_plugin_register_settings_rows( $settings_rows ) {
// …
}
add_action( 'poly_community_register_settings_rows', 'my_plugin_register_settings_rows' );
```
| Argument | As the plugin passes it |
|---|---|
| `$settings_rows` | `$this` |
Runs in `inc/settings-rows.php:128`.
## poly_community_register_signals
```php
function my_plugin_register_signals( $signals ) {
// …
}
add_action( 'poly_community_register_signals', 'my_plugin_register_signals' );
```
| Argument | As the plugin passes it |
|---|---|
| `$signals` | `$this` |
Runs in `inc/signals.php:59`.
## poly_community_register_trees
```php
function my_plugin_register_trees( $terms ) {
// …
}
add_action( 'poly_community_register_trees', 'my_plugin_register_trees' );
```
| Argument | As the plugin passes it |
|---|---|
| `$terms` | `$this` |
Runs in `inc/terms.php:98`.
## poly_community_register_ui
```php
function my_plugin_register_ui( $ui ) {
// …
}
add_action( 'poly_community_register_ui', 'my_plugin_register_ui' );
```
| Argument | As the plugin passes it |
|---|---|
| `$ui` | `$this` |
Runs in `inc/ui.php:306`.
---
# Filters
Address: https://www.poly-community.com/docs/reference/php-filters/
The 15 stable filters of Poly Community, read from the code. The plugin runs 559 hooks named `poly_community_` in all, and only these are kept from one release to the next. Each says where it runs and what it is given, the first of which it returns, changed or not.
## poly_community_account_items
**Deprecated** since 0.1.0: use `poly_community_register_ui` instead. It still runs, with a deprecation notice, for at least two releases.
Runs in `inc/navigation.php:252`.
## poly_community_blueprints
```php
function my_plugin_blueprints( $value ) {
return $value;
}
add_filter( 'poly_community_blueprints', 'my_plugin_blueprints' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array( Poly_Community()->path . 'blueprints' )` |
Runs in `inc/blueprints.php:159`.
## poly_community_comment_data
```php
function my_plugin_comment_data( $value, $reply, $root, $form ) {
return $value;
}
add_filter( 'poly_community_comment_data', 'my_plugin_comment_data', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array()` |
| `$reply` | `$reply` |
| `$root` | `$root` |
| `$form` | `$form` |
Runs in `inc/comments.php:230`.
## poly_community_content_width
```php
function my_plugin_content_width( $width, $view ) {
return $width;
}
add_filter( 'poly_community_content_width', 'my_plugin_content_width', 10, 2 );
```
Runs in `inc/templates.php:1102`.
## poly_community_home_choices
```php
function my_plugin_home_choices( $value ) {
return $value;
}
add_filter( 'poly_community_home_choices', 'my_plugin_home_choices' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array( 'activity' => array( 'label' => _x( 'Activity', 'Home page', 'poly-community' ), 'icon' => 'activity', 'description' => _x( 'The community address opens the composer and the activity feed', 'Home page', 'poly-community' ), 'available' => Poly_Community()->apps->feed(), ), )` |
Runs in `inc/routes.php:608`.
## poly_community_home_rewrites
```php
function my_plugin_home_rewrites( $value ) {
return $value;
}
add_filter( 'poly_community_home_rewrites', 'my_plugin_home_rewrites' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array()` |
Runs in `inc/routes.php:587`.
## poly_community_item_data
```php
function my_plugin_item_data( $data, $arg2, $kind_slug ) {
return $data;
}
add_filter( 'poly_community_item_data', 'my_plugin_item_data', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$data` | `$data` |
| `$arg2` | `null` |
| `$kind_slug` | `$kind['slug']` |
Runs in `inc/activity.php:1760`, `inc/activity.php:2781`.
## poly_community_main_markup
```php
function my_plugin_main_markup( $value, $view ) {
return $value;
}
add_filter( 'poly_community_main_markup', 'my_plugin_main_markup', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `$this->default_main_markup( $view )` |
| `$view` | `$view` |
Runs in `inc/layouts.php:208`.
## poly_community_nav_items
```php
function my_plugin_nav_items( $items, $route ) {
return $items;
}
add_filter( 'poly_community_nav_items', 'my_plugin_nav_items', 10, 2 );
```
Still supported, with no notice. `poly_community_register_ui` is the way for new code: this filter will be deprecated in a later release, once Better Messages has moved to it.
Runs in `inc/templates.php:1134`.
## poly_community_page_kind
```php
function my_plugin_page_kind( $kind, $route ) {
return $kind;
}
add_filter( 'poly_community_page_kind', 'my_plugin_page_kind', 10, 2 );
```
Runs in `inc/templates.php:1077`.
## poly_community_profile_tabs
**Deprecated** since 0.1.0: use `poly_community_register_ui` instead. It still runs, with a deprecation notice, for at least two releases.
Runs in `inc/profiles.php:1226`.
## poly_community_requirements
```php
function my_plugin_requirements( $value ) {
return $value;
}
add_filter( 'poly_community_requirements', 'my_plugin_requirements' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array()` |
Runs in `inc/access.php:1224`.
## poly_community_sidebar_blocks
```php
function my_plugin_sidebar_blocks( $blocks, $view ) {
return $blocks;
}
add_filter( 'poly_community_sidebar_blocks', 'my_plugin_sidebar_blocks', 10, 2 );
```
Runs in `inc/layouts.php:353`.
## poly_community_space_tabs
```php
function my_plugin_space_tabs( $tabs, $space ) {
return $tabs;
}
add_filter( 'poly_community_space_tabs', 'my_plugin_space_tabs', 10, 2 );
```
Still supported, with no notice. `poly_community_register_ui` is the way for new code: this filter will be deprecated in a later release, once Better Messages has moved to it.
Runs in `inc/spaces.php:738`.
## poly_community_structured_data
```php
function my_plugin_structured_data( $value, $item, $visitor ) {
return $value;
}
add_filter( 'poly_community_structured_data', 'my_plugin_structured_data', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array()` |
| `$item` | `$item` |
| `$visitor` | `$visitor` |
Runs in `inc/structured-data.php:203`.
---
# Hooks of the components
Address: https://www.poly-community.com/docs/reference/component-hooks/
Beside the hooks of the core, which every component shares ([Actions](https://www.poly-community.com/docs/reference/php-actions/), [Filters](https://www.poly-community.com/docs/reference/php-filters/)), some components run hooks of their own, read from the code. None of them is on the stable list yet. The comment above each place in the code says what it is for. For which hook changes what, see [Changing a component](https://www.poly-community.com/docs/developers/changing-components/).
## Courses
3 hooks of its own, in `kits/courses/`.
### poly_community_course_finish
```php
function my_plugin_course_finish( $course, $standing ) {
// …
}
add_action( 'poly_community_course_finish', 'my_plugin_course_finish', 10, 2 );
```
Runs in `kits/courses/views/course-finish.php:53`.
### poly_community_course_finished
```php
function my_plugin_course_finished( $course_id, $context_profile_id, $context ) {
// …
}
add_action( 'poly_community_course_finished', 'my_plugin_course_finished', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$course_id` | `(int) $course_id` |
| `$context_profile_id` | `(int) $context['profile_id']` |
| `$context` | `$context` |
Runs in `kits/courses/inc/trait-progress.php:505`.
### poly_community_course_lesson_kinds
```php
function my_plugin_course_lesson_kinds( $value ) {
return $value;
}
add_filter( 'poly_community_course_lesson_kinds', 'my_plugin_course_lesson_kinds' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `self::OFFERED` |
Runs in `kits/courses/kit.php:626`.
## Events
6 hooks of its own, in `kits/events/`.
### poly_community_event_attachments
```php
function my_plugin_event_attachments( $value ) {
return $value;
}
add_filter( 'poly_community_event_attachments', 'my_plugin_event_attachments' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array()` |
Runs in `kits/events/inc/trait-rest.php:289`, `kits/events/inc/trait-series.php:562`, `kits/events/kit.php:226`.
### poly_community_event_checkin_names
```php
function my_plugin_event_checkin_names( $value ) {
return $value;
}
add_filter( 'poly_community_event_checkin_names', 'my_plugin_event_checkin_names' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `1000` |
Runs in `kits/events/inc/trait-answers.php:322`.
### poly_community_event_form_sections
```php
function my_plugin_event_form_sections( $value, $item, $event ) {
return $value;
}
add_filter( 'poly_community_event_form_sections', 'my_plugin_event_form_sections', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array()` |
| `$item` | `$item` |
| `$event` | `$event` |
Runs in `kits/events/views/form-more.php:212`.
### poly_community_event_join_sources
```php
function my_plugin_event_join_sources( $sources ) {
return $sources;
}
add_filter( 'poly_community_event_join_sources', 'my_plugin_event_join_sources' );
```
Runs in `kits/events/inc/trait-join.php:85`.
### poly_community_event_offer_seconds
```php
function my_plugin_event_offer_seconds( $value ) {
return $value;
}
add_filter( 'poly_community_event_offer_seconds', 'my_plugin_event_offer_seconds' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `DAY_IN_SECONDS` |
Runs in `kits/events/inc/class-store.php:672`.
### poly_community_event_series_months
```php
function my_plugin_event_series_months( $value ) {
return $value;
}
add_filter( 'poly_community_event_series_months', 'my_plugin_event_series_months' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `6` |
Runs in `kits/events/inc/trait-series.php:190`.
## Listings
One hook of its own, in `kits/listings/`.
### poly_community_listing_directions_url
```php
function my_plugin_listing_directions_url( $url, $place ) {
return $url;
}
add_filter( 'poly_community_listing_directions_url', 'my_plugin_listing_directions_url', 10, 2 );
```
Runs in `kits/listings/inc/trait-page.php:143`.
## Votes
One hook of its own, in `kits/votes/`.
### poly_community_idea_status
```php
function my_plugin_idea_status( $item_id, $slug, $arg3, $context_profile_id ) {
// …
}
add_action( 'poly_community_idea_status', 'my_plugin_idea_status', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$item_id` | `(int) $item->id` |
| `$slug` | `$slug` |
| `$arg3` | `$before ? $before['slug'] : ''` |
| `$context_profile_id` | `(int) $context['profile_id']` |
Runs in `kits/votes/inc/trait-ideas.php:161`.
## Matching
3 hooks of its own, in `kits/matching/`.
### poly_community_matching_age_class
```php
function my_plugin_matching_age_class( $class, $profile_id, $facts ) {
return $class;
}
add_filter( 'poly_community_matching_age_class', 'my_plugin_matching_age_class', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$class` | `$class` |
| `$profile_id` | `(int) $profile_id` |
| `$facts` | `$facts` |
Runs in `kits/matching/inc/trait-scope.php:150`.
### poly_community_matching_age_sql
```php
function my_plugin_matching_age_sql( $value ) {
return $value;
}
add_filter( 'poly_community_matching_age_sql', 'my_plugin_matching_age_sql' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array( 'minor' => $minor, 'adult' => $adult )` |
Runs in `kits/matching/inc/trait-scope.php:177`.
### poly_community_matching_minors_meet
```php
function my_plugin_matching_minors_meet( $value ) {
return $value;
}
add_filter( 'poly_community_matching_minors_meet', 'my_plugin_matching_minors_meet' );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `false` |
Runs in `kits/matching/inc/trait-scope.php:193`.
## Member types
One hook of its own, in `kits/member-types/`.
### poly_community_member_type_changed
```php
function my_plugin_member_type_changed( $profile_id, $arg2, $arg3, $args_by ) {
// …
}
add_action( 'poly_community_member_type_changed', 'my_plugin_member_type_changed', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$profile_id` | `(int) $profile->id` |
| `$arg2` | `$after ? $after['slug'] : ''` |
| `$arg3` | `$before ? $before['slug'] : ''` |
| `$args_by` | `(int) $args['by']` |
Runs in `kits/member-types/inc/trait-members.php:58`.
## Organizations
2 hooks of its own, in `kits/organizations/`.
### poly_community_organization_created
```php
function my_plugin_organization_created( $id, $context_user_id ) {
// …
}
add_action( 'poly_community_organization_created', 'my_plugin_organization_created', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$id` | `$id` |
| `$context_user_id` | `(int) $context['user_id']` |
Runs in `kits/organizations/inc/trait-writes.php:127`.
### poly_community_organization_deleted
```php
function my_plugin_organization_deleted( $id, $keep ) {
// …
}
add_action( 'poly_community_organization_deleted', 'my_plugin_organization_deleted', 10, 2 );
```
Runs in `kits/organizations/inc/trait-writes.php:524`.
## Paid membership
10 hooks of its own, in `kits/payments/`.
### poly_community_billing_entitlement_shown
```php
function my_plugin_billing_entitlement_shown( $value, $entitlement ) {
return $value;
}
add_filter( 'poly_community_billing_entitlement_shown', 'my_plugin_billing_entitlement_shown', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `true` |
| `$entitlement` | `$entitlement` |
Runs in `kits/payments/inc/trait-blocks.php:420`, `kits/payments/views/billing.php:22`.
### poly_community_billing_more
```php
function my_plugin_billing_more( $me, $args_context ) {
// …
}
add_action( 'poly_community_billing_more', 'my_plugin_billing_more', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$me` | `$me` |
| `$args_context` | `$args['context']` |
Runs in `kits/payments/views/billing.php:92`.
### poly_community_pay_can_buy
```php
function my_plugin_pay_can_buy( $value, $user_id, $product, $price, $args ) {
return $value;
}
add_filter( 'poly_community_pay_can_buy', 'my_plugin_pay_can_buy', 10, 5 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `$no( 'no_product', _x( 'That is no longer on sale.', 'REST error', 'poly-community' ), 404 )` |
| `$user_id` | `$user_id` |
| `$product` | `$product` |
| `$price` | `$price` |
| `$args` | `$args` |
Runs in `kits/payments/inc/trait-sync.php:116`.
### poly_community_pay_describe
```php
function my_plugin_pay_describe( $said, $product ) {
return $said;
}
add_filter( 'poly_community_pay_describe', 'my_plugin_pay_describe', 10, 2 );
```
Runs in `kits/payments/inc/trait-sync.php:211`.
### poly_community_pay_released
```php
function my_plugin_pay_released( $order ) {
// …
}
add_action( 'poly_community_pay_released', 'my_plugin_pay_released' );
```
Runs in `kits/payments/inc/trait-sync.php:95`.
### poly_community_paywall_held
```php
function my_plugin_paywall_held( $value, $item, $product, $context ) {
return $value;
}
add_filter( 'poly_community_paywall_held', 'my_plugin_paywall_held', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `false` |
| `$item` | `$item` |
| `$product` | `$product` |
| `$context` | `$context` |
Runs in `kits/payments/kit.php:239`.
### poly_community_paywall_teaser
```php
function my_plugin_paywall_teaser( $value, $item, $other, $context ) {
return $value;
}
add_filter( 'poly_community_paywall_teaser', 'my_plugin_paywall_teaser', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `'
' . esc_html_x( 'This post is for some members only.', 'Post teaser', 'poly-community' ) . '
'` |
| `$item` | `$item` |
| `$other` | `$other` |
| `$context` | `$context` |
Runs in `kits/payments/inc/trait-blocks.php:321`.
### poly_community_paywall_text
```php
function my_plugin_paywall_text( $value, $item, $other ) {
return $value;
}
add_filter( 'poly_community_paywall_text', 'my_plugin_paywall_text', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `_x( 'This post is for some members only.', 'Post teaser', 'poly-community' )` |
| `$item` | `$item` |
| `$other` | `$other` |
Runs in `kits/payments/kit.php:462`.
### poly_community_space_plan_sets
```php
function my_plugin_space_plan_sets( $value, $space ) {
return $value;
}
add_filter( 'poly_community_space_plan_sets', 'my_plugin_space_plan_sets', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `array( Poly_Community()->money->space_plans( $space ) )` |
| `$space` | `$space` |
Runs in `kits/payments/kit.php:517`.
### poly_community_space_plans_sql
```php
function my_plugin_space_plans_sql( $value, $context, $alias, $team ) {
return $value;
}
add_filter( 'poly_community_space_plans_sql', 'my_plugin_space_plans_sql', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `''` |
| `$context` | `$context` |
| `$alias` | `$alias` |
| `$team` | `$team` |
Runs in `kits/payments/kit.php:337`.
## Ratings and warnings
5 hooks of its own, in `kits/ratings/`.
### poly_community_item_pictures
```php
function my_plugin_item_pictures( $has, $args ) {
return $has;
}
add_filter( 'poly_community_item_pictures', 'my_plugin_item_pictures', 10, 2 );
```
Runs in `kits/ratings/kit.php:807`.
### poly_community_item_rated
```php
function my_plugin_item_rated( $item_id, $rating, $now_r, $by ) {
// …
}
add_action( 'poly_community_item_rated', 'my_plugin_item_rated', 10, 4 );
```
| Argument | As the plugin passes it |
|---|---|
| `$item_id` | `(int) $item->id` |
| `$rating` | `$rating` |
| `$now_r` | `$now['r']` |
| `$by` | `$by` |
Runs in `kits/ratings/kit.php:1108`.
### poly_community_ratings_minor
```php
function my_plugin_ratings_minor( $value, $user_id, $arg3 ) {
return $value;
}
add_filter( 'poly_community_ratings_minor', 'my_plugin_ratings_minor', 10, 3 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `false` |
| `$user_id` | `$user_id` |
| `$arg3` | `$row ? (int) $row->age_band : 0` |
Runs in `kits/ratings/kit.php:330`.
### poly_community_ratings_vouched
```php
function my_plugin_ratings_vouched( $value, $user_id ) {
return $value;
}
add_filter( 'poly_community_ratings_vouched', 'my_plugin_ratings_vouched', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `false` |
| `$user_id` | `$user_id` |
Runs in `kits/ratings/kit.php:340`.
### poly_community_viewer_country
```php
function my_plugin_viewer_country( $value, $user_id ) {
return $value;
}
add_filter( 'poly_community_viewer_country', 'my_plugin_viewer_country', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `(string) $this->choices_of( (int) $user_id )['country']` |
| `$user_id` | `(int) $user_id` |
Runs in `kits/ratings/inc/trait-adult.php:51`.
## Trust levels
2 hooks of its own, in `kits/trust/`.
### poly_community_action_asked
```php
function my_plugin_action_asked( $value, $action ) {
return $value;
}
add_filter( 'poly_community_action_asked', 'my_plugin_action_asked', 10, 2 );
```
| Argument | As the plugin passes it |
|---|---|
| `$value` | `false` |
| `$action` | `$action` |
Runs in `kits/trust/kit.php:201`.
### poly_community_trust_level_changed
```php
function my_plugin_trust_level_changed( $user_id, $after, $before ) {
// …
}
add_action( 'poly_community_trust_level_changed', 'my_plugin_trust_level_changed', 10, 3 );
```
Runs in `kits/trust/inc/trait-levels.php:448`.
---
# Blocks
Address: https://www.poly-community.com/docs/reference/blocks/
Every one of the 408 blocks of Poly Community is stable, with every template part name and every `--poly-*` design token, as sites keep them in their templates. The blocks of a component are there while the component is on.
Each is a WordPress block drawn with the [Interactivity API](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/), and each declares `"supports": { "interactivity": true }` in its block.json: it uses the directives and works with [client-side navigation](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/core-concepts/client-side-navigation-compatibility/). See [Built on the Interactivity API](https://www.poly-community.com/docs/developers/interactivity-api/).
## The community
| Block | Name | What it is |
|---|---|---|
| Accept answer | `poly-community/accept-button` | Inside an answer: the mark of the accepted answer, and for the one who asked, the button to accept it. |
| Account menu | `poly-community/account-menu` | The member picture, opening their profile, settings and Log out. Log in and Join for visitors. One a page. |
| Account screen | `poly-community/account-screen` | A whole screen for logging in, signing up or a new password: the Community welcome beside the form, or the form over a picture. Its inner blocks are what it shows. |
| Account settings | `poly-community/account-settings` | The signed-in member email address, password, devices and deleting the account. Shown on the Account tab of Edit profile. |
| Achievements | `poly-community/achievements` | The Achievements of a profile tab: the member points with their rank and what is left to the next, the badges they earned, and to the member alone the badges on their way and their latest points. |
| Question answers | `poly-community/answer-count` | The answers of a question, in a box that turns solid once one is accepted. |
| Answer form | `poly-community/answer-form` | Your answer: the composer, or for one who answered already, Edit your answer. |
| Answers | `poly-community/answers` | The answers of a question: the accepted one first, then by votes (or newest, oldest), each through the template part Community answer. |
| Community | `poly-community/app` | The community page: its navigation, main column and sidebar, which are its inner blocks. Empty, it shows the default layout of the page it is on. |
| Ask button | `poly-community/ask-button` | Ask a question, in the Q&A topic the page is about. Visitors are asked to log in first. |
| Ask: question form | `poly-community/ask-form` | On Ask: the title and text of the question, in the composer, with tips. |
| Ask: Q&A topic | `poly-community/ask-topic` | On Ask: the Q&A topic the question goes in. |
| Badges | `poly-community/badges` | Every badge of the community: how each is earned, how many members have it, and a few of them. |
| Sub-boards | `poly-community/board-children` | A board sub-boards, as links. |
| Board numbers | `poly-community/board-counts` | A board number of topics, and how many are unread for the member. |
| Board latest topic | `poly-community/board-last-topic` | The topic last active in a board: its title, who wrote last and when. |
| Boards | `poly-community/board-list` | The forum boards, compact, with a dot where something is unread. |
| Community name | `poly-community/brand` | The community logo and name, linking to its home. Both are set in Poly Community → Settings → Appearance → Layout. |
| Forum breadcrumbs | `poly-community/breadcrumbs` | Where a page is: Forum, a category and the boards a board or topic is in. On a space inside others, Spaces and those spaces. |
| Call button | `poly-community/call-button` | Starts a video or audio call in Better Messages. Not with oneself. Where Better Messages calls are on. |
| Closed question notice | `poly-community/closed-notice` | Why a closed question is closed, or the question it repeats. Reopen for moderators. |
| Community footer | `poly-community/community-footer` | Small print: the site name (or your own text) and the year. |
| Community in numbers | `poly-community/community-stats` | How many members, posts and spaces the community has, and for signed-in members who is online. Counted every ten minutes. |
| Community welcome | `poly-community/community-welcome` | The community name, logo and a line about it, over its picture, with a few member faces on a public community. Beside the form on the account screen, or anywhere. |
| Post composer | `poly-community/composer` | Where members write a post: text, pictures, mentions, and who can see it. Shown to signed-in members only. |
| Contact the owner | `poly-community/contact-owner` | On a post page: Message where Better Messages runs, then its owner phone, email and website as its kind gives them, shown or revealed by a press as its kit page chooses. Nothing for a kind without them. |
| Earnings | `poly-community/earnings` | What the signed-in member sells: how they are paid, their balance, their sales, payouts and statements. Shown on the Earnings tab of Edit profile to members who sell. |
| Edit profile button | `poly-community/edit-profile-button` | Edit profile, on their own profile only. |
| Activity feed | `poly-community/feed` | Posts with their replies, likes and new posts as they arrive: Following (people and spaces the member follows) or Everyone, as the feed bar asks. It holds each post layout: the Community post part, shared by every feed, or blocks of its own. |
| Feed bar | `poly-community/feed-tabs` | For signed-in members, what the Activity feed shows: Following or Everyone, one kind of post, Latest or Top over a period. |
| Connect button | `poly-community/follow-button` | Follow, Add friend or both, as members connect on this site (Settings → Members). Nothing on their own profile. |
| Follow tag button | `poly-community/follow-tag-button` | Follow a hashtag: its posts join the member Following feed. Visitors are asked to log in. |
| Form | `poly-community/form` | A community form: an application, a request, a claim. Members answer it here. Once they have, it shows what they answered and where it stands. Its reviewers answer in the Requests block or Settings → Moderation. |
| Forum index | `poly-community/forum-index` | The forum boards, grouped by category, each with its topics, its latest topic and whether it holds unread ones. Each board shows as the Community board row part. |
| Forum post actions | `poly-community/forum-post-actions` | Like, Quote, Reply and Share under a post in a topic, and Mark as the solution in a board that takes solutions. |
| Forum tabs | `poly-community/forum-tabs` | Boards, Latest, Unread and Watching, with New topic at the end. |
| Install app button | `poly-community/install-app` | Lets a member install the community as an app: the browser prompt, or on an iPhone or iPad the steps. Shows only where the browser can install it and it is not installed, while Appearance → App has it on. |
| Comments | `poly-community/item-comments` | Inside a question or an answer: its comments, the first five then Show more, and Add a comment. |
| Ended banner | `poly-community/item-ended` | On a post page, once its life has ended: one line in its kind words (“This listing ended on 3 May”). Nothing while it runs. |
| Item field | `poly-community/item-field` | One field of a post, alone: its label and value, wherever the card or the page puts it. |
| Item fields | `poly-community/item-fields` | The fields of a post: in a card those marked for cards, the price first. Under a post all of them, label and value. |
| Item filters | `poly-community/item-filters` | How an Item list is narrowed and sorted: words to search for, a place and how far around it, a price range, the searchable field choices and ranges. All of it in the page address. |
| Item list | `poly-community/item-list` | The posts of a kind by their fields: each through its card, or for a kind with a place on one map, sorted and narrowed as the Item filters beside it say, featured ones first, new ones waiting behind a pill. |
| Item picture | `poly-community/item-picture` | A post picture in a card: its picture field, else its first. |
| Views and contacts | `poly-community/item-stats` | On a post page: how many times it was viewed, for whoever the site shows it to. For whoever looks after a listing-like post, the views this week and the presses of its owner phone, email or website, with its last two weeks drawn small. A kit page gets it in its head by itself. |
| Item title | `poly-community/item-title` | A post title in a card, leading to the post. |
| Join button | `poly-community/join-button` | Join, Request to join, Joined, Leave. |
| Latest topics | `poly-community/latest-topics` | The topics last active across the forum: their titles, boards and when. |
| Login form | `poly-community/login-form` | Logging in to the community, through WordPress login (two-factor and captcha plugins keep working), with Forgot your password and Create an account. For a member logged in already, a way into the community. Works on any page. |
| Forgot password form | `poly-community/lost-password-form` | Asking for a link to choose a new password, through the WordPress form (captcha and limit plugins keep working). It never says whether an account exists. Works on any page. |
| Community main column | `poly-community/main` | The main column of the page. Any blocks go in it, as wide as the page type has it: a feed, a list or a form width, or all the room the other columns leave. A members-only community shows visitors the login here instead. |
| Member buttons | `poly-community/member-actions` | The member buttons in a row: the Search button, Light and dark switch, Messages, Notifications bell and Account menu blocks, which can be reordered or removed. |
| Member picture | `poly-community/member-avatar` | The member picture. On their own profile it leads to changing it. |
| Member cover | `poly-community/member-cover` | The member cover picture. |
| Member distance | `poly-community/member-distance` | How far the member is, in a directory measured from a place: about, never under 1 km or mile. |
| Member fields | `poly-community/member-fields` | The member answers to the profile fields set to show on member cards, as each reader may see them. |
| Member handle | `poly-community/member-handle` | The member @handle. |
| Member headline | `poly-community/member-headline` | The line the member wrote under their name. |
| Member name | `poly-community/member-name` | The member name: a heading in a profile header, a link to the profile in a member card. |
| Member stats | `poly-community/member-stats` | Friends, followers and following as members connect on this site, and posts, each leading to its list. |
| Online status | `poly-community/member-status` | Online, while the member is. Nothing otherwise. |
| Member directory | `poly-community/members` | The members the tab, search and sort ask for, and Load more. It holds each member card: the Community member card part, shared by every member list, or blocks of its own. |
| Members search & sort | `poly-community/members-filters` | Search by name. Near a place, within a distance, where members have one. Recently active, Newest, Name or Nearest. And the profile answers marked as filters. |
| Members tabs | `poly-community/members-tabs` | Discover, then Friends and Following as members connect on this site, for signed-in members: which members the directory shows. |
| Message button | `poly-community/message-button` | Starts a conversation in Better Messages, where it is installed. Not with oneself. |
| Messages button | `poly-community/messages-button` | Opens the member conversations in Better Messages, with the unread count. Where Better Messages is installed. Signed-in members only. One a page. |
| Messenger | `poly-community/messenger` | Better Messages messenger, filling the column: the member conversations and the open one. Where Better Messages is installed. Guests are asked to log in. |
| My items | `poly-community/my-items` | The member posts of a kind, by state: active with when each ends, waiting for review, ended, drafts. Renew, end, edit or delete each. Only they see it. |
| Your spaces | `poly-community/my-spaces` | The signed-in member spaces, as links, with a way to all of them. The community spaces for visitors and members in none. |
| My requests | `poly-community/my-submissions` | What the signed-in member asked for with the community forms, where each stands, and taking one back. Shown on the Requests tab of Edit profile. |
| Community navigation | `poly-community/nav` | Activity, Members, Spaces and Profile, where Appearance → Layout puts them: a column, tabs, the top bar of the portal or behind a menu button. The member spaces are the Your spaces block. |
| Community menu button | `poly-community/nav-button` | Opens the community navigation as a panel. Shows where Appearance → Layout keeps the navigation behind a menu button: always with that choice, and on narrow screens with the navigation in the top bar or the phone tab bar off. |
| New members | `poly-community/new-members` | The members who joined last, newest first. It holds each member row: the Community member row part, shared by the short member lists, or blocks of its own. |
| New topic board | `poly-community/new-topic-board` | On New topic: the board the topic goes in, or the boards to pick from. |
| New topic button | `poly-community/new-topic-button` | Starts a topic: in the board shown, or with a board to pick. Visitors are asked to log in. |
| Not found message | `poly-community/not-found` | What an address under the community that holds nothing shows: that the page is not here, and a way back to the community. |
| Notification settings | `poly-community/notification-settings` | What the signed-in member is told about, in the community and by email. Shown on the Notifications tab of Edit profile. |
| Notifications list | `poly-community/notifications` | The signed-in member notifications. Showing them marks them as read. |
| Notifications bell | `poly-community/notifications-bell` | The bell with the unread count and the latest notifications. See all opens them all. Signed-in members only. One a page. |
| Online now | `poly-community/online-members` | Members who are here right now, for signed-in members: faces or rows, and how many in all. Follows who comes and goes without drawing the page again. |
| Waiting for an answer | `poly-community/open-questions` | Questions without an answer yet, those of their own Q&A topics first. |
| Community page button | `poly-community/page-action` | The button of the community page it is on: New space on Spaces, Mark all as read on Notifications, View profile on Edit profile, Back on a single post. Nothing on pages without one. |
| Community page header | `poly-community/page-header` | The title of the community page it is on, the line under it, and the page button, as one block. Layouts now build the head from a Heading, a Paragraph and the Community page button. This block still renders where it was saved. |
| Community page type | `poly-community/page-type` | Blocks that show on one type of community page only: the activity, a single post, a member profile, a space… In a classic theme the main column of a community page holds one for each page type of its section. |
| Page type widgets | `poly-community/page-widgets` | The widgets each page has by default for its type: Online now and Who to follow beside the members, Trending beside the activity. A page type given a Community page type block in the same widget area shows that block widgets instead. |
| Announcements | `poly-community/pinned-posts` | The posts an administrator pinned for everyone, as posts or as a list of titles. A member can hide one they have read. Shows nothing while none is pinned. |
| Points board | `poly-community/points-board` | The members with the most points: the whole community or the space it stands in, this week, this month or of all time. Or a contest, with its days and, once it ended, its winners. |
| Popular spaces | `poly-community/popular-spaces` | Spaces to find: the most members, the most active or the newest, or those the people a member knows are in. It holds each space row: the Community space row part, shared by the short space lists, or blocks of its own. |
| Single post | `poly-community/post` | The post a single post page is about, with every reply. |
| Post actions | `poly-community/post-actions` | Like, Reply and Share. |
| Post attachments | `poly-community/post-attachments` | Everything else the post carries that no other block of the layout shows, such as what a kit adds. |
| Post audio clip | `poly-community/post-audio` | The post audio clip: its waveform to play and seek, and its speed. |
| Post author | `poly-community/post-author` | Who wrote the post: picture, name, the space it is in, when, and who can see it. |
| Post text | `poly-community/post-content` | What the post says, with links and mentions. |
| Post files | `poly-community/post-files` | The files attached to the post besides its pictures: audio and video to play, documents and others to download. |
| Post GIF | `poly-community/post-gif` | The post GIF or sticker, when it has one: a GIF plays muted on a loop, and stands still for readers who ask for less motion. |
| Post images | `poly-community/post-images` | The post pictures: one at its own shape, two to four in a grid. |
| Post link | `poly-community/post-link` | The post link as a card: its picture, title and site, or a video player behind a click. |
| Post menu | `poly-community/post-menu` | The post ⋮ menu: copy its link, delete it (its author, admins and the space managers). |
| Post number | `poly-community/post-permalink` | A post number in its topic, linking to it. |
| Post place | `poly-community/post-place` | Where the post was written, or the place it is about: a line that opens the place on a map. |
| Post poll | `poly-community/post-poll` | The post poll or quiz: its options to vote on, then the results as they come in. |
| Post replies | `poly-community/post-replies` | The latest replies (all of them on the post page) and the reply form. |
| In reply to | `poly-community/post-reply-to` | Which post a reply answers, linking to it. |
| Author role in the board | `poly-community/post-role` | A chip saying the author is an admin or a moderator of the board. |
| Post shared | `poly-community/post-shared` | The post a share shows, as a card under the share words: drawn for each reader as they may see it. |
| Post tags | `poly-community/post-tags` | A post, a topic or a question hashtags as chips, each leading to its page (in a board or a Q&A topic list, to that list filtered by it). |
| Post video | `poly-community/post-video` | The post video: its poster, then the player once it is ready. |
| Post blog card | `poly-community/post-wp` | A post of the site itself, brought into the feed: its featured picture, title and excerpt, and a link to read it. |
| Privacy settings | `poly-community/privacy-settings` | The members and posts the signed-in member muted, and the members they blocked. Shown on the Privacy tab of Edit profile. |
| Profile completeness | `poly-community/profile-completeness` | How complete the member profile is, and the next things to add, each a link to its place on Edit profile. Only the member sees it, only while their profile is incomplete, and only where Settings → Members → Profile fields counts completeness. Works on any page. |
| Profile tab content | `poly-community/profile-content` | What the current tab of the profile shows: the member posts, About, Friends (with their requests on their own profile), Followers or Following. |
| Profile details | `poly-community/profile-details` | Beside a profile: the short About of its member, their location, website and spaces. Shows nothing on other pages. |
| Edit profile form | `poly-community/profile-form` | The picture, cover, name, headline and profile fields of the signed-in member. |
| Profile header | `poly-community/profile-header` | The card at the top of a profile, holding its blocks: cover, picture, name, @handle, headline, stats, buttons and tabs. Rearrange or remove any of them. |
| Profile menu | `poly-community/profile-menu` | More: copy the profile link, block the member. |
| Profile tabs | `poly-community/profile-tabs` | Posts, About, then Friends, Followers and Following as members connect on this site, the one open marked. |
| Question breadcrumbs | `poly-community/question-breadcrumbs` | Questions › its Q&A topic. |
| Close question | `poly-community/question-close` | Closing a question is in the ⋯ menu of the question: this block draws nothing. |
| Question excerpt | `poly-community/question-excerpt` | The start of a question text, on one or two lines. |
| Questions filters | `poly-community/question-filters` | The sorts of the questions (Newest, Active, Unanswered, Most votes), the Q&A topics as chips, and Asked by me and Watching. |
| Question header | `poly-community/question-header` | The head of a question page: its blocks (breadcrumbs, title, details, Watch, Close, Ask) inside. |
| Questions | `poly-community/question-list` | Questions as a list: their votes, answers (the accepted mark), title, an excerpt, the topic and the asker. Follows the page sort, topic and filter, or shows the questions it is set to. |
| Question details | `poly-community/question-meta` | Who asked and when. On a question page, when it was asked and last active, and its answers. |
| Question | `poly-community/question-post` | The question itself: its votes, text, pictures and files, the asker and the comments. Each part of it is the template part Community question. |
| Question title | `poly-community/question-title` | A question title, with Closed or Duplicate beside it. |
| Question topic | `poly-community/question-topic` | The Q&A topic a question was asked in, as a chip. |
| Q&A topic bar | `poly-community/question-topic-head` | On a Q&A topic page: its picture, how many questions it has, and Watch. |
| Registration form | `poly-community/register-form` | Creating an account: name, username, email, password and the profile fields asked at sign-up, then the email to confirm where the site asks for one. Says so when sign-ups are closed. Works on any page. |
| Related questions | `poly-community/related-questions` | Beside a question: questions with similar words. |
| Relationships | `poly-community/relationships` | The relationships of a member of one type a kit adds (mentors and mentees, vouches), each side as its own section, and on their own profile the requests waiting. |
| New password form | `poly-community/reset-password-form` | Choosing a new password from the emailed link, checked as WordPress checks it (password policy plugins keep working). Then the member logs in with it. Works on any page. |
| Review form | `poly-community/review-form` | Where a member writes their review of a thing: stars, a few words and an optional title, or changes the one they wrote. Says why when they cannot review it. On a page it is about the page post or member. |
| Review list | `poly-community/review-list` | The reviews of a thing, newest, highest or lowest first, with Load more, and its owner answer under each. On a page it is about the page post or member. |
| Review summary | `poly-community/review-summary` | What members thought of a thing: the average to one decimal, how many reviews, and a bar for each number of stars. Shows nothing while there are no reviews. In a card it is about the card post. On a page, the page post or member. |
| Saved posts | `poly-community/saved-posts` | The posts the member saved from a post menu, the latest saved first. Only they see it, and a post they may no longer see leaves it. |
| Saved searches | `poly-community/saved-searches` | The searches the signed-in member saved from the community lists, how often each tells them what is new, and renaming, opening or deleting each. Shown on the Alerts tab of Edit profile. |
| Light and dark switch | `poly-community/scheme-toggle` | Switches the community between light and dark. Shows when Appearance has the switch on. One a page. |
| Community search | `poly-community/search` | A search box with suggestions as you type. |
| Search button | `poly-community/search-button` | A magnifier that opens the community search, with suggestions as you type. One of the member buttons: it goes in the site menu. One a page. |
| Search results | `poly-community/search-results` | The Search page: the search box, a tab per kind (All, People, Spaces, Posts) and what matches, only what the visitor may see. |
| Settings tabs | `poly-community/settings-tabs` | The tabs of the signed-in member settings: Profile, Notifications, Privacy and Account. |
| Share button | `poly-community/share-button` | Copies the link of the space, or the member, it is about. |
| Community sidebar | `poly-community/sidebar` | A column beside the main one, on either side. A page can have more than one. Any blocks go in it, the Community sidebar widgets block included (classic themes). The one holding the community navigation is the navigation column. |
| Account field | `poly-community/signup-account` | The account name, username, email address, phone number or password. Which of the email address and the phone number are asked is set under Joining → Signing up: the form adds them to its first step where they are missing and leaves out those the site does not ask. A password is always asked. Without a username, one is made from the name. |
| Agreement | `poly-community/signup-agreement` | A box to tick before going on, linking to the terms and the site privacy policy. |
| Profile picture | `poly-community/signup-picture` | A profile picture or a cover picked at sign-up, cropped in the browser before it is sent. Optional unless it is required here. |
| Profile field | `poly-community/signup-profile-field` | A profile field asked at sign-up. Its type, options, width and who sees it are set in Poly Community → Settings → Members → Profile fields. The form only places it. |
| Sign-up step | `poly-community/signup-step` | One step of the Registration form: its title, a line under it, and the fields it asks. Next takes the visitor on once the step is checked and kept. |
| Verification | `poly-community/signup-verification` | An identity check (a document and a selfie) or an age check at the service set up in Poly Community → Settings → Identity and age checks, on a step after the first. The visitor goes to the service page and comes back to the form. Optional unless it is required here. Shows nothing where the site checks no such thing. |
| Similar questions | `poly-community/similar-questions` | On Ask: questions like the one being written, while its title is typed. |
| Space activity | `poly-community/space-activity` | When something last happened in the space. |
| Space picture | `poly-community/space-avatar` | The space picture. |
| Space chat | `poly-community/space-chat` | The space group chat in Better Messages, with its group calls, on the space Messages tab. For its members, where Better Messages is installed and space chats are on (Settings → Messages). |
| Space chat button | `poly-community/space-chat-button` | Opens the space group chat in Better Messages. For its members, where Better Messages is installed and space chats are on (Settings → Messages). |
| Space tab content | `poly-community/space-content` | What the current tab of the space shows: its posts, Members (with join requests for its admins) or About. |
| Space cover | `poly-community/space-cover` | The space cover picture. |
| Delete space | `poly-community/space-danger-zone` | Deleting the space, its name typed to confirm, for its owner and the site administrators. Shown on the General tab of its settings. |
| Space details | `poly-community/space-details` | Beside a space: what it is about and, unless Who runs it shows them, its admins. Shows nothing on other pages. |
| New space form | `poly-community/space-form` | Create a space: name, description, cover and who can see and join it. |
| Space header | `poly-community/space-header` | The card at the top of a space, holding its blocks: cover, picture, name, privacy, stats, members, Join, share and tabs. Rearrange or remove any of them. |
| Space invite button | `poly-community/space-invite-button` | Invite members to the space by name. For its members who may invite: its admins and moderators, or every member where the space says so. |
| Space manage button | `poly-community/space-manage-button` | Leads the space admins, and the site administrators, to its settings. |
| Space member pictures | `poly-community/space-member-avatars` | A few of the space member pictures. |
| Space menu | `poly-community/space-menu` | The space ⋯ menu: its settings, inviting where no button offers it, copying its link, and leaving it. |
| Space name | `poly-community/space-name` | The space name: a heading in a space header, a link to the space in a space card. |
| Space post settings | `poly-community/space-posts-form` | Who posts in the space, whether posts need a title, and the composer tools it offers. Shown on the Posts tab of its settings. |
| Space privacy | `poly-community/space-privacy` | Who can see and join it: Public, Members only, Private or Hidden. |
| Space privacy settings | `poly-community/space-privacy-form` | Who can see the space, how people join it and who may invite, for its admins. Shown on the Privacy tab of its settings. |
| Space rules | `poly-community/space-rules` | Beside a space: its rules, numbered, the first three then Show all. Shows nothing on other pages or where a space has none. |
| Space settings form | `poly-community/space-settings-form` | A space picture, cover, name, description, address and rules, for its admins. Shown on the General tab of its settings, where a kit tab shows too. |
| Space settings tabs | `poly-community/space-settings-tabs` | The tabs of the settings of a space: General, Privacy, Posts, and those of a kit. |
| Space stats | `poly-community/space-stats` | Members and posts. |
| Space summary | `poly-community/space-summary` | What the space is about, shortened. |
| Space tabs | `poly-community/space-tabs` | Posts, Members and About, the one open marked. |
| Who runs it | `poly-community/space-team` | Beside a space: its admins and moderators, each with their role. Shows nothing on other pages. |
| Spaces directory | `poly-community/spaces` | The spaces the tab, search and sort ask for, and Load more. It holds each space card: the Community space card part, or blocks of its own. |
| Spaces search & sort | `poly-community/spaces-filters` | Search spaces, and Active, Most members or Newest. |
| Spaces tabs | `poly-community/spaces-tabs` | Discover and Your spaces for signed-in members, and New space at the row end for those who may create one. |
| Requests to review | `poly-community/submission-list` | The requests of a form for its reviewers: a tab a status with how many, the answers of each request opened in place, Accept, Decline with a reason they read, notes only reviewers see. Nobody else sees it. |
| Tag filter | `poly-community/tag-filter` | Above a board or a Q&A topic list filtered by a hashtag: which one, the way to its page, and Clear. |
| Tag name | `poly-community/tag-name` | A hashtag name as its page title, with its mark. |
| Tagged posts | `poly-community/tag-posts` | The posts, topics or questions a hashtag tags, newest first, new ones as they are posted. On a tag page, that tag. Anywhere else, the tag you name. |
| Tag numbers | `poly-community/tag-stats` | How many posts a hashtag has that the reader audience may see, kept up to date as members post. |
| Tag tabs | `poly-community/tag-tabs` | Posts, Topics and Questions of a hashtag, each shown once it has any. Nothing when it has one kind only. |
| Category path | `poly-community/term-crumbs` | Where a post is in its categories (Listings › Food › Cafés), each step opening the list in it, said to search engines as breadcrumbs. |
| Category tiles | `poly-community/term-grid` | A directory index: a tile for each category of a tree (its top ones, those inside one, or those inside the page), each its icon or picture, its name and how many posts it holds, opening the list in it. |
| Community top bar | `poly-community/topbar` | The portal header bar. Its blocks are the community name and the member buttons by default, with the menu button and the navigation where Appearance → Layout puts them there. Any block can join them, such as the site menu. |
| Topic numbers | `poly-community/topic-counts` | The replies of a topic, views (for whom the site shows them) and readers (members who read it). |
| Topic header | `poly-community/topic-header` | The card at the top of a topic, holding its blocks: breadcrumbs, title, status, byline, Watch and the topic menu. Rearrange or remove any of them. |
| Topic last reply | `poly-community/topic-last-reply` | Who replied last to a topic, and when. |
| Topic list | `poly-community/topic-list` | Topics as a list: a board, the latest across boards, the member unread or watched ones. Pinned first, sorted by activity or newest, with Load more. Each topic shows as the Community topic row part. |
| Topic menu | `poly-community/topic-menu` | A topic ⋯ menu: pin, lock, move and delete for its moderators. Copy link, mute and report for everyone. |
| Topic byline | `poly-community/topic-meta` | Who started a topic and when. On its page also its replies and readers. |
| Topic pages | `poly-community/topic-pager` | A topic numbered pages, and Jump to first unread. |
| Topic participants | `poly-community/topic-participants` | The faces of up to four members who replied to a topic lately. |
| Topic posts | `poly-community/topic-posts` | The first post of a topic and a page of its replies, oldest first. Each shows as the Community forum post part. |
| Topic reply box | `poly-community/topic-reply` | Where members reply at the end of a topic. A locked topic says so, and visitors are asked to log in. |
| Topic solution | `poly-community/topic-solution` | In a solved topic, the solution words and a link to it. |
| Topic status | `poly-community/topic-status` | Whether a topic is pinned, locked or solved, as icons in a row or chips on its page. |
| Topic title | `poly-community/topic-title` | A topic title: a link in a list, with how many replies are new. The heading on its page. |
| Trending | `poly-community/trending-posts` | The posts people like and reply to most, of the last day or week: what each says, who wrote it, its likes and replies. Only posts open to everyone or to members show, each to whoever may see it. |
| Trending tags | `poly-community/trending-tags` | The hashtags of the most posts this week, counted every hour. Only posts open to everyone or to members count, of the reader audience. |
| Verification settings | `poly-community/verification-settings` | Where the signed-in member stands with the community ways to verify, and what to do next. Shown on the Verification tab of Edit profile. |
| Welcome for visitors | `poly-community/visitor-welcome` | For visitors alone, nothing for members: the community name and a line about it, a few member faces on a public community, Join and Log in. |
| Vote buttons | `poly-community/vote-buttons` | Inside a question or an answer: the vote button and its score. |
| Question votes | `poly-community/vote-count` | The votes of a question, in a box. |
| Watch button | `poly-community/watch-button` | Watch a topic or a board to hear of its new replies or topics. |
| Who to follow | `poly-community/who-to-follow` | Members the signed-in member may want to follow or befriend (People you may know, where members are friends), with their buttons. It holds each member row: the Community member row part, shared by the short member lists, or blocks of its own. |
| Community sidebar widgets | `poly-community/widget-area` | The Community sidebar widget area, edited in Appearance → Widgets. Classic themes only. In a block theme it shows nothing. |
## Courses
| Block | Name | What it is |
|---|---|---|
| Course details | `poly-community/course-about` | One part of what a course says of itself: what you will learn, who it is for, before you start, or its description. |
| Course builder | `poly-community/course-builder` | A course builder: its outline of sections and lessons beside the editor of what is picked, its Basics, team and publishing. |
| Course: bundle | `poly-community/course-bundle` | A bundle page: its courses, what they cost apart and together, and Buy. Its owner edits it there. |
| Course: certificate | `poly-community/course-certificate` | A certificate page: whether it is valid, the certificate to print, its LinkedIn link and its address. |
| Course cover | `poly-community/course-cover` | A course cover at sixteen by nine, leading to its page. |
| Course enrol card | `poly-community/course-enrol` | What a course costs, its one action for the viewer (Enrol, Start, Log in to enrol, Edit) and what is in it. On a phone its action stays in a bar at the bottom. As a banner: the action and progress in the course header. As a bar: only the phone bar. |
| Course facts | `poly-community/course-facts` | A course level, language, how many lessons and how long, and its students, in one line. |
| Course: finished | `poly-community/course-finish` | A finished course for its student: what they completed, how long it took, and what is next. |
| Course header | `poly-community/course-header` | The top of a course page: its cover beside the blocks it holds (its path, title, line of reviews, facts and teachers). |
| Course instructors | `poly-community/course-instructors` | A course owner and instructors as the community member cards. |
| Course marking | `poly-community/course-marking` | A course quiz answers waiting for its team marks: each answer, its points and a comment for the student. |
| Course: where I stand | `poly-community/course-mine` | On a course card, for its student: how far they are, and Continue, or Finished once they are. |
| Course: more from its instructor | `poly-community/course-more` | Up to three more published courses by the same instructor, as the catalogue cards. |
| New course form | `poly-community/course-new` | Making a course: its title and a line about it, then its builder opens. |
| Course: my notes | `poly-community/course-notes` | The notes of a student in a course, lesson by lesson, each at its video time, with a file of them all to download. |
| Course outline | `poly-community/course-outline` | The sections of a course and their published lessons, each with its kind and length. A long course folds its sections. |
| Course student | `poly-community/course-student` | One student of a course for its team: each lesson as it stands for them, each quiz try and hand-in with its mark, another try granted and their place. |
| Course students | `poly-community/course-students` | The students of a course for its team: when each enrolled, how far they have come, when they were last active and their marks, found by name and sorted. |
| Course teachers | `poly-community/course-teachers` | Who teaches a course: its owner and instructor faces and names. |
| Course title | `poly-community/course-title` | A course title as its page heading, with its one-line summary under it. |
| Course player: bar | `poly-community/learn-bar` | The course player bar: back to the course, its title and that of the lesson, the lesson switch, before and after, how far the student is, their notes and more. |
| Course player: lesson | `poly-community/learn-lesson` | The lesson open in the course player, as its kind draws it: a video resuming where the student left it, text with its pictures, an embedded player, files to download. |
| Course player: next | `poly-community/learn-next` | Under the lesson: the one before it, and the one way on: Complete and next, Next, or the finish. |
| Course player: notes | `poly-community/learn-notes` | The student notes on the open lesson, saved as they are typed, each at the video time where it has one. |
| Course player: lessons | `poly-community/learn-outline` | The course player outline: its sections and lessons, each with where the student stands in it, the open one marked. A sheet on a phone. |
| My learning | `poly-community/my-learning` | The courses the member takes: in progress, not started, finished, each with Continue and Leave. |
| Profile: learning | `poly-community/profile-learning` | The courses of a member on their profile: those they finished and show, with their certificates, and for the member their courses in progress. |
| Teaching list | `poly-community/teaching-list` | The courses the member builds, drafts too, each opening its builder. |
## Events
| Block | Name | What it is |
|---|---|---|
| Event description | `poly-community/event-about` | The event text, its files, likes and replies. |
| Add to calendar | `poly-community/event-add-to-calendar` | Adds the event to Google Calendar, Outlook or Apple Calendar. |
| Who is going | `poly-community/event-attendees` | The faces of members going, who may go, and the waiting list for its host. |
| Event calendar | `poly-community/event-calendar` | A month of events as a calendar, with the month before and after. On a phone, a list of its days. |
| Event places | `poly-community/event-capacity` | How many places are left, as a bar, with how many are going and waiting. |
| Check-in | `poly-community/event-checkin` | The members going, for its hosts at the door: search, tap to check in, undo, how many are in. |
| Event picture | `poly-community/event-cover` | An event picture in a row of a list. Without one, the picture of its space or of the community. |
| Event date badge | `poly-community/event-date-badge` | The day an event starts, as a calendar leaf. |
| Event form | `poly-community/event-form` | Creating or editing an event: its name, cover, time and time zone, place or link, places and text. |
| Event header | `poly-community/event-header` | The event card at the top of its page: holds its date, name, time, place, host, the answer buttons and Add to calendar. |
| Event host | `poly-community/event-host` | Who hosts it, and the space it is in. |
| Event invitations | `poly-community/event-invites` | For its hosts: invite members by name to an event by invitation, and see who answered. |
| Event list | `poly-community/event-list` | Events, soonest first and by day: upcoming, those of the viewer, those they host, or past. On the Events of a space tab, that space. |
| Event tools | `poly-community/event-manage` | For its host: edit, cancel, and the attendance list. |
| Event place | `poly-community/event-place` | Where it is, or Online with the link to join for members going. |
| Requests to come | `poly-community/event-requests` | The requests of an approval for its hosts: the answers, Accept, Decline with a reason, notes. |
| Event numbers | `poly-community/event-row-meta` | The numbers of an event in a row of a list: going, places left, its price, its space, whether it repeats. |
| Event answer | `poly-community/event-rsvp` | Going, Maybe and Cannot go, and the waiting list when it is full. |
| Event roles | `poly-community/event-slots` | The roles an event needs, how many each, and who took them. Members going take one here. |
| Event summary | `poly-community/event-summary` | The first lines of an event text, in a row of a list. |
| Event tabs | `poly-community/event-tabs` | Upcoming, Calendar, Going, Hosting and Past, with New event and Subscribe. |
| Event tickets | `poly-community/event-tickets` | For its hosts: tickets sold, the money in, and what a cancelled event refunds take. |
| Event time | `poly-community/event-time` | When it is, in the reader time zone, with the event named when they differ. |
| Event name | `poly-community/event-title` | The event name, and whether it is cancelled, full or over. |
| Upcoming events | `poly-community/upcoming-events` | The next events, live. Beside a space, its own. |
## Jobs
| Block | Name | What it is |
|---|---|---|
| About the job | `poly-community/job-about` | A job description, its benefits and the rest of its details. |
| Job application | `poly-community/job-application` | One application, for its candidate and the job employer: what was sent, where it stands and the messages. Moving it along, or withdrawing it. |
| Job applications | `poly-community/job-applications` | A job pipeline for whoever hires for it: a column for each stage with its number, a card for each applicant to move by dragging or from its menu, several at once, and the application opened beside them. |
| Apply to a job | `poly-community/job-apply` | Apply by email or on the employer site, with Save, Share and the job menu. On a phone, Apply at the screen foot. |
| Candidates | `poly-community/job-candidates` | Members open to work who let the viewer find them, as cards with what each is looking for, Message and their CV. Filtered by category, type, workplace, experience or a job the viewer posted. |
| Job company | `poly-community/job-company` | The company card beside a job: its logo, name and line, leading to its page where it has one. |
| Company other jobs | `poly-community/job-company-jobs` | On the Jobs of an organization tab, for its team alone: its jobs not open now (closed, filled, waiting for review or payment, and the drafts of the viewer for it), each with where it stands and its applicants. |
| Job facts | `poly-community/job-facts` | A job salary, type, experience and workplace as equal tiles. |
| Job form | `poly-community/job-form` | A new job or its edit, on one page: the company, the job, its pay, its description and how to apply. |
| Job header | `poly-community/job-header` | The top of a job page: holds the company logo, the title, where and when, the facts and Apply. |
| Job company and place | `poly-community/job-line` | In a job row: the company, where it is or Remote, how far, its type and experience. |
| Job company logo | `poly-community/job-logo` | The company logo, else its initials, in a job row or at the head of its page. |
| Job poster bar | `poly-community/job-manage` | Above a job page, for whoever may change it: where it stands, Edit, and Publish for a draft. |
| Job salary and date | `poly-community/job-pay` | In a job row: its salary as people read it, its category, and how long ago it was posted. |
| Job search | `poly-community/job-seeker` | Edit profile → Job search: whether the member is open to work, who sees it, the organizations whose people never do, their CV and what they are looking for. |
| Job title | `poly-community/job-title` | A job title with where it stands when it is not open, the company, where it is, and when it was posted and closes. |
| Jobs heading | `poly-community/jobs-heading` | The heading over the board list and its filters. |
| My applications | `poly-community/my-applications` | The jobs a member applied to in the community: when, where each stands, and what the employer wrote. |
## Listings
| Block | Name | What it is |
|---|---|---|
| Listing description | `poly-community/listing-about` | A listing description, as its owner wrote it. |
| Listing actions | `poly-community/listing-actions` | Save, Share and the listing menu, as a post has them. |
| Listing claims | `poly-community/listing-claims` | For the site moderators: the claims of the listing, each with what was sent, to accept or decline. |
| Listing contact | `poly-community/listing-contact` | The ways to reach a listing owner the viewer may use: Message, Call, Email, the website. A bar at a phone foot. |
| Listing details | `poly-community/listing-details` | The other fields of a listing as a table of facts, each drawn as its type draws it. |
| Listing price and facts | `poly-community/listing-facts` | A listing price or whether it is open now, the key facts its category asks, and when it was listed. |
| Listing form | `poly-community/listing-form` | A new listing or its edit, in steps: its category, details, photos, place, contact and a last look. |
| Listing photos | `poly-community/listing-gallery` | The photos of a listing, the cover first: one large and the next beside it, swiped on a phone, each opening the image viewer. |
| Listing header | `poly-community/listing-header` | The top of a listing page: holds its category path, title, reviews, price and key facts, Save and Share. |
| Listing opening hours | `poly-community/listing-hours` | A place week of opening hours, today marked, with its closed days. |
| Listing tools | `poly-community/listing-manage` | For whoever may change the listing: where it stands and when it ends, its numbers, Edit, Renew, Mark sold or Close, Feature, and taking it back to the drafts. |
| Listing category and place | `poly-community/listing-meta` | In a listing card: its category, its area or city, and how far it is where the list measures. |
| Listed by | `poly-community/listing-owner` | Who lists it: their picture, name, since when they are a member and their other listings. |
| Listing place | `poly-community/listing-place` | Where a listing is, as exactly as its owner shows it: its map where the site draws maps, and Get directions. |
| Listing price or hours | `poly-community/listing-price` | In a listing card: its price, or Free, and whether a place is open now. |
| Listing title | `poly-community/listing-title` | A listing title, with where it stands when it is not simply out, and Featured. |
| Listings heading | `poly-community/listings-heading` | The heading over the directory list and its filters. |
| My listings | `poly-community/my-listings` | The member listings by where each stands (active, waiting, ended, drafts), each with when it ends and what to do next. |
## Live
| Block | Name | What it is |
|---|---|---|
| Go live button | `poly-community/go-live-button` | For whoever may go live: on their own profile, and in a space they post in. |
| Live post | `poly-community/live-about` | The live post under the player: its host, Live and how many watch, its title and text, likes and replies. |
| Post live | `poly-community/live-card` | A live in a post: its picture, LIVE and how many watch, or how it went. |
| Live chat | `poly-community/live-chat` | The live chat, beside the player (below it on a phone). |
| Live details | `poly-community/live-details` | Who is live, since when, and how many watch. |
| Live post head | `poly-community/live-head` | The head of a live post on its page: its host, Live or Ended, since when and how many watch, or how it went. |
| Live host | `poly-community/live-host` | A live row member, and the space it is in. |
| Lives | `poly-community/live-list` | Who is live now, or was lately: everywhere, or in the space whose tab it is. |
| Live times | `poly-community/live-meta` | A live row line: since when and how many watch, or how long and how many watched. |
| Live now | `poly-community/live-now` | Who is live now, kept up to date. It stands unseen while no one is. |
| Live player | `poly-community/live-player` | The live picture while it is live, and how it went once it ends. |
| Live picture | `poly-community/live-poster` | A live row picture: LIVE and how many watch, or how long it was. |
| Live studio | `poly-community/live-studio` | Live Stream studio for the member going live, with the chat beside it. |
## Photo albums
| Block | Name | What it is |
|---|---|---|
| Album replies | `poly-community/album-about` | On an album page: the album as a post, its likes and its replies. |
| Album cover | `poly-community/album-cover` | In an album card: its cover photo, a square, with how many photos it holds. |
| Album form | `poly-community/album-form` | Making or editing an album: its name, who sees it, and its photos, uploaded many at once, put in order, captioned and described. |
| Album photos | `poly-community/album-grid` | The photos of an album as a grid, a page at a time, each opening the picture viewer. On an event page, its gallery. Whoever may add photos adds many at once here. |
| Album header | `poly-community/album-header` | On an album page: its name, who made it, how many photos it holds, who sees it, its text, and Edit album for who runs it. |
| Photos tab | `poly-community/album-list` | The albums of a profile or a space as cards, and on a profile all of its photos too. New album for whoever may make one. |
| Album photo | `poly-community/album-photo` | On a photo page: the photo large with its caption, its album and the photos either side, then its likes and replies. |
| Album name | `poly-community/album-title` | In an album card: its name, leading to it, and how many photos it holds. |
| Latest photos | `poly-community/latest-photos` | The newest photos of the albums each reader may see, each leading to its album. It fills as photos are added. |
## Votes
| Block | Name | What it is |
|---|---|---|
| Idea details | `poly-community/idea-meta` | In a roadmap card: the space the idea was posted in, and how many replies it has. |
| Idea status | `poly-community/idea-status` | An idea status, such as Planned or Done, as a chip in its colour. The space admins and moderators change it from there. |
| Idea title | `poly-community/idea-title` | In a roadmap card: the idea title, or its first words, leading to it. |
| New petition form | `poly-community/petition-form` | Start a petition: where, what it asks for and why, its goal, its last day, and whether its signer names are listed. |
| Petitions | `poly-community/petition-list` | The petitions the viewer may see: open ones, newest first, or closed ones, each through the petition row part. |
| Petition progress | `poly-community/petition-progress` | The signatures of a petition toward its goal, the days left, and Sign. It moves as people sign. |
| Petition signers | `poly-community/petition-signers` | On a petition that lists its signers: those who chose to show their name, the latest first. Nothing on a petition that only counts. |
| Petition name | `poly-community/petition-title` | In a petition row: what it asks for, leading to it, and who started it where. |
| Vote buttons for posts | `poly-community/post-votes` | A post, a topic or a reply votes: up, its score, and down where its space allows it. Shows only where the space takes votes. |
| Roadmap | `poly-community/roadmap` | A column for each status on the roadmap, its ideas by their votes, of every space that collects ideas or of one. Each reader sees only the ideas they may read. |
| Ideas by status | `poly-community/vote-filters` | Above the topics of a board, where they are ideas: a chip a status, which lists only its ideas. |
| Vote score | `poly-community/vote-score` | A topic or a post votes as a number, for a row in a list. Shows only where the space takes votes. |
## Applications to join
| Block | Name | What it is |
|---|---|---|
| Community application | `poly-community/community-application` | A member waiting for approval applies to join the community: its agreement first, then your questions. Then where it stands, its vouches and the link to share. On Edit profile Application tab. |
| Agreements and vouches | `poly-community/my-agreements` | On Edit profile Requests tab: the agreements a member accepted (the text, its version, when), any asked again, the vouches they gave, and the community roles they may apply for. |
| Request forms | `poly-community/request-forms` | The request forms you make (maintenance, a grievance, a ticket), one at a time: what a member sends only they and its reviewers see. |
| Requests to review | `poly-community/review-queue` | The community applications and requests, a queue at a time, for those who answer them: answers, vouches, notes only they read, Assign, Accept, Decline with a message. |
| Space requests | `poly-community/space-requests` | The requests of a space to join and to help run it, for its team: answers, vouches, notes, Assign, Accept, Decline with a message. Its Requests tab. |
| Vouch | `poly-community/vouch-card` | The page an applicant link opens: who asks and what for, and Vouch for a member who may. |
## Matching
| Block | Name | What it is |
|---|---|---|
| How well you match | `poly-community/matching-compatibility` | On another member profile: how well the viewer and they match by their answers, where both answered enough of the same questions. |
| Discover | `poly-community/matching-discover` | A few members at a time to choose or pass, in a grid or one at a time, a stack to swipe on a phone. |
| Meet people going | `poly-community/matching-event` | On an event, for members going: take part in its Discover, and open it. |
| Discover filters | `poly-community/matching-filters` | Discover by age and distance, and in a grid or one at a time. |
| Likes you | `poly-community/matching-likes` | The members who chose the member: who they are, or only how many, as the owner says. |
| Matches | `poly-community/matching-matches` | The members the member and they both chose, with a message and a way to end it. |
| Mentoring | `poly-community/matching-mentoring` | The member mentor and mentees this cycle, requests asked of them and sent, and whether they take mentees. |
| Mentors with room | `poly-community/matching-mentors` | Mentors who take mentees and have a place left this cycle, for a member to ask. |
| Matching questions | `poly-community/matching-questions` | The answers of a member to the matching questions, which answers they accept from others and how much each matters. |
| Discover choices | `poly-community/matching-settings` | Edit profile → Privacy: whether the member is in Discover, and whether they show their visits. |
| Suggest a match | `poly-community/matching-suggest` | For matchmakers: suggest that two members meet, and see whether each suggestion became a match or lapsed. |
| Suggested for you | `poly-community/matching-suggestions` | Members a matchmaker suggested the member meets, each to say yes or no to, privately. |
| Discover tabs | `poly-community/matching-tabs` | Discover, who likes the member, their matches and who viewed them. |
| Profile visit | `poly-community/matching-visit` | On a profile: notes the visit for Who viewed you, only when the visitor and the member both show their visits. Shows nothing. |
| Who viewed you | `poly-community/matching-visitors` | For a member who shows their visits: who looked at their profile lately. |
| Your Discover | `poly-community/matching-you` | Beside Discover pages: their own side of it, whether they are shown there, how many of the questions they answered, and a tip. Names no other member. |
## Member types
| Block | Name | What it is |
|---|---|---|
| Birthday settings | `poly-community/birthday-settings` | Edit profile card where members choose whether their birthday shows in Birthdays, and with their age. |
| Birthdays | `poly-community/birthdays` | Members whose birthday is today or this week, of those who chose to show theirs. |
| Member type badge | `poly-community/member-type-badge` | A member type beside their name, in its colour: a profile header or a member card piece. Where it shows by itself is Settings → Components → Member types. |
| Member type filter | `poly-community/member-type-filter` | The member directory by type: Everyone, then each member type with how many there are. |
| Member type | `poly-community/member-type-picker` | Edit profile card where members see their type and change it, ask for one that needs approval, or accept an invitation. |
| Member type choice | `poly-community/signup-member-type` | Cards of the member types open to sign-up: the one picked decides which steps and fields follow. |
## Organizations
| Block | Name | What it is |
|---|---|---|
| Organization buttons | `poly-community/org-actions` | In an organization header: Edit for those who run it, Accept and Decline for someone invited. A profile header piece. |
| Where they belong | `poly-community/org-affiliations` | “Works at Acme” on a member profile: the organizations they choose to show. A profile header piece. |
| New organization form | `poly-community/org-create-form` | Making an organization (or a household, where the site has them): its name, its line and who sees its page. The New organization page block. |
| New organization button | `poly-community/org-directory-head` | Above the member Organizations tab: New organization, for whoever may make one. |
| Organization people | `poly-community/org-people` | An organization People tab: who is in it and shows it, their roles. For those who run it, inviting, roles, handing it on and taking people out. |
| Organization settings | `poly-community/org-settings` | An organization form, for those who run it: its logo, cover, name, line, who sees it and its fields. Its owner deletes it here. |
## Reputation
| Block | Name | What it is |
|---|---|---|
| Vote to close | `poly-community/close-vote` | On a question page: members with the reputation vote to close it, and its moderators see who voted. |
| Leaderboard | `poly-community/leaderboard` | The members with the most reputation this week, this month and of all time, live. |
| How to earn reputation | `poly-community/reputation-earn` | How reputation is earned here and what it opens. On their own tab, members see what they reached. |
| Reputation history | `poly-community/reputation-history` | Each award of a member reputation, the newest first, on their profile Reputation tab. |
| Reputation | `poly-community/reputation-summary` | A member reputation and what earned it, by reason, on their profile Reputation tab. |
## Bookings
| Block | Name | What it is |
|---|---|---|
| Availability | `poly-community/availability` | Edit profile → Availability: the hours a member who offers services can be booked, their dates and time off, and their busy calendars. |
| Book a time | `poly-community/book` | The open times of a service to pick from, in the time zone of the visitor. The time picked is held while they check it and booked with one press. |
| Booking | `poly-community/booking` | One booking, for its two people: what, when, where, with whom, its calendar file and Cancel while it is to come. |
| Bookings in my calendar | `poly-community/booking-feed` | Edit profile → Availability: a private address a provider calendar app follows for the bookings made with them, changed or stopped here. |
| My bookings | `poly-community/my-bookings` | The bookings of a member, upcoming and past: the times they booked, and the times booked with them. |
| My services | `poly-community/my-services` | Edit profile → Availability: the services a member offers, drafts and paused ones too, with Offer a service. |
| Provider calendar | `poly-community/provider-calendar` | A provider week or day: their bookings, time off and busy times, a booking panel, and Block time. |
| About the service | `poly-community/service-about` | The pictures of a service, what its provider says of it, and its details. |
| Service facts | `poly-community/service-facts` | A service price from its lowest, how long it takes, where, and a group session seats, in one line. |
| Service form | `poly-community/service-form` | Offering a service or changing one: what it is, how long it takes, where, when it can be booked, and how its times look this week. |
| Service head | `poly-community/service-head` | A service name and state, how long it takes, where, and who offers it. |
| Service next time | `poly-community/service-next` | The next open of a service time on the reader clock, with the seats left of a group session. |
| Service provider | `poly-community/service-provider` | Who offers a service: their face and name, with their rating where clients review providers. |
| Open times this week | `poly-community/service-week` | The open times of a service for the seven days from today, in the time zone of the visitor. |
## Creators sell
| Block | Name | What it is |
|---|---|---|
| Become a creator | `poly-community/become-creator` | The steps of a member to a creator page of their own: the site approval, getting paid, their page words and cover, their tiers, then opening or pausing it. |
| Membership | `poly-community/creator-membership` | A creator Membership tab: why join, their tiers as cards with Join, the viewer tier, and how many support them where the creator shows it. |
| Your studio | `poly-community/creator-studio` | A creator studio: who supports them and since when, what they earned each month, their goal and tiers, and every tip they received. |
| Supporting | `poly-community/creator-supporting` | The creators a member supports, each tier with what it costs and until when, their badge on that creator posts, and the posts they unlocked. |
| Your tiers | `poly-community/creator-tiers` | The tiers of a creator to edit: the name of each one, prices a month and a year, what it gives, a limit of supporters and its space, in order, with the supporter view of it beside. |
| Creators | `poly-community/creators-directory` | The directory of creators: each open creator cover, face, name, what they make, supporters where they show them and their lowest price, searched by name and sorted. |
## Paid membership
| Block | Name | What it is |
|---|---|---|
| Billing | `poly-community/billing` | Edit profile → Billing: the member plans, when each renews or ends, Manage and Cancel, and receipts. |
| Plans | `poly-community/plans` | The plans members may buy: each with its price as the payment provider will charge it, what it includes, and Join. Their own plan is marked, and a return from paying says when it is theirs. |
| Paid post teaser | `poly-community/post-paywall` | What someone without a post plan sees in its place: which plan opens it and the way to it. Never the post words, pictures or replies. |
| Space plan gate | `poly-community/space-plan-gate` | On a space open by plan: the plans it is included in, and the way in for whoever holds none. |
## Spaces inside spaces
| Block | Name | What it is |
|---|---|---|
| Automatic members | `poly-community/space-auto-members` | The settings of a space: the rule that adds members by who they are (a profile field, a member type, when they joined), and how far its count got. |
| Sub-spaces | `poly-community/space-children` | The spaces inside a space the viewer may see: a few beside its page, or all of them as its tab, with New for whoever may make one. |
| Space place | `poly-community/space-place` | The settings of a space: where it is, and the spaces it may move inside with everything inside it, each refusal with its reason. |
| Sub-space count | `poly-community/sub-space-count` | A space card piece: how many spaces are inside it, for the viewer, leading to them. |
## Ratings and warnings
| Block | Name | What it is |
|---|---|---|
| Where you live | `poly-community/age-country` | Edit profile card where members say where they live, for the age check of the 18+ mode. |
| Rated posts settings | `poly-community/content-choices` | Edit profile card where members choose how mature and explicit posts and warnings show to them, and incognito. |
| Space rating gate | `poly-community/space-rating-gate` | Above the posts of a space: they are rated, and open once the member says so or passes the age check. |
## Trust levels
| Block | Name | What it is |
|---|---|---|
| Trust level | `poly-community/trust-level` | Edit profile → Trust level: their own level, what the next one still needs, and what each level opens. |
## Young members
| Block | Name | What it is |
|---|---|---|
| Date of birth settings | `poly-community/birth-date-settings` | Edit profile card where a member gives their date of birth once, and a young member chooses who sees their profile. |
| Parent or guardian link | `poly-community/guardian-card` | The page a young member email to a parent or guardian opens: who asks, what being linked means, and Confirm. |
| Parents and guardians | `poly-community/guardians-settings` | Edit profile card where a young member asks a parent or guardian to link their account, and a guardian sees the young members in their care. |
| Date of birth | `poly-community/signup-birth-date` | The sign-up date of birth: always asked on the first step, before anything is kept. |
---
# Icons
Address: https://www.poly-community.com/docs/reference/icons/
An item of a menu, a button under a post and a field take an icon by its name. These are the 169 names of Poly Community, each drawn as it shows: lines in the colour of the words beside it, on a grid of 24 by 24. A plugin [adds its own](#add-your-own) by name, or gives a whole SVG.
The icon pickers of Settings (of a field, a category, a menu item and a member type) offer every one, in groups, and an icon a plugin adds under More.
## Add your own
An item of a menu and a button under a post take an icon of a plugin in two ways: by a name the plugin adds, or as a whole SVG. [Buttons and menus](https://www.poly-community.com/docs/developers/buttons-and-menus/#icons) shows both on the items of its example.
### By name
Add an icon on `poly_community_register_icons` with `$icons->add()`, under a name that starts with the name of your plugin: the shapes of a 24 by 24 icon, with a label and a group of the icon pickers. It joins the icons file, so it costs a page nothing more however many items show it:
```php
function my_plugin_icons( $icons ) {
$icons->add( 'my-plugin-notes', ''
. '', array(
'label' => __( 'Notes', 'my-plugin' ),
'group' => 'work',
) );
}
add_action( 'poly_community_register_icons', 'my_plugin_icons' );
```
Then `'icon' => 'my-plugin-notes'` in an item. In markup of your own, `poly_the_icon( 'my-plugin-notes', 18 )` prints it 18 px wide, and `poly_icon()` gives it back as a string.
The groups are `contact`, `person`, `work`, `interests`, `other`, `community`, `media` and `signs`, or one of yours, added with `$icons->add_group( $slug, $label, $after )`. An icon with no group is offered under More. A name the community or another plugin has is refused. `$icons->has( $name )` says whether a name is there, `$icons->names()` gives them all.
It is drawn as lines in the colour of the words around it, 1.75 wide with round ends, and not filled. A shape drawn filled takes `fill="currentColor"`. The icons file keeps `path`, `circle`, `ellipse`, `rect`, `line`, `polyline`, `polygon` and `g`, with what draws them. A whole SVG may have a name too, its `viewBox` and its paint kept, drawn as it says.
### A whole SVG
Give an item the SVG itself, from any icon set, with any `viewBox`:
```php
function my_plugin_star_svg() {
return '';
}
```
Then `'icon' => my_plugin_star_svg()` in an item. It is drawn in place, filled in the colour of the words unless the SVG says otherwise. Its shapes are kept (`path`, `circle`, `ellipse`, `rect`, `line`, `polyline`, `polygon` and `g`), and anything else is taken out, such as a script, a style or a link. `poly_icon()` and `poly_the_icon()` take it too.
### Which one
A name for an icon that many items show at once: one file, which the browser keeps. A whole SVG for an icon from another set, shown in a few places. A name there is none of draws no icon.
The registry (`poly_community_register_icons`, `add()`, `add_group()`, `has()`, `names()`), the functions `poly_icon()` and `poly_the_icon()` and the names on this page are on the stable list ([What is stable](https://www.poly-community.com/docs/developers/#what-is-stable)): none of the names goes, and a renamed one keeps its old name. The filters `poly_community_icons` and `poly_community_icon_categories` of before are deprecated: they keep working after the registry, with a notice, for at least two releases.
## In the icons file
Every page keeps these 98 in one file, which the browser holds until they change.
home
activity
users
user
user-plus
user-check
spaces
bell
search
heart
comment
share
more
image
paperclip
file
music
download
globe
lock
unlock
eye
eye-off
anonymous
plus
check
x
chevron-down
chevron-up
chevron-right
chevron-left
arrow-left
arrow-up
sun
moon
monitor
sliders
log-out
map-pin
calendar
link
messages
video
video-record
live
mic
play
phone
edit
crop
heading
history
trash
bookmark
send
reply
star
camera
clock
flag
grid
list
menu
sparkles
compass
smile
gif
sticker
shield
external
bold
italic
strikethrough
format-heading
quote
list-ordered
code
type
pin
megaphone
chart
level
poll
user-minus
ban
key
mail
settings
alert
forum
question
trending
check-all
unread
upload
rss
bell-plus
sort
## Drawn where they are used
These 34 are drawn in the page where they are used, not kept in the icons file.
at-sign
id-card
cake
gift
languages
info
tag
ruler
briefcase
building
store
graduation
book
award
lightbulb
target
wallet
headphones
film
gamepad
palette
plane
car
bike
mountain
leaf
coffee
utensils
dumbbell
paw
shopping-bag
hash
cloud
puzzle
## With a part or a component
These 37 join the icons file while the part or the component under each is on.
album Photo albums
arrow-down Courses
arrow-right Poly Community
begun Courses
bookmark-filled Poly Community
calendar-clock Poly Community
cards Matching
clipboard Applications to join
copy Courses
directions Listings
done Courses
door Events
draft Poly Community
expand Listings
grip Courses
images Photo albums
layers Courses
live-end Live
notebook Courses
panel Courses
pause Creators sell
petition Votes
playing Courses
repeat Events
repost Poly Community
reputation Reputation
roadmap Votes
scroll Applications to join
share-out Poly Community
teach Courses
text-lines Courses
ticket Events
todo Courses
trust Trust levels
trust-todo Trust levels
undo Courses
vouch Applications to join
---
# Stable routes
Address: https://www.poly-community.com/docs/reference/rest-routes/
- `/poly-community/v1/items`
- `/poly-community/v1/lists/(?P[a-z][a-z0-9_-]*)`
Every other route under `poly-community/v1` belongs to the front end and may change.