Custom Fonts - Version 1.0.4

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon 128x128 Custom Fonts
Version 1.0.4
Comparing to
See all releases

Code changes from version 1.0.3 to 1.0.4

classes/class-bsf-custom-fonts-render.php CHANGED
@@ -52,7 +52,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
52
  */
53
  public function __construct() {
54
 
55
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
56
 
57
  add_action( 'admin_notices', array( $this, 'theme_update_notice' ) );
58
 
@@ -62,10 +62,82 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
62
  // Delete custom fonts action.
63
  add_action( 'delete_term', array( $this, 'delete_custom_fonts_fallback_astra' ), 10, 5 );
64
 
65
- add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
66
 
67
  // add Custom Font list into Astra customizer.
68
  add_action( 'astra_customizer_font_list', array( $this, 'add_customizer_font_list' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  }
70
 
71
  /**
@@ -81,7 +153,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
81
  echo '<optgroup label="Custom">';
82
 
83
  foreach ( $fonts as $font => $links ) {
84
- echo '<option value="' . esc_attr( $font ) . '" ' . selected( $font, $value , false ) . '>' . esc_attr( $font ) . '</option>';
85
  }
86
  }
87
 
@@ -90,7 +162,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
90
  *
91
  * @since 1.0.0
92
  */
93
- public function enqueue_scripts() {
94
 
95
  wp_enqueue_style( 'bsf-custom-fonts-css', BSF_CUSTOM_FONTS_URI . 'assets/css/bsf-custom-fonts.css', array(), BSF_CUSTOM_FONTS_VER );
96
  wp_enqueue_media();
@@ -106,16 +178,13 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
106
  */
107
  public function render_fonts( $load_fonts ) {
108
 
109
- $fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
110
 
111
  foreach ( $load_fonts as $load_font_name => $load_font ) {
112
- if ( array_key_exists( $load_font_name , $fonts ) ) {
113
- $this->render_font_css( $load_font_name );
114
  unset( $load_fonts[ $load_font_name ] );
115
  }
116
  }
117
- // Add Astra inline css for custom Fonys.
118
- wp_add_inline_style( 'astra-theme-css', $this->font_css );
119
  return $load_fonts;
120
  }
121
 
@@ -131,7 +200,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
131
  foreach ( $fonts as $font => $links ) :
132
  $css = '@font-face { font-family:' . esc_attr( $font ) . ';';
133
  $css .= 'src:';
134
- $arr = array();
135
  if ( $links['font_woff_2'] ) {
136
  $arr[] = 'url(' . esc_url( $links['font_woff_2'] ) . ") format('woff2')";
137
  }
@@ -145,8 +214,8 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
145
  $arr[] = 'url(' . esc_url( $links['font_svg'] ) . '#' . esc_attr( strtolower( str_replace( ' ', '_', $font ) ) ) . ") format('svg')";
146
  }
147
  $css .= join( ', ', $arr );
148
- $css .= ';}' ;
149
- endforeach;
150
 
151
  $this->font_css .= $css;
152
  }
52
  */
53
  public function __construct() {
54
 
55
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
56
 
57
  add_action( 'admin_notices', array( $this, 'theme_update_notice' ) );
58
 
62
  // Delete custom fonts action.
63
  add_action( 'delete_term', array( $this, 'delete_custom_fonts_fallback_astra' ), 10, 5 );
64
 
65
+ add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
66
 
67
  // add Custom Font list into Astra customizer.
68
  add_action( 'astra_customizer_font_list', array( $this, 'add_customizer_font_list' ) );
69
+
70
+ // Beaver builder theme customizer, beaver buidler page builder.
71
+ add_filter( 'fl_theme_system_fonts', array( $this, 'bb_custom_fonts' ) );
72
+ add_filter( 'fl_builder_font_families_system', array( $this, 'bb_custom_fonts' ) );
73
+
74
+ // Elementor page builder.
75
+ add_action( 'elementor/controls/controls_registered', array( $this, 'elementor_custom_fonts' ), 10, 1 );
76
+
77
+ // Add font files style.
78
+ add_action( 'wp_head', array( $this, 'add_style' ) );
79
+ }
80
+
81
+
82
+ /**
83
+ * Add Custom Font list to BB theme and BB Page Builder
84
+ *
85
+ * @since 1.0.4
86
+ * @param array $bb_fonts font families added by bb.
87
+ */
88
+ function bb_custom_fonts( $bb_fonts ) {
89
+
90
+ $fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
91
+ $custom_fonts = array();
92
+ if ( ! empty( $fonts ) ) :
93
+ foreach ( $fonts as $font_family_name => $fonts_url ) :
94
+ $custom_fonts[ $font_family_name ] = array(
95
+ 'fallback' => 'Verdana, Arial, sans-serif',
96
+ 'weights' => array( '100', '200', '300', '400', '500', '600', '700', '800', '900' ),
97
+ );
98
+ endforeach;
99
+ endif;
100
+
101
+ return array_merge( $bb_fonts, $custom_fonts );
102
+ }
103
+
104
+ /**
105
+ * Add Custom Font list to Elementor Page Builder
106
+ *
107
+ * @since 1.0.4
108
+ * @param array $controls_registry font families added by elementor.
109
+ */
110
+ function elementor_custom_fonts( $controls_registry ) {
111
+ $fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
112
+ $fonts_elementor = array( 'Use Any Fonts' => array() );
113
+ if ( ! empty( $fonts ) ) :
114
+ foreach ( $fonts as $font_family_name => $fonts_url ) :
115
+ $fonts_elementor[ $font_family_name ] = 'system';
116
+ endforeach;
117
+ endif;
118
+
119
+ $fonts = $controls_registry->get_control( 'font' )->get_settings( 'options' );
120
+ $new_fonts = array_merge( $fonts, $fonts_elementor );
121
+ $controls_registry->get_control( 'font' )->set_settings( 'options', $new_fonts );
122
+ }
123
+
124
+ /**
125
+ * Enqueue Scripts
126
+ *
127
+ * @since 1.0.4
128
+ */
129
+ public function add_style() {
130
+ $fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
131
+ if ( ! empty( $fonts ) ) {
132
+ foreach ( $fonts as $load_font_name => $load_font ) {
133
+ $this->render_font_css( $load_font_name );
134
+ }
135
+ ?>
136
+ <style type="text/css">
137
+ <?php echo $this->font_css; ?>
138
+ </style>
139
+ <?php
140
+ }
141
  }
142
 
143
  /**
153
  echo '<optgroup label="Custom">';
154
 
155
  foreach ( $fonts as $font => $links ) {
156
+ echo '<option value="' . esc_attr( $font ) . '" ' . selected( $font, $value, false ) . '>' . esc_attr( $font ) . '</option>';
157
  }
158
  }
159
 
162
  *
163
  * @since 1.0.0
164
  */
165
+ public function enqueue_admin_scripts() {
166
 
167
  wp_enqueue_style( 'bsf-custom-fonts-css', BSF_CUSTOM_FONTS_URI . 'assets/css/bsf-custom-fonts.css', array(), BSF_CUSTOM_FONTS_VER );
168
  wp_enqueue_media();
178
  */
179
  public function render_fonts( $load_fonts ) {
180
 
181
+ $fonts = Bsf_Custom_Fonts_Taxonomy::get_fonts();
182
 
183
  foreach ( $load_fonts as $load_font_name => $load_font ) {
184
+ if ( array_key_exists( $load_font_name, $fonts ) ) {
 
185
  unset( $load_fonts[ $load_font_name ] );
186
  }
187
  }
 
 
188
  return $load_fonts;
189
  }
190
 
200
  foreach ( $fonts as $font => $links ) :
201
  $css = '@font-face { font-family:' . esc_attr( $font ) . ';';
202
  $css .= 'src:';
203
+ $arr = array();
204
  if ( $links['font_woff_2'] ) {
205
  $arr[] = 'url(' . esc_url( $links['font_woff_2'] ) . ") format('woff2')";
206
  }
214
  $arr[] = 'url(' . esc_url( $links['font_svg'] ) . '#' . esc_attr( strtolower( str_replace( ' ', '_', $font ) ) ) . ") format('svg')";
215
  }
216
  $css .= join( ', ', $arr );
217
+ $css .= ';}';
218
+ endforeach;
219
 
220
  $this->font_css .= $css;
221
  }
classes/class-bsf-custom-fonts-white-label.php CHANGED
@@ -53,9 +53,9 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_White_Label' ) ) :
53
  */
54
  public function __construct() {
55
 
56
- add_filter( 'all_plugins' , array( $this, 'plugins_page' ) );
57
- add_filter( 'astra_addon_branding_options' , __CLASS__ . '::settings' );
58
- add_action( 'astra_pro_white_label_add_form' , __CLASS__ . '::add_white_lavel_form' );
59
 
60
  add_filter( 'bsf_custom_fonts_menu_title', array( $this, 'white_label_custom_fonts_title' ) );
61
  if ( is_admin() ) {
@@ -118,7 +118,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_White_Label' ) ) :
118
  function white_label_custom_fonts_title( $title ) {
119
 
120
  if ( is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
121
- $name = Astra_Ext_White_Label_Markup::get_white_label( 'bsf-custom-fonts', 'name' );
122
  if ( ! empty( $name ) ) {
123
  $title = $name;
124
  }
@@ -164,8 +164,8 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_White_Label' ) ) :
164
  public static function settings( $settings = array() ) {
165
 
166
  $settings['bsf-custom-fonts'] = array(
167
- 'name' => '',
168
- 'description' => '',
169
  );
170
 
171
  return $settings;
53
  */
54
  public function __construct() {
55
 
56
+ add_filter( 'all_plugins', array( $this, 'plugins_page' ) );
57
+ add_filter( 'astra_addon_branding_options', __CLASS__ . '::settings' );
58
+ add_action( 'astra_pro_white_label_add_form', __CLASS__ . '::add_white_lavel_form' );
59
 
60
  add_filter( 'bsf_custom_fonts_menu_title', array( $this, 'white_label_custom_fonts_title' ) );
61
  if ( is_admin() ) {
118
  function white_label_custom_fonts_title( $title ) {
119
 
120
  if ( is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
121
+ $name = Astra_Ext_White_Label_Markup::get_white_label( 'bsf-custom-fonts', 'name' );
122
  if ( ! empty( $name ) ) {
123
  $title = $name;
124
  }
164
  public static function settings( $settings = array() ) {
165
 
166
  $settings['bsf-custom-fonts'] = array(
167
+ 'name' => '',
168
+ 'description' => '',
169
  );
170
 
171
  return $settings;
custom-fonts.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Brainstorm Force
7
  * Author URI: http://www.brainstormforce.com
8
  * Text Domain: custom-fonts
9
- * Version: 1.0.3
10
  *
11
  * @package Bsf_Custom_Fonts
12
  */
@@ -25,7 +25,7 @@ define( 'BSF_CUSTOM_FONTS_FILE', __FILE__ );
25
  define( 'BSF_CUSTOM_FONTS_BASE', plugin_basename( BSF_CUSTOM_FONTS_FILE ) );
26
  define( 'BSF_CUSTOM_FONTS_DIR', plugin_dir_path( BSF_CUSTOM_FONTS_FILE ) );
27
  define( 'BSF_CUSTOM_FONTS_URI', plugins_url( '/', BSF_CUSTOM_FONTS_FILE ) );
28
- define( 'BSF_CUSTOM_FONTS_VER', '1.0.3' );
29
 
30
  /**
31
  * BSF Custom Fonts
6
  * Author: Brainstorm Force
7
  * Author URI: http://www.brainstormforce.com
8
  * Text Domain: custom-fonts
9
+ * Version: 1.0.4
10
  *
11
  * @package Bsf_Custom_Fonts
12
  */
25
  define( 'BSF_CUSTOM_FONTS_BASE', plugin_basename( BSF_CUSTOM_FONTS_FILE ) );
26
  define( 'BSF_CUSTOM_FONTS_DIR', plugin_dir_path( BSF_CUSTOM_FONTS_FILE ) );
27
  define( 'BSF_CUSTOM_FONTS_URI', plugins_url( '/', BSF_CUSTOM_FONTS_FILE ) );
28
+ define( 'BSF_CUSTOM_FONTS_VER', '1.0.4' );
29
 
30
  /**
31
  * BSF Custom Fonts
includes/class-bsf-custom-fonts-admin.php CHANGED
@@ -121,8 +121,8 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
121
  if ( 'edit-tags' == $screen->base ) {
122
 
123
  $old_columns = $columns;
124
- $columns = array(
125
- 'cb' => $old_columns['cb'],
126
  'name' => $old_columns['name'],
127
  );
128
 
121
  if ( 'edit-tags' == $screen->base ) {
122
 
123
  $old_columns = $columns;
124
+ $columns = array(
125
+ 'cb' => $old_columns['cb'],
126
  'name' => $old_columns['name'],
127
  );
128
 
includes/class-bsf-custom-fonts-taxonomy.php CHANGED
@@ -78,29 +78,29 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
78
  public function create_custom_fonts_taxonomies() {
79
  // Taxonomy: bsf_custom_fonts.
80
  $labels = array(
81
- 'name' => __( 'Custom Fonts', 'custom-fonts' ),
82
- 'singular_name' => __( 'Font', 'custom-fonts' ),
83
- 'menu_name' => _x( 'Custom Fonts', 'Admin menu name', 'custom-fonts' ),
84
- 'search_items' => __( 'Search Fonts', 'custom-fonts' ),
85
- 'all_items' => __( 'All Fonts', 'custom-fonts' ),
86
- 'parent_item' => __( 'Parent Font', 'custom-fonts' ),
87
  'parent_item_colon' => __( 'Parent Font:', 'custom-fonts' ),
88
- 'edit_item' => __( 'Edit Font', 'custom-fonts' ),
89
- 'update_item' => __( 'Update Font', 'custom-fonts' ),
90
- 'add_new_item' => __( 'Add New Font', 'custom-fonts' ),
91
- 'new_item_name' => __( 'New Font Name', 'custom-fonts' ),
92
- 'not_found' => __( 'No fonts found', 'custom-fonts' ),
93
  );
94
 
95
  $args = array(
96
- 'hierarchical' => false,
97
- 'labels' => $labels,
98
- 'public' => false,
99
  'show_in_nav_menus' => false,
100
- 'show_ui' => true,
101
- 'capabilities' => array( self::$capability ),
102
- 'query_var' => false,
103
- 'rewrite' => false,
104
  );
105
 
106
  register_taxonomy(
@@ -121,10 +121,10 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
121
  $fonts,
122
  array(
123
  'font_woff_2' => '',
124
- 'font_woff' => '',
125
- 'font_ttf' => '',
126
- 'font_svg' => '',
127
- 'font_eot' => '',
128
  )
129
  );
130
  }
@@ -165,7 +165,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
165
  */
166
  public static function get_links_by_name( $name ) {
167
 
168
- $terms = get_terms(
169
  self::$register_taxonomy_slug,
170
  array(
171
  'hide_empty' => false,
78
  public function create_custom_fonts_taxonomies() {
79
  // Taxonomy: bsf_custom_fonts.
80
  $labels = array(
81
+ 'name' => __( 'Custom Fonts', 'custom-fonts' ),
82
+ 'singular_name' => __( 'Font', 'custom-fonts' ),
83
+ 'menu_name' => _x( 'Custom Fonts', 'Admin menu name', 'custom-fonts' ),
84
+ 'search_items' => __( 'Search Fonts', 'custom-fonts' ),
85
+ 'all_items' => __( 'All Fonts', 'custom-fonts' ),
86
+ 'parent_item' => __( 'Parent Font', 'custom-fonts' ),
87
  'parent_item_colon' => __( 'Parent Font:', 'custom-fonts' ),
88
+ 'edit_item' => __( 'Edit Font', 'custom-fonts' ),
89
+ 'update_item' => __( 'Update Font', 'custom-fonts' ),
90
+ 'add_new_item' => __( 'Add New Font', 'custom-fonts' ),
91
+ 'new_item_name' => __( 'New Font Name', 'custom-fonts' ),
92
+ 'not_found' => __( 'No fonts found', 'custom-fonts' ),
93
  );
94
 
95
  $args = array(
96
+ 'hierarchical' => false,
97
+ 'labels' => $labels,
98
+ 'public' => false,
99
  'show_in_nav_menus' => false,
100
+ 'show_ui' => true,
101
+ 'capabilities' => array( self::$capability ),
102
+ 'query_var' => false,
103
+ 'rewrite' => false,
104
  );
105
 
106
  register_taxonomy(
121
  $fonts,
122
  array(
123
  'font_woff_2' => '',
124
+ 'font_woff' => '',
125
+ 'font_ttf' => '',
126
+ 'font_svg' => '',
127
+ 'font_eot' => '',
128
  )
129
  );
130
  }
165
  */
166
  public static function get_links_by_name( $name ) {
167
 
168
+ $terms = get_terms(
169
  self::$register_taxonomy_slug,
170
  array(
171
  'hide_empty' => false,
includes/white-label.php CHANGED
@@ -12,11 +12,11 @@
12
  <span class="screen-reader-text"><?php _e( 'Custom Fonts Branding', 'custom-fonts' ); ?></span>
13
  <span class="toggle-indicator" aria-hidden="true"></span>
14
  </button>
15
-
16
  <h2 class="hndle ui-sortable-handle">
17
  <span><?php _e( 'Custom Fonts Branding', 'custom-fonts' ); ?></span>
18
  </h2>
19
-
20
  <div class="inside">
21
  <div class="form-wrap">
22
  <div class="form-field">
12
  <span class="screen-reader-text"><?php _e( 'Custom Fonts Branding', 'custom-fonts' ); ?></span>
13
  <span class="toggle-indicator" aria-hidden="true"></span>
14
  </button>
15
+
16
  <h2 class="hndle ui-sortable-handle">
17
  <span><?php _e( 'Custom Fonts Branding', 'custom-fonts' ); ?></span>
18
  </h2>
19
+
20
  <div class="inside">
21
  <div class="form-wrap">
22
  <div class="form-field">
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Custom Fonts ===
2
  Contributors: brainstormforce
3
  Donate link: https://wpastra.com/
4
- Tags: custom fonts, theme custom fonts, unlimited custom fonts, typography
5
  Requires at least: 4.4
6
- Tested up to: 4.8.1
7
- Stable tag: 1.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,20 +12,22 @@ Custom Fonts allows you to add more fonts that extend formatting options in your
12
 
13
  == Description ==
14
 
15
- Custom Fonts allows you to add more fonts that extend formatting options in your site.
 
 
16
 
17
- Upload your desired fonts and start using it without knowing any CSS.
 
 
 
18
 
19
- The font’s file types you can add:
20
- * woff2
21
- * woff
22
- * ttf
23
- * svg
24
- * eot
25
 
26
- You can directly select the font from the customizer under typography section.
 
 
27
 
28
- This plugin is compatible with the [Astra](https://wpastra.com/) theme only.
29
 
30
  == Installation ==
31
 
@@ -36,10 +38,14 @@ This plugin is compatible with the [Astra](https://wpastra.com/) theme only.
36
  == Screenshots ==
37
 
38
  1. Add new custom font
39
- 2. Select your any custom font into the Customizer
 
40
 
41
  == Changelog ==
42
 
 
 
 
43
  v1.0.3
44
  * Fix: When two custom fonts are loaded on a site, only one of the fonts will be actually enqueued.
45
 
1
  === Custom Fonts ===
2
  Contributors: brainstormforce
3
  Donate link: https://wpastra.com/
4
+ Tags: Beaver Builder, Elementor, Astra, woff2, woff, ttf, svg, eot, Custom Fonts, Font, Typography
5
  Requires at least: 4.4
6
+ Tested up to: 4.9.4
7
+ Stable tag: 1.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ This plugin helps you easily embed custom fonts files (woff2, woff, ttf, svg, eot) easily in your WordPress website.
16
+
17
+ Currently, it works with:
18
 
19
+ * <a href="https://wpastra.com/?utm_source=wp-repo&utm_campaign=custom-fonts&utm_medium=description">Astra Theme</a>
20
+ * <a href="https://www.wpbeaverbuilder.com/?fla=713">Beaver Builder Theme</a>
21
+ * <a href="https://www.wpbeaverbuilder.com/?fla=713">Beaver Builder Plugin</a>
22
+ * <a href="https://elementor.com/?ref=1352">Elementor Page Builder</a>
23
 
24
+ How does it work?
 
 
 
 
 
25
 
26
+ 1. Install the plugin
27
+ 2. Upload the font files in as many formats as possible for best browser compatibility.
28
+ 3. And done. You will be able to see the fonts added in the settings of Astra / Beaver Builder / Elementor. Please refer screenshots.
29
 
30
+ If you're not using any of the supported plugins and theme, you can write the custom CSS to apply the fonts.
31
 
32
  == Installation ==
33
 
38
  == Screenshots ==
39
 
40
  1. Add new custom font
41
+ 2. Select your any custom font into the Customizer of Astra Theme
42
+
43
 
44
  == Changelog ==
45
 
46
+ v1.0.4
47
+ * New: Added compatibility with Beaver Builder Theme, Beaver Builder Plugin and Elementor.
48
+
49
  v1.0.3
50
  * Fix: When two custom fonts are loaded on a site, only one of the fonts will be actually enqueued.
51