Use Any Font - Version 6.2

Version Description

  • Added multi variation font support.
Download this release

Release Info

Developer dnesscarkey
Plugin Icon 128x128 Use Any Font
Version 6.2
Comparing to
See all releases

Code changes from version 6.1.8 to 6.2

includes/assets/css/uaf_admin.css CHANGED
@@ -1,11 +1,12 @@
1
  #font_upload_message.ok{display: block; background:#060 url(../img/ajax-loader.gif) no-repeat 5px center; color:#fff; padding:5px 10px; border:none; margin:5px 0px;-webkit-border-radius: 3px;border-radius: 3px; padding-left:40px;}
2
  #font_upload_message.error{display: block;background:#900; color:#fff;padding:5px 10px; border:none;margin:5px 0px;-webkit-border-radius: 3px;border-radius: 3px;}
3
  span.active_key{font-weight:bold; color:#060; padding-right: 20px;}
4
- .font_holder{background: #fff;border-radius: 5px;border: 1px solid #dadce0;}
5
  .font_holder{ padding: 10px; margin: 0px 0px 10px 0px; }
 
6
  .font_holder .font_meta .font_name{font-weight: bold; float: left;}
7
  .font_holder .font_meta .font_name em{font-weight: normal;}
8
- .font_holder .font_meta .delete_link{ float: right; }
9
  .font_holder .font_meta .add_font_link{ float: right; }
10
  .font_holder .font_demo{ clear: both; padding-top: 10px; font-size: 25px !important; line-height: 30px !important; }
11
  .font_holder .fontclassname{text-align: right; float: right;}
@@ -22,7 +23,7 @@ span.active_key{font-weight:bold; color:#060; padding-right: 20px;}
22
  .dcform p label.error{ color: #900; padding-left: 5px; }
23
  .dcform p label .required{ color: #900; font-weight: bold; }
24
  .dcform p input.large, .dcform p textarea.large{ max-width: 500px; width: 100%;}
25
- .dcform p input.medium, .dcform p textarea.medium{ max-width: 300px; width: 100%;}
26
  .dcform p input.small{ max-width: 85px;}
27
  .dcinstructions{border:1px solid #ccd0d4;background: #fff;margin-top: 20px; }
28
  .dcinstructions .instruct-head{border-bottom:1px solid #ccd0d4; font-size: 14px; padding: 10px; font-weight: 600; cursor: pointer;}
@@ -49,12 +50,11 @@ span.active_key{font-weight:bold; color:#060; padding-right: 20px;}
49
  .dcwidget .dcwidgetbody{ background: #fff; border-radius: 0px 0px 5px 5px;padding:10px; margin-bottom: 20px;}
50
  span.field_error{ display: none; color: #900; }
51
  @media ( max-width: 768px) { .dchideMobile { display : none; } }
52
-
53
-
54
  .uaf_search_bar{ padding: 10px 10px 20px 10px; position: relative;width: 80%; max-width: 500px; margin: 10px auto 0px auto; }
55
  .uaf_search_bar input[type=search]{ display: block; width: 100%; padding: 3px;}
56
  .uaf_search_bar input[type=submit]{ display: inline-block; position: absolute;right: 12px;top: 13px;}
57
-
58
  body.rtl .uaf_search_bar input[type=submit]{left: 12px !important;right: auto !important;}
59
-
60
- #predefined_font_load_msg{ text-align: center;color:#04a2c7; }
 
 
1
  #font_upload_message.ok{display: block; background:#060 url(../img/ajax-loader.gif) no-repeat 5px center; color:#fff; padding:5px 10px; border:none; margin:5px 0px;-webkit-border-radius: 3px;border-radius: 3px; padding-left:40px;}
2
  #font_upload_message.error{display: block;background:#900; color:#fff;padding:5px 10px; border:none;margin:5px 0px;-webkit-border-radius: 3px;border-radius: 3px;}
3
  span.active_key{font-weight:bold; color:#060; padding-right: 20px;}
4
+ .font_holder{background: #fafafa;border-radius: 5px;border: 1px solid #e9e9e9;}
5
  .font_holder{ padding: 10px; margin: 0px 0px 10px 0px; }
6
+ .font_holder:nth-child(even){ background: #f1f1f1; }
7
  .font_holder .font_meta .font_name{font-weight: bold; float: left;}
8
  .font_holder .font_meta .font_name em{font-weight: normal;}
9
+ .font_holder .font_demo .delete_link{ float: right; font-size: 12px; font-weight: normal; }
10
  .font_holder .font_meta .add_font_link{ float: right; }
11
  .font_holder .font_demo{ clear: both; padding-top: 10px; font-size: 25px !important; line-height: 30px !important; }
12
  .font_holder .fontclassname{text-align: right; float: right;}
23
  .dcform p label.error{ color: #900; padding-left: 5px; }
24
  .dcform p label .required{ color: #900; font-weight: bold; }
25
  .dcform p input.large, .dcform p textarea.large{ max-width: 500px; width: 100%;}
26
+ .dcform p input.medium, .dcform p textarea.medium, .dcform p select.medium{ width: 200px; max-width: 100%;}
27
  .dcform p input.small{ max-width: 85px;}
28
  .dcinstructions{border:1px solid #ccd0d4;background: #fff;margin-top: 20px; }
29
  .dcinstructions .instruct-head{border-bottom:1px solid #ccd0d4; font-size: 14px; padding: 10px; font-weight: 600; cursor: pointer;}
50
  .dcwidget .dcwidgetbody{ background: #fff; border-radius: 0px 0px 5px 5px;padding:10px; margin-bottom: 20px;}
51
  span.field_error{ display: none; color: #900; }
52
  @media ( max-width: 768px) { .dchideMobile { display : none; } }
 
 
53
  .uaf_search_bar{ padding: 10px 10px 20px 10px; position: relative;width: 80%; max-width: 500px; margin: 10px auto 0px auto; }
54
  .uaf_search_bar input[type=search]{ display: block; width: 100%; padding: 3px;}
55
  .uaf_search_bar input[type=submit]{ display: inline-block; position: absolute;right: 12px;top: 13px;}
 
56
  body.rtl .uaf_search_bar input[type=submit]{left: 12px !important;right: auto !important;}
57
+ #predefined_font_load_msg{ text-align: center;color:#04a2c7; }
58
+ .font_holder .font_demo{ border-bottom: 1px dashed #d8d8d8; padding-bottom: 10px;}
59
+ .font_holder .font_demo:last-of-type{ border-bottom: none; }
60
+ .font_holder .font_demo .font-weight-style{ font-size: 12px; font-weight: normal; text-transform: capitalize;}
includes/assets/js/uaf_admin.js CHANGED
@@ -18,6 +18,10 @@ function open_add_font(){
18
  jQuery('#font-upload').toggle('fast');
19
  }
20
 
 
 
 
 
21
  function open_assign_font(){
22
  jQuery('#open_assign_font').toggle('fast');
23
  if (jQuery('#open_assign_font_button').val() == 'Assign Font'){
@@ -35,12 +39,12 @@ jQuery('document').ready(function(){
35
 
36
  breakValidation = false;
37
  jQuery('#open_add_font_form_js .uaf_required').each(function(){
38
- if(!jQuery(this).val()){
39
- jQuery(this).next('.field_error').show();
40
- breakValidation = true;
41
- return false;
42
- }
43
- });
44
 
45
  if(breakValidation){return false;}
46
 
18
  jQuery('#font-upload').toggle('fast');
19
  }
20
 
21
+ function multi_variation_holder_toggle(){
22
+ jQuery('.multi_variation_holder').slideToggle('medium');
23
+ }
24
+
25
  function open_assign_font(){
26
  jQuery('#open_assign_font').toggle('fast');
27
  if (jQuery('#open_assign_font_button').val() == 'Assign Font'){
39
 
40
  breakValidation = false;
41
  jQuery('#open_add_font_form_js .uaf_required').each(function(){
42
+ if(!jQuery(this).val()){
43
+ jQuery(this).next('.field_error').show();
44
+ breakValidation = true;
45
+ return false;
46
+ }
47
+ });
48
 
49
  if(breakValidation){return false;}
50
 
includes/functions/uaf_admin_functions.php CHANGED
@@ -172,12 +172,12 @@ function uaf_save_options(){
172
  'uaf_disbale_editor_font_list',
173
  'uaf_enable_multi_lang_support',
174
  'uaf_font_display_property'
175
- );
176
 
177
  foreach ($all_fields_name as $fieldname) {
178
  update_option($fieldname,sanitize_text_field($_POST[$fieldname]));
179
  }
180
-
181
  uaf_get_options();
182
  uaf_write_css();
183
  $return['status'] = 'ok';
@@ -202,14 +202,12 @@ function uaf_admin_notices(){
202
  if ($installedDays > 30 && $fonts_uploaded > 1){
203
  echo '<div class="updated success" style="padding:10px; font-size:16px; line-height:1.6;color:#205225;">
204
  Hey, You have been using Use Any Font for more than 30 days - that’s awesome! Could you please do us a BIG favor and give it a 5-star rating on WordPress ? Just to help us spread the word and boost our motivation.<br/>
205
-
206
  <ul style="padding-left:50px;list-style-type: square;">
207
  <li><a href="https://wordpress.org/support/plugin/use-any-font/reviews/?filter=5" target="_blank">Ok, you deserve it</a></li>
208
  <li><a href="https://dineshkarki.com.np/contact" target="_blank">I still have problem !!</a></li>
209
  <li><a href="?uaf_reviews_notice_hide=1">I already did</a></li>
210
  <li><a href="?uaf_reviews_notice_hide=1">Hide this message</a></li>
211
  </ul>
212
-
213
  </div>';
214
  }
215
  }
@@ -248,14 +246,24 @@ function uaf_trigger_actions(){
248
  }
249
 
250
  if (isset($_POST['submit-uaf-font-js'])){
251
- $actionReturn = uaf_save_font_files($_POST['font_name'], $_POST['convert_response']);
 
 
 
 
 
252
  }
253
 
254
  if (isset($_POST['submit-uaf-font-php'])){
255
  if ( isset($_POST['uaf_nonce']) && wp_verify_nonce($_POST['uaf_nonce'], 'uaf_font_upload_php')) {
256
  $actionReturn = uaf_upload_font_to_server();
257
  if ($actionReturn['status'] == 'success'){
258
- $actionReturn = uaf_save_font_files($_POST['font_name'], $actionReturn['body']);
 
 
 
 
 
259
  }
260
  } else {
261
  $actionReturn = $actionReturnNonceError;
172
  'uaf_disbale_editor_font_list',
173
  'uaf_enable_multi_lang_support',
174
  'uaf_font_display_property'
175
+ );
176
 
177
  foreach ($all_fields_name as $fieldname) {
178
  update_option($fieldname,sanitize_text_field($_POST[$fieldname]));
179
  }
180
+
181
  uaf_get_options();
182
  uaf_write_css();
183
  $return['status'] = 'ok';
202
  if ($installedDays > 30 && $fonts_uploaded > 1){
203
  echo '<div class="updated success" style="padding:10px; font-size:16px; line-height:1.6;color:#205225;">
204
  Hey, You have been using Use Any Font for more than 30 days - that’s awesome! Could you please do us a BIG favor and give it a 5-star rating on WordPress ? Just to help us spread the word and boost our motivation.<br/>
 
205
  <ul style="padding-left:50px;list-style-type: square;">
206
  <li><a href="https://wordpress.org/support/plugin/use-any-font/reviews/?filter=5" target="_blank">Ok, you deserve it</a></li>
207
  <li><a href="https://dineshkarki.com.np/contact" target="_blank">I still have problem !!</a></li>
208
  <li><a href="?uaf_reviews_notice_hide=1">I already did</a></li>
209
  <li><a href="?uaf_reviews_notice_hide=1">Hide this message</a></li>
210
  </ul>
 
211
  </div>';
212
  }
213
  }
246
  }
247
 
248
  if (isset($_POST['submit-uaf-font-js'])){
249
+ $font_weight = $font_style = '';
250
+ if (isset($_POST['enable_font_variation'])){
251
+ $font_weight = $_POST['font_weight'];
252
+ $font_style = $_POST['font_style'];
253
+ }
254
+ $actionReturn = uaf_save_font_files($_POST['font_name'], $font_weight, $font_style, $_POST['convert_response']);
255
  }
256
 
257
  if (isset($_POST['submit-uaf-font-php'])){
258
  if ( isset($_POST['uaf_nonce']) && wp_verify_nonce($_POST['uaf_nonce'], 'uaf_font_upload_php')) {
259
  $actionReturn = uaf_upload_font_to_server();
260
  if ($actionReturn['status'] == 'success'){
261
+ $font_weight = $font_style = '';
262
+ if (isset($_POST['enable_font_variation'])){
263
+ $font_weight = $_POST['font_weight'];
264
+ $font_style = $_POST['font_style'];
265
+ }
266
+ $actionReturn = uaf_save_font_files($_POST['font_name'], $font_weight, $font_style, $actionReturn['body']);
267
  }
268
  } else {
269
  $actionReturn = $actionReturnNonceError;
includes/functions/uaf_client_functions.php CHANGED
@@ -8,12 +8,11 @@ function uaf_client_assets() {
8
  wp_enqueue_style( 'uaf_client_css' );
9
  }
10
 
11
-
12
  if (!function_exists('array_key_first')) { // FOR OLDER VERSION PHP SUPPORT
13
  function array_key_first(array $arr) {
14
  foreach($arr as $key => $unused) {
15
- return $key;
16
- }
17
- return NULL;
18
- }
19
  }
8
  wp_enqueue_style( 'uaf_client_css' );
9
  }
10
 
 
11
  if (!function_exists('array_key_first')) { // FOR OLDER VERSION PHP SUPPORT
12
  function array_key_first(array $arr) {
13
  foreach($arr as $key => $unused) {
14
+ return $key;
15
+ }
16
+ return NULL;
17
+ }
18
  }
includes/functions/uaf_editor_functions.php CHANGED
@@ -9,10 +9,10 @@ endif;
9
 
10
  function uaf_mce_before_init( $init_array ) {
11
  $theme_advanced_fonts = '';
12
- $fontsData = uaf_get_uploaded_font_data();
13
  if (!empty($fontsData)):
14
- foreach ($fontsData as $key=>$fontData):
15
- $theme_advanced_fonts .= ucfirst(str_replace('_',' ', $fontData['font_name'])) .'='.$fontData['font_name'].';';
16
  endforeach;
17
  endif;
18
 
@@ -29,11 +29,11 @@ function wp_editor_fontsize_filter( $options ) {
29
  // DIVI CUSTOMIZER AND BUILDER (Tested with 4.0.9 and 4.0.9)
30
  add_filter('et_websafe_fonts', 'uaf_send_fonts_divi_list',10,2);
31
  function uaf_send_fonts_divi_list($fonts){
32
- $fontsData = uaf_get_uploaded_font_data();
33
  $fonts_uaf = array();
34
  if (!empty($fontsData)):
35
- foreach ($fontsData as $key=>$fontData):
36
- $fonts_uaf[$fontData['font_name']] = array(
37
  'styles' => '400',
38
  'character_set' => 'cyrillic,greek,latin',
39
  'type' => 'serif'
@@ -46,11 +46,11 @@ function uaf_send_fonts_divi_list($fonts){
46
  // SITE ORIGIN BUILDER
47
  add_filter('siteorigin_widgets_font_families', 'uaf_send_fonts_siteorigin_list',10,2);
48
  function uaf_send_fonts_siteorigin_list($fonts){
49
- $fontsData = uaf_get_uploaded_font_data();
50
  $fonts_uaf = array();
51
  if (!empty($fontsData)):
52
- foreach ($fontsData as $key=>$fontData):
53
- $fonts_uaf[$fontData['font_name']] = $fontData['font_name'];
54
  endforeach;
55
  endif;
56
  return array_merge($fonts_uaf,$fonts);
@@ -65,11 +65,11 @@ if (class_exists( 'Redux' ) ) {
65
  }
66
 
67
  function uaf_send_fonts_redux_list( $custom_fonts ) {
68
- $fontsData = uaf_get_uploaded_font_data();
69
  $fonts_uaf = array('Use Any Fonts' => array());
70
  if (!empty($fontsData)):
71
- foreach ($fontsData as $key=>$fontData):
72
- $fonts_uaf['Use Any Fonts'][$fontData['font_name']] = $fontData['font_name'];
73
  endforeach;
74
  endif;
75
  return $fonts_uaf;
@@ -79,14 +79,14 @@ function uaf_send_fonts_redux_list( $custom_fonts ) {
79
  // X Theme
80
  add_filter('x_fonts_data', 'uaf_send_fonts_x_theme_list',10,2);
81
  function uaf_send_fonts_x_theme_list($fonts){
82
- $fontsData = uaf_get_uploaded_font_data();
83
  $fonts_uaf = array();
84
  if (!empty($fontsData)):
85
- foreach ($fontsData as $key=>$fontData):
86
- $fonts_uaf[$fontData['font_name']] = array(
87
  'source' => 'Use Any Font',
88
- 'family' => $fontData['font_name'],
89
- 'stack' => '"'.$fontData['font_name'].'"',
90
  'weights' => array( '400' )
91
  );
92
  endforeach;
@@ -96,11 +96,11 @@ function uaf_send_fonts_x_theme_list($fonts){
96
 
97
  // elementor
98
  function uaf_send_fonts_elementor_list( $controls_registry ) {
99
- $fontsData = uaf_get_uploaded_font_data();
100
  $fonts_uaf = array('Use Any Fonts' => array());
101
  if (!empty($fontsData)):
102
- foreach ($fontsData as $key=>$fontData):
103
- $fonts_uaf[$fontData['font_name']] = 'system';
104
  endforeach;
105
  endif;
106
 
@@ -114,11 +114,11 @@ add_action( 'elementor/controls/controls_registered', 'uaf_send_fonts_elementor_
114
  add_filter('fl_theme_system_fonts', 'uaf_send_fonts_beaver_builder_list',10,2);
115
  add_filter('fl_builder_font_families_system', 'uaf_send_fonts_beaver_builder_list',10,2);
116
  function uaf_send_fonts_beaver_builder_list($fonts){
117
- $fontsData = uaf_get_uploaded_font_data();
118
  $fonts_uaf = array();
119
  if (!empty($fontsData)):
120
- foreach ($fontsData as $key=>$fontData):
121
- $fonts_uaf[$fontData['font_name']] = array(
122
  'fallback' => 'Verdana, Arial, sans-serif',
123
  'weights' => array('400')
124
  );
@@ -130,13 +130,13 @@ function uaf_send_fonts_beaver_builder_list($fonts){
130
  // Themify Builder
131
  add_filter('themify_get_web_safe_font_list', 'uaf_send_fonts_themify_builder_list',10,2);
132
  function uaf_send_fonts_themify_builder_list($fonts){
133
- $fontsData = uaf_get_uploaded_font_data();
134
  $fonts_uaf = array();
135
  if (!empty($fontsData)):
136
- foreach ($fontsData as $key=>$fontData):
137
  $fonts_uaf[] = array(
138
- 'value' => $fontData['font_name'],
139
- 'name' => $fontData['font_name']
140
  );
141
  endforeach;
142
  endif;
@@ -152,12 +152,12 @@ add_filter( 'generate_typography_default_fonts', function( $fonts ) {
152
  // ASTRA THEME ver 2.2.1
153
  add_action( 'astra_customizer_font_list', 'uaf_astra_customizer_font_list');
154
  function uaf_astra_customizer_font_list( $value ) {
155
- $fontsData = uaf_get_uploaded_font_data();
156
  $fonts_uaf = array();
157
  if (!empty($fontsData)):
158
  echo '<optgroup label="Use Any Font">';
159
- foreach ($fontsData as $key=>$fontData):
160
- echo '<option value="' .$fontData['font_name'] . '">' . $fontData['font_name']. '</option>';
161
  endforeach;
162
  endif;
163
  }
@@ -183,14 +183,14 @@ function uaf_oxygen_builder_font_list() {
183
  // KIRKI CUSTOMIZER FRAMEWORK //Like FLATSOME THEME
184
  add_filter( 'kirki/fonts/standard_fonts', 'uaf_kirki_custom_fonts', 20 );
185
  function uaf_kirki_custom_fonts($standard_fonts) {
186
- $fontsData = uaf_get_uploaded_font_data();
187
  $fonts_uaf = array();
188
  if (!empty($fontsData)):
189
- foreach ($fontsData as $key=>$fontData):
190
  $fonts_uaf[$fontData['font_name']] = array(
191
- 'label' => $fontData['font_name'].' [Use Any Font]',
192
  'variants' => array('regular'),
193
- 'stack' => $fontData['font_name']
194
  );
195
  endforeach;
196
  endif;
@@ -200,14 +200,14 @@ function uaf_kirki_custom_fonts($standard_fonts) {
200
  // REVOLUTION SLIDER
201
  add_filter( 'revslider_data_get_font_familys', 'uaf_revslider_custom_fonts', 20 );
202
  function uaf_revslider_custom_fonts($fonts) {
203
- $fontsData = uaf_get_uploaded_font_data();
204
  $fonts_uaf = array();
205
  if (!empty($fontsData)):
206
- foreach ($fontsData as $key=>$fontData):
207
  $fonts_uaf[] = array(
208
  'type' => 'Use Any Font',
209
  'version' => 'Serif Fonts',
210
- 'label' => $fontData['font_name']
211
  );
212
  endforeach;
213
  endif;
@@ -217,12 +217,12 @@ function uaf_revslider_custom_fonts($fonts) {
217
  // FOR WP BAKERY VISUAL BUILDER (JS Composer)
218
  add_filter('vc_google_fonts_get_fonts_filter', 'uaf_wpbakery_custom_fonts');
219
  function uaf_wpbakery_custom_fonts($fonts) {
220
- $fontsData = uaf_get_uploaded_font_data();
221
  $fonts_uaf = array();
222
  if (!empty($fontsData)):
223
- foreach ($fontsData as $key=>$fontData):
224
  $fonts_uaf[] = array(
225
- 'font_family' => $fontData['font_name'],
226
  'font_types' => '400 regular:400:normal',
227
  'font_styles' => 'regular'
228
  );
@@ -236,7 +236,6 @@ function uaf_wpbakery_custom_fonts($fonts) {
236
  add_filter('presscore_options_get_safe_fonts', 'uaf_presscore_options_custom_fonts');
237
  function uaf_presscore_options_custom_fonts($fonts) {
238
  $fontsData = uaf_get_font_families();
239
-
240
  if (!empty($fontsData)):
241
  foreach ($fontsData as $key=>$fontName):
242
  $fonts_uaf[$fontName] = $fontName;
9
 
10
  function uaf_mce_before_init( $init_array ) {
11
  $theme_advanced_fonts = '';
12
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
13
  if (!empty($fontsData)):
14
+ foreach ($fontsData as $fontName=>$fontData):
15
+ $theme_advanced_fonts .= ucfirst(str_replace('_',' ', $fontName)) .'='.$fontName.';';
16
  endforeach;
17
  endif;
18
 
29
  // DIVI CUSTOMIZER AND BUILDER (Tested with 4.0.9 and 4.0.9)
30
  add_filter('et_websafe_fonts', 'uaf_send_fonts_divi_list',10,2);
31
  function uaf_send_fonts_divi_list($fonts){
32
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
33
  $fonts_uaf = array();
34
  if (!empty($fontsData)):
35
+ foreach ($fontsData as $fontName=>$fontData):
36
+ $fonts_uaf[$fontName] = array(
37
  'styles' => '400',
38
  'character_set' => 'cyrillic,greek,latin',
39
  'type' => 'serif'
46
  // SITE ORIGIN BUILDER
47
  add_filter('siteorigin_widgets_font_families', 'uaf_send_fonts_siteorigin_list',10,2);
48
  function uaf_send_fonts_siteorigin_list($fonts){
49
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
50
  $fonts_uaf = array();
51
  if (!empty($fontsData)):
52
+ foreach ($fontsData as $fontName=>$fontData):
53
+ $fonts_uaf[$fontName] = $fontName;
54
  endforeach;
55
  endif;
56
  return array_merge($fonts_uaf,$fonts);
65
  }
66
 
67
  function uaf_send_fonts_redux_list( $custom_fonts ) {
68
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
69
  $fonts_uaf = array('Use Any Fonts' => array());
70
  if (!empty($fontsData)):
71
+ foreach ($fontsData as $fontName=>$fontData):
72
+ $fonts_uaf['Use Any Fonts'][$fontName] = $fontName;
73
  endforeach;
74
  endif;
75
  return $fonts_uaf;
79
  // X Theme
80
  add_filter('x_fonts_data', 'uaf_send_fonts_x_theme_list',10,2);
81
  function uaf_send_fonts_x_theme_list($fonts){
82
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
83
  $fonts_uaf = array();
84
  if (!empty($fontsData)):
85
+ foreach ($fontsData as $fontName=>$fontData):
86
+ $fonts_uaf[$fontName] = array(
87
  'source' => 'Use Any Font',
88
+ 'family' => $fontName,
89
+ 'stack' => '"'.$fontName.'"',
90
  'weights' => array( '400' )
91
  );
92
  endforeach;
96
 
97
  // elementor
98
  function uaf_send_fonts_elementor_list( $controls_registry ) {
99
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
100
  $fonts_uaf = array('Use Any Fonts' => array());
101
  if (!empty($fontsData)):
102
+ foreach ($fontsData as $fontName=>$fontData):
103
+ $fonts_uaf[$fontName] = 'system';
104
  endforeach;
105
  endif;
106
 
114
  add_filter('fl_theme_system_fonts', 'uaf_send_fonts_beaver_builder_list',10,2);
115
  add_filter('fl_builder_font_families_system', 'uaf_send_fonts_beaver_builder_list',10,2);
116
  function uaf_send_fonts_beaver_builder_list($fonts){
117
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
118
  $fonts_uaf = array();
119
  if (!empty($fontsData)):
120
+ foreach ($fontsData as $fontName=>$fontData):
121
+ $fonts_uaf[$fontName] = array(
122
  'fallback' => 'Verdana, Arial, sans-serif',
123
  'weights' => array('400')
124
  );
130
  // Themify Builder
131
  add_filter('themify_get_web_safe_font_list', 'uaf_send_fonts_themify_builder_list',10,2);
132
  function uaf_send_fonts_themify_builder_list($fonts){
133
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
134
  $fonts_uaf = array();
135
  if (!empty($fontsData)):
136
+ foreach ($fontsData as $fontName=>$fontData):
137
  $fonts_uaf[] = array(
138
+ 'value' => $fontName,
139
+ 'name' => $fontName
140
  );
141
  endforeach;
142
  endif;
152
  // ASTRA THEME ver 2.2.1
153
  add_action( 'astra_customizer_font_list', 'uaf_astra_customizer_font_list');
154
  function uaf_astra_customizer_font_list( $value ) {
155
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
156
  $fonts_uaf = array();
157
  if (!empty($fontsData)):
158
  echo '<optgroup label="Use Any Font">';
159
+ foreach ($fontsData as $fontName=>$fontData):
160
+ echo '<option value="' .$fontName. '">' . $fontName. '</option>';
161
  endforeach;
162
  endif;
163
  }
183
  // KIRKI CUSTOMIZER FRAMEWORK //Like FLATSOME THEME
184
  add_filter( 'kirki/fonts/standard_fonts', 'uaf_kirki_custom_fonts', 20 );
185
  function uaf_kirki_custom_fonts($standard_fonts) {
186
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
187
  $fonts_uaf = array();
188
  if (!empty($fontsData)):
189
+ foreach ($fontsData as $fontName=>$fontData):
190
  $fonts_uaf[$fontData['font_name']] = array(
191
+ 'label' => $fontName.' [Use Any Font]',
192
  'variants' => array('regular'),
193
+ 'stack' => $fontName
194
  );
195
  endforeach;
196
  endif;
200
  // REVOLUTION SLIDER
201
  add_filter( 'revslider_data_get_font_familys', 'uaf_revslider_custom_fonts', 20 );
202
  function uaf_revslider_custom_fonts($fonts) {
203
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
204
  $fonts_uaf = array();
205
  if (!empty($fontsData)):
206
+ foreach ($fontsData as $fontName=>$fontData):
207
  $fonts_uaf[] = array(
208
  'type' => 'Use Any Font',
209
  'version' => 'Serif Fonts',
210
+ 'label' => $fontName
211
  );
212
  endforeach;
213
  endif;
217
  // FOR WP BAKERY VISUAL BUILDER (JS Composer)
218
  add_filter('vc_google_fonts_get_fonts_filter', 'uaf_wpbakery_custom_fonts');
219
  function uaf_wpbakery_custom_fonts($fonts) {
220
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
221
  $fonts_uaf = array();
222
  if (!empty($fontsData)):
223
+ foreach ($fontsData as $fontName=>$fontData):
224
  $fonts_uaf[] = array(
225
+ 'font_family' => $fontName,
226
  'font_types' => '400 regular:400:normal',
227
  'font_styles' => 'regular'
228
  );
236
  add_filter('presscore_options_get_safe_fonts', 'uaf_presscore_options_custom_fonts');
237
  function uaf_presscore_options_custom_fonts($fonts) {
238
  $fontsData = uaf_get_font_families();
 
239
  if (!empty($fontsData)):
240
  foreach ($fontsData as $key=>$fontName):
241
  $fonts_uaf[$fontName] = $fontName;
includes/functions/uaf_font_functions.php CHANGED
@@ -16,17 +16,17 @@ function uaf_get_uploaded_font_data(){
16
  }
17
 
18
  function uaf_get_font_families(){
19
- $fontsData = uaf_get_uploaded_font_data();
20
  $fonts_uaf = array();
21
  if (!empty($fontsData)):
22
- foreach ($fontsData as $key=>$fontData):
23
- $fonts_uaf[] = $fontData['font_name'];
24
  endforeach;
25
  endif;
26
  return $fonts_uaf;
27
  }
28
 
29
- function uaf_save_font_files($font_name, $convertResponse, $predefined_font_id = ''){
30
  uaf_create_folder(); // CREATE FOLDER IF DOESN"T EXISTS
31
  $uafPath = uaf_path_details();
32
  $fontNameToStore = sanitize_file_name(rand(0,9999).$font_name);
@@ -75,7 +75,7 @@ function uaf_save_font_files($font_name, $convertResponse, $predefined_font_id =
75
  endif;
76
  endforeach;
77
  else:
78
- uaf_save_font_entry_to_db($font_name, $fontNameToStore, $predefined_font_id);
79
  $fontUploadFinalResponse['status'] = 'success';
80
  $fontUploadFinalResponse['body'] = 'Font Uploaded';
81
  endif;
@@ -153,14 +153,29 @@ function uaf_create_folder() {
153
  }
154
  }
155
 
156
- function uaf_save_font_entry_to_db($font_name, $font_path, $predefined_font_id = ''){
157
  $fontsRawData = get_option('uaf_font_data');
158
  $fontsData = json_decode($fontsRawData, true);
159
  if (empty($fontsData)):
160
  $fontsData = array();
161
  endif;
162
 
163
- $fontsData[date('ymdhis')] = array('font_name' => sanitize_title($font_name), 'font_path' => $font_path, 'predefined_font_id' => $predefined_font_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  $updateFontData = json_encode($fontsData);
165
  update_option('uaf_font_data',$updateFontData);
166
  uaf_write_css();
@@ -194,21 +209,26 @@ function uaf_write_css(){
194
  font-family: '<?php echo $fontData['font_name'] ?>';
195
  src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff2') format('woff2'),
196
  <?php } ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
197
- font-display: <?php echo $GLOBALS['uaf_user_settings']['uaf_font_display_property']; ?>;
198
  }
199
 
200
  .<?php echo $fontData['font_name'] ?>{font-family: '<?php echo $fontData['font_name'] ?>' !important;}
201
 
202
  <?php
203
  endforeach;
204
- endif;
205
 
206
  $fontsImplementRawData = get_option('uaf_font_implement');
207
  $fontsImplementData = json_decode($fontsImplementRawData, true);
208
  if (!empty($fontsImplementData)):
209
- foreach ($fontsImplementData as $key=>$fontImplementData): ?>
 
 
 
 
 
210
  <?php echo $fontImplementData['font_elements']; ?>{
211
- font-family: '<?php echo $fontsData[$fontImplementData['font_key']]['font_name']; ?>' !important;
212
  }
213
  <?php
214
  endforeach;
@@ -228,6 +248,7 @@ function uaf_write_css(){
228
  font-family: '<?php echo $fontData['font_name'] ?>';
229
  src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff2') format('woff2'),
230
  <?php } ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
 
231
  }
232
 
233
  .<?php echo $fontData['font_name'] ?>{font-family: '<?php echo $fontData['font_name'] ?>' !important;}
@@ -307,8 +328,11 @@ function uaf_get_language_selector(){
307
  }
308
 
309
  function uaf_save_font_assign(){
 
 
310
  $fontsImplementRawData = get_option('uaf_font_implement');
311
  $fontsImplementData = json_decode($fontsImplementRawData, true);
 
312
  if (empty($fontsImplementData)):
313
  $fontsImplementData = array();
314
  endif;
@@ -322,7 +346,8 @@ function uaf_save_font_assign(){
322
 
323
  if (!empty($finalElements) && !empty($_POST['font_key'])){
324
  $fontsImplementData[date('ymdhis')] = array(
325
- 'font_key' => $_POST['font_key'],
 
326
  'font_elements' => $finalElements
327
  );
328
  $updateFontsImplementData = json_encode($fontsImplementData);
@@ -331,7 +356,7 @@ function uaf_save_font_assign(){
331
  $return['status'] = 'success';
332
  $return['body'] = 'Font Assigned';
333
  } else {
334
- $return['body'] = "Couldn't assign font. Please select font and atleast one element or add a custom element";
335
  $return['status'] = "error";
336
  }
337
  return $return;
@@ -360,7 +385,8 @@ function uaf_delete_font(){
360
  $updateFontData = json_encode($fontsData);
361
  update_option('uaf_font_data',$updateFontData);
362
 
363
- $fontsImplementRawData = get_option('uaf_font_implement');
 
364
  $fontsImplementData = json_decode($fontsImplementRawData, true);
365
 
366
  if (!empty($fontsImplementData)){
@@ -369,10 +395,9 @@ function uaf_delete_font(){
369
  unset($fontsImplementData[$implement_key]);
370
  }
371
  }
372
-
373
  $updatefontsImplementData = json_encode($fontsImplementData);
374
  update_option('uaf_font_implement',$updatefontsImplementData);
375
- }
376
 
377
  $return['status'] = 'success';
378
  $return['body'] = 'Font Deleted';
@@ -401,8 +426,7 @@ function uaf_get_uploaded_predefined_fonts(){
401
  foreach ($fontsData as $fontKey => $fontData) {
402
  if (isset($fontData['predefined_font_id']) && !empty(trim($fontData['predefined_font_id']))){
403
  $predefindFonts[] = $fontData['predefined_font_id'];
404
- }
405
-
406
  }
407
  }
408
  return $predefindFonts;
@@ -433,8 +457,21 @@ function uaf_add_pre_defined_font($fontId){
433
  $return['status'] = 'error';
434
  $return['body'] = $responseArray['global']['msg'];
435
  else:
436
- $return = uaf_save_font_files($responseArray['global']['font_name'], $response['body'], $fontId);
437
  endif;
438
  }
439
  return $return;
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  }
16
  }
17
 
18
  function uaf_get_font_families(){
19
+ $fontsData = uaf_group_fontdata_by_fontname(uaf_get_uploaded_font_data());
20
  $fonts_uaf = array();
21
  if (!empty($fontsData)):
22
+ foreach ($fontsData as $fontName=>$fontData):
23
+ $fonts_uaf[] = $fontName;
24
  endforeach;
25
  endif;
26
  return $fonts_uaf;
27
  }
28
 
29
+ function uaf_save_font_files($font_name, $font_weight, $font_style, $convertResponse, $predefined_font_id = ''){
30
  uaf_create_folder(); // CREATE FOLDER IF DOESN"T EXISTS
31
  $uafPath = uaf_path_details();
32
  $fontNameToStore = sanitize_file_name(rand(0,9999).$font_name);
75
  endif;
76
  endforeach;
77
  else:
78
+ uaf_save_font_entry_to_db($font_name, $font_weight, $font_style, $fontNameToStore, $predefined_font_id);
79
  $fontUploadFinalResponse['status'] = 'success';
80
  $fontUploadFinalResponse['body'] = 'Font Uploaded';
81
  endif;
153
  }
154
  }
155
 
156
+ function uaf_save_font_entry_to_db($font_name, $font_weight, $font_style, $font_path, $predefined_font_id = ''){
157
  $fontsRawData = get_option('uaf_font_data');
158
  $fontsData = json_decode($fontsRawData, true);
159
  if (empty($fontsData)):
160
  $fontsData = array();
161
  endif;
162
 
163
+ $fontArrayKey = date('ymdhis');
164
+
165
+ $fontsData[$fontArrayKey] = array(
166
+ 'font_name' => sanitize_title($font_name),
167
+ 'font_path' => $font_path,
168
+ 'predefined_font_id' => $predefined_font_id
169
+ );
170
+
171
+ if (!empty(trim($font_weight))){
172
+ $fontsData[$fontArrayKey]['font_weight'] = sanitize_title($font_weight);
173
+ }
174
+
175
+ if (!empty(trim($font_style))){
176
+ $fontsData[$fontArrayKey]['font_style'] = sanitize_title($font_style);
177
+ }
178
+
179
  $updateFontData = json_encode($fontsData);
180
  update_option('uaf_font_data',$updateFontData);
181
  uaf_write_css();
209
  font-family: '<?php echo $fontData['font_name'] ?>';
210
  src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff2') format('woff2'),
211
  <?php } ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
212
+ <?php echo array_key_exists('font_weight',$fontData)?'font-weight: '.$fontData['font_weight'].';':''; ?> <?php echo array_key_exists('font_style',$fontData)?'font-style: '.$fontData['font_style'].';':''; ?> font-display: <?php echo $GLOBALS['uaf_user_settings']['uaf_font_display_property']; ?>;
213
  }
214
 
215
  .<?php echo $fontData['font_name'] ?>{font-family: '<?php echo $fontData['font_name'] ?>' !important;}
216
 
217
  <?php
218
  endforeach;
219
+ endif;
220
 
221
  $fontsImplementRawData = get_option('uaf_font_implement');
222
  $fontsImplementData = json_decode($fontsImplementRawData, true);
223
  if (!empty($fontsImplementData)):
224
+ foreach ($fontsImplementData as $key=>$fontImplementData):
225
+ if (isset($fontImplementData['font_name']) && !empty(trim($fontImplementData['font_name']))){
226
+ $font_name = $fontImplementData['font_name'];
227
+ } else {
228
+ $font_name = $fontsData[$fontImplementData['font_key']]['font_name'];
229
+ }?>
230
  <?php echo $fontImplementData['font_elements']; ?>{
231
+ font-family: '<?php echo $font_name; ?>' !important;
232
  }
233
  <?php
234
  endforeach;
248
  font-family: '<?php echo $fontData['font_name'] ?>';
249
  src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff2') format('woff2'),
250
  <?php } ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
251
+ <?php echo array_key_exists('font_weight',$fontData)?'font-weight: '.$fontData['font_weight'].';':''; ?> <?php echo array_key_exists('font_style',$fontData)?'font-style: '.$fontData['font_style'].';':''; ?> font-display: <?php echo $GLOBALS['uaf_user_settings']['uaf_font_display_property']; ?>;
252
  }
253
 
254
  .<?php echo $fontData['font_name'] ?>{font-family: '<?php echo $fontData['font_name'] ?>' !important;}
328
  }
329
 
330
  function uaf_save_font_assign(){
331
+ $fontsData = uaf_get_uploaded_font_data();
332
+ $font_name = $fontsData[$_POST['font_key']]['font_name'];
333
  $fontsImplementRawData = get_option('uaf_font_implement');
334
  $fontsImplementData = json_decode($fontsImplementRawData, true);
335
+
336
  if (empty($fontsImplementData)):
337
  $fontsImplementData = array();
338
  endif;
346
 
347
  if (!empty($finalElements) && !empty($_POST['font_key'])){
348
  $fontsImplementData[date('ymdhis')] = array(
349
+ 'font_key' => $_POST['font_key'],
350
+ 'font_name' => $font_name,
351
  'font_elements' => $finalElements
352
  );
353
  $updateFontsImplementData = json_encode($fontsImplementData);
356
  $return['status'] = 'success';
357
  $return['body'] = 'Font Assigned';
358
  } else {
359
+ $return['body'] = "Couldn't assign font. Please select font and atleast one element or add a custom element";
360
  $return['status'] = "error";
361
  }
362
  return $return;
385
  $updateFontData = json_encode($fontsData);
386
  update_option('uaf_font_data',$updateFontData);
387
 
388
+ // DELETING FONT ASSIGN AFTER THE FONT IS DELETED. REMOVED DUE TO MULTI VARIATION COMPLICATIONS.
389
+ /*$fontsImplementRawData = get_option('uaf_font_implement');
390
  $fontsImplementData = json_decode($fontsImplementRawData, true);
391
 
392
  if (!empty($fontsImplementData)){
395
  unset($fontsImplementData[$implement_key]);
396
  }
397
  }
 
398
  $updatefontsImplementData = json_encode($fontsImplementData);
399
  update_option('uaf_font_implement',$updatefontsImplementData);
400
+ }*/
401
 
402
  $return['status'] = 'success';
403
  $return['body'] = 'Font Deleted';
426
  foreach ($fontsData as $fontKey => $fontData) {
427
  if (isset($fontData['predefined_font_id']) && !empty(trim($fontData['predefined_font_id']))){
428
  $predefindFonts[] = $fontData['predefined_font_id'];
429
+ }
 
430
  }
431
  }
432
  return $predefindFonts;
457
  $return['status'] = 'error';
458
  $return['body'] = $responseArray['global']['msg'];
459
  else:
460
+ $return = uaf_save_font_files($responseArray['global']['font_name'], '', '', $response['body'], $fontId);
461
  endif;
462
  }
463
  return $return;
464
+ }
465
+
466
+
467
+ function uaf_group_fontdata_by_fontname($fontDatas){
468
+ $returnArray = array();
469
+ foreach($fontDatas as $key => $value){
470
+ $returnArray[$value['font_name']][$key] = $value;
471
+ }
472
+ return $returnArray;
473
+ }
474
+
475
+ function uaf_order_font_by_weight($a, $b) {
476
+ return strcmp($a["font_weight"], $b["font_weight"]);
477
  }
includes/uaf_config.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
- $GLOBALS['uaf_current_version'] = '6.1.8';
5
 
6
 
7
  $GLOBALS['uaf_fix_settings'] = array(
@@ -15,11 +15,21 @@ $GLOBALS['uaf_fix_settings'] = array(
15
  'polylang/polylang.php', // POLYLANG
16
  'polylang-pro/polylang.php', // POLYLANG PRO
17
  'sitepress-multilingual-cms/sitepress.php' //WPML
18
- )
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  );
21
 
22
-
23
  $GLOBALS['uaf_user_settings'] = array(
24
  'uaf_api_key' => '',
25
  'uaf_server_url_type' => 'default',
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
+ $GLOBALS['uaf_current_version'] = '6.2';
5
 
6
 
7
  $GLOBALS['uaf_fix_settings'] = array(
15
  'polylang/polylang.php', // POLYLANG
16
  'polylang-pro/polylang.php', // POLYLANG PRO
17
  'sitepress-multilingual-cms/sitepress.php' //WPML
18
+ ),
19
+ 'font_weight_variations'=> array(
20
+ '100' => 'Thin 100',
21
+ '200' => 'Extra light 200',
22
+ '300' => 'Light 300',
23
+ '400' => 'Regular/Normal 400',
24
+ '500' => 'Medium 500',
25
+ '600' => 'Semi Bold 600',
26
+ '700' => 'Bold 700',
27
+ '800' => 'Extra Bold 800',
28
+ '900' => 'Black 900'
29
+ )
30
 
31
  );
32
 
 
33
  $GLOBALS['uaf_user_settings'] = array(
34
  'uaf_api_key' => '',
35
  'uaf_server_url_type' => 'default',
includes/views/uaf_api_interface.php CHANGED
@@ -20,7 +20,7 @@
20
  echo '##############################';
21
  } else {
22
  echo $GLOBALS['uaf_user_settings']['uaf_api_key'];
23
- } ?>
24
 
25
  - Active</span>
26
 
20
  echo '##############################';
21
  } else {
22
  echo $GLOBALS['uaf_user_settings']['uaf_api_key'];
23
+ } ?>
24
 
25
  - Active</span>
26
 
includes/views/uaf_font_assign.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
- $fontsData = uaf_get_uploaded_font_data(); ?>
 
 
4
 
5
  <p align="right"><input type="button" name="open_assign_font" onClick="open_assign_font();" class="button-primary" id="open_assign_font_button" value="Assign Font" /><br/></p>
6
 
@@ -13,10 +15,10 @@ $fontsData = uaf_get_uploaded_font_data(); ?>
13
  <td>
14
  <select name="font_key" class="uaf_required" style="width:200px;">
15
  <option value="">- Select -</option>
16
- <?php
17
- if (!empty($fontsData)):
18
- foreach ($fontsData as $key=>$fontData) : ?>
19
- <option value="<?php echo $key ?>"><?php echo $fontData['font_name']; ?></option>
20
  <?php endforeach;
21
  endif;
22
  ?>
@@ -48,8 +50,7 @@ $fontsData = uaf_get_uploaded_font_data(); ?>
48
  <input name="elements[]" value="body.single-post .entry-title" type="checkbox" /> Post Title Only<br/>
49
  <input name="elements[]" value="body.page .entry-title" type="checkbox" /> Page Title Only<br/>
50
  <input name="elements[]" value="body.category .entry-title" type="checkbox" /> Category Title Only<br/>
51
- <input name="elements[]" value=".widget-title" type="checkbox" /> Widget Title<br/>
52
-
53
  </div>
54
 
55
  <div class="elements_holder">
@@ -81,11 +82,7 @@ $fontsData = uaf_get_uploaded_font_data(); ?>
81
  echo 'No Menus Found<br/>';
82
  }
83
  ?>
84
- </div>
85
-
86
-
87
-
88
-
89
  </td>
90
  </tr>
91
  <tr>
@@ -137,7 +134,15 @@ $fontsImplementData = json_decode($fontsImplementRawData, true);
137
  ?>
138
  <tr>
139
  <td><?php echo $sn; ?></td>
140
- <td><?php echo @$fontsData[$fontImplementData['font_key']]['font_name']; ?></td>
 
 
 
 
 
 
 
 
141
  <td><?php echo $fontImplementData['font_elements'] ?></td>
142
  <td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="<?php echo wp_nonce_url( 'admin.php?page=use-any-font&tab=font_assign&delete_font_assign_key='.$key, 'uaf_delete_font_assign', 'uaf_nonce' ); ?>">Delete</a></td>
143
  </tr>
@@ -147,6 +152,5 @@ $fontsImplementData = json_decode($fontsImplementRawData, true);
147
  <td colspan="4">No font assign yet. Click on Assign Font to start.</td>
148
  </tr>
149
  <?php endif; ?>
150
- </tbody>
151
-
152
  </table>
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
+ $fontsData = uaf_get_uploaded_font_data();
4
+ $fontsDataWithVariations = uaf_group_fontdata_by_fontname($fontsData);
5
+ ?>
6
 
7
  <p align="right"><input type="button" name="open_assign_font" onClick="open_assign_font();" class="button-primary" id="open_assign_font_button" value="Assign Font" /><br/></p>
8
 
15
  <td>
16
  <select name="font_key" class="uaf_required" style="width:200px;">
17
  <option value="">- Select -</option>
18
+ <?php
19
+ if (!empty($fontsDataWithVariations)):
20
+ foreach ($fontsDataWithVariations as $key=>$fontDataVariation) : ?>
21
+ <option value="<?php echo array_key_first($fontDataVariation); ?>"><?php echo $key ?></option>
22
  <?php endforeach;
23
  endif;
24
  ?>
50
  <input name="elements[]" value="body.single-post .entry-title" type="checkbox" /> Post Title Only<br/>
51
  <input name="elements[]" value="body.page .entry-title" type="checkbox" /> Page Title Only<br/>
52
  <input name="elements[]" value="body.category .entry-title" type="checkbox" /> Category Title Only<br/>
53
+ <input name="elements[]" value=".widget-title" type="checkbox" /> Widget Title<br/>
 
54
  </div>
55
 
56
  <div class="elements_holder">
82
  echo 'No Menus Found<br/>';
83
  }
84
  ?>
85
+ </div>
 
 
 
 
86
  </td>
87
  </tr>
88
  <tr>
134
  ?>
135
  <tr>
136
  <td><?php echo $sn; ?></td>
137
+ <td>
138
+ <?php
139
+ if (isset($fontImplementData['font_name']) && !empty(trim($fontImplementData['font_name']))){
140
+ echo $fontImplementData['font_name'];
141
+ } else {
142
+ echo @$fontsData[$fontImplementData['font_key']]['font_name'];
143
+ }
144
+ ?>
145
+ </td>
146
  <td><?php echo $fontImplementData['font_elements'] ?></td>
147
  <td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="<?php echo wp_nonce_url( 'admin.php?page=use-any-font&tab=font_assign&delete_font_assign_key='.$key, 'uaf_delete_font_assign', 'uaf_nonce' ); ?>">Delete</a></td>
148
  </tr>
152
  <td colspan="4">No font assign yet. Click on Assign Font to start.</td>
153
  </tr>
154
  <?php endif; ?>
155
+ </tbody>
 
156
  </table>
includes/views/uaf_font_upload_js.php CHANGED
@@ -20,8 +20,34 @@ add_thickbox();
20
  <span class="field_error">Please give font name.</span>
21
  </span>
22
  </p>
23
-
24
  <p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  <label>Font File *</label>
26
  <span class="field">
27
  <input type="file" id="fontfile" name="fontfile" value="" class="uaf_required" accept=".woff,.ttf,.otf" />
@@ -48,8 +74,8 @@ add_thickbox();
48
  </form>
49
  <?php else: ?>
50
  <div class="dcinfo"><p>You need to add API key in <a href="admin.php?page=use-any-font&tab=api">API key</a> section to upload the fonts.</p></div>
51
- <?php endif; ?>
52
  </div>
53
  </div>
54
 
55
- <?php include('uaf_uploaded_font_list.php'); ?>
20
  <span class="field_error">Please give font name.</span>
21
  </span>
22
  </p>
 
23
  <p>
24
+ <label>&nbsp;</label>
25
+ <span class="field">
26
+ <input type="checkbox" name="enable_font_variation" id="enable_font_variation" onclick="multi_variation_holder_toggle();"> Enable Font Weight Variation ( For Advance Users ). <a href="https://dineshkarki.com.np/add-multiple-font-variation-in-use-any-font.html" target="_blank">How to !</a>
27
+ </span>
28
+ </p>
29
+ <div class="multi_variation_holder" style="display:none;">
30
+ <p>
31
+ <label>Font Weight *</label>
32
+ <span class="field">
33
+ <select name="font_weight" class="medium">
34
+ <?php foreach ($GLOBALS['uaf_fix_settings']['font_weight_variations'] as $variation => $variation_label): ?>
35
+ <option value="<?php echo $variation ?>"><?php echo $variation_label; ?></option>
36
+ <?php endforeach; ?>
37
+ </select>
38
+ </span>
39
+ </p>
40
+ <p>
41
+ <label>Font Style *</label>
42
+ <span class="field">
43
+ <select name="font_style" class="medium">
44
+ <option value="normal">Normal</option>
45
+ <option value="italic">Italic</option>
46
+ </select>
47
+ </span>
48
+ </p>
49
+ </div>
50
+ <p>
51
  <label>Font File *</label>
52
  <span class="field">
53
  <input type="file" id="fontfile" name="fontfile" value="" class="uaf_required" accept=".woff,.ttf,.otf" />
74
  </form>
75
  <?php else: ?>
76
  <div class="dcinfo"><p>You need to add API key in <a href="admin.php?page=use-any-font&tab=api">API key</a> section to upload the fonts.</p></div>
77
+ <?php endif; ?>
78
  </div>
79
  </div>
80
 
81
+ <?php include('uaf_uploaded_font_list.php'); ?>
includes/views/uaf_font_upload_php.php CHANGED
@@ -9,8 +9,7 @@ add_thickbox();
9
  <br/></p>
10
 
11
  <div id="font-upload" style="display:none;">
12
- <div class="dcform">
13
-
14
  <?php if (!empty($GLOBALS['uaf_user_settings']['uaf_api_key'])) : ?>
15
  <form action="admin.php?page=use-any-font&tab=font_upload" id="open_add_font_form_php" method="post" enctype="multipart/form-data">
16
 
@@ -21,6 +20,33 @@ add_thickbox();
21
  <span class="field_error">Please give font name.</span>
22
  </span>
23
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  <p>
25
  <label>Font File *</label>
26
  <span class="field">
@@ -41,9 +67,8 @@ add_thickbox();
41
  <?php wp_nonce_field( 'uaf_font_upload_php', 'uaf_nonce' ); ?>
42
  <br/>
43
  <span>By clicking on Upload, you confirm that you have rights to use this font.</span>
44
- </span>
45
-
46
- </p>
47
  </form>
48
  <?php else: ?>
49
  <div class="dcinfo"><p>You need to add API key in <a href="admin.php?page=use-any-font&tab=api">API key</a> section to upload the fonts.</p></div>
9
  <br/></p>
10
 
11
  <div id="font-upload" style="display:none;">
12
+ <div class="dcform">
 
13
  <?php if (!empty($GLOBALS['uaf_user_settings']['uaf_api_key'])) : ?>
14
  <form action="admin.php?page=use-any-font&tab=font_upload" id="open_add_font_form_php" method="post" enctype="multipart/form-data">
15
 
20
  <span class="field_error">Please give font name.</span>
21
  </span>
22
  </p>
23
+ <p>
24
+ <label>&nbsp;</label>
25
+ <span class="field">
26
+ <input type="checkbox" name="enable_font_variation" id="enable_font_variation" onclick="multi_variation_holder_toggle();"> Enable Font Weight Variation ( For Advance Users ). <a href="https://dineshkarki.com.np/add-multiple-font-variation-in-use-any-font.html" target="_blank">How to !</a>
27
+ </span>
28
+ </p>
29
+ <div class="multi_variation_holder" style="display:none;">
30
+ <p>
31
+ <label>Font Weight *</label>
32
+ <span class="field">
33
+ <select name="font_weight" class="medium">
34
+ <?php foreach ($GLOBALS['uaf_fix_settings']['font_weight_variations'] as $variation => $variation_label): ?>
35
+ <option value="<?php echo $variation ?>"><?php echo $variation_label; ?></option>
36
+ <?php endforeach; ?>
37
+ </select>
38
+ </span>
39
+ </p>
40
+ <p>
41
+ <label>Font Style *</label>
42
+ <span class="field">
43
+ <select name="font_style" class="medium">
44
+ <option value="normal">Normal</option>
45
+ <option value="italic">Italic</option>
46
+ </select>
47
+ </span>
48
+ </p>
49
+ </div>
50
  <p>
51
  <label>Font File *</label>
52
  <span class="field">
67
  <?php wp_nonce_field( 'uaf_font_upload_php', 'uaf_nonce' ); ?>
68
  <br/>
69
  <span>By clicking on Upload, you confirm that you have rights to use this font.</span>
70
+ </span>
71
+ </p>
 
72
  </form>
73
  <?php else: ?>
74
  <div class="dcinfo"><p>You need to add API key in <a href="admin.php?page=use-any-font&tab=api">API key</a> section to upload the fonts.</p></div>
includes/views/uaf_predefined_fonts.php CHANGED
@@ -9,7 +9,7 @@ $predefinedUplaodedFonts = uaf_get_uploaded_predefined_fonts();
9
  </form>
10
  </div>
11
 
12
- <div id="predefined_fonts_list" class="ready" data-page="1" data-totalPage = '1' data-randnumber="<?php echo rand(1111, 99999); ?>">
13
  </div>
14
 
15
  <div id="predefined_font_load_msg"></div>
@@ -33,7 +33,7 @@ $predefinedUplaodedFonts = uaf_get_uploaded_predefined_fonts();
33
  } else {
34
  jQuery('#predefined_font_load_msg').html('No Font Found');
35
  }
36
- });
37
  }
38
 
39
  function uaf_font_list_block(font, predefinedUplaodedFonts){
@@ -54,7 +54,7 @@ $predefinedUplaodedFonts = uaf_get_uploaded_predefined_fonts();
54
  }
55
 
56
  function uaf_add_loading_text(e){
57
- jQuery(e).html('Adding...');
58
  }
59
 
60
  jQuery(document).ready(function(){
@@ -64,7 +64,6 @@ $predefinedUplaodedFonts = uaf_get_uploaded_predefined_fonts();
64
  uaf_load_predefined_fonts('1', 'all', jQuery('#predefined_search_input').val());
65
  jQuery('#predefined_fonts_list').attr('data-page', '1');
66
  return false;
67
-
68
  });
69
 
70
  jQuery('#TB_ajaxContent').bind('scroll', function() {
@@ -81,6 +80,6 @@ $predefinedUplaodedFonts = uaf_get_uploaded_predefined_fonts();
81
  }
82
  }
83
  }
84
- });
85
  });
86
  </script>
9
  </form>
10
  </div>
11
 
12
+ <div id="predefined_fonts_list" class="ready" data-page="1" data-totalPage = '1' data-randnumber="<?php echo rand(1111, 99999); ?>">
13
  </div>
14
 
15
  <div id="predefined_font_load_msg"></div>
33
  } else {
34
  jQuery('#predefined_font_load_msg').html('No Font Found');
35
  }
36
+ });
37
  }
38
 
39
  function uaf_font_list_block(font, predefinedUplaodedFonts){
54
  }
55
 
56
  function uaf_add_loading_text(e){
57
+ jQuery(e).html('Adding...');
58
  }
59
 
60
  jQuery(document).ready(function(){
64
  uaf_load_predefined_fonts('1', 'all', jQuery('#predefined_search_input').val());
65
  jQuery('#predefined_fonts_list').attr('data-page', '1');
66
  return false;
 
67
  });
68
 
69
  jQuery('#TB_ajaxContent').bind('scroll', function() {
80
  }
81
  }
82
  }
83
+ });
84
  });
85
  </script>
includes/views/uaf_sidebar.php CHANGED
@@ -55,14 +55,11 @@ if(is_plugin_active( 'gravityforms/gravityforms.php' ) && !is_plugin_active( 'jq
55
  </div>
56
  <div class="dcwidgetbody">
57
  <ul class="uaf_list">
58
- <li><a href="http://goo.gl/3XDDzi" target="_blank">WP Masonry Layout</a></li>
59
- <li><a href="http://wordpress.org/extend/plugins/any-mobile-theme-switcher/" target="_blank">Any Mobile Theme Switcher</a></li>
60
- <li><a href="http://wordpress.org/extend/plugins/jquery-validation-for-contact-form-7/" target="_blank">Jquery Validation For Contact Form 7</a></li>
61
- <li><a href="http://wordpress.org/extend/plugins/add-tags-and-category-to-page/" target="_blank">Add Tags And Category To Page</a></li>
62
- <li><a href="http://wordpress.org/extend/plugins/block-specific-plugin-updates/" target="_blank">Block Specific Plugin Updates</a></li>
63
- <li><a href="http://wordpress.org/extend/plugins/featured-image-in-rss-feed/" target="_blank">Featured Image In RSS Feed</a></li>
64
- <li><a href="http://wordpress.org/extend/plugins/remove-admin-bar-for-client/" target="_blank">Remove Admin Bar</a></li>
65
- <li><a href="http://wordpress.org/extend/plugins/html-in-category-and-pages/" target="_blank">.html in category and page url</a></li>
66
  </ul>
67
  </div>
68
 
@@ -81,5 +78,4 @@ if(is_plugin_active( 'gravityforms/gravityforms.php' ) && !is_plugin_active( 'jq
81
  <li><a href="https://dineshkarki.com.np/contact" target="_blank">Contact Us</a></li>
82
  </ul>
83
  </div>
84
-
85
  </div>
55
  </div>
56
  <div class="dcwidgetbody">
57
  <ul class="uaf_list">
58
+ <li><a href="http://wordpress.org/plugins/any-mobile-theme-switcher/" target="_blank">Any Mobile Theme Switcher</a></li>
59
+ <li><a href="http://wordpress.org/plugins/jquery-validation-for-contact-form-7/" target="_blank">Jquery Validation For Contact Form 7</a></li>
60
+ <li><a href="http://wordpress.org/plugins/add-tags-and-category-to-page/" target="_blank">Add Tags And Category To Page</a></li>
61
+ <li><a href="http://wordpress.org/plugins/block-specific-plugin-updates/" target="_blank">Block Specific Plugin Updates</a></li>
62
+ <li><a href="http://wordpress.org/plugins/featured-image-in-rss-feed/" target="_blank">Featured Image In RSS Feed</a></li>
 
 
 
63
  </ul>
64
  </div>
65
 
78
  <li><a href="https://dineshkarki.com.np/contact" target="_blank">Contact Us</a></li>
79
  </ul>
80
  </div>
 
81
  </div>
includes/views/uaf_uploaded_font_list.php CHANGED
@@ -4,25 +4,41 @@ $fontsData = uaf_get_uploaded_font_data(); ?>
4
 
5
  <?php
6
  if (!empty($fontsData)):
 
7
  $sn = 0;
8
- foreach ($fontsData as $key=>$fontData):
9
  $sn++
10
  ?>
11
  <div class="font_holder">
12
  <div class="font_meta">
13
- <div class="font_name"><?php echo ucfirst($fontData['font_name']); ?></div>
14
- <?php /* <div class="class_name"><?php echo $fontData['font_name'] ?></div> */ ?>
15
- <div class="delete_link"><a onclick="if (!confirm('Are you sure ?')){return false;}" href="<?php echo wp_nonce_url( 'admin.php?page=use-any-font&tab=font_upload&delete_font_key='.$key, 'uaf_delete_font', 'uaf_nonce' ); ?>">Delete</a></div>
16
  </div>
17
 
18
- <div class="font_demo">
19
- <span class="<?php echo $fontData['font_name'] ?>">The quick brown fox jumps over the lazy dog</span>
20
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- <div class="fontclassname">Class to use this font : <em><strong><?php echo $fontData['font_name']; ?></strong></em></div>
 
 
 
 
23
  <br style="clear:both;" />
24
  </div>
25
-
26
  <?php endforeach; ?>
27
 
28
  <?php else: ?>
4
 
5
  <?php
6
  if (!empty($fontsData)):
7
+ $fontsDataWithVariations = uaf_group_fontdata_by_fontname($fontsData);
8
  $sn = 0;
9
+ foreach ($fontsDataWithVariations as $fontName=>$fontsData):
10
  $sn++
11
  ?>
12
  <div class="font_holder">
13
  <div class="font_meta">
14
+ <div class="font_name"><?php echo ucfirst($fontName); ?></div>
15
+ <div class="fontclassname">Class to use this font : <em><strong><?php echo $fontName; ?></strong></em></div>
 
16
  </div>
17
 
18
+ <?php
19
+ if (!empty($fontsData)):
20
+ uasort($fontsData, 'uaf_order_font_by_weight');
21
+ foreach ($fontsData as $key => $fontData):
22
+ ?>
23
+ <div class="font_demo">
24
+
25
+ <?php
26
+ if (isset($fontData['font_weight']) && !empty(trim($fontData['font_weight']))):
27
+ ?>
28
+ <div class="font-weight-style">
29
+ <?php echo $GLOBALS['uaf_fix_settings']['font_weight_variations'][$fontData['font_weight']]; ?> <?php echo $fontData['font_style']; ?>
30
+ </div>
31
+ <?php endif; ?>
32
+
33
+ <span class="<?php echo $fontData['font_name'] ?>" style="font-weight:<?php echo $fontData['font_weight']; ?>; font-style: <?php echo $fontData['font_style']; ?>;">The quick brown fox jumps over the lazy dog</span>
34
 
35
+ <div class="delete_link"><a onclick="if (!confirm('Are you sure ?')){return false;}" href="<?php echo wp_nonce_url( 'admin.php?page=use-any-font&tab=font_upload&delete_font_key='.$key, 'uaf_delete_font', 'uaf_nonce' ); ?>">Delete</a></div>
36
+ </div>
37
+ <?php
38
+ endforeach;
39
+ endif; ?>
40
  <br style="clear:both;" />
41
  </div>
 
42
  <?php endforeach; ?>
43
 
44
  <?php else: ?>
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: dnesscarkey
3
  Tags: custom fonts, font embed, font uploader, typography, install font
4
  Requires at least: 3.0
5
- Tested up to: 5.8.2
6
- Stable tag: 6.1.8
7
 
8
  Embed any custom font using font uploader and assign to elements. Upload font in 1 format and other needed formats are auto converted even woff2.
9
 
@@ -127,7 +127,7 @@ No, our server is needed during font conversion only. After that all fonts are s
127
  You can use <strong>uaf_get_font_families();</strong> function to get the list of custom fonts uploaded with Use Any Font. You can add it in your font family select box or list.
128
 
129
  <em>if (function_exists('uaf_get_font_families')){
130
- $uaf_font_families = uaf_get_font_families(); // Return Array
131
  }</em>
132
 
133
  Please do write us after integration and we will add it in our supported list.
@@ -143,6 +143,9 @@ Please do write us after integration and we will add it in our supported list.
143
 
144
  == Changelog ==
145
 
 
 
 
146
  = 6.1.8 =
147
  * Added wpnonce for forms
148
 
2
  Contributors: dnesscarkey
3
  Tags: custom fonts, font embed, font uploader, typography, install font
4
  Requires at least: 3.0
5
+ Tested up to: 5.8.3
6
+ Stable tag: 6.2
7
 
8
  Embed any custom font using font uploader and assign to elements. Upload font in 1 format and other needed formats are auto converted even woff2.
9
 
127
  You can use <strong>uaf_get_font_families();</strong> function to get the list of custom fonts uploaded with Use Any Font. You can add it in your font family select box or list.
128
 
129
  <em>if (function_exists('uaf_get_font_families')){
130
+ $uaf_font_families = uaf_get_font_families(); // Returns Array
131
  }</em>
132
 
133
  Please do write us after integration and we will add it in our supported list.
143
 
144
  == Changelog ==
145
 
146
+ = 6.2 =
147
+ * Added multi variation font support.
148
+
149
  = 6.1.8 =
150
  * Added wpnonce for forms
151
 
use-any-font.php CHANGED
@@ -5,7 +5,7 @@ Plugin Name: Use Any Font
5
  Plugin URI: https://dineshkarki.com.np/use-any-font
6
  Description: Embed any font in your website
7
  Author: Dnesscarkey
8
- Version: 6.1.8
9
  Author URI: https://dineshkarki.com.np/use-any-font
10
  */
11
 
5
  Plugin URI: https://dineshkarki.com.np/use-any-font
6
  Description: Embed any font in your website
7
  Author: Dnesscarkey
8
+ Version: 6.2
9
  Author URI: https://dineshkarki.com.np/use-any-font
10
  */
11