Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Custom Fonts |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- assets/css/bsf-custom-fonts.css +7 -4
- classes/class-bsf-custom-fonts-render.php +26 -26
- classes/class-bsf-custom-fonts.php +1 -1
- custom-fonts.php +3 -3
- includes/class-bsf-custom-fonts-admin.php +51 -27
- includes/class-bsf-custom-fonts-taxonomy.php +49 -33
- languages/{bsf-custom-fonts.pot → custom-fonts.pot} +45 -27
- readme.txt +24 -4
assets/css/bsf-custom-fonts.css
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
-
.bsf-custom-fonts-
|
2 |
-
|
|
|
3 |
}
|
4 |
-
.bsf-custom-fonts-
|
5 |
-
|
|
|
|
|
6 |
}
|
1 |
+
.bsf-custom-fonts-file-wrap.form-field{
|
2 |
+
position: relative;
|
3 |
+
margin: 1.5em 0;
|
4 |
}
|
5 |
+
.bsf-custom-fonts-upload.button {
|
6 |
+
float: right;
|
7 |
+
margin-right: 5%;
|
8 |
+
margin-top: 2px;
|
9 |
}
|
classes/class-bsf-custom-fonts-render.php
CHANGED
@@ -52,20 +52,20 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
52 |
*/
|
53 |
public function __construct() {
|
54 |
|
55 |
-
add_action( 'admin_enqueue_scripts', array( $this
|
56 |
|
57 |
-
add_action( 'admin_notices', array( $this
|
58 |
|
59 |
-
// Enqueue the custom fonts
|
60 |
add_action( 'astra_render_fonts', array( $this, 'render_fonts' ) );
|
61 |
|
62 |
-
// Delete custom fonts action
|
63 |
-
add_action( 'delete_term', array($this
|
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 |
/**
|
@@ -80,9 +80,9 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
80 |
|
81 |
echo '<optgroup label="Custom">';
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
}
|
87 |
|
88 |
/**
|
@@ -90,7 +90,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();
|
@@ -129,20 +129,20 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
129 |
$fonts = Bsf_Custom_Fonts_Taxonomy::get_links_by_name( $font );
|
130 |
|
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[] =
|
137 |
}
|
138 |
if ( $links['font_woff'] ) {
|
139 |
-
$arr[] =
|
140 |
}
|
141 |
if ( $links['font_ttf'] ) {
|
142 |
-
$arr[] =
|
143 |
}
|
144 |
if ( $links['font_svg'] ) {
|
145 |
-
$arr[] =
|
146 |
}
|
147 |
$css .= join( ', ', $arr );
|
148 |
$css .= ';}' ;
|
@@ -155,10 +155,10 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
155 |
* Set default 'inherit' if custom font is selected in customizer if this is deleted.
|
156 |
*
|
157 |
* @since 1.0.0
|
158 |
-
* @param int
|
159 |
-
* @param int
|
160 |
* @param string $taxonomy Taxonomy slug.
|
161 |
-
* @param mixed
|
162 |
* @param object $object_ids objects ids.
|
163 |
*/
|
164 |
function delete_custom_fonts_fallback_astra( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) {
|
@@ -169,7 +169,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
169 |
foreach ( $options as $key => $value ) {
|
170 |
if ( $value == $deleted_term->name ) {
|
171 |
// set default inherit if custom font is deleted.
|
172 |
-
$options[$key] = 'inherit';
|
173 |
}
|
174 |
}
|
175 |
// update astra options.
|
@@ -183,17 +183,17 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
183 |
* @since 1.0.0
|
184 |
*/
|
185 |
function theme_update_notice() {
|
186 |
-
if ( defined('ASTRA_THEME_VERSION')) {
|
187 |
-
if ( version_compare( ASTRA_THEME_VERSION, '1.0.16', '<') ) {
|
188 |
?>
|
189 |
<div class="notice notice-error is-dismissible">
|
190 |
<p>
|
191 |
<?php
|
192 |
printf(
|
193 |
-
|
194 |
-
__( 'Custom Fonts Plugin requires minimum 1.0.16 version of the Astra Theme.', '
|
195 |
-
|
196 |
-
|
197 |
?>
|
198 |
</p>
|
199 |
</div>
|
@@ -208,7 +208,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Render' ) ) :
|
|
208 |
* @since 1.0.0
|
209 |
*/
|
210 |
function load_textdomain() {
|
211 |
-
load_plugin_textdomain( '
|
212 |
}
|
213 |
}
|
214 |
|
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 |
|
59 |
+
// Enqueue the custom fonts.
|
60 |
add_action( 'astra_render_fonts', array( $this, 'render_fonts' ) );
|
61 |
|
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 |
/**
|
80 |
|
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 |
|
88 |
/**
|
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();
|
129 |
$fonts = Bsf_Custom_Fonts_Taxonomy::get_links_by_name( $font );
|
130 |
|
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 |
}
|
138 |
if ( $links['font_woff'] ) {
|
139 |
+
$arr[] = 'url(' . esc_url( $links['font_woff'] ) . ") format('woff')";
|
140 |
}
|
141 |
if ( $links['font_ttf'] ) {
|
142 |
+
$arr[] = 'url(' . esc_url( $links['font_ttf'] ) . ") format('truetype')";
|
143 |
}
|
144 |
if ( $links['font_svg'] ) {
|
145 |
+
$arr[] = 'url(' . esc_url( $links['font_svg'] ) . '#' . esc_attr( strtolower( str_replace( ' ', '_', $font ) ) ) . ") format('svg')";
|
146 |
}
|
147 |
$css .= join( ', ', $arr );
|
148 |
$css .= ';}' ;
|
155 |
* Set default 'inherit' if custom font is selected in customizer if this is deleted.
|
156 |
*
|
157 |
* @since 1.0.0
|
158 |
+
* @param int $term Term ID.
|
159 |
+
* @param int $tt_id Term taxonomy ID.
|
160 |
* @param string $taxonomy Taxonomy slug.
|
161 |
+
* @param mixed $deleted_term deleted term.
|
162 |
* @param object $object_ids objects ids.
|
163 |
*/
|
164 |
function delete_custom_fonts_fallback_astra( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) {
|
169 |
foreach ( $options as $key => $value ) {
|
170 |
if ( $value == $deleted_term->name ) {
|
171 |
// set default inherit if custom font is deleted.
|
172 |
+
$options[ $key ] = 'inherit';
|
173 |
}
|
174 |
}
|
175 |
// update astra options.
|
183 |
* @since 1.0.0
|
184 |
*/
|
185 |
function theme_update_notice() {
|
186 |
+
if ( defined( 'ASTRA_THEME_VERSION' ) ) {
|
187 |
+
if ( version_compare( ASTRA_THEME_VERSION, '1.0.16', '<' ) ) {
|
188 |
?>
|
189 |
<div class="notice notice-error is-dismissible">
|
190 |
<p>
|
191 |
<?php
|
192 |
printf(
|
193 |
+
/* translators: 1: Astra theme from wordpress.org*/
|
194 |
+
__( 'Custom Fonts Plugin requires minimum 1.0.16 version of the Astra Theme.', 'custom-fonts' ),
|
195 |
+
esc_url( 'https://downloads.wordpress.org/theme/astra.zip' )
|
196 |
+
);
|
197 |
?>
|
198 |
</p>
|
199 |
</div>
|
208 |
* @since 1.0.0
|
209 |
*/
|
210 |
function load_textdomain() {
|
211 |
+
load_plugin_textdomain( 'custom-fonts' );
|
212 |
}
|
213 |
}
|
214 |
|
classes/class-bsf-custom-fonts.php
CHANGED
@@ -46,4 +46,4 @@ if ( ! class_exists( 'Bsf_Custom_Fonts' ) ) {
|
|
46 |
* Kicking this off by calling 'get_instance()' method
|
47 |
*/
|
48 |
Bsf_Custom_Fonts::get_instance();
|
49 |
-
}// End if().
|
46 |
* Kicking this off by calling 'get_instance()' method
|
47 |
*/
|
48 |
Bsf_Custom_Fonts::get_instance();
|
49 |
+
}// End if().
|
custom-fonts.php
CHANGED
@@ -5,8 +5,8 @@
|
|
5 |
* Description: Custom Fonts allows you to add more fonts that extend formatting options in your site.
|
6 |
* Author: Brainstorm Force
|
7 |
* Author URI: http://www.brainstormforce.com
|
8 |
-
* Text Domain:
|
9 |
-
* Version: 1.0.
|
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.
|
29 |
|
30 |
/**
|
31 |
* BSF Custom Fonts
|
5 |
* Description: Custom Fonts allows you to add more fonts that extend formatting options in your site.
|
6 |
* Author: Brainstorm Force
|
7 |
* Author URI: http://www.brainstormforce.com
|
8 |
+
* Text Domain: custom-fonts
|
9 |
+
* Version: 1.0.1
|
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.1' );
|
29 |
|
30 |
/**
|
31 |
* BSF Custom Fonts
|
includes/class-bsf-custom-fonts-admin.php
CHANGED
@@ -75,8 +75,8 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
|
|
75 |
public function register_custom_fonts_menu() {
|
76 |
add_submenu_page(
|
77 |
$this->parent_menu_slug,
|
78 |
-
__( '
|
79 |
-
__( '
|
80 |
Bsf_Custom_Fonts_Taxonomy::$capability,
|
81 |
'edit-tags.php?taxonomy=' . Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug
|
82 |
);
|
@@ -93,15 +93,16 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
|
|
93 |
if ( 'edit-tags.php?taxonomy=' . Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug === $submenu_file ) {
|
94 |
$parent_file = $this->parent_menu_slug;
|
95 |
}
|
96 |
-
if ( 'edit-' . Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug
|
97 |
return;
|
98 |
}
|
99 |
|
100 |
?><style>#addtag div.form-field.term-slug-wrap, #edittag tr.form-field.term-slug-wrap { display: none; }
|
101 |
#addtag div.form-field.term-description-wrap, #edittag tr.form-field.term-description-wrap { display: none; }</style><script>jQuery( document ).ready( function( $ ) {
|
102 |
var $wrapper = $( '#addtag, #edittag' );
|
103 |
-
$wrapper.find( 'tr.form-field.term-name-wrap p, div.form-field.term-name-wrap > p' ).text( '<?php esc_html_e( 'The name of the font as it appears in the
|
104 |
-
} );</script
|
|
|
105 |
}
|
106 |
|
107 |
/**
|
@@ -112,12 +113,18 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
|
|
112 |
* @return array $columns updated columns.
|
113 |
*/
|
114 |
public function manage_columns( $columns ) {
|
115 |
-
$old_columns = $columns;
|
116 |
-
$columns = array(
|
117 |
-
'cb' => $old_columns['cb'],
|
118 |
-
'name' => $old_columns['name'],
|
119 |
-
);
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
return $columns;
|
122 |
}
|
123 |
|
@@ -127,39 +134,45 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
|
|
127 |
* @since 1.0.0
|
128 |
*/
|
129 |
public function add_new_taxonomy_data() {
|
130 |
-
$this->font_file_new_field( 'font_woff_2', __( 'Font .woff2', '
|
131 |
-
$this->font_file_new_field( 'font_woff', __( 'Font .woff', '
|
132 |
-
$this->font_file_new_field( 'font_ttf', __( 'Font .ttf', '
|
133 |
-
$this->font_file_new_field( 'font_eot', __( 'Font .eot', '
|
134 |
-
$this->font_file_new_field( 'font_svg', __( 'Font .svg', '
|
135 |
}
|
136 |
|
137 |
/**
|
138 |
* Edit Taxonomy data
|
139 |
*
|
140 |
* @since 1.0.0
|
|
|
141 |
*/
|
142 |
public function edit_taxonomy_data( $term ) {
|
143 |
$data = Bsf_Custom_Fonts_Taxonomy::get_font_links( $term->term_id );
|
144 |
-
$this->font_file_edit_field( 'font_woff_2', __( 'Font .woff2', '
|
145 |
-
$this->font_file_edit_field( 'font_woff', __( 'Font .woff', '
|
146 |
-
$this->font_file_edit_field( 'font_ttf', __( 'Font .ttf', '
|
147 |
-
$this->font_file_edit_field( 'font_eot', __( 'Font .eot', '
|
148 |
-
$this->font_file_edit_field( 'font_svg', __( 'Font .svg', '
|
149 |
}
|
150 |
|
151 |
/**
|
152 |
* Add Taxonomy data field
|
153 |
*
|
154 |
* @since 1.0.0
|
|
|
|
|
|
|
|
|
155 |
*/
|
156 |
-
protected function font_file_new_field( $id, $title, $value = '' ) {
|
157 |
?>
|
158 |
<div class="bsf-custom-fonts-file-wrap form-field term-<?php echo esc_attr( $id ); ?>-wrap" >
|
159 |
|
160 |
-
<label><?php echo esc_html( $title ); ?></label>
|
161 |
-
<
|
162 |
-
<
|
|
|
163 |
</div>
|
164 |
<?php
|
165 |
}
|
@@ -168,8 +181,12 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
|
|
168 |
* Add Taxonomy data field
|
169 |
*
|
170 |
* @since 1.0.0
|
|
|
|
|
|
|
|
|
171 |
*/
|
172 |
-
protected function font_file_edit_field( $id, $title, $value = '' ) {
|
173 |
?>
|
174 |
<tr class="bsf-custom-fonts-file-wrap form-field term-<?php echo esc_attr( $id ); ?>-wrap ">
|
175 |
<th scope="row">
|
@@ -178,13 +195,20 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Admin' ) ) :
|
|
178 |
</label>
|
179 |
</th>
|
180 |
<td>
|
181 |
-
<
|
182 |
-
<
|
|
|
183 |
</td>
|
184 |
</tr>
|
185 |
<?php
|
186 |
}
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
public function save_metadata( $term_id ) {
|
189 |
|
190 |
if ( isset( $_POST[ Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug ] ) ) {
|
75 |
public function register_custom_fonts_menu() {
|
76 |
add_submenu_page(
|
77 |
$this->parent_menu_slug,
|
78 |
+
__( 'Custom Fonts', 'custom-fonts' ),
|
79 |
+
__( 'Custom Fonts', 'custom-fonts' ),
|
80 |
Bsf_Custom_Fonts_Taxonomy::$capability,
|
81 |
'edit-tags.php?taxonomy=' . Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug
|
82 |
);
|
93 |
if ( 'edit-tags.php?taxonomy=' . Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug === $submenu_file ) {
|
94 |
$parent_file = $this->parent_menu_slug;
|
95 |
}
|
96 |
+
if ( get_current_screen()->id != 'edit-' . Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug ) {
|
97 |
return;
|
98 |
}
|
99 |
|
100 |
?><style>#addtag div.form-field.term-slug-wrap, #edittag tr.form-field.term-slug-wrap { display: none; }
|
101 |
#addtag div.form-field.term-description-wrap, #edittag tr.form-field.term-description-wrap { display: none; }</style><script>jQuery( document ).ready( function( $ ) {
|
102 |
var $wrapper = $( '#addtag, #edittag' );
|
103 |
+
$wrapper.find( 'tr.form-field.term-name-wrap p, div.form-field.term-name-wrap > p' ).text( '<?php esc_html_e( 'The name of the font as it appears in the customizer options.', 'custom-fonts' ); ?>' );
|
104 |
+
} );</script>
|
105 |
+
<?php
|
106 |
}
|
107 |
|
108 |
/**
|
113 |
* @return array $columns updated columns.
|
114 |
*/
|
115 |
public function manage_columns( $columns ) {
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
+
$screen = get_current_screen();
|
118 |
+
// If current screen is add new custom fonts screen.
|
119 |
+
if ( 'edit-tags' == $screen->base ) {
|
120 |
+
|
121 |
+
$old_columns = $columns;
|
122 |
+
$columns = array(
|
123 |
+
'cb' => $old_columns['cb'],
|
124 |
+
'name' => $old_columns['name'],
|
125 |
+
);
|
126 |
+
|
127 |
+
}
|
128 |
return $columns;
|
129 |
}
|
130 |
|
134 |
* @since 1.0.0
|
135 |
*/
|
136 |
public function add_new_taxonomy_data() {
|
137 |
+
$this->font_file_new_field( 'font_woff_2', __( 'Font .woff2', 'custom-fonts' ), __( 'Upload the font\'s woff2 file or enter the URL.', 'custom-fonts' ) );
|
138 |
+
$this->font_file_new_field( 'font_woff', __( 'Font .woff', 'custom-fonts' ), __( 'Upload the font\'s woff file or enter the URL.', 'custom-fonts' ) );
|
139 |
+
$this->font_file_new_field( 'font_ttf', __( 'Font .ttf', 'custom-fonts' ), __( 'Upload the font\'s ttf file or enter the URL.', 'custom-fonts' ) );
|
140 |
+
$this->font_file_new_field( 'font_eot', __( 'Font .eot', 'custom-fonts' ), __( 'Upload the font\'s eot file or enter the URL.', 'custom-fonts' ) );
|
141 |
+
$this->font_file_new_field( 'font_svg', __( 'Font .svg', 'custom-fonts' ), __( 'Upload the font\'s svg file or enter the URL.', 'custom-fonts' ) );
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* Edit Taxonomy data
|
146 |
*
|
147 |
* @since 1.0.0
|
148 |
+
* @param object $term taxonomy terms.
|
149 |
*/
|
150 |
public function edit_taxonomy_data( $term ) {
|
151 |
$data = Bsf_Custom_Fonts_Taxonomy::get_font_links( $term->term_id );
|
152 |
+
$this->font_file_edit_field( 'font_woff_2', __( 'Font .woff2', 'custom-fonts' ), $data['font_woff_2'], __( 'Upload the font\'s woff2 file or enter the URL.', 'custom-fonts' ) );
|
153 |
+
$this->font_file_edit_field( 'font_woff', __( 'Font .woff', 'custom-fonts' ), $data['font_woff'], __( 'Upload the font\'s woff file or enter the URL.', 'custom-fonts' ) );
|
154 |
+
$this->font_file_edit_field( 'font_ttf', __( 'Font .ttf', 'custom-fonts' ), $data['font_ttf'], __( 'Upload the font\'s ttf file or enter the URL.', 'custom-fonts' ) );
|
155 |
+
$this->font_file_edit_field( 'font_eot', __( 'Font .eot', 'custom-fonts' ), $data['font_eot'], __( 'Upload the font\'s eot file or enter the URL.', 'custom-fonts' ) );
|
156 |
+
$this->font_file_edit_field( 'font_svg', __( 'Font .svg', 'custom-fonts' ), $data['font_svg'], __( 'Upload the font\'s svg file or enter the URL.', 'custom-fonts' ) );
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
* Add Taxonomy data field
|
161 |
*
|
162 |
* @since 1.0.0
|
163 |
+
* @param int $id current term id.
|
164 |
+
* @param string $title font type title.
|
165 |
+
* @param string $description title font type description.
|
166 |
+
* @param string $value title font type meta values.
|
167 |
*/
|
168 |
+
protected function font_file_new_field( $id, $title, $description, $value = '' ) {
|
169 |
?>
|
170 |
<div class="bsf-custom-fonts-file-wrap form-field term-<?php echo esc_attr( $id ); ?>-wrap" >
|
171 |
|
172 |
+
<label for="font-<?php echo esc_attr( $id ); ?>"><?php echo esc_html( $title ); ?></label>
|
173 |
+
<input type="text" id="font-<?php echo esc_attr( $id ); ?>" class="bsf-custom-fonts-link <?php echo esc_attr( $id ); ?>" name="<?php echo Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug; ?>[<?php echo esc_attr( $id ); ?>]" value="<?php echo esc_attr( $value ); ?>" />
|
174 |
+
<a href="#" class="bsf-custom-fonts-upload button" data-upload-type="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Upload', 'custom-fonts' ); ?></a>
|
175 |
+
<p><?php echo esc_html( $description ); ?></p>
|
176 |
</div>
|
177 |
<?php
|
178 |
}
|
181 |
* Add Taxonomy data field
|
182 |
*
|
183 |
* @since 1.0.0
|
184 |
+
* @param int $id current term id.
|
185 |
+
* @param string $title font type title.
|
186 |
+
* @param string $value title font type meta values.
|
187 |
+
* @param string $description title font type description.
|
188 |
*/
|
189 |
+
protected function font_file_edit_field( $id, $title, $value = '', $description ) {
|
190 |
?>
|
191 |
<tr class="bsf-custom-fonts-file-wrap form-field term-<?php echo esc_attr( $id ); ?>-wrap ">
|
192 |
<th scope="row">
|
195 |
</label>
|
196 |
</th>
|
197 |
<td>
|
198 |
+
<input id="metadata-<?php echo esc_attr( $id ); ?>" type="text" class="bsf-custom-fonts-link <?php echo esc_attr( $id ); ?>" name="<?php echo Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug; ?>[<?php echo esc_attr( $id ); ?>]" value="<?php echo esc_attr( $value ); ?>" />
|
199 |
+
<a href="#" class="bsf-custom-fonts-upload button" data-upload-type="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Upload', 'custom-fonts' ); ?></a>
|
200 |
+
<p><?php echo esc_html( $description ); ?></p>
|
201 |
</td>
|
202 |
</tr>
|
203 |
<?php
|
204 |
}
|
205 |
|
206 |
+
/**
|
207 |
+
* Save Taxonomy meta data value
|
208 |
+
*
|
209 |
+
* @since 1.0.0
|
210 |
+
* @param int $term_id current term id.
|
211 |
+
*/
|
212 |
public function save_metadata( $term_id ) {
|
213 |
|
214 |
if ( isset( $_POST[ Bsf_Custom_Fonts_Taxonomy::$register_taxonomy_slug ] ) ) {
|
includes/class-bsf-custom-fonts-taxonomy.php
CHANGED
@@ -78,17 +78,18 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
|
|
78 |
public function create_custom_fonts_taxonomies() {
|
79 |
// Taxonomy: bsf_custom_fonts.
|
80 |
$labels = array(
|
81 |
-
'name' => __( '
|
82 |
-
'singular_name' => __( 'Font', '
|
83 |
-
'menu_name' => _x( '
|
84 |
-
'search_items' => __( 'Search Fonts', '
|
85 |
-
'all_items' => __( 'All Fonts', '
|
86 |
-
'parent_item' => __( 'Parent Font', '
|
87 |
-
'parent_item_colon' => __( 'Parent Font:', '
|
88 |
-
'edit_item' => __( 'Edit Font', '
|
89 |
-
'update_item' => __( 'Update Font', '
|
90 |
-
'add_new_item' => __( 'Add New Font', '
|
91 |
-
'new_item_name' => __( 'New Font Name', '
|
|
|
92 |
);
|
93 |
|
94 |
$args = array(
|
@@ -113,13 +114,13 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
|
|
113 |
* Default fonts
|
114 |
*
|
115 |
* @since 1.0.0
|
116 |
-
* @param array fonts array of fonts.
|
117 |
*/
|
118 |
protected static function default_args( $fonts ) {
|
119 |
return wp_parse_args(
|
120 |
$fonts,
|
121 |
array(
|
122 |
-
'font_woff_2'=> '',
|
123 |
'font_woff' => '',
|
124 |
'font_ttf' => '',
|
125 |
'font_svg' => '',
|
@@ -132,7 +133,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
|
|
132 |
* Get fonts
|
133 |
*
|
134 |
* @since 1.0.0
|
135 |
-
* @return array fonts array of fonts.
|
136 |
*/
|
137 |
public static function get_fonts() {
|
138 |
|
@@ -155,39 +156,54 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
|
|
155 |
return self::$fonts;
|
156 |
}
|
157 |
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
$terms = get_terms(
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
$font_links = array();
|
168 |
if ( ! empty( $terms ) ) {
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
}
|
174 |
}
|
175 |
}
|
176 |
-
|
177 |
-
return $font_links;
|
178 |
|
179 |
-
|
180 |
|
181 |
-
public static function has_fonts() {
|
182 |
-
$fonts = self::get_fonts();
|
183 |
-
return ! empty( $fonts );
|
184 |
}
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
public static function get_font_links( $term_id ) {
|
187 |
-
$links = get_option(
|
188 |
return self::default_args( $links );
|
189 |
}
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
public static function update_font_links( $posted, $term_id ) {
|
192 |
|
193 |
$links = self::get_font_links( $term_id );
|
@@ -198,7 +214,7 @@ if ( ! class_exists( 'Bsf_Custom_Fonts_Taxonomy' ) ) :
|
|
198 |
$links[ $key ] = '';
|
199 |
}
|
200 |
}
|
201 |
-
update_option(
|
202 |
}
|
203 |
|
204 |
}
|
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(
|
114 |
* Default fonts
|
115 |
*
|
116 |
* @since 1.0.0
|
117 |
+
* @param array $fonts fonts array of fonts.
|
118 |
*/
|
119 |
protected static function default_args( $fonts ) {
|
120 |
return wp_parse_args(
|
121 |
$fonts,
|
122 |
array(
|
123 |
+
'font_woff_2' => '',
|
124 |
'font_woff' => '',
|
125 |
'font_ttf' => '',
|
126 |
'font_svg' => '',
|
133 |
* Get fonts
|
134 |
*
|
135 |
* @since 1.0.0
|
136 |
+
* @return array $fonts fonts array of fonts.
|
137 |
*/
|
138 |
public static function get_fonts() {
|
139 |
|
156 |
return self::$fonts;
|
157 |
}
|
158 |
|
159 |
+
/**
|
160 |
+
* Get font data from name
|
161 |
+
*
|
162 |
+
* @since 1.0.0
|
163 |
+
* @param string $name custom font name.
|
164 |
+
* @return array $font_links custom font data.
|
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,
|
172 |
+
)
|
173 |
+
);
|
174 |
$font_links = array();
|
175 |
if ( ! empty( $terms ) ) {
|
176 |
|
177 |
+
foreach ( $terms as $term ) {
|
178 |
+
if ( $term->name == $name ) {
|
179 |
+
$font_links[ $term->name ] = self::get_font_links( $term->term_id );
|
|
|
180 |
}
|
181 |
}
|
182 |
+
}
|
|
|
183 |
|
184 |
+
return $font_links;
|
185 |
|
|
|
|
|
|
|
186 |
}
|
187 |
|
188 |
+
/**
|
189 |
+
* Get font links
|
190 |
+
*
|
191 |
+
* @since 1.0.0
|
192 |
+
* @param int $term_id custom font term id.
|
193 |
+
* @return array $links custom font data links.
|
194 |
+
*/
|
195 |
public static function get_font_links( $term_id ) {
|
196 |
+
$links = get_option( 'taxonomy_' . self::$register_taxonomy_slug . "_{$term_id}", array() );
|
197 |
return self::default_args( $links );
|
198 |
}
|
199 |
|
200 |
+
/**
|
201 |
+
* Update font data from name
|
202 |
+
*
|
203 |
+
* @since 1.0.0
|
204 |
+
* @param array $posted custom font data.
|
205 |
+
* @param int $term_id custom font term id.
|
206 |
+
*/
|
207 |
public static function update_font_links( $posted, $term_id ) {
|
208 |
|
209 |
$links = self::get_font_links( $term_id );
|
214 |
$links[ $key ] = '';
|
215 |
}
|
216 |
}
|
217 |
+
update_option( 'taxonomy_' . self::$register_taxonomy_slug . "_{$term_id}", $links );
|
218 |
}
|
219 |
|
220 |
}
|
languages/{bsf-custom-fonts.pot → custom-fonts.pot}
RENAMED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Custom Fonts package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Custom Fonts 1.0.
|
6 |
-
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/
|
7 |
-
"POT-Creation-Date: 2017-08-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -29,49 +29,67 @@ msgstr ""
|
|
29 |
msgid "Custom Fonts Plugin requires minimum 1.0.16 version of the Astra Theme."
|
30 |
msgstr ""
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
#: includes/class-bsf-custom-fonts-taxonomy.php:81
|
35 |
-
msgid "BSF Custom Fonts"
|
36 |
msgstr ""
|
37 |
|
38 |
#: includes/class-bsf-custom-fonts-admin.php:103
|
39 |
-
msgid "The name of the font as it appears in the
|
40 |
msgstr ""
|
41 |
|
42 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
43 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
44 |
msgid "Font .woff2"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
48 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
|
|
|
|
|
|
|
|
|
|
49 |
msgid "Font .woff"
|
50 |
msgstr ""
|
51 |
|
52 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
53 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
|
|
|
|
|
|
|
|
|
|
54 |
msgid "Font .ttf"
|
55 |
msgstr ""
|
56 |
|
57 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
58 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
|
|
|
|
|
|
|
|
|
|
59 |
msgid "Font .eot"
|
60 |
msgstr ""
|
61 |
|
62 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
63 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
|
|
|
|
|
|
|
|
|
|
64 |
msgid "Font .svg"
|
65 |
msgstr ""
|
66 |
|
67 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
68 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
69 |
-
msgid "Upload"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
73 |
-
#: includes/class-bsf-custom-fonts-admin.php:
|
74 |
-
msgid "Upload
|
75 |
msgstr ""
|
76 |
|
77 |
#: includes/class-bsf-custom-fonts-taxonomy.php:82
|
@@ -110,8 +128,8 @@ msgstr ""
|
|
110 |
msgid "New Font Name"
|
111 |
msgstr ""
|
112 |
|
113 |
-
|
114 |
-
msgid "
|
115 |
msgstr ""
|
116 |
|
117 |
#. Plugin URI of the plugin/theme
|
@@ -134,5 +152,5 @@ msgstr ""
|
|
134 |
|
135 |
#: includes/class-bsf-custom-fonts-taxonomy.php:83
|
136 |
msgctxt "Admin menu name"
|
137 |
-
msgid "
|
138 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Custom Fonts package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Custom Fonts 1.0.1\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/custom-fonts\n"
|
7 |
+
"POT-Creation-Date: 2017-08-16 08:50:20+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
29 |
msgid "Custom Fonts Plugin requires minimum 1.0.16 version of the Astra Theme."
|
30 |
msgstr ""
|
31 |
|
32 |
+
#. Plugin Name of the plugin/theme
|
33 |
+
msgid "Custom Fonts"
|
|
|
|
|
34 |
msgstr ""
|
35 |
|
36 |
#: includes/class-bsf-custom-fonts-admin.php:103
|
37 |
+
msgid "The name of the font as it appears in the customizer options."
|
38 |
msgstr ""
|
39 |
|
40 |
+
#: includes/class-bsf-custom-fonts-admin.php:137
|
41 |
+
#: includes/class-bsf-custom-fonts-admin.php:152
|
42 |
msgid "Font .woff2"
|
43 |
msgstr ""
|
44 |
|
45 |
+
#: includes/class-bsf-custom-fonts-admin.php:137
|
46 |
+
#: includes/class-bsf-custom-fonts-admin.php:152
|
47 |
+
msgid "Upload the font's woff2 file or enter the URL."
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: includes/class-bsf-custom-fonts-admin.php:138
|
51 |
+
#: includes/class-bsf-custom-fonts-admin.php:153
|
52 |
msgid "Font .woff"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: includes/class-bsf-custom-fonts-admin.php:138
|
56 |
+
#: includes/class-bsf-custom-fonts-admin.php:153
|
57 |
+
msgid "Upload the font's woff file or enter the URL."
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: includes/class-bsf-custom-fonts-admin.php:139
|
61 |
+
#: includes/class-bsf-custom-fonts-admin.php:154
|
62 |
msgid "Font .ttf"
|
63 |
msgstr ""
|
64 |
|
65 |
+
#: includes/class-bsf-custom-fonts-admin.php:139
|
66 |
+
#: includes/class-bsf-custom-fonts-admin.php:154
|
67 |
+
msgid "Upload the font's ttf file or enter the URL."
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: includes/class-bsf-custom-fonts-admin.php:140
|
71 |
+
#: includes/class-bsf-custom-fonts-admin.php:155
|
72 |
msgid "Font .eot"
|
73 |
msgstr ""
|
74 |
|
75 |
+
#: includes/class-bsf-custom-fonts-admin.php:140
|
76 |
+
#: includes/class-bsf-custom-fonts-admin.php:155
|
77 |
+
msgid "Upload the font's eot file or enter the URL."
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: includes/class-bsf-custom-fonts-admin.php:141
|
81 |
+
#: includes/class-bsf-custom-fonts-admin.php:156
|
82 |
msgid "Font .svg"
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: includes/class-bsf-custom-fonts-admin.php:141
|
86 |
+
#: includes/class-bsf-custom-fonts-admin.php:156
|
87 |
+
msgid "Upload the font's svg file or enter the URL."
|
88 |
msgstr ""
|
89 |
|
90 |
+
#: includes/class-bsf-custom-fonts-admin.php:174
|
91 |
+
#: includes/class-bsf-custom-fonts-admin.php:199
|
92 |
+
msgid "Upload"
|
93 |
msgstr ""
|
94 |
|
95 |
#: includes/class-bsf-custom-fonts-taxonomy.php:82
|
128 |
msgid "New Font Name"
|
129 |
msgstr ""
|
130 |
|
131 |
+
#: includes/class-bsf-custom-fonts-taxonomy.php:92
|
132 |
+
msgid "No fonts found"
|
133 |
msgstr ""
|
134 |
|
135 |
#. Plugin URI of the plugin/theme
|
152 |
|
153 |
#: includes/class-bsf-custom-fonts-taxonomy.php:83
|
154 |
msgctxt "Admin menu name"
|
155 |
+
msgid "Custom Fonts"
|
156 |
msgstr ""
|
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
|
5 |
Requires at least: 4.4
|
6 |
Tested up to: 4.8.1
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -16,13 +16,33 @@ Custom Fonts allows you to add more fonts that extend formatting options in your
|
|
16 |
|
17 |
Upload your desired fonts and start using it without knowing any CSS.
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
== Installation ==
|
20 |
|
21 |
1. Upload the plugin files to the `/wp-content/plugins/custom-fonts` directory, or install the plugin through the WordPress plugins screen directly.
|
22 |
2. Activate the plugin through the 'Plugins' screen in WordPress
|
23 |
-
3. Use the Appearance->
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
27 |
v1.0.0
|
28 |
-
|
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.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
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 |
|
32 |
1. Upload the plugin files to the `/wp-content/plugins/custom-fonts` directory, or install the plugin through the WordPress plugins screen directly.
|
33 |
2. Activate the plugin through the 'Plugins' screen in WordPress
|
34 |
+
3. Use the Appearance -> Custom Fonts -> Add Custom Fonts name, woff2, woff, ttf, eot and svg files.
|
35 |
+
|
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.1
|
44 |
+
1. Improved the design of the Admin UI.
|
45 |
+
2. Changed the plugin name to be Custom Fonts instead of BSF Custom Fonts.
|
46 |
+
|
47 |
v1.0.0
|
48 |
+
1. Initial release.
|