Skip to content

Commit

Permalink
create kirki styles.css manually (#273)
Browse files Browse the repository at this point in the history
* create kirki styles.css manually

* Corrected formatting

* Using wp_filesystem
  • Loading branch information
jamesros161 authored Aug 18, 2020
1 parent 99068c3 commit 9c301f9
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,19 @@ public function generate_font_size_css( $css = '' ) {
* @since 2.2.2
*/
public function override_kirki_styles() {
global $wp_filesystem;

$kirki_styles = apply_filters( 'kirki_bgtfw_dynamic_css', Kirki_Modules_CSS::loop_controls( 'bgtfw' ) );
$filtered_styles = preg_replace( '/font-family:(\w+(\s\w+)+);/', 'font-family:"${1}";', $kirki_styles );

/*
* Kirki no longer creates the kirki-css/styles.css file including their dynamic css.
* Therefore we must create it for them in order to use the styles in the editor.
*/
if ( ! $wp_filesystem->is_dir( wp_upload_dir()['basedir'] . '/kirki-css' ) ) {
$wp_filesystem->mkdir( wp_upload_dir()['basedir'] . '/kirki-css' );
}
$wp_filesystem->put_contents( wp_upload_dir()['basedir'] . '/kirki-css/styles.css', $filtered_styles );
Boldgrid_Framework_Customizer_Generic::add_inline_style( 'boldgrid-kirki-override', $filtered_styles );
}

Expand Down

0 comments on commit 9c301f9

Please sign in to comment.