Skip to content

Commit

Permalink
Merge pull request #113 from brainstormforce/v2.1.2
Browse files Browse the repository at this point in the history
Release 2.1.2
  • Loading branch information
imnavanath authored Jan 15, 2024
2 parents 9fde96e + c43e614 commit bb1f85e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 20 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Tags:** typography, fonts, custom fonts, Google Fonts, performance, privacy, full site editing, adobe fonts, GDPR
**Requires at least:** 5.0
**Tested up to:** 6.4
**Stable tag:** 2.1.1
**Stable tag:** 2.1.2
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -151,6 +151,10 @@ Yes, Custom Fonts is completely free to use, without any limitation.


## Changelog ##
### 2.1.2 ###
- Fix: Resolve PHP Warning 'Cannot modify header information' during post content editing in Gutenberg.
- Fix: Thrive product created layout's changes not saved due to Custom fonts plugin conflicts.

### 2.1.1 ###
- Improvement: Compatibility with WordPress 6.4.

Expand Down
47 changes: 32 additions & 15 deletions classes/class-bsf-custom-fonts-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public static function get_instance() {
return self::$instance;
}

/**
* Check if either 'Thrive_Product_Manager' or 'TVA_Const' classes exist.
*
* @return bool
*/
public static function is_thrive_or_tva_active() {
return class_exists( 'Thrive_Product_Manager' ) || class_exists( 'TVA_Const' );
}

/**
* Constructor.
*
Expand All @@ -131,10 +140,11 @@ public function __construct() {
add_filter( 'fl_theme_system_fonts', array( $this, 'bb_custom_fonts' ) );
add_filter( 'fl_builder_font_families_system', array( $this, 'bb_custom_fonts' ) );

// Add font files style.
// Add font file styles.
add_action( 'wp_head', array( $this, 'add_style' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'preload_styles' ), 1 );
add_action( 'init', array( $this, 'add_block_assets_style' ) );

add_action( 'init', array( $this, 'add_block_assets_style' ) );
add_filter( 'elementor/fonts/groups', array( $this, 'elementor_group' ) );
add_filter( 'elementor/fonts/additional_fonts', array( $this, 'add_elementor_fonts' ) );
// Astra filter before creating google fonts URL.
Expand Down Expand Up @@ -277,22 +287,24 @@ public function enque_data() {
* @since 1.0.4
*/
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 );
if ( self::is_thrive_or_tva_active() ) {

$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();
}
wp_reset_postdata();
}

if ( ! empty( $font_styles ) ) {
?>
<style type="text/css" id="cst_font_data">
<?php echo wp_strip_all_tags( $font_styles ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</style>
<?php
if ( ! empty( $font_styles ) ) {
wp_register_style( 'cf-frontend-style', false, array(), BSF_CUSTOM_FONTS_VER );
wp_enqueue_style( 'cf-frontend-style' );
wp_add_inline_style( 'cf-frontend-style', wp_strip_all_tags( $font_styles ) );
}
}
}

Expand All @@ -302,6 +314,11 @@ public function add_style() {
* @since x.x.x
*/
public function preload_styles() {

if ( self::is_thrive_or_tva_active() ) {
return;
}

$font_urls = get_option( 'bcf_font_urls', array() );

if ( true === (bool) get_option( 'bcf_preloading_fonts', false ) && ! empty( $font_urls ) ) {
Expand Down
4 changes: 2 additions & 2 deletions custom-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: Brainstorm Force
* Author URI: http://www.brainstormforce.com
* Text Domain: custom-fonts
* Version: 2.1.1
* Version: 2.1.2
*
* @package Bsf_Custom_Fonts
*/
Expand All @@ -25,7 +25,7 @@
define( 'BSF_CUSTOM_FONTS_BASE', plugin_basename( BSF_CUSTOM_FONTS_FILE ) );
define( 'BSF_CUSTOM_FONTS_DIR', plugin_dir_path( BSF_CUSTOM_FONTS_FILE ) );
define( 'BSF_CUSTOM_FONTS_URI', plugins_url( '/', BSF_CUSTOM_FONTS_FILE ) );
define( 'BSF_CUSTOM_FONTS_VER', '2.1.1' );
define( 'BSF_CUSTOM_FONTS_VER', '2.1.2' );
define( 'BSF_CUSTOM_FONTS_POST_TYPE', 'bsf_custom_fonts' );
define( 'BSF_CUSTOM_FONTS_ADMIN_PAGE', 'bsf-custom-fonts' );

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custom-fonts",
"version": "2.1.1",
"version": "2.1.2",
"main": "Gruntfile.js",
"author": "Brainstorm Force",
"workspaces": [
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/BrainstormForce
Tags: typography, fonts, custom fonts, Google Fonts, performance, privacy, full site editing, adobe fonts, GDPR
Requires at least: 5.0
Tested up to: 6.4
Stable tag: 2.1.1
Stable tag: 2.1.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -151,6 +151,10 @@ Yes, Custom Fonts is completely free to use, without any limitation.


== Changelog ==
= 2.1.2 =
- Fix: Resolve PHP Warning 'Cannot modify header information' during post content editing in Gutenberg.
- Fix: Thrive product created layout's changes not saved due to Custom fonts plugin conflicts.

= 2.1.1 =
- Improvement: Compatibility with WordPress 6.4.

Expand Down

0 comments on commit bb1f85e

Please sign in to comment.