Skip to content

Commit dfaf826

Browse files
authored
Merge pull request #13 from brainstormforce/typekit-updates
Version 1.0.8 - Fixed: A Few Typekit fonts not being rendered correctly.
2 parents cdde84d + 2c5fa4b commit dfaf826

16 files changed

+603
-93
lines changed

.distignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ node_modules
2828
*.sql
2929
*.tar.gz
3030
*.zip
31+
package-lock.json

.gitignore

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
.DS_Store
2-
Thumbs.db
3-
wp-cli.local.yml
1+
# ignore PHPStorm extra directories
2+
.idea/
3+
4+
# Leave node_modules from git
45
node_modules/
5-
*.sql
6-
*.tar.gz
6+
7+
# sass cache
8+
.sass-cache
9+
10+
# map files
11+
*.map
12+
13+
# ignore PHPCS report files
14+
phpcs-summary.log
15+
phpcs-full.log
16+
17+
# Org Package
18+
astra
719
*.zip
20+
21+
# Ignore Composer's directories
22+
vendor/

.travis.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
sudo: false
22

33
language: php
4+
dist: precise
45

56
notifications:
67
email:
78
on_success: never
89
on_failure: change
910

10-
directories:
11-
- vendor
11+
cache:
1212
- $HOME/.composer/cache
1313

1414
matrix:
1515
include:
16-
- php: 7.1
16+
- php: 7.3
1717
env: WP_TRAVISCI=phpcs
18-
- php: 7.1
19-
env: WP_VERSION=trunk
20-
- php: 7.0
21-
env: WP_VERSION=trunk
22-
- php: 5.6
23-
env: WP_VERSION=trunk
2418

2519
before_script:
26-
- export PATH="$HOME/.composer/vendor/bin:$PATH"
2720
- |
2821
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
29-
composer global require wp-coding-standards/wpcs
30-
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
22+
composer install
3123
fi
3224
3325
script:
34-
- if find . -name "*.php" ! -path "./vendor/*" ! -path "./admin/bsf-core/*" -exec php -l {} \; | grep "Errors parsing"; then exit 1; fi
3526
- |
3627
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
37-
phpcs
28+
vendor/bin/phpcs
3829
fi
30+
- if find . -name "*.php" ! -path "./vendor/*" ! -path "./admin/bsf-core/*" -exec php -l {} \; | grep "Errors parsing"; then exit 1; fi
31+

README.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Tags:** custom typekit fonts, theme custom fonts, unlimited typekit custom fonts
55
**Requires at least:** 4.4
66
**Tested up to:** 5.0
7-
**Stable tag:** 1.0.7
7+
**Stable tag:** 1.0.8
88
**License:** GPLv2 or later
99
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -49,30 +49,33 @@ If you're not using any of the supported plugins and theme, you can write the cu
4949

5050
## Changelog ##
5151

52-
v1.0.7
53-
* Improvement: Enqueue typekit fonts in the block editor.
52+
### v1.0.8 ###
53+
- Fixed: A few TypeKit fonts not being rendered correctly.
5454

55-
v1.0.6
56-
* Fixed: Update font name to correct font family to be rendered correctly for all the fonts.
57-
* Fixed: Typekit fonts not rendered ccorrectly in Beaver Builder and Elementor settings.
55+
### v1.0.7 ###
56+
- Improvement: Enqueue typekit fonts in the block editor.
5857

59-
v1.0.5
60-
* Fixed: Fatal error: Uncaught Error: Class ‘Bsf_Custom_Fonts_Taxonomy’ not found
58+
### v1.0.6 ###
59+
- Fixed: Update font name to correct font family to be rendered correctly for all the fonts.
60+
- Fixed: Typekit fonts not rendered ccorrectly in Beaver Builder and Elementor settings.
6161

62-
v1.0.4
63-
* Fixed: Added Fonts in separate group for Elementor fonts & global fonts selection.
62+
### v1.0.5 ###
63+
- Fixed: Fatal error: Uncaught Error: Class ‘Bsf_Custom_Fonts_Taxonomy’ not found
6464

65-
v1.0.3
66-
* New: Added compatibility with Beaver Builder Theme, Beaver Builder Plugin and Elementor.
65+
### v1.0.4 ###
66+
- Fixed: Added Fonts in separate group for Elementor fonts & global fonts selection.
6767

68-
v1.0.2
69-
* Typekit fonts support added for all themes.
70-
* White Label support added from the [Astra Pro](https://wpastra.com/pro/) plugin.
68+
### v1.0.3 ###
69+
- New: Added compatibility with Beaver Builder Theme, Beaver Builder Plugin and Elementor.
7170

72-
v1.0.1
73-
* Custom Typekit Fonts wp admin menu renamed to Typekit Fonts.
74-
* Empty Kit notice added if there is not fonts in the Kit.
75-
* Php waring if there is no font list handled.
71+
### v1.0.2 ###
72+
- Typekit fonts support added for all themes.
73+
- White Label support added from the [Astra Pro](https://wpastra.com/pro/) plugin.
7674

77-
v1.0.0
78-
* Initial release
75+
### v1.0.1 ###
76+
- Custom Typekit Fonts wp admin menu renamed to Typekit Fonts.
77+
- Empty Kit notice added if there is not fonts in the Kit.
78+
- Php waring if there is no font list handled.
79+
80+
### v1.0.0 ###
81+
- Initial release

classes/class-custom-typekit-fonts-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function set_custom_typekit_fonts_notice() {
9090
<p><?php _e( 'Custom Typekit Fonts settings have been successfully saved.', 'custom-typekit-fonts' ); ?></p>
9191
</div>
9292
<?php
93-
}
93+
}
9494
}
9595
}
9696
}

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ public function add_elementor_fonts( $fonts ) {
105105
$custom_fonts = array();
106106
if ( ! empty( $all_fonts ) ) {
107107
foreach ( $all_fonts as $font_family_name => $fonts_url ) {
108-
$custom_fonts[ strtolower( str_replace( ' ', '-', $font_family_name ) ) ] = self::$font_base;
108+
$font_slug = isset( $fonts_url['slug'] ) ? $fonts_url['slug'] : '';
109+
$font_css = isset( $fonts_url['css_names'][0] ) ? $fonts_url['css_names'][0] : $font_slug;
110+
$custom_fonts[ $font_css ] = self::$font_base;
109111
}
110112
}
113+
111114
return array_merge( $fonts, $custom_fonts );
112115
}
113116

