fix font definitions
This commit is contained in:
83
functions.php
Normal file
83
functions.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
function disable_default_patterns()
|
||||
{
|
||||
remove_theme_support('core-block-patterns');
|
||||
}
|
||||
add_action('after_setup_theme', 'disable_default_patterns');
|
||||
|
||||
// enqueue custom css on front-end and editor
|
||||
function somosinfinitos_editor_css()
|
||||
{
|
||||
add_editor_style(get_theme_file_uri('/assets/css/custom.css'));
|
||||
}
|
||||
add_action('after_setup_theme', 'somosinfinitos_editor_css');
|
||||
|
||||
function somosinfinitos_frontend_css()
|
||||
{
|
||||
wp_enqueue_style('jett_css', get_theme_file_uri('/assets/css/custom.css'));
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'somosinfinitos_frontend_css');
|
||||
|
||||
// enable svg uploads
|
||||
add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename, $mimes) {
|
||||
|
||||
global $wp_version;
|
||||
if ($wp_version !== '4.7.1') {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$filetype = wp_check_filetype($filename, $mimes);
|
||||
|
||||
return [
|
||||
'ext' => $filetype['ext'],
|
||||
'type' => $filetype['type'],
|
||||
'proper_filename' => $data['proper_filename']
|
||||
];
|
||||
}, 10, 4);
|
||||
function cc_mime_types($mimes)
|
||||
{
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}
|
||||
add_filter('upload_mimes', 'cc_mime_types');
|
||||
|
||||
// remove default woocommerce fonts
|
||||
add_filter('wp_theme_json_data_theme', 'disable_inter_font', 100);
|
||||
function disable_inter_font($theme_json)
|
||||
{
|
||||
$theme_data = $theme_json->get_data();
|
||||
$font_data = $theme_data['settings']['typography']['fontFamilies']['theme'] ?? array();
|
||||
|
||||
// The font name to be removed
|
||||
$font_names = ['Inter', 'Cardo'];
|
||||
$font_names_total = 2;
|
||||
$font_names_found = 0;
|
||||
|
||||
// Check if 'Inter' font exists
|
||||
foreach ($font_data as $font_key => $font) {
|
||||
if (isset($font['name']) && in_array($font['name'], $font_names)) {
|
||||
// Increment found font names
|
||||
$font_names_found++;
|
||||
|
||||
// Remove the font
|
||||
unset($font_data[$font_key]);
|
||||
|
||||
// Update font data
|
||||
$theme_json->update_with(array(
|
||||
'version' => 1,
|
||||
'settings' => array(
|
||||
'typography' => array(
|
||||
'fontFamilies' => array(
|
||||
'theme' => $font_data,
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
if ($font_names_found === $font_names_total) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $theme_json;
|
||||
}
|
Reference in New Issue
Block a user