From 7b0348f170245dfd81a4cefd367ba3cfcf8d6bc6 Mon Sep 17 00:00:00 2001 From: Stephen Cameron Date: Wed, 5 Feb 2020 16:10:56 -0200 Subject: [PATCH] Done #3394 @2 --- .gitignore | 1 + wp-content/themes/CCV/app/setup.php | 37 ++++++++++++++++++++++++++++ wp-content/themes/CCV/package.json | 2 +- wp-content/themes/CCV/webpack.mix.js | 9 +++++++ wp-content/themes/CCV/yarn.lock | 7 +++--- 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 90a5ca0..de21215 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store *.log +.uploads-proxy local-config.php node_modules /wp-content/* diff --git a/wp-content/themes/CCV/app/setup.php b/wp-content/themes/CCV/app/setup.php index c6c770d..ba18817 100755 --- a/wp-content/themes/CCV/app/setup.php +++ b/wp-content/themes/CCV/app/setup.php @@ -155,3 +155,40 @@ add_action('widgets_init', function () { 'id' => 'sidebar-footer-copyright' ] + $config); }); + + +/** + * Add Custom Styles to TinyMCE editor + */ +// https://codex.wordpress.org/TinyMCE_Custom_Styles +// Callback function to insert 'styleselect' into the $buttons array +add_filter( 'mce_buttons_2', function($buttons) { + array_unshift( $buttons, 'styleselect' ); + return $buttons; +}); + +// Add format classes to +add_filter( 'tiny_mce_before_init', function($init_array) { + $sizes = [ + 'xs', + 'sm', + 'lg', + 'xl', + ]; + + // Text size styles + foreach ($sizes as $size) { + $style_formats[] = [ + 'title' => 'Text '. strtoupper($size), + 'inline' => 'span', + 'selector' => 'h1, h2, h3, h4, h5, p, div', + 'classes' => 'text-'. $size, + 'wrapper' => false, + ]; + } + + // Insert the array, JSON ENCODED, into 'style_formats' + $init_array['style_formats'] = json_encode( $style_formats ); + + return $init_array; +}); diff --git a/wp-content/themes/CCV/package.json b/wp-content/themes/CCV/package.json index 000fb9f..8fbfeb1 100644 --- a/wp-content/themes/CCV/package.json +++ b/wp-content/themes/CCV/package.json @@ -30,7 +30,7 @@ "mix-tailwindcss": "^1.0.2", "mmenu-light": "^2.3.1", "npm-run-all": "^4.1", - "purgecss-with-wordpress": "knowler/purgecss-with-wordpress#more-wp-generated-classes", + "purgecss-with-wordpress": "^1.1.0", "rimraf": "^2.6", "rupture": "^0.7.1", "stylelint": "^10.1", diff --git a/wp-content/themes/CCV/webpack.mix.js b/wp-content/themes/CCV/webpack.mix.js index f1ff744..946c1ff 100644 --- a/wp-content/themes/CCV/webpack.mix.js +++ b/wp-content/themes/CCV/webpack.mix.js @@ -84,6 +84,15 @@ mix.purgeCss({ */ whitelist: [ ...whitelist, + 'text-xs', + 'text-sm', + 'text-base', + 'text-lg', + 'text-xl', + 'text-2xl', + 'text-3xl', + 'italic', + 'mt-2', ], whitelistPatterns: [ ...whitelistPatterns, diff --git a/wp-content/themes/CCV/yarn.lock b/wp-content/themes/CCV/yarn.lock index 9407d5c..63dcb9e 100644 --- a/wp-content/themes/CCV/yarn.lock +++ b/wp-content/themes/CCV/yarn.lock @@ -6556,9 +6556,10 @@ purgecss-webpack-plugin@^1.3.0: purgecss "^1.3.0" webpack-sources "^1.3.0" -purgecss-with-wordpress@knowler/purgecss-with-wordpress#more-wp-generated-classes: - version "1.0.0" - resolved "https://codeload.github.com/knowler/purgecss-with-wordpress/tar.gz/0838cc9c88d83f0cc1c0f2e61cef43a0242c2392" +purgecss-with-wordpress@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/purgecss-with-wordpress/-/purgecss-with-wordpress-1.1.0.tgz#ceeef62f9e092fef1c2f4748a447cbf6b790382a" + integrity sha512-7hlRdGToDyyh+GF/At1GNB07viUG+dppvdq34H7DUm8ySgp4OULPr58R2Ww8/Fe5nOsCQ6YihTDjFHFlSwwCsQ== purgecss@^1.3.0: version "1.3.0" -- 2.39.5