-
-
Save krishna19/cb242b143bcd7aa2a8f1bf71718e47d0 to your computer and use it in GitHub Desktop.
generate_options_css()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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