54 lines
1006 B
PHP
54 lines
1006 B
PHP
<?php
|
|
|
|
/**
|
|
* Settings | WP SCSS
|
|
*
|
|
* @package Dotspice
|
|
* @version 1.3.0
|
|
*/
|
|
|
|
|
|
/**
|
|
* Set variables
|
|
*/
|
|
add_filter('wp_scss_variables', function () {
|
|
$variables = array();
|
|
$theme_colors = dotspice_get_theme_option('colors');
|
|
|
|
foreach ($theme_colors as $color_key => $color_value) {
|
|
if (!empty($theme_colors[$color_key])) {
|
|
$variables[$color_key . '-color'] = esc_attr($theme_colors[$color_key]);
|
|
}
|
|
}
|
|
|
|
return $variables;
|
|
});
|
|
|
|
|
|
/**
|
|
* Recompile WP SCSS on save options
|
|
*/
|
|
function dotspice_wp_scss_recompile($post_ID)
|
|
{
|
|
if ($post_ID == 'options') {
|
|
if (function_exists('wp_scss_compile')) {
|
|
wp_scss_compile();
|
|
}
|
|
}
|
|
}
|
|
add_action('acf/save_post', 'dotspice_wp_scss_recompile');
|
|
|
|
|
|
/**
|
|
* WP-SCSS Plugin folder Fix
|
|
*/
|
|
function dotspice_wp_scss_folder_fix()
|
|
{
|
|
if (file_exists(WP_PLUGIN_DIR . '/wp-scss')) {
|
|
if (!file_exists(WP_PLUGIN_DIR . '/wp-scss/cache')) {
|
|
wp_mkdir_p(WP_PLUGIN_DIR . '/wp-scss/cache');
|
|
}
|
|
}
|
|
}
|
|
add_action('after_setup_theme', 'dotspice_wp_scss_folder_fix');
|