Skip to main content
Improved
Source Link
require_once( ABSPATH . 'wp-admin/includes/file.php' ); // you have to load this file

global $wp_filesystem;
$upload_dir = wp_upload_dir(); // Grab uploads folder array
$dir = trailingslashit( $upload_dir['basedir'] )  . 'cutomizer-css/'; // Set storage directory path
WP_Filesystem(); // Initial WP file system
$wp_filesystem->mkdir( $dir ); // Make a new directory folder if folder not their

$wp_filesystem->put_contents( $dir . 'news24-customize.css', $css, 0644 ); // Finally, store the file :D

Add above code in functions.php. After that enqueue that style

$uploads = wp_upload_dir();
wp_enqueue_style( 'newstweentyfour-customize', trailingslashit($uploads['baseurl']) . 'newstweentyfour-customize.css', array()  );

Its works i have tested..

require_once( ABSPATH . 'wp-admin/includes/file.php' ); // you have to load this file

global $wp_filesystem;
$upload_dir = wp_upload_dir(); // Grab uploads folder array
$dir = trailingslashit( $upload_dir['basedir'] )  . 'cutomizer-css/'; // Set storage directory path
WP_Filesystem(); // Initial WP file system
$wp_filesystem->mkdir( $dir ); // Make a new directory folder if folder not their

$wp_filesystem->put_contents( $dir . 'news24-customize.css', $css, 0644 ); // Finally, store the file :D

Its works i have tested..

require_once( ABSPATH . 'wp-admin/includes/file.php' ); // you have to load this file

global $wp_filesystem;
$upload_dir = wp_upload_dir(); // Grab uploads folder array
$dir = trailingslashit( $upload_dir['basedir'] )  . 'cutomizer-css/'; // Set storage directory path
WP_Filesystem(); // Initial WP file system
$wp_filesystem->mkdir( $dir ); // Make a new directory folder if folder not their

$wp_filesystem->put_contents( $dir . 'news24-customize.css', $css, 0644 ); // Finally, store the file :D

Add above code in functions.php. After that enqueue that style

$uploads = wp_upload_dir();
wp_enqueue_style( 'newstweentyfour-customize', trailingslashit($uploads['baseurl']) . 'newstweentyfour-customize.css', array()  );

Its works i have tested..

Source Link

require_once( ABSPATH . 'wp-admin/includes/file.php' ); // you have to load this file

global $wp_filesystem;
$upload_dir = wp_upload_dir(); // Grab uploads folder array
$dir = trailingslashit( $upload_dir['basedir'] )  . 'cutomizer-css/'; // Set storage directory path
WP_Filesystem(); // Initial WP file system
$wp_filesystem->mkdir( $dir ); // Make a new directory folder if folder not their

$wp_filesystem->put_contents( $dir . 'news24-customize.css', $css, 0644 ); // Finally, store the file :D

Its works i have tested..