-
Notifications
You must be signed in to change notification settings - Fork 17
Writing Themes
Alex Kirk edited this page Nov 22, 2024
·
2 revisions
Themes can be added to the theme selector through other plugins, found in the Frontend section of the
A reference implementation can be found in the Friends Mastodon Like Interface plugin.
Check out the main plugin file to see the necessary steps:
add_action(
'friends_load_themes',
function ( Frontend $friends_frontend ) {
$name = 'Mastodon';
$slug = 'mastodon';
$friends_frontend->register_theme( $name, $slug );
}
);
The slug is important as it will be used for subsequent filters.
Likely you'll want to have a stylesheet loaded:
$slug = 'mastodon';
add_action(
'friends_load_theme_' . $slug,
function() {
// For example, enqueue your styles:
wp_enqueue_style( $handle, plugins_url( $file, __DIR__ . '/style.css' ) );
}
);
If you provide template files (see Overriding the template files), register them like this:
$slug = 'mastodon';
add_filter( 'friends_template_paths_theme_' . $slug, function( $file_paths ) {
$file_paths[ 15 ] = __DIR__ . '/templates';
return $file_paths;
} );