Google Fonts for WordPress - Version 2.5.6

Version Description

Download this release

Release Info

Developer DannyCooper
Plugin Icon 128x128 Google Fonts for WordPress
Version 2.5.6
Comparing to
See all releases

Code changes from version 2.5.5 to 2.5.6

blocks/init.php CHANGED
@@ -12,6 +12,10 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  exit;
13
  }
14
 
 
 
 
 
15
  /**
16
  * Enqueue Gutenberg block assets for backend editor.
17
  */
12
  exit;
13
  }
14
 
15
+ if ( false !== get_theme_mod( 'ogf_disable_post_level_controls', false ) ) {
16
+ return;
17
+ }
18
+
19
  /**
20
  * Enqueue Gutenberg block assets for backend editor.
21
  */
changelog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  = 2.5.5 =
2
 
3
  * Fix bug where Custom Font Files weren't being enqueued in Gutenberg.
1
+ = 2.5.6 =
2
+
3
+ * Code optimization for future improvements.
4
+ * Fix inefficiencies with Typekit enqueues.
5
+ * Improve output of CSS variables.
6
+
7
  = 2.5.5 =
8
 
9
  * Fix bug where Custom Font Files weren't being enqueued in Gutenberg.
class-olympus-google-fonts.php CHANGED
@@ -16,7 +16,9 @@ class Olympus_Google_Fonts {
16
  * Initialize plugin.
17
  */
18
  public function __construct() {
 
19
  $this->includes();
 
20
 
21
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
22
 
@@ -32,6 +34,23 @@ class Olympus_Google_Fonts {
32
  }
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * Load plugin files.
37
  */
@@ -53,6 +72,7 @@ class Olympus_Google_Fonts {
53
  require_once OGF_DIR_PATH . 'includes/class-ogf-typekit.php';
54
 
55
  // Required files for the Gutenberg editor.
 
56
  require_once OGF_DIR_PATH . 'includes/gutenberg/output-css.php';
57
 
58
  // Notifications class.
@@ -69,6 +89,22 @@ class Olympus_Google_Fonts {
69
 
70
  // News widget.
71
  require_once OGF_DIR_PATH . 'includes/class-ogf-dashboard-widget.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
 
74
  /**
@@ -87,10 +123,6 @@ class Olympus_Google_Fonts {
87
  if ( $fonts->has_google_fonts() ) {
88
  $url = $fonts->build_url();
89
  wp_enqueue_style( 'olympus-google-fonts', $url, array(), OGF_VERSION );
90
-
91
- $css = ogf_generate_css_variables();
92
- wp_add_inline_style( 'olympus-google-fonts', $css );
93
-
94
  }
95
  }
96
 
@@ -173,3 +205,5 @@ class Olympus_Google_Fonts {
173
  }
174
 
175
  }
 
 
16
  * Initialize plugin.
17
  */
18
  public function __construct() {
19
+ $this->constants();
20
  $this->includes();
21
+ $this->compatability();
22
 
23
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
24
 
34
  }
35
  }
36
 
37
+ /**
38
+ * Load plugin files.
39
+ */
40
+ public function constants() {
41
+ if ( ! defined( 'OGF_VERSION' ) ) {
42
+ define( 'OGF_VERSION', '2.5.6' );
43
+ }
44
+
45
+ if ( ! defined( 'OGF_DIR_PATH' ) ) {
46
+ define( 'OGF_DIR_PATH', plugin_dir_path( __FILE__ ) );
47
+ }
48
+
49
+ if ( ! defined( 'OGF_DIR_URL' ) ) {
50
+ define( 'OGF_DIR_URL', plugin_dir_url( __FILE__ ) );
51
+ }
52
+ }
53
+
54
  /**
55
  * Load plugin files.
56
  */
72
  require_once OGF_DIR_PATH . 'includes/class-ogf-typekit.php';
73
 
74
  // Required files for the Gutenberg editor.
75
+ require_once OGF_DIR_PATH . 'blocks/init.php';
76
  require_once OGF_DIR_PATH . 'includes/gutenberg/output-css.php';
77
 
78
  // Notifications class.
89
 
90
  // News widget.
91
  require_once OGF_DIR_PATH . 'includes/class-ogf-dashboard-widget.php';
92
+
93
+ // Admin sidebar page(s).
94
+ require_once OGF_DIR_PATH . 'admin/class-ogf-welcome-screen.php';
95
+ }
96
+
97
+ /**
98
+ * Load plugin textdomain.
99
+ */
100
+ public function compatability() {
101
+ $current_theme = wp_get_theme();
102
+ $theme_author = strtolower( esc_attr( $current_theme->get( 'Author' ) ) );
103
+ $theme_author = str_replace( ' ', '', $theme_author );
104
+ $author_compat_path = OGF_DIR_PATH . '/compatibility/' . $theme_author . '.php';
105
+ if ( file_exists( $author_compat_path ) ) {
106
+ require_once $author_compat_path;
107
+ }
108
  }
109
 
110
  /**
123
  if ( $fonts->has_google_fonts() ) {
124
  $url = $fonts->build_url();
125
  wp_enqueue_style( 'olympus-google-fonts', $url, array(), OGF_VERSION );
 
 
 
 
126
  }
127
  }
128
 
205
  }
206
 
207
  }
208
+
209
+ $gfwp = new Olympus_Google_Fonts();
includes/class-ogf-typekit.php CHANGED
@@ -288,14 +288,13 @@ class OGF_Typekit {
288
  public static function get_fonts() {
289
  $fonts = array();
290
  $kits = get_option( 'fp-typekit-data', array() );
291
-
292
  if ( ! is_array( $kits ) ) {
293
  return $fonts;
294
  }
295
 
296
  foreach ( $kits as $kit ) {
297
  if ( ! $kit['enabled'] ) {
298
- return $fonts;
299
  }
300
  foreach ( $kit['families'] as $family ) {
301
  $fonts[ 'tk-' . $family['id'] ] = array(
@@ -317,6 +316,12 @@ class OGF_Typekit {
317
 
318
  if ( is_array( $typekit_data ) ) {
319
  foreach ( $typekit_data as $id => $values ) {
 
 
 
 
 
 
320
  wp_enqueue_style( 'typekit-' . $id, 'https://use.typekit.com/' . $id . '.css', array(), OGF_VERSION );
321
  }
322
  }
288
  public static function get_fonts() {
289
  $fonts = array();
290
  $kits = get_option( 'fp-typekit-data', array() );
 
291
  if ( ! is_array( $kits ) ) {
292
  return $fonts;
293
  }
294
 
295
  foreach ( $kits as $kit ) {
296
  if ( ! $kit['enabled'] ) {
297
+ continue;
298
  }
299
  foreach ( $kit['families'] as $family ) {
300
  $fonts[ 'tk-' . $family['id'] ] = array(
316
 
317
  if ( is_array( $typekit_data ) ) {
318
  foreach ( $typekit_data as $id => $values ) {
319
+
320
+ // skip if the kit is disabled.
321
+ if ( $values['enabled'] === false ) {
322
+ continue;
323
+ }
324
+
325
  wp_enqueue_style( 'typekit-' . $id, 'https://use.typekit.com/' . $id . '.css', array(), OGF_VERSION );
326
  }
327
  }
includes/customizer/controls/class-ogf-customize-repeater-control.php CHANGED
@@ -29,9 +29,6 @@ class OGF_Customize_Repeater_Control extends WP_Customize_Control {
29
  */
30
  public function enqueue() {
31
  wp_enqueue_script( 'customizer-repeater-script', OGF_DIR_URL . 'assets/js/customizer-repeater.js', array( 'jquery', 'jquery-ui-draggable', 'wp-color-picker' ), OGF_VERSION, true );
32
- $custom_selectors_url = esc_url( admin_url( '/customize.php?autofocus[section]=ogf_custom' ) );
33
- wp_localize_script( 'customizer-repeater-script', 'ogf_custom_selectors_url', $custom_selectors_url );
34
-
35
  }
36
 
37
  /**
29
  */
30
  public function enqueue() {
31
  wp_enqueue_script( 'customizer-repeater-script', OGF_DIR_URL . 'assets/js/customizer-repeater.js', array( 'jquery', 'jquery-ui-draggable', 'wp-color-picker' ), OGF_VERSION, true );
 
 
 
32
  }
33
 
34
  /**
includes/customizer/output-css.php CHANGED
@@ -239,28 +239,33 @@ function ogf_generate_css_variables() {
239
  $headings_font = get_theme_mod( 'ogf_headings_font', false );
240
  $inputs_font = get_theme_mod( 'ogf_inputs_font', false );
241
 
242
- $body_font_stack = '';
243
- $headings_font_stack = '';
244
- $inputs_font_stack = '';
 
 
 
 
 
 
245
 
246
  if ( $body_font ) {
247
  $body_font_stack = str_replace( '"', '', ogf_build_font_stack( $body_font ) );
 
248
  }
249
  if ( $headings_font ) {
250
  $headings_font_stack = str_replace( '"', '', ogf_build_font_stack( $headings_font ) );
 
251
  }
252
  if ( $inputs_font ) {
253
  $inputs_font_stack = str_replace( '"', '', ogf_build_font_stack( $inputs_font ) );
 
254
  }
255
 
256
- $css =
257
- '
258
- :root {
259
- --font-base: ' . esc_attr( $body_font_stack ) . ';
260
- --font-headings: ' . esc_attr( $headings_font_stack ) . ';
261
- --font-input: ' . esc_attr( $inputs_font_stack ) . ';
262
- }
263
- ';
264
 
265
- return $css;
266
  }
 
 
 
239
  $headings_font = get_theme_mod( 'ogf_headings_font', false );
240
  $inputs_font = get_theme_mod( 'ogf_inputs_font', false );
241
 
242
+ if ( $body_font === 'default' && $headings_font === 'default' && $inputs_font === 'default' ) {
243
+ return;
244
+ }
245
+
246
+ if ( ! $body_font && ! $headings_font && ! $inputs_font ) {
247
+ return;
248
+ }
249
+
250
+ $css = ':root {';
251
 
252
  if ( $body_font ) {
253
  $body_font_stack = str_replace( '"', '', ogf_build_font_stack( $body_font ) );
254
+ $css .= '--font-base: ' . esc_attr( $body_font_stack ) . ';';
255
  }
256
  if ( $headings_font ) {
257
  $headings_font_stack = str_replace( '"', '', ogf_build_font_stack( $headings_font ) );
258
+ $css .= '--font-headings: ' . esc_attr( $headings_font_stack ) . ';';
259
  }
260
  if ( $inputs_font ) {
261
  $inputs_font_stack = str_replace( '"', '', ogf_build_font_stack( $inputs_font ) );
262
+ $css .= '--font-input: ' . esc_attr( $inputs_font_stack ) . ';';
263
  }
264
 
265
+ $css .= '}';
 
 
 
 
 
 
 
266
 
267
+ echo $css;
268
  }
269
+
270
+ add_action( 'ogf_inline_styles', 'ogf_generate_css_variables', 1 );
271
+ add_action( 'ogf_gutenberg_inline_styles', 'ogf_generate_css_variables', 1 );
includes/gutenberg/output-css.php CHANGED
@@ -16,9 +16,6 @@ function ogf_gutenberg_enqueue_fonts() {
16
  if ( $fonts->has_google_fonts() ) {
17
  $url = $fonts->build_url();
18
  wp_enqueue_style( 'olympus-google-fonts', $url, array(), OGF_VERSION );
19
-
20
- $css = ogf_generate_css_variables();
21
- wp_add_inline_style( 'olympus-google-fonts', $css );
22
  }
23
  }
24
  add_action( 'enqueue_block_editor_assets', 'ogf_gutenberg_enqueue_fonts' );
@@ -177,4 +174,4 @@ function ogf_generate_css_gutenberg( $selector, $option_name ) {
177
  function ogf_gutenberg_custom_font_css() {
178
  echo ogf_return_custom_font_css();
179
  }
180
- add_action( 'ogf_gutenberg_inline_styles', 'ogf_gutenberg_custom_font_css', 1 );
16
  if ( $fonts->has_google_fonts() ) {
17
  $url = $fonts->build_url();
18
  wp_enqueue_style( 'olympus-google-fonts', $url, array(), OGF_VERSION );
 
 
 
19
  }
20
  }
21
  add_action( 'enqueue_block_editor_assets', 'ogf_gutenberg_enqueue_fonts' );
174
  function ogf_gutenberg_custom_font_css() {
175
  echo ogf_return_custom_font_css();
176
  }
177
+ add_action( 'ogf_gutenberg_inline_styles', 'ogf_gutenberg_custom_font_css', 2 );
olympus-google-fonts.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin Name: Fonts Plugin | Google Fonts Typography
6
  * Plugin URI: https://wordpress.org/plugins/olympus-google-fonts/
7
  * Description: The easiest to use Google Fonts typography plugin. No coding required. 1000+ font choices.
8
- * Version: 2.5.5
9
  * Author: Fonts Plugin
10
  * Author URI: https://fontsplugin.com/?utm_source=wporg&utm_medium=readme&utm_campaign=description
11
  * Text Domain: olympus-google-fonts
@@ -18,59 +18,31 @@
18
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
19
  */
20
 
21
- if ( ! defined( 'OGF_VERSION' ) ) {
22
- define( 'OGF_VERSION', '2.5.5' );
23
- }
24
-
25
- if ( ! defined( 'OGF_DIR_PATH' ) ) {
26
- define( 'OGF_DIR_PATH', plugin_dir_path( __FILE__ ) );
27
- }
28
-
29
- if ( ! defined( 'OGF_DIR_URL' ) ) {
30
- define( 'OGF_DIR_URL', plugin_dir_url( __FILE__ ) );
31
- }
32
-
33
- require_once OGF_DIR_PATH . 'class-olympus-google-fonts.php';
34
- require_once OGF_DIR_PATH . 'admin/class-ogf-welcome-screen.php';
35
-
36
-
37
- if ( false === get_theme_mod( 'ogf_disable_post_level_controls', false ) ) {
38
- require_once OGF_DIR_PATH . 'blocks/init.php';
39
- }
40
-
41
- $gfwp = new Olympus_Google_Fonts();
42
-
43
- $current_theme = wp_get_theme();
44
- $theme_author = strtolower( esc_attr( $current_theme->get( 'Author' ) ) );
45
- $theme_author = str_replace( ' ', '', $theme_author );
46
- $author_compat_path = OGF_DIR_PATH . '/compatibility/' . $theme_author . '.php';
47
- if ( file_exists( $author_compat_path ) ) {
48
- require_once $author_compat_path;
49
  }
 
50
 
51
- if ( ! function_exists( 'ogf_activate' ) ) {
52
- /**
53
- * Add a redirection check on activation.
54
- */
55
- function ogf_activate() {
56
- add_option( 'ogf_do_activation_redirect', true );
57
- }
58
- register_activation_hook( __FILE__, 'ogf_activate' );
59
  }
 
60
 
61
-
62
- if ( ! function_exists( 'ogf_redirect' ) ) {
63
- /**
64
- * Redirect to the Google Fonts Welcome page.
65
- */
66
- function ogf_redirect() {
67
-
68
- if ( get_option( 'ogf_do_activation_redirect', false ) ) {
69
- delete_option( 'ogf_do_activation_redirect' );
70
- if ( ! isset( $_GET['activate-multi'] ) ) {
71
- wp_redirect( 'admin.php?page=fonts-plugin' );
72
- exit;
73
- }
74
  }
75
  }
76
  }
5
  * Plugin Name: Fonts Plugin | Google Fonts Typography
6
  * Plugin URI: https://wordpress.org/plugins/olympus-google-fonts/
7
  * Description: The easiest to use Google Fonts typography plugin. No coding required. 1000+ font choices.
8
+ * Version: 2.5.6
9
  * Author: Fonts Plugin
10
  * Author URI: https://fontsplugin.com/?utm_source=wporg&utm_medium=readme&utm_campaign=description
11
  * Text Domain: olympus-google-fonts
18
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
19
  */
20
 
21
+ /**
22
+ * Initiate the plugin, unless the Pro version is active.
23
+ */
24
+ function ogf_initiate() {
25
+ require_once 'class-olympus-google-fonts.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
+ add_action( 'plugins_loaded', 'ogf_initiate', 10 );
28
 
29
+ /**
30
+ * Add a redirection check on activation.
31
+ */
32
+ function ogf_activate() {
33
+ add_option( 'ogf_do_activation_redirect', true );
 
 
 
34
  }
35
+ register_activation_hook( __FILE__, 'ogf_activate' );
36
 
37
+ /**
38
+ * Redirect to the Google Fonts Welcome page.
39
+ */
40
+ function ogf_redirect() {
41
+ if ( get_option( 'ogf_do_activation_redirect', false ) ) {
42
+ delete_option( 'ogf_do_activation_redirect' );
43
+ if ( ! isset( $_GET['activate-multi'] ) ) {
44
+ wp_redirect( 'admin.php?page=fonts-plugin' );
45
+ exit;
 
 
 
 
46
  }
47
  }
48
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://fontsplugin.com/#pricing
5
  Requires at least: 4.0
6
  Tested up to: 5.7
7
  License: GPLv2 or later
8
- Stable tag: 2.5.5
9
 
10
  The easiest to use Google Fonts Typography Plugin. No coding required. 1000+ font choices.
11
 
5
  Requires at least: 4.0
6
  Tested up to: 5.7
7
  License: GPLv2 or later
8
+ Stable tag: 2.5.6
9
 
10
  The easiest to use Google Fonts Typography Plugin. No coding required. 1000+ font choices.
11