We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The part with <style type=”text/css” id=”cst_font_data”> is added twice when I go to edit a page.
I did test it on a simple site, with the default theme and just that plugin.
And it output one time before : Like that:
Here is some suggested code to help : public function add_block_assets_style() { if ( is_admin() && ! is_customize_preview() ) { wp_register_style( 'cst_font_data', false ); wp_enqueue_style( 'cst_font_data' ); add_action( 'enqueue_block_assets', array( $this, 'add_style' ) ); } add_action( 'enqueue_block_editor_assets', array( $this, 'enque_data' ) ); }
public function add_style() { $font_styles = ''; $query_posts = $this->get_existing_font_posts(); if ( $query_posts ) { foreach ( $query_posts as $key => $post_id ) { $font_styles .= get_post_meta( $post_id, 'fonts-face', true ); } wp_reset_postdata(); } if ( ! empty( $font_styles ) ) { wp_add_inline_style('cst_font_data',wp_strip_all_tags( $font_styles )); /* ?>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The part with <style type=”text/css” id=”cst_font_data”> is added twice when I go to edit a page.
I did test it on a simple site, with the default theme and just that plugin.
And it output one time before :
<style type="text/css" id="cst_font_data"> @font-face { font-family: 'Gotham Bold'; font-weight: 400; src: url('http://gutenberg.local/wp-content/uploads/2023/10/Gotham-Bold.otf') format('OpenType'); } </style>Like that:
Here is some suggested code to help :
public function add_block_assets_style() {
if ( is_admin() && ! is_customize_preview() ) {
wp_register_style( 'cst_font_data', false );
wp_enqueue_style( 'cst_font_data' );
add_action( 'enqueue_block_assets', array( $this, 'add_style' ) );
}
add_action( 'enqueue_block_editor_assets', array( $this, 'enque_data' ) );
}
public function add_style() {
<style type="text/css" id="cst_font_data"> </style>$font_styles = '';
$query_posts = $this->get_existing_font_posts();
if ( $query_posts ) {
foreach ( $query_posts as $key => $post_id ) {
$font_styles .= get_post_meta( $post_id, 'fonts-face', true );
}
wp_reset_postdata();
}
if ( ! empty( $font_styles ) ) {
wp_add_inline_style('cst_font_data',wp_strip_all_tags( $font_styles ));
/*
?>
The text was updated successfully, but these errors were encountered: