function weaverx_fwrite_current_css() { // write the current generated CSS to a file - called only from Weaver II Admin if (!weaverx_f_file_access_available() || !current_user_can('edit_theme_options')) { return ''; } $save_dir = weaverx_f_uploads_base_dir() . 'weaverx-subthemes'; $save_url = weaverx_f_uploads_base_url() . 'weaverx-subthemes'; $usename = 'style-weaverxt.css'; $theme_dir_exists = weaverx_f_mkdir($save_dir); if (!$theme_dir_exists) { weaverx_f_file_access_fail(__('Unable to create directory. Probably a file system permission problem. Directory', 'weaver-xtreme') . $save_dir); } $theme_dir_writable = $theme_dir_exists; if (!weaverx_f_is_writable($save_dir)) { weaverx_f_file_access_fail(__('Directory not writable. Probably a file system permission problem. Directory: ', 'weaver-xtreme') . $save_dir); $theme_dir_writable = false; } $filename = $save_dir . '/' . $usename; // we will add txt if (!$theme_dir_writable || !$theme_dir_exists || !($handle = weaverx_f_open($filename, 'w'))) { weaverx_f_file_access_fail(__('Unable to create file. Probably a file system permission problem. File: ', 'weaver-xtreme') . $filename); return ''; } // This string goes in the generated CSS file weaverx_f_write($handle, sprintf("/* WARNING: Do not edit this file. It is dynamically generated. Any edits you make will be overwritten. */\n/* This file generated using %s %s subtheme: %s */\n", WEAVERX_THEMENAME, WEAVERX_VERSION, weaverx_getopt('wii_subtheme'))); weaverx_output_style($handle); if (!weaverx_f_close($handle)) { weaverx_f_file_access_fail(__('Unable to create file. Probably a file system permission problem. File: ', 'weaver-xtreme') . $filename); return ''; } return $save_url . '/' . $usename; }
function weaverx_filter_css($css) { // filter user added CSS for root relative file paths if (strpos($css, '%template_directory%') !== false) { $css = str_replace('%template_directory%', parse_url(trailingslashit(get_template_directory_uri()), PHP_URL_PATH), $css); } if (strpos($css, '%stylesheet_directory%') !== false) { $css = str_replace('%stylesheet_directory%', parse_url(trailingslashit(get_stylesheet_directory_uri()), PHP_URL_PATH), $css); } if (strpos($css, '%addon_directory%') !== false) { $css = str_replace('%addon_directory%', parse_url(trailingslashit(weaverx_f_uploads_base_url()) . 'weaverx-subthemes/addon-subthemes/', PHP_URL_PATH), $css); } return $css; }