create custom css file that loads on editor and frontend

This commit is contained in:
Aadil Ayub 2024-06-13 12:04:16 +05:00
parent 289ebea30b
commit 02b9d53f27
2 changed files with 92 additions and 80 deletions

0
assets/css/custom.css Normal file
View File

View File

@ -1,58 +1,16 @@
<?php <?php
/* Remove default CSS variables that come with Wordpress // enqueue custom css on front-end and editor
https://github.com/WordPress/gutenberg/issues/56180#issuecomment-1819222376 function jett_editor_css() {
*/ add_editor_style( get_theme_file_uri('/assets/css/custom.css') );
function custom_wp_theme_json_default( $theme_json ) {
$new_data = array(
'version' => 2,
'settings' => array(
'color' => array(
'palette' => array(),
'gradients' => array(),
),
'shadow' => array(
'presets' => array(),
),
'typography' => array(
'fontSizes' => array(),
),
// 'dimensions' => array(
// 'aspectRatios' => array(),
// ),
// 'spacing' => array(
// 'spacingScale' => array(
// 'steps' => 0,
// ),
// ),
),
);
return $theme_json->update_with( $new_data );
} }
add_filter( 'wp_theme_json_data_default', 'custom_wp_theme_json_default' ); add_action( 'after_setup_theme', 'twentytwentytwo_support' );
// enable svg uploads function jett_frontend_css() {
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) { wp_enqueue_style('jett_css', get_theme_file_uri('/assets/css/custom.css'));
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'); add_action('wp_enqueue_scripts', 'jett_frontend_css');
// define block styles // define block styles
function jett_block_styles() { function jett_block_styles() {
@ -133,3 +91,57 @@ function jett_block_styles() {
); );
} }
add_action( 'init', 'jett_block_styles' ); add_action( 'init', 'jett_block_styles' );
/* Remove default CSS variables that come with Wordpress
https://github.com/WordPress/gutenberg/issues/56180#issuecomment-1819222376
*/
function custom_wp_theme_json_default( $theme_json ) {
$new_data = array(
'version' => 2,
'settings' => array(
'color' => array(
'palette' => array(),
'gradients' => array(),
),
'shadow' => array(
'presets' => array(),
),
'typography' => array(
'fontSizes' => array(),
),
// 'dimensions' => array(
// 'aspectRatios' => array(),
// ),
// 'spacing' => array(
// 'spacingScale' => array(
// 'steps' => 0,
// ),
// ),
),
);
return $theme_json->update_with( $new_data );
}
add_filter( 'wp_theme_json_data_default', 'custom_wp_theme_json_default' );
// 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');