Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function generate_options_css($newdata) {
/** Define some vars **/
$data = $newdata;
$uploads = wp_upload_dir();
$css_dir = get_template_directory() . '/css/'; // Shorten code, save 1 call
/** Save on different directory if on multisite **/
if(is_multisite()) {
$aq_uploads_dir = trailingslashit($uploads['basedir']);
} else {
$aq_uploads_dir = $css_dir;
}
/** Capture CSS output **/
ob_start();
require($css_dir . 'styles.php');
$css = ob_get_clean();
/** Write to options.css file **/
WP_Filesystem();
global $wp_filesystem;
if ( ! $wp_filesystem->put_contents( $aq_uploads_dir . 'options.css', $css, 0644) ) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment