Please notice that this is a technical article. Adding your own custom font into Massive Addons requires basic PHP programming knowledge .
Any syntax error in PHP script will probably result in server error 500 – website will not work from both frontend & wp-admin!
In Massive Addons, custom fonts for Typography Presets usage can be added by using build-in filter ma_custom_fonts
Code example:
add_filter( 'ma_custom_fonts', 'my_custom_fonts' );
function my_custom_fonts() {
return $fonts = array(
'text' => __( 'My Custom Fonts', 'mpc' ),
'children' => array(
array(
'id' => 'My Custom Font',
'text' => 'My Custom Font Name',
'variants' => array( '100', '300', 'regular', 'italic', '500', '700', '800', '900' ),
'url' => '',
),
array(
'id' => 'My Custom Font 2',
'text' => 'My Custom Font 2 Name',
'variants' => array( 'regular', '500', '700italic' ),
'url' => 'https://url_to_your_custom_font_2_css_file.css',
),
),
);
}
Snippet usage:
Code snippet can be placed in child theme functions.php file or a custom plugin .
Google Fonts in Massive Addons are being cached for 24hours, so to see your fonts in Typography Presets->Font Family dropdown right away you need to delete google_webfonts.json file ( wp-content\plugins\mpc-massive\params\mpc_typography\ ) – it will be regenerated on Typography Presets settings load.
In case you have got “Remove Google Fonts” option enabled in Massive Panel, you need to delete standard_webfonts.json file ( wp-content\plugins\mpc-massive\params\mpc_typography\ ).
Code explanation:
Whole custom font group is being passed as an array into ma_custom_fonts filter.
In a top-level array, ‘text’ value is responsible for a group name.
‘children’ value contains an array with new custom fonts.
‘id’ – font family name, which will be printed in CSS code
‘text’ – font name used in Typography Preset->Font Family dropdown
‘variants’ – font thickness & style
‘url’ – link to font CSS file, it’s important if font is stored by external service, this can be left empty ” in case font is already loaded via child theme styles