Astra_WebFont_Loader::write_stylesheet()
Write the CSS to the filesystem.
Description
Return
(string|false) Returns the absolute path of the file on success, or false on fail.
Source
File: inc/lib/webfont/class-astra-webfont-loader.php
protected function write_stylesheet() {
$file_path = $this->get_local_stylesheet_path();
$filesystem = $this->get_filesystem();
if ( ! defined( 'FS_CHMOD_DIR' ) ) {
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
}
// If the folder doesn't exist, create it.
if ( ! file_exists( $this->get_fonts_folder() ) ) {
$this->get_filesystem()->mkdir( $this->get_fonts_folder(), FS_CHMOD_DIR );
}
// If the file doesn't exist, create it. Return false if it can not be created.
if ( ! $filesystem->exists( $file_path ) && ! $filesystem->touch( $file_path ) ) {
return false;
}
// If we got this far, we need to write the file.
// Get the CSS.
if ( ! $this->css ) {
$this->get_styles();
}
// Put the contents in the file. Return false if that fails.
if ( ! $filesystem->put_contents( $file_path, $this->css ) ) {
return false;
}
return $file_path;
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |