Google Fonts for WordPress - Version 2.3.0

Version Description

Download this release

Release Info

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

Code changes from version 2.2.4 to 2.3.0

admin/class-ogf-welcome-screen.php CHANGED
@@ -16,6 +16,7 @@ class OGF_Admin_Welcome_Screen {
16
  public function __construct() {
17
  add_action( 'admin_menu', array( $this, 'add_plugin_page' ), 1 );
18
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
 
19
  }
20
 
21
  /**
@@ -39,9 +40,20 @@ class OGF_Admin_Welcome_Screen {
39
  __( 'Customize Fonts', 'olympus-google-fonts' ),
40
  'manage_options',
41
  esc_url( admin_url( '/customize.php?autofocus[panel]=ogf_google_fonts' ) ),
 
42
  5
43
  );
44
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /**
@@ -49,12 +61,20 @@ class OGF_Admin_Welcome_Screen {
49
  */
50
  public function enqueue() {
51
  wp_enqueue_style( 'olympus-google-fonts-welcome', plugins_url( 'admin/style.css', dirname( __FILE__ ) ), false, '1.0.0' );
 
52
  }
53
 
54
  /**
55
  * Options page callback
56
  */
57
- public function render_upload_page() {
 
 
 
 
 
 
 
58
  ?>
59
  <div class="eb-wrap">
60
  <div class="eb-content">
@@ -75,7 +95,7 @@ class OGF_Admin_Welcome_Screen {
75
  <form action="https://fontsplugin.us9.list-manage.com/subscribe/post?u=1ed15f4383eb532a1a1034fb9&amp;id=2ed49283a0" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
76
  <input type="email" value="<?php echo sanitize_email( $email ); ?>" placeholder="Your email address..." name="EMAIL" class="required email" id="mce-EMAIL">
77
  <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_1ed15f4383eb532a1a1034fb9_2ed49283a0" tabindex="-1" value=""></div>
78
- <input type="submit" value="Send My Guide!" name="subscribe" id="mc-embedded-subscribe" class="button">
79
  </form>
80
  <!--End mc_embed_signup-->
81
  </div>
@@ -85,38 +105,11 @@ class OGF_Admin_Welcome_Screen {
85
  }
86
 
87
  /**
88
- * Options page callback
89
  */
90
- public function render_welcome_page() {
91
- $current_user = wp_get_current_user();
92
- $email = ( string ) $current_user->user_email;
93
- ?>
94
- <div class="eb-wrap">
95
- <div class="eb-content">
96
- <div class="eb-content__header">
97
- <h1>Your Quickstart Guide</h1>
98
- </div>
99
- <div class="eb-content__inner">
100
- <img class="ebook-cover" src="<?php echo esc_url( plugins_url( 'admin/fonts-plugin-quickstart-guide.png', dirname( __FILE__ ) ) ); ?>">
101
- <p>To help you get the most out of the Google Fonts plugin we’ve put together a free quickstart guide.</p>
102
- <p>In this beautifully-formatted, easy-to-read PDF you will learn:
103
- <ul>
104
- <li>How to <strong>easily</strong> customize your typography.</li>
105
- <li>How to host fonts <strong>locally</strong> for speed, GDPR & DSGVO.</li>
106
- <li>How to use Google Fonts without <strong>slowing down</strong> your website.</li>
107
- </ul>
108
- <p>Download your free copy today.</p>
109
- <!-- Begin Mailchimp Signup Form -->
110
- <form action="https://fontsplugin.us9.list-manage.com/subscribe/post?u=1ed15f4383eb532a1a1034fb9&amp;id=2ed49283a0" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
111
- <input type="email" value="<?php echo sanitize_email( $email ); ?>" placeholder="Your email address..." name="EMAIL" class="required email" id="mce-EMAIL">
112
- <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_1ed15f4383eb532a1a1034fb9_2ed49283a0" tabindex="-1" value=""></div>
113
- <input type="submit" value="Send My Guide!" name="subscribe" id="mc-embedded-subscribe" class="button">
114
- </form>
115
- <!--End mc_embed_signup-->
116
- </div>
117
- </div>
118
- </div>
119
- <?php
120
  }
121
  }
122
 
16
  public function __construct() {
17
  add_action( 'admin_menu', array( $this, 'add_plugin_page' ), 1 );
18
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
19
+ add_action( 'wp_ajax_ogf_dismiss_guide', array( $this, 'dismiss_guide' ) );
20
  }
21
 
22
  /**
40
  __( 'Customize Fonts', 'olympus-google-fonts' ),
41
  'manage_options',
42
  esc_url( admin_url( '/customize.php?autofocus[panel]=ogf_google_fonts' ) ),
43
+ '',
44
  5
45
  );
46
 
47
+ add_submenu_page(
48
+ 'fonts-plugin',
49
+ __( 'Documentation', 'olympus-google-fonts' ),
50
+ __( 'Documentation', 'olympus-google-fonts' ),
51
+ 'manage_options',
52
+ 'https://docs.fontsplugin.com/',
53
+ '',
54
+ 25
55
+ );
56
+
57
  }
58
 
59
  /**
61
  */
62
  public function enqueue() {
63
  wp_enqueue_style( 'olympus-google-fonts-welcome', plugins_url( 'admin/style.css', dirname( __FILE__ ) ), false, '1.0.0' );
64
+ wp_enqueue_script( 'ogf-admin', esc_url( OGF_DIR_URL . 'assets/js/admin.js' ), 'jquery', OGF_VERSION, false );
65
  }
66
 
67
  /**
68
  * Options page callback
69
  */
70
+ public function render_welcome_page() {
71
+
72
+ if ( get_option( 'ogf_dismiss_guide', false ) !== false ) {
73
+ return;
74
+ }
75
+
76
+ $current_user = wp_get_current_user();
77
+ $email = ( string ) $current_user->user_email;
78
  ?>
79
  <div class="eb-wrap">
80
  <div class="eb-content">
95
  <form action="https://fontsplugin.us9.list-manage.com/subscribe/post?u=1ed15f4383eb532a1a1034fb9&amp;id=2ed49283a0" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
96
  <input type="email" value="<?php echo sanitize_email( $email ); ?>" placeholder="Your email address..." name="EMAIL" class="required email" id="mce-EMAIL">
97
  <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_1ed15f4383eb532a1a1034fb9_2ed49283a0" tabindex="-1" value=""></div>
98
+ <input type="submit" value="Send My Guide!" name="subscribe" id="mc-embedded-subscribe" class="ogf-send-guide-button button">
99
  </form>
100
  <!--End mc_embed_signup-->
101
  </div>
105
  }
106
 
107
  /**
108
+ * AJAX handler to store the state of dismissible notices.
109
  */
110
+ public function dismiss_guide() {
111
+ // Store it in the options table.
112
+ update_option( 'ogf_dismiss_guide', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
  }
115
 
assets/js/{dismiss.js → admin.js} RENAMED
@@ -1,5 +1,29 @@
1
  /* global ajaxurl */
2
  jQuery( document ).ready( function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  // Hook into the "notice-dismiss-welcome" class we added to the notice, so
4
  // Only listen to YOUR notices being dismissed
5
  jQuery( document ).on(
1
  /* global ajaxurl */
2
  jQuery( document ).ready( function() {
3
+
4
+ const menuGetHelpLink = jQuery('a[href="https://docs.fontsplugin.com"]');
5
+ menuGetHelpLink.attr('target', '_blank');
6
+
7
+ // Hook into the "notice-dismiss-welcome" class we added to the notice, so
8
+ // Only listen to YOUR notices being dismissed
9
+ jQuery( document ).on(
10
+ 'click',
11
+ '.ogf-send-guide-button',
12
+ function() {
13
+ // Make an AJAX call
14
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
15
+ jQuery.ajax(
16
+ ajaxurl,
17
+ {
18
+ type: 'POST',
19
+ data: {
20
+ action: 'ogf_dismiss_guide',
21
+ },
22
+ }
23
+ );
24
+ }
25
+ );
26
+
27
  // Hook into the "notice-dismiss-welcome" class we added to the notice, so
28
  // Only listen to YOUR notices being dismissed
29
  jQuery( document ).on(
changelog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  = 2.2.4 =
2
 
3
  * Add failsafe to protect against fonts getting removed
1
+ = 2.3.0 =
2
+
3
+ * Add font-display option (block, swap, fallback, optional).
4
+
5
  = 2.2.4 =
6
 
7
  * Add failsafe to protect against fonts getting removed
includes/class-ogf-fonts.php CHANGED
@@ -197,7 +197,7 @@ class OGF_Fonts {
197
 
198
  $query_args = array(
199
  'family' => implode( '|', $families ),
200
- 'display' => 'swap',
201
  );
202
 
203
  return add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
197
 
198
  $query_args = array(
199
  'family' => implode( '|', $families ),
200
+ 'display' => get_theme_mod( 'ogf_font_display', 'swap' ),
201
  );
202
 
203
  return add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
includes/class-ogf-reset.php CHANGED
@@ -56,6 +56,8 @@ if ( ! class_exists( 'OGF_Reset' ) ) :
56
  'ogf_reset_fonts',
57
  array(
58
  'type' => 'button',
 
 
59
  'settings' => array(),
60
  'priority' => 100,
61
  'section' => 'ogf_debugging',
56
  'ogf_reset_fonts',
57
  array(
58
  'type' => 'button',
59
+ 'label' => __( 'Reset All Fonts', 'olympus-google-fonts' ),
60
+ 'description' => __( 'This will reset all fonts set by this plugin to their defaults. This action can not be reversed.', 'olympus-google-fonts' ),
61
  'settings' => array(),
62
  'priority' => 100,
63
  'section' => 'ogf_debugging',
includes/class-ogf-welcome.php CHANGED
@@ -58,7 +58,7 @@ if ( ! class_exists( 'OGF_Welcome' ) ) :
58
  */
59
  public function enqueue() {
60
 
61
- wp_enqueue_script( 'ogf-dismiss-welcome', esc_url( OGF_DIR_URL . 'assets/js/dismiss.js' ), 'jquery', OGF_VERSION, false );
62
 
63
  }
64
 
58
  */
59
  public function enqueue() {
60
 
61
+ wp_enqueue_script( 'ogf-admin', esc_url( OGF_DIR_URL . 'assets/js/admin.js' ), 'jquery', OGF_VERSION, false );
62
 
63
  }
64
 
includes/customizer/settings.php CHANGED
@@ -178,6 +178,29 @@ function ogf_customize_register( $wp_customize ) {
178
  )
179
  );
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  $fonts = new OGF_Fonts();
182
 
183
  if ( $fonts->has_google_fonts() ) {
@@ -269,3 +292,15 @@ function ogf_customize_register( $wp_customize ) {
269
 
270
  }
271
  add_action( 'customize_register', 'ogf_customize_register' );
 
 
 
 
 
 
 
 
 
 
 
 
178
  )
179
  );
180
 
181
+ $wp_customize->add_setting(
182
+ 'ogf_font_display',
183
+ array(
184
+ 'sanitize_callback' => 'ogf_sanitize_select',
185
+ 'default' => 'swap',
186
+ )
187
+ );
188
+
189
+ $wp_customize->add_control(
190
+ 'ogf_font_display',
191
+ array(
192
+ 'type' => 'select',
193
+ 'section' => 'ogf_debugging', // Add a default or your own section
194
+ 'label' => __( 'Font Display' ),
195
+ 'choices' => array(
196
+ 'swap' => __( 'Swap', 'olympus-google-fonts' ),
197
+ 'block' => __( 'Block', 'olympus-google-fonts' ),
198
+ 'fallback' => __( 'Fallback', 'olympus-google-fonts' ),
199
+ 'optional' => __( 'Optional', 'olympus-google-fonts' ),
200
+ ),
201
+ )
202
+ );
203
+
204
  $fonts = new OGF_Fonts();
205
 
206
  if ( $fonts->has_google_fonts() ) {
292
 
293
  }
294
  add_action( 'customize_register', 'ogf_customize_register' );
295
+
296
+ function ogf_sanitize_select( $input, $setting ) {
297
+
298
+ // Ensure input is a slug.
299
+ $input = sanitize_key( $input );
300
+
301
+ // Get list of choices from the control associated with the setting.
302
+ $choices = $setting->manager->get_control( $setting->id )->choices;
303
+
304
+ // If the input is a valid key, return it; otherwise, return the default.
305
+ return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
306
+ }
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. 900+ font choices.
8
- * Version: 2.2.4
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,7 +18,7 @@
18
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
19
  */
20
 
21
- define( 'OGF_VERSION', '2.2.4' );
22
  define( 'OGF_DIR_PATH', plugin_dir_path( __FILE__ ) );
23
  define( 'OGF_DIR_URL', plugin_dir_url( __FILE__ ) );
24
 
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. 900+ font choices.
8
+ * Version: 2.3.0
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
+ define( 'OGF_VERSION', '2.3.0' );
22
  define( 'OGF_DIR_PATH', plugin_dir_path( __FILE__ ) );
23
  define( 'OGF_DIR_URL', plugin_dir_url( __FILE__ ) );
24
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://fontsplugin.com/#pricing
5
  Requires at least: 4.0
6
  Tested up to: 5.5
7
  License: GPLv2 or later
8
- Stable tag: 2.2.4
9
 
10
  The easiest to use Google Fonts Typography Plugin. No coding required. 900+ font choices.
11
 
5
  Requires at least: 4.0
6
  Tested up to: 5.5
7
  License: GPLv2 or later
8
+ Stable tag: 2.3.0
9
 
10
  The easiest to use Google Fonts Typography Plugin. No coding required. 900+ font choices.
11