Skip to main content

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.

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