diff --git a/inc/block-editor.php b/inc/block-editor.php index ea3850a2..5bf458a6 100644 --- a/inc/block-editor.php +++ b/inc/block-editor.php @@ -43,7 +43,11 @@ if ( ! function_exists( 'understrap_generate_color_palette' ) ) { $color_palette = array(); // Grabs the autogenerated color palette that we're pulling from our compiled bootstrap stylesheets. - $color_palette_json = file_get_contents( get_theme_file_path( '/inc/editor-color-palette.json' ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents + $file_path = get_theme_file_path( '/inc/editor-color-palette.json' ); + if ( 'bootstrap4' === get_theme_mod( 'understrap_bootstrap_version', 'bootstrap4' ) ) { + $file_path = get_theme_file_path( '/inc/editor-color-palette-bootstrap4.json' ); + } + $color_palette_json = file_get_contents( $file_path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents if ( $color_palette_json ) { $color_palette_json = json_decode( $color_palette_json, true ); diff --git a/inc/editor-color-palette-bootstrap4.json b/inc/editor-color-palette-bootstrap4.json new file mode 100644 index 00000000..34917598 --- /dev/null +++ b/inc/editor-color-palette-bootstrap4.json @@ -0,0 +1 @@ +{"--blue":"#007bff","--indigo":"#6610f2","--purple":"#5533ff","--pink":"#e83e8c","--red":"#dc3545","--orange":"#fd7e14","--yellow":"#ffc107","--green":"#28a745","--teal":"#20c997","--cyan":"#17a2b8","--white":"#fff","--gray":"#6c757d","--gray-dark":"#343a40"} \ No newline at end of file diff --git a/inc/editor-color-palette.json b/inc/editor-color-palette.json index 34917598..5d2030fe 100644 --- a/inc/editor-color-palette.json +++ b/inc/editor-color-palette.json @@ -1 +1 @@ -{"--blue":"#007bff","--indigo":"#6610f2","--purple":"#5533ff","--pink":"#e83e8c","--red":"#dc3545","--orange":"#fd7e14","--yellow":"#ffc107","--green":"#28a745","--teal":"#20c997","--cyan":"#17a2b8","--white":"#fff","--gray":"#6c757d","--gray-dark":"#343a40"} \ No newline at end of file +{"--bs-blue":"#0d6efd","--bs-indigo":"#6610f2","--bs-purple":"#5533ff","--bs-pink":"#d63384","--bs-red":"#dc3545","--bs-orange":"#fd7e14","--bs-yellow":"#ffc107","--bs-green":"#198754","--bs-teal":"#20c997","--bs-cyan":"#0dcaf0","--bs-white":"#fff","--bs-gray":"#6c757d","--bs-gray-dark":"#343a40"} \ No newline at end of file diff --git a/src/build/postcss.config.js b/src/build/postcss.config.js index ccdbe513..f20d8f85 100644 --- a/src/build/postcss.config.js +++ b/src/build/postcss.config.js @@ -20,6 +20,7 @@ const colors = [ const BS4 = process.argv[ process.argv.length - 1 ] === 'BS4'; const colorInfix = BS4 ? '' : 'bs-'; +const output = 'inc/editor-color-palette' + ( BS4 ? '-bootstrap4' : '' ) + '.json'; module.exports = ( ctx ) => { return { @@ -35,6 +36,7 @@ module.exports = ( ctx ) => { }, 'postcss-understrap-palette-generator': { colors: colors.map( ( x ) => `--${ colorInfix }${ x }` ), + output: output, }, }, };