Skip to content

Commit a6c05ef

Browse files
committed
chore:resolved phpcbf
1 parent 44c0384 commit a6c05ef

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

classes/class-bsf-custom-fonts-render.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@ public function __construct() {
154154
* @since 2.1.11
155155
*/
156156
public function load_local_google_fonts() {
157+
// We are using WP_Filesystem for managing google fonts files which is necessary for the proper functionality of the plugin.
158+
global $wp_filesystem;
159+
160+
// If the filesystem has not been instantiated yet, do it here.
161+
if ( ! function_exists( 'WP_Filesystem' ) ) {
162+
require_once ABSPATH . 'wp-admin/includes/file.php'; // PHPCS:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
163+
}
164+
165+
WP_Filesystem(); // Initialize the filesystem
166+
157167
$upload_dir = WP_CONTENT_DIR . '/bcf-fonts';
158168
$css_file = WP_CONTENT_DIR . '/bcf-fonts/local-fonts.css';
159169

@@ -223,7 +233,8 @@ public function load_local_google_fonts() {
223233
}
224234
}
225235

226-
file_put_contents( $css_file, $font_face_css );
236+
// Use WP_Filesystem to write to file instead of file_put_contents
237+
$wp_filesystem->put_contents( $css_file, $font_face_css, FS_CHMOD_FILE );
227238

228239
wp_enqueue_style( 'local-google-fonts', content_url( '/bcf-fonts/local-fonts.css' ), array(), null );
229240
}

0 commit comments

Comments
 (0)