@@ -192,7 +195,7 @@ public function add_customizer_font_list( $value ) {
192195
if ( ! empty( $kit_list['custom-typekit-font-details'] ) ) {
193196
echo '<optgroup label="Typekit">';
194197
foreach ( $kit_list['custom-typekit-font-details'] as $font => $properties ) {
195-
echo '<option value="' . esc_attr( $font ) . ',' . $properties['fallback'] . '" ' . selected( $font, $value, false ) . '>' . esc_attr( $font ) . '</option>';
198+
echo '<option value="\'' . esc_attr( $font ) . '\',' . esc_attr( $properties['fallback'] ) . '" ' . selected( $font, $value, false ) . '>' . esc_html( $font ) . '</option>';
196199
}
197200
}
198201
}
@@ -209,12 +212,15 @@ function bb_custom_fonts( $bb_fonts ) {
209212
$fonts = $kit_list['custom-typekit-font-details'];
210213
$custom_fonts = array();
211214
if ( ! empty( $fonts ) ) :
212-
foreach ( $fonts as $font_family_name => $fonts_url ) :
213-
$custom_fonts[ $font_family_name ] = array(
215+
foreach ( $fonts as $font_family_name => $fonts_url ) {
216+
$font_slug = isset( $fonts_url['slug'] ) ? $fonts_url['slug'] : '';
217+
$font_css = isset( $fonts_url['css_names'][0] ) ? $fonts_url['css_names'][0] : $font_slug;
218+
219+
$custom_fonts[ $font_css ] = array(
214220
'fallback' => 'Verdana, Arial, sans-serif',
215221
'weights' => array( '100', '200', '300', '400', '500', '600', '700', '800', '900' ),
216222
);
217-
endforeach;
223+
}
218224
endif;
219225

220226
return array_merge( $bb_fonts, $custom_fonts );
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Custom Typekit Fonts Update
4+
*
5+
* @package Custom Typekit Fonts
6+
* @author Brainstorm Force
7+
* @copyright Copyright (c) 2018, Astra
8+
* @link https://wpastra.com/
9+
* @since Astra 1.0.0
10+
*/
11+
12+
if ( ! class_exists( 'Custom_Typekit_Fonts_Update' ) ) {
13+
14+
/**
15+
* Custom_Typekit_Fonts_Update initial setup
16+
*
17+
* @since 1.0.0
18+
*/
19+
class Custom_Typekit_Fonts_Update {
20+
21+
22+
/**
23+
* Class instance.
24+
*
25+
* @access private
26+
* @var $instance Class instance.
27+
*/
28+
private static $instance;
29+
30+
/**
31+
* Initiator
32+
*/
33+
public static function get_instance() {
34+
if ( ! isset( self::$instance ) ) {
35+
self::$instance = new self();
36+
}
37+
return self::$instance;
38+
}
39+
40+
/**
41+
* Constructor
42+
*/
43+
public function __construct() {
44+
45+
// Theme Updates.
46+
if ( is_admin() ) {
47+
add_action( 'admin_init', array( $this, 'init' ), 5 );
48+
} else {
49+
add_action( 'init', array( $this, 'init' ), 5 );
50+
}
51+
52+
}
53+
54+
/**
55+
* Return option name for storing the custom typekit version.
56+
*
57+
* @return String
58+
*/
59+
private function get_option_name() {
60+
return '_custom_typekit_fonts_version';
61+
}
62+
63+
/**
64+
* Implement theme update logic.
65+
*
66+
* @since 1.0.7
67+
*/
68+
public function init() {
69+
do_action( 'custom_typekit_fonts_update_before' );
70+
71+
// Get auto saved version number.
72+
$saved_version = get_option( $this->get_option_name(), false );
73+
74+
// If equals then return.
75+
if ( version_compare( $saved_version, CUSTOM_TYPEKIT_FONTS_VER, '=' ) ) {
76+
return;
77+
}
78+
79+
// Update to older version than 1.0.8 version.
80+
if ( version_compare( $saved_version, '1.0.8', '<' ) ) {
81+
$this->v_1_0_8();
82+
}
83+
84+
// Update auto saved version number.
85+
update_option( $this->get_option_name(), CUSTOM_TYPEKIT_FONTS_VER );
86+
87+
do_action( 'custom_typekit_fonts_update_after' );
88+
}
89+
90+
/**
91+
* Force udpate typekit fonts.
92+
*
93+
* @return void
94+
*/
95+
private function v_1_0_8() {
96+
$typekit = new Custom_Typekit_Fonts();
97+
$custom_typekit = get_option( 'custom-typekit-fonts' );
98+
$option = array();
99+
$option['custom-typekit-font-id'] = sanitize_text_field( $custom_typekit['custom-typekit-font-id'] );
100+
$option['custom-typekit-font-details'] = $typekit->get_custom_typekit_details( $custom_typekit['custom-typekit-font-id'] );
101+
102+
update_option( 'custom-typekit-fonts', $option );
103+
}
104+
105+
}
106+
107+
}
108+
109+
/**
110+
* Kicking this off by calling 'get_instance()' method
111+
*/
112+
Custom_Typekit_Fonts_Update::get_instance();

classes/class-custom-typekit-fonts.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static function get_instance() {
3838
public function __construct() {
3939
require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts-admin.php';
4040
require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts-render.php';
41+
require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts-update.php';
4142

4243
add_action( 'init', array( $this, 'options_setting' ) );
4344

@@ -151,6 +152,9 @@ function get_custom_typekit_details( $kit_id ) {
151152
$typekit_info[ $family_name ]['weights'][] = $weight;
152153
}
153154
}
155+
156+
$typekit_info[ $family_name ]['slug'] = $family['slug'];
157+
$typekit_info[ $family_name ]['css_names'] = $family['css_names'];
154158
}
155159

156160
return $typekit_info;

composer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"require-dev": {
3+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
4+
"wp-coding-standards/wpcs": "dev-master",
5+
"phpcompatibility/phpcompatibility-wp": "*"
6+
},
7+
"require": {
8+
}
9+
}

0 commit comments

Comments
 (0)