method_available_social_platforms

 
 
 
 

apply_filters( 'method_available_social_platforms', array $platforms )

Filters the list of available social media platforms and their icons.


Description

This filter allows child themes and plugins to add, remove, or modify the social media platforms available in Method’s Social Nav block and the Method Settings options page. Each platform entry includes an SVG icon and a display label.


Parameters

$platforms (array) : An associative array of platform definitions. Each key is a platform slug and each value is an array with the following structure:

PHP
array(
    'icon'  => '<svg ...>...</svg>',  // SVG markup for the platform icon
    'label' => 'Platform Name',       // Display name shown in the UI
)

Default platforms

bluesky, facebook, github, instagram, linkedin, pinterest, threads, tiktok, twitch, twitter, vimeo, youtube, custom


Source

PHP
return apply_filters( 'method_available_social_platforms', $defaults );

File: lib/helper-functions.php, function method_get_social_platforms()


Usage

PHP
add_filter( 'method_available_social_platforms', 'mytheme_add_social_platform' );

function mytheme_add_social_platform( $platforms ) {
    $platforms['mastodon'] = array(
        'icon'  => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><!-- mastodon icon path --></svg>',
        'label' => 'Mastodon',
    );
    return $platforms;
}

Notes

  • Platform slugs are used as the stored value in the social_accounts option group. Changing a slug after links have been configured will break existing entries.
  • Icons should use fill="currentColor" to inherit the color set by Method’s color controls.
  • The custom platform provides a generic link icon and is intended for platforms not in the default list.

Related

  • method_build_social_nav_items() — Generates the HTML for social nav from configured accounts
  • method_get_options_page_social_options() — Formats platforms for CMB2 radio fields
  • Social Nav block

Changelog

VersionDescription
2.0.0Introduced.