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 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 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:
function my_plugin_icons( $icons ) {
$icons->add( 'my-plugin-notes', '<rect x="5" y="3.5" width="14" height="17" rx="2"/>'
. '<path d="M8.5 8.5h7M8.5 12h7M8.5 15.5h4"/>', 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:
function my_plugin_star_svg() {
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">'
. '<path d="M8 1.5l2 4.2 4.5.6-3.3 3.1.8 4.5L8 11.7l-4 2.2.8-4.5-3.3-3.1 4.5-.6z"/></svg>';
}
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): 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.
homeactivityusersuseruser-plususer-checkspacesbellsearchheartcommentsharemoreimagepaperclipfilemusicdownloadglobelockunlockeyeeye-offanonymouspluscheckxchevron-downchevron-upchevron-rightchevron-leftarrow-leftarrow-upsunmoonmonitorsliderslog-outmap-pincalendarlinkmessagesvideovideo-recordlivemicplayphoneeditcropheadinghistorytrashbookmarksendreplystarcameraclockflaggridlistmenusparklescompasssmilegifstickershieldexternalbolditalicstrikethroughformat-headingquotelist-orderedcodetypepinmegaphonechartlevelpolluser-minusbankeymailsettingsalertforumquestiontrendingcheck-allunreaduploadrssbell-plussortDrawn where they are used
These 34 are drawn in the page where they are used, not kept in the icons file.
at-signid-cardcakegiftlanguagesinfotagrulerbriefcasebuildingstoregraduationbookawardlightbulbtargetwalletheadphonesfilmgamepadpaletteplanecarbikemountainleafcoffeeutensilsdumbbellpawshopping-baghashcloudpuzzleWith a part or a component
These 37 join the icons file while the part or the component under each is on.
albumPhoto albums
arrow-downCourses
arrow-rightPoly Community
begunCourses
bookmark-filledPoly Community
calendar-clockPoly Community
cardsMatching
clipboardApplications to join
copyCourses
directionsListings
doneCourses
doorEvents
draftPoly Community
expandListings
gripCourses
imagesPhoto albums
layersCourses
live-endLive
notebookCourses
panelCourses
pauseCreators sell
petitionVotes
playingCourses
repeatEvents
repostPoly Community
reputationReputation
roadmapVotes
scrollApplications to join
share-outPoly Community
teachCourses
text-linesCourses
ticketEvents
todoCourses
trustTrust levels
trust-todoTrust levels
undoCourses
vouchApplications to join