Version Description
- Font upload supported upto 25 MB.
- Use of woff2 compression for better and faster font loading.
Download this release
Release Info
Developer | dnesscarkey |
Plugin | Use Any Font |
Version | 5.4 |
Comparing to | |
See all releases |
Code changes from version 5.3 to 5.4
- includes/uaf_editor_setup.php +10 -18
- includes/uaf_font_implement.php +1 -1
- includes/uaf_font_upload_js.php +21 -142
- includes/uaf_font_upload_php.php +12 -163
- includes/uaf_footer.php +16 -18
- includes/uaf_functions.php +356 -0
- includes/uaf_header.php +18 -42
- includes/uaf_uploaded_font_list.php +30 -0
- plugin_interface.php +2 -162
- readme.txt +8 -4
- uaf_config.php +16 -0
- use-any-font.php +4 -1
includes/uaf_editor_setup.php
CHANGED
@@ -2,8 +2,7 @@
|
|
2 |
// DEFAULT WORDPRESS EDITOR
|
3 |
function uaf_mce_before_init( $init_array ) {
|
4 |
$theme_advanced_fonts = '';
|
5 |
-
$
|
6 |
-
$fontsData = json_decode($fontsRawData, true);
|
7 |
if (!empty($fontsData)):
|
8 |
foreach ($fontsData as $key=>$fontData):
|
9 |
$theme_advanced_fonts .= ucfirst(str_replace('_',' ', $fontData['font_name'])) .'='.$fontData['font_name'].';';
|
@@ -20,11 +19,10 @@ function wp_editor_fontsize_filter( $options ) {
|
|
20 |
return $options;
|
21 |
}
|
22 |
|
23 |
-
// DIVI CUSTOMIZER AND BUILDER
|
24 |
add_filter('et_websafe_fonts', 'uaf_send_fonts_divi_list',10,2);
|
25 |
function uaf_send_fonts_divi_list($fonts){
|
26 |
-
$
|
27 |
-
$fontsData = json_decode($fontsRawData, true);
|
28 |
$fonts_uaf = array();
|
29 |
if (!empty($fontsData)):
|
30 |
foreach ($fontsData as $key=>$fontData):
|
@@ -41,8 +39,7 @@ function uaf_send_fonts_divi_list($fonts){
|
|
41 |
// SITE ORIGIN BUILDER
|
42 |
add_filter('siteorigin_widgets_font_families', 'uaf_send_fonts_siteorigin_list',10,2);
|
43 |
function uaf_send_fonts_siteorigin_list($fonts){
|
44 |
-
$
|
45 |
-
$fontsData = json_decode($fontsRawData, true);
|
46 |
$fonts_uaf = array();
|
47 |
if (!empty($fontsData)):
|
48 |
foreach ($fontsData as $key=>$fontData):
|
@@ -59,8 +56,7 @@ if (class_exists( 'Redux' ) ) {
|
|
59 |
}
|
60 |
|
61 |
function uaf_send_fonts_redux_list( $custom_fonts ) {
|
62 |
-
$
|
63 |
-
$fontsData = json_decode($fontsRawData, true);
|
64 |
$fonts_uaf = array('Use Any Fonts' => array());
|
65 |
if (!empty($fontsData)):
|
66 |
foreach ($fontsData as $key=>$fontData):
|
@@ -74,8 +70,7 @@ function uaf_send_fonts_redux_list( $custom_fonts ) {
|
|
74 |
// X Theme
|
75 |
add_filter('x_fonts_data', 'uaf_send_fonts_x_theme_list',10,2);
|
76 |
function uaf_send_fonts_x_theme_list($fonts){
|
77 |
-
$
|
78 |
-
$fontsData = json_decode($fontsRawData, true);
|
79 |
$fonts_uaf = array();
|
80 |
if (!empty($fontsData)):
|
81 |
foreach ($fontsData as $key=>$fontData):
|
@@ -92,8 +87,7 @@ function uaf_send_fonts_x_theme_list($fonts){
|
|
92 |
|
93 |
// ELEMENTOR
|
94 |
function uaf_send_fonts_elementor_list( $controls_registry ) {
|
95 |
-
$
|
96 |
-
$fontsData = json_decode($fontsRawData, true);
|
97 |
$fonts_uaf = array('Use Any Fonts' => array());
|
98 |
if (!empty($fontsData)):
|
99 |
foreach ($fontsData as $key=>$fontData):
|
@@ -107,11 +101,10 @@ function uaf_send_fonts_elementor_list( $controls_registry ) {
|
|
107 |
}
|
108 |
add_action( 'elementor/controls/controls_registered', 'uaf_send_fonts_elementor_list', 10, 1 );
|
109 |
|
110 |
-
// Beaver Builder
|
111 |
add_filter('fl_builder_font_families_system', 'uaf_send_fonts_beaver_builder_list',10,2);
|
112 |
function uaf_send_fonts_beaver_builder_list($fonts){
|
113 |
-
$
|
114 |
-
$fontsData = json_decode($fontsRawData, true);
|
115 |
$fonts_uaf = array();
|
116 |
if (!empty($fontsData)):
|
117 |
foreach ($fontsData as $key=>$fontData):
|
@@ -127,8 +120,7 @@ function uaf_send_fonts_beaver_builder_list($fonts){
|
|
127 |
// Themify Builder
|
128 |
add_filter('themify_get_web_safe_font_list', 'uaf_send_fonts_themify_builder_list',10,2);
|
129 |
function uaf_send_fonts_themify_builder_list($fonts){
|
130 |
-
$
|
131 |
-
$fontsData = json_decode($fontsRawData, true);
|
132 |
$fonts_uaf = array();
|
133 |
if (!empty($fontsData)):
|
134 |
foreach ($fontsData as $key=>$fontData):
|
2 |
// DEFAULT WORDPRESS EDITOR
|
3 |
function uaf_mce_before_init( $init_array ) {
|
4 |
$theme_advanced_fonts = '';
|
5 |
+
$fontsData = get_uploaded_font_list();
|
|
|
6 |
if (!empty($fontsData)):
|
7 |
foreach ($fontsData as $key=>$fontData):
|
8 |
$theme_advanced_fonts .= ucfirst(str_replace('_',' ', $fontData['font_name'])) .'='.$fontData['font_name'].';';
|
19 |
return $options;
|
20 |
}
|
21 |
|
22 |
+
// DIVI CUSTOMIZER AND BUILDER (Tested with 4.0.9 and 4.0.9)
|
23 |
add_filter('et_websafe_fonts', 'uaf_send_fonts_divi_list',10,2);
|
24 |
function uaf_send_fonts_divi_list($fonts){
|
25 |
+
$fontsData = get_uploaded_font_list();
|
|
|
26 |
$fonts_uaf = array();
|
27 |
if (!empty($fontsData)):
|
28 |
foreach ($fontsData as $key=>$fontData):
|
39 |
// SITE ORIGIN BUILDER
|
40 |
add_filter('siteorigin_widgets_font_families', 'uaf_send_fonts_siteorigin_list',10,2);
|
41 |
function uaf_send_fonts_siteorigin_list($fonts){
|
42 |
+
$fontsData = get_uploaded_font_list();
|
|
|
43 |
$fonts_uaf = array();
|
44 |
if (!empty($fontsData)):
|
45 |
foreach ($fontsData as $key=>$fontData):
|
56 |
}
|
57 |
|
58 |
function uaf_send_fonts_redux_list( $custom_fonts ) {
|
59 |
+
$fontsData = get_uploaded_font_list();
|
|
|
60 |
$fonts_uaf = array('Use Any Fonts' => array());
|
61 |
if (!empty($fontsData)):
|
62 |
foreach ($fontsData as $key=>$fontData):
|
70 |
// X Theme
|
71 |
add_filter('x_fonts_data', 'uaf_send_fonts_x_theme_list',10,2);
|
72 |
function uaf_send_fonts_x_theme_list($fonts){
|
73 |
+
$fontsData = get_uploaded_font_list();
|
|
|
74 |
$fonts_uaf = array();
|
75 |
if (!empty($fontsData)):
|
76 |
foreach ($fontsData as $key=>$fontData):
|
87 |
|
88 |
// ELEMENTOR
|
89 |
function uaf_send_fonts_elementor_list( $controls_registry ) {
|
90 |
+
$fontsData = get_uploaded_font_list();
|
|
|
91 |
$fonts_uaf = array('Use Any Fonts' => array());
|
92 |
if (!empty($fontsData)):
|
93 |
foreach ($fontsData as $key=>$fontData):
|
101 |
}
|
102 |
add_action( 'elementor/controls/controls_registered', 'uaf_send_fonts_elementor_list', 10, 1 );
|
103 |
|
104 |
+
// Beaver Builder (Tested with 2.3.0.1 )
|
105 |
add_filter('fl_builder_font_families_system', 'uaf_send_fonts_beaver_builder_list',10,2);
|
106 |
function uaf_send_fonts_beaver_builder_list($fonts){
|
107 |
+
$fontsData = get_uploaded_font_list();
|
|
|
108 |
$fonts_uaf = array();
|
109 |
if (!empty($fontsData)):
|
110 |
foreach ($fontsData as $key=>$fontData):
|
120 |
// Themify Builder
|
121 |
add_filter('themify_get_web_safe_font_list', 'uaf_send_fonts_themify_builder_list',10,2);
|
122 |
function uaf_send_fonts_themify_builder_list($fonts){
|
123 |
+
$fontsData = get_uploaded_font_list();
|
|
|
124 |
$fonts_uaf = array();
|
125 |
if (!empty($fontsData)):
|
126 |
foreach ($fontsData as $key=>$fontData):
|
includes/uaf_font_implement.php
CHANGED
@@ -155,7 +155,7 @@ $fontsImplementData = json_decode($fontsImplementRawData, true);
|
|
155 |
?>
|
156 |
<tr>
|
157 |
<td><?php echo $sn; ?></td>
|
158 |
-
<td><?php echo
|
159 |
<td><?php echo $fontImplementData['font_elements'] ?></td>
|
160 |
<td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="admin.php?page=uaf_settings_page&delete_implement_key=<?php echo $key; ?>">Delete</a></td>
|
161 |
</tr>
|
155 |
?>
|
156 |
<tr>
|
157 |
<td><?php echo $sn; ?></td>
|
158 |
+
<td><?php echo @$fontsData[$fontImplementData['font_key']]['font_name']; ?></td>
|
159 |
<td><?php echo $fontImplementData['font_elements'] ?></td>
|
160 |
<td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="admin.php?page=uaf_settings_page&delete_implement_key=<?php echo $key; ?>">Delete</a></td>
|
161 |
</tr>
|
includes/uaf_font_upload_js.php
CHANGED
@@ -1,96 +1,15 @@
|
|
1 |
<?php
|
2 |
-
/* *******FONT UPLOAD VIA JS ******** */
|
3 |
-
$allowedFontFormats = array ('ttf','otf','woff');
|
4 |
-
$uaf_api_key = get_option('uaf_api_key');
|
5 |
-
|
6 |
if (isset($_POST['submit-uaf-font'])){
|
7 |
-
$
|
8 |
-
$
|
9 |
-
|
10 |
-
if (!empty($_POST['font_name'])):
|
11 |
-
$fontNameToStore = sanitize_file_name(date('ymdhis').$_POST['font_name']);
|
12 |
-
$fontNameToStoreWithUrl = $fontNameToStore;
|
13 |
-
if (!empty($_POST['convert_response'])):
|
14 |
-
$convertResponseArray = json_decode(stripslashes($_POST['convert_response']), true);
|
15 |
-
if ($convertResponseArray['global']['status'] == 'ok'):
|
16 |
-
$neededFontFormats = array('woff','eot');
|
17 |
-
foreach ($neededFontFormats as $neededFontFormat):
|
18 |
-
if ($convertResponseArray[$neededFontFormat]['status'] == 'ok'):
|
19 |
-
$fontFileContent = '';
|
20 |
-
$fontFileContent = wp_remote_fopen($convertResponseArray[$neededFontFormat]['filename']);
|
21 |
-
if (!empty($fontFileContent)):
|
22 |
-
$newFileName = $fontNameToStore.'.'.$neededFontFormat;
|
23 |
-
$newFilePath = $uaf_upload_dir.$newFileName;
|
24 |
-
$fh = fopen($newFilePath, 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
25 |
-
fwrite($fh, $fontFileContent);
|
26 |
-
fclose($fh);
|
27 |
-
$fontUploadMsg[$neededFontFormat]['status'] = 'ok';
|
28 |
-
$fontUploadMsg[$neededFontFormat]['text'] = "Done";
|
29 |
-
else:
|
30 |
-
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
31 |
-
$fontUploadMsg[$neededFontFormat]['text'] = "Couldn't receive $neededFontFormat file";
|
32 |
-
endif;
|
33 |
-
else:
|
34 |
-
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
35 |
-
$fontUploadMsg[$neededFontFormat]['text'] = "Problem converting to $neededFontFormat format";
|
36 |
-
endif;
|
37 |
-
endforeach;
|
38 |
-
else:
|
39 |
-
$fontUploadFinalStatus = 'error';
|
40 |
-
$fontUploadFinalMsg .= $convertResponseArray['global']['msg'].'<br/>';
|
41 |
-
endif;
|
42 |
-
else:
|
43 |
-
$fontUploadFinalStatus = 'error';
|
44 |
-
$fontUploadFinalMsg = "Convert Response is Empty. Please try again enabling alternative uploader from Additional settings below.";
|
45 |
-
endif;
|
46 |
-
else:
|
47 |
-
$fontUploadFinalStatus = 'error';
|
48 |
-
$fontUploadFinalMsg = "Font Name is empty";
|
49 |
-
endif;
|
50 |
-
|
51 |
-
|
52 |
-
if (!empty($fontUploadMsg)):
|
53 |
-
foreach ($fontUploadMsg as $formatKey => $formatData):
|
54 |
-
if ($formatData['status'] == 'error'):
|
55 |
-
$fontUploadFinalStatus = 'error';
|
56 |
-
$fontUploadFinalMsg .= $formatData['text'].'<br/>';
|
57 |
-
endif;
|
58 |
-
endforeach;
|
59 |
-
endif;
|
60 |
-
|
61 |
-
if ($fontUploadFinalStatus != 'error'):
|
62 |
-
$fontUploadFinalMsg = 'Font Uploaded';
|
63 |
-
endif;
|
64 |
-
|
65 |
-
if ($fontUploadFinalStatus != 'error'):
|
66 |
-
$fontsRawData = get_option('uaf_font_data');
|
67 |
-
$fontsData = json_decode($fontsRawData, true);
|
68 |
-
if (empty($fontsData)):
|
69 |
-
$fontsData = array();
|
70 |
-
endif;
|
71 |
-
|
72 |
-
$fontsData[date('ymdhis')] = array('font_name' => sanitize_title($_POST['font_name']), 'font_path' => $fontNameToStoreWithUrl);
|
73 |
-
$updateFontData = json_encode($fontsData);
|
74 |
-
update_option('uaf_font_data',$updateFontData);
|
75 |
-
uaf_write_css();
|
76 |
-
endif;
|
77 |
}
|
78 |
-
|
79 |
-
if (isset($_GET['delete_font_key'])):
|
80 |
-
$fontsRawData = get_option('uaf_font_data');
|
81 |
-
$fontsData = json_decode($fontsRawData, true);
|
82 |
-
$key_to_delete = $_GET['delete_font_key'];
|
83 |
-
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.woff'));
|
84 |
-
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.eot'));
|
85 |
-
unset($fontsData[$key_to_delete]);
|
86 |
-
$updateFontData = json_encode($fontsData);
|
87 |
-
update_option('uaf_font_data',$updateFontData);
|
88 |
-
$fontUploadFinalStatus = 'updated';
|
89 |
-
$fontUploadFinalMsg = 'Font Deleted';
|
90 |
-
uaf_write_css();
|
91 |
-
endif;
|
92 |
?>
|
93 |
|
|
|
|
|
|
|
|
|
94 |
<table class="wp-list-table widefat fixed bookmarks">
|
95 |
<thead>
|
96 |
<tr>
|
@@ -101,15 +20,6 @@ endif;
|
|
101 |
<tr>
|
102 |
<td>
|
103 |
|
104 |
-
<?php if (!empty($fontUploadFinalMsg)):?>
|
105 |
-
<div class="<?php echo $fontUploadFinalStatus; ?>" id="message"><p><?php echo $fontUploadFinalMsg ?></p></div>
|
106 |
-
<?php endif; ?>
|
107 |
-
|
108 |
-
<?php
|
109 |
-
$fontsRawData = get_option('uaf_font_data');
|
110 |
-
$fontsData = json_decode($fontsRawData, true);
|
111 |
-
?>
|
112 |
-
|
113 |
<p align="right"><input type="button" name="open_add_font" onClick="open_add_font();" class="button-primary" value="Add Fonts" /><br/></p>
|
114 |
|
115 |
<div id="font-upload" style="display:none;">
|
@@ -125,7 +35,7 @@ $fontsData = json_decode($fontsRawData, true);
|
|
125 |
<?php
|
126 |
|
127 |
?>
|
128 |
-
<em>Accepted Font Format : <?php echo join(", ",$allowedFontFormats); ?> | Font Size: Upto
|
129 |
|
130 |
</td>
|
131 |
</tr>
|
@@ -135,10 +45,12 @@ $fontsData = json_decode($fontsRawData, true);
|
|
135 |
</td>
|
136 |
<td>
|
137 |
<input type="hidden" name="url" value="<?php echo home_url(); ?>" />
|
138 |
-
<input type="hidden" name="api_key" value="<?php echo $uaf_api_key; ?>" />
|
139 |
-
<input type="hidden" name="font_count" value="<?php echo
|
140 |
<input type="hidden" name="convert_response" id="convert_response" value="" />
|
|
|
141 |
<input type="submit" name="submit-uaf-font" id="submit-uaf-font" class="button-primary" value="Upload" />
|
|
|
142 |
<div id="font_upload_message" class=""></div>
|
143 |
<p>By clicking on Upload, you confirm that you have rights to use this font.</p>
|
144 |
</td>
|
@@ -148,36 +60,7 @@ $fontsData = json_decode($fontsRawData, true);
|
|
148 |
<br/><br/>
|
149 |
</div>
|
150 |
|
151 |
-
|
152 |
-
<thead>
|
153 |
-
<tr>
|
154 |
-
<th width="20">Sn</th>
|
155 |
-
<th>Font</th>
|
156 |
-
<th width="100">Delete</th>
|
157 |
-
</tr>
|
158 |
-
</thead>
|
159 |
-
|
160 |
-
<tbody>
|
161 |
-
<?php if (!empty($fontsData)): ?>
|
162 |
-
<?php
|
163 |
-
$sn = 0;
|
164 |
-
foreach ($fontsData as $key=>$fontData):
|
165 |
-
$sn++
|
166 |
-
?>
|
167 |
-
<tr>
|
168 |
-
<td><?php echo $sn; ?></td>
|
169 |
-
<td><?php echo $fontData['font_name'] ?></td>
|
170 |
-
<td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="admin.php?page=uaf_settings_page&delete_font_key=<?php echo $key; ?>">Delete</a></td>
|
171 |
-
</tr>
|
172 |
-
<?php endforeach; ?>
|
173 |
-
<?php else: ?>
|
174 |
-
<tr>
|
175 |
-
<td colspan="3">No font found. Please click on Add Fonts to add font</td>
|
176 |
-
</tr>
|
177 |
-
<?php endif; ?>
|
178 |
-
</tbody>
|
179 |
-
|
180 |
-
</table>
|
181 |
|
182 |
<script>
|
183 |
function open_add_font(){
|
@@ -192,18 +75,19 @@ $fontsData = json_decode($fontsRawData, true);
|
|
192 |
</table>
|
193 |
<br/>
|
194 |
<script>
|
195 |
-
jQuery('#open_add_font_form')
|
196 |
-
|
197 |
var $formValid = jQuery(this);
|
198 |
if(! $formValid.valid()) return false;
|
199 |
|
|
|
|
|
200 |
jQuery.ajax( {
|
201 |
-
url: '<?php echo
|
202 |
type: 'POST',
|
203 |
data: new FormData( this ),
|
204 |
processData: false,
|
205 |
contentType: false,
|
206 |
-
async: false,
|
207 |
beforeSend : function(){
|
208 |
jQuery('#submit-uaf-font').attr('disabled',true);
|
209 |
jQuery('#font_upload_message').attr('class','ok');
|
@@ -218,22 +102,19 @@ jQuery('#open_add_font_form')
|
|
218 |
if (status == 'error'){
|
219 |
jQuery('#font_upload_message').attr('class',status);
|
220 |
jQuery('#font_upload_message').html(msg);
|
221 |
-
e.preventDefault();
|
222 |
} else {
|
223 |
woffStatus = dataReturn.woff.status;
|
224 |
-
|
225 |
-
if (woffStatus == 'ok' &&
|
226 |
-
woffFilePath = dataReturn.woff.filename;
|
227 |
-
eotFilePath = dataReturn.eot.filename;
|
228 |
jQuery('#convert_response').val(data);
|
229 |
jQuery('#font_upload_message').attr('class','ok');
|
230 |
jQuery('#font_upload_message').html('Font Conversion Complete. Finalizing...');
|
231 |
jQuery('#submit-uaf-font').attr('disabled',false);
|
232 |
jQuery('#fontfile').remove();
|
|
|
233 |
} else {
|
234 |
jQuery('#font_upload_message').attr('class','error');
|
235 |
jQuery('#font_upload_message').html('Problem converting font to woff/eot.');
|
236 |
-
e.preventDefault();
|
237 |
}
|
238 |
}
|
239 |
},
|
@@ -242,9 +123,7 @@ jQuery('#open_add_font_form')
|
|
242 |
jQuery('#font_upload_message').attr('class','error');
|
243 |
jQuery('#font_upload_message').html('Unexpected Error Occured.');
|
244 |
jQuery('#submit-uaf-font').attr('disabled',false);
|
245 |
-
e.preventDefault();
|
246 |
}
|
247 |
});
|
248 |
-
// e.preventDefault();
|
249 |
});
|
250 |
</script>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
if (isset($_POST['submit-uaf-font'])){
|
3 |
+
$fontSaveResponse = uaf_save_font_files($_POST['font_name'], $_POST['convert_response']);
|
4 |
+
$operationStatus = $fontSaveResponse['status'];
|
5 |
+
$operationMsg = $fontSaveResponse['body'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
?>
|
8 |
|
9 |
+
<?php if (!empty($operationMsg)):?>
|
10 |
+
<div class="updated <?php echo $operationStatus; ?>" id="message"><p><?php echo $operationMsg ?></p></div>
|
11 |
+
<?php endif; ?>
|
12 |
+
|
13 |
<table class="wp-list-table widefat fixed bookmarks">
|
14 |
<thead>
|
15 |
<tr>
|
20 |
<tr>
|
21 |
<td>
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
<p align="right"><input type="button" name="open_add_font" onClick="open_add_font();" class="button-primary" value="Add Fonts" /><br/></p>
|
24 |
|
25 |
<div id="font-upload" style="display:none;">
|
35 |
<?php
|
36 |
|
37 |
?>
|
38 |
+
<em>Accepted Font Format : <?php echo join(", ",$GLOBALS['allowedFontFormats']); ?> | Font Size: Upto <?php echo $GLOBALS['allowedFontSize'] ?> MB</em><br/>
|
39 |
|
40 |
</td>
|
41 |
</tr>
|
45 |
</td>
|
46 |
<td>
|
47 |
<input type="hidden" name="url" value="<?php echo home_url(); ?>" />
|
48 |
+
<input type="hidden" name="api_key" value="<?php echo $GLOBALS['uaf_api_key']; ?>" />
|
49 |
+
<input type="hidden" name="font_count" value="<?php echo count_uploaded_fonts(); ?>" />
|
50 |
<input type="hidden" name="convert_response" id="convert_response" value="" />
|
51 |
+
<input type="hidden" name="submit-uaf-font" id="submit-uaf-font" value="Upload" />
|
52 |
<input type="submit" name="submit-uaf-font" id="submit-uaf-font" class="button-primary" value="Upload" />
|
53 |
+
|
54 |
<div id="font_upload_message" class=""></div>
|
55 |
<p>By clicking on Upload, you confirm that you have rights to use this font.</p>
|
56 |
</td>
|
60 |
<br/><br/>
|
61 |
</div>
|
62 |
|
63 |
+
<?php include('uaf_uploaded_font_list.php'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
<script>
|
66 |
function open_add_font(){
|
75 |
</table>
|
76 |
<br/>
|
77 |
<script>
|
78 |
+
jQuery('#open_add_font_form').submit(function(e){
|
79 |
+
|
80 |
var $formValid = jQuery(this);
|
81 |
if(! $formValid.valid()) return false;
|
82 |
|
83 |
+
e.preventDefault();
|
84 |
+
|
85 |
jQuery.ajax( {
|
86 |
+
url: '<?php echo uaf_get_server_url(); ?>/uaf_convertor/convert.php',
|
87 |
type: 'POST',
|
88 |
data: new FormData( this ),
|
89 |
processData: false,
|
90 |
contentType: false,
|
|
|
91 |
beforeSend : function(){
|
92 |
jQuery('#submit-uaf-font').attr('disabled',true);
|
93 |
jQuery('#font_upload_message').attr('class','ok');
|
102 |
if (status == 'error'){
|
103 |
jQuery('#font_upload_message').attr('class',status);
|
104 |
jQuery('#font_upload_message').html(msg);
|
|
|
105 |
} else {
|
106 |
woffStatus = dataReturn.woff.status;
|
107 |
+
woff2Status = dataReturn.woff2.status;
|
108 |
+
if (woffStatus == 'ok' && woff2Status == 'ok'){
|
|
|
|
|
109 |
jQuery('#convert_response').val(data);
|
110 |
jQuery('#font_upload_message').attr('class','ok');
|
111 |
jQuery('#font_upload_message').html('Font Conversion Complete. Finalizing...');
|
112 |
jQuery('#submit-uaf-font').attr('disabled',false);
|
113 |
jQuery('#fontfile').remove();
|
114 |
+
e.currentTarget.submit();
|
115 |
} else {
|
116 |
jQuery('#font_upload_message').attr('class','error');
|
117 |
jQuery('#font_upload_message').html('Problem converting font to woff/eot.');
|
|
|
118 |
}
|
119 |
}
|
120 |
},
|
123 |
jQuery('#font_upload_message').attr('class','error');
|
124 |
jQuery('#font_upload_message').html('Unexpected Error Occured.');
|
125 |
jQuery('#submit-uaf-font').attr('disabled',false);
|
|
|
126 |
}
|
127 |
});
|
|
|
128 |
});
|
129 |
</script>
|
includes/uaf_font_upload_php.php
CHANGED
@@ -1,130 +1,18 @@
|
|
1 |
<?php
|
2 |
-
/* *******FONT UPLOAD VIA PHP ******** */
|
3 |
-
$allowedFontFormats = array ('ttf','otf','woff');
|
4 |
-
$allowedFontSize = 15;
|
5 |
-
$wpAllowedMaxSize = wp_max_upload_size();
|
6 |
-
$wpAllowedMaxSizeToMB = $wpAllowedMaxSize / 1048576 ;
|
7 |
-
if ($wpAllowedMaxSizeToMB < $allowedFontSize){
|
8 |
-
$allowedFontSize = $wpAllowedMaxSizeToMB;
|
9 |
-
}
|
10 |
-
$allowedFontSizeinBytes = $allowedFontSize * 1024 * 1024; // 10 MB to bytes
|
11 |
-
|
12 |
if (isset($_POST['submit-uaf-font'])){
|
13 |
-
$
|
14 |
-
|
15 |
-
|
16 |
-
$file_extension = strtolower($font_file_details['extension']);
|
17 |
-
$font_size = $_FILES['font_file']['size'];
|
18 |
-
$fontUploadFinalMsg = '';
|
19 |
-
$fontUploadFinalStatus = 'updated';
|
20 |
-
|
21 |
-
if ((in_array($file_extension, $allowedFontFormats)) && ($font_size <= $allowedFontSizeinBytes)){
|
22 |
-
|
23 |
-
$fontNameToStore = sanitize_file_name(date('ymdhis').$font_file_details['filename']);
|
24 |
-
$fontNameToStoreWithUrl = $fontNameToStore;
|
25 |
-
|
26 |
-
// SEND FONT CONERSION REQUEST
|
27 |
-
@set_time_limit(0);
|
28 |
-
$ch = curl_init();
|
29 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
30 |
-
curl_setopt($ch, CURLOPT_URL, $uaf_font_convert_server_url.'/font-convertor/convertor/edd_convert.php');
|
31 |
-
curl_setopt($ch, CURLOPT_POST, true);
|
32 |
-
$post = array(
|
33 |
-
'fontfile' => "@".$_FILES['font_file']['tmp_name'],
|
34 |
-
'fontfileext' => pathinfo($_FILES['font_file']['name'], PATHINFO_EXTENSION),
|
35 |
-
'api_key' => $uaf_api_key,
|
36 |
-
'url' => $_POST['url'],
|
37 |
-
'font_count' => $_POST['font_count']
|
38 |
-
);
|
39 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
40 |
-
$convertResponse = curl_exec($ch);
|
41 |
-
if(curl_errno($ch)) {
|
42 |
-
echo 'Error: ' . curl_error($ch);
|
43 |
-
exit();
|
44 |
-
}
|
45 |
-
else {
|
46 |
-
$CrulStatinfo = curl_getinfo($ch);
|
47 |
-
if ($CrulStatinfo['http_code'] == '200'):
|
48 |
-
$convertResponseArray = json_decode($convertResponse, true);
|
49 |
-
if ($convertResponseArray['global']['status'] == 'ok'):
|
50 |
-
$neededFontFormats = array('woff','eot');
|
51 |
-
foreach ($neededFontFormats as $neededFontFormat):
|
52 |
-
if ($convertResponseArray[$neededFontFormat]['status'] == 'ok'):
|
53 |
-
$fontFileContent = '';
|
54 |
-
$fontFileContent = wp_remote_fopen($convertResponseArray[$neededFontFormat]['filename']);
|
55 |
-
if (!empty($fontFileContent)):
|
56 |
-
$newFileName = $fontNameToStore.'.'.$neededFontFormat;
|
57 |
-
$newFilePath = $uaf_upload_dir.$newFileName;
|
58 |
-
$fh = fopen($newFilePath, 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
59 |
-
fwrite($fh, $fontFileContent);
|
60 |
-
fclose($fh);
|
61 |
-
$fontUploadMsg[$neededFontFormat]['status'] = 'ok';
|
62 |
-
$fontUploadMsg[$neededFontFormat]['text'] = "Done";
|
63 |
-
else:
|
64 |
-
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
65 |
-
$fontUploadMsg[$neededFontFormat]['text'] = "Couldn't receive $neededFontFormat file";
|
66 |
-
endif;
|
67 |
-
else:
|
68 |
-
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
69 |
-
$fontUploadMsg[$neededFontFormat]['text'] = "Problem converting to $neededFontFormat format";
|
70 |
-
endif;
|
71 |
-
endforeach;
|
72 |
-
else:
|
73 |
-
$fontUploadFinalStatus = 'error';
|
74 |
-
$fontUploadFinalMsg .= $convertResponseArray['global']['msg'].'<br/>';
|
75 |
-
endif;
|
76 |
-
else:
|
77 |
-
$fontUploadFinalStatus = 'error';
|
78 |
-
$fontUploadFinalMsg = $convertResponse;
|
79 |
-
endif;
|
80 |
-
}
|
81 |
-
|
82 |
-
if (!empty($fontUploadMsg)):
|
83 |
-
foreach ($fontUploadMsg as $formatKey => $formatData):
|
84 |
-
if ($formatData['status'] == 'error'):
|
85 |
-
$fontUploadFinalStatus = 'error';
|
86 |
-
$fontUploadFinalMsg .= $formatData['text'].'<br/>';
|
87 |
-
endif;
|
88 |
-
endforeach;
|
89 |
-
endif;
|
90 |
-
|
91 |
-
if ($fontUploadFinalStatus != 'error'):
|
92 |
-
$fontUploadFinalMsg = 'Font Uploaded';
|
93 |
-
endif;
|
94 |
-
|
95 |
-
if ($fontUploadFinalStatus != 'error'):
|
96 |
-
$fontsRawData = get_option('uaf_font_data');
|
97 |
-
$fontsData = json_decode($fontsRawData, true);
|
98 |
-
if (empty($fontsData)):
|
99 |
-
$fontsData = array();
|
100 |
-
endif;
|
101 |
-
|
102 |
-
$fontsData[date('ymdhis')] = array('font_name' => sanitize_title($_POST['font_name']), 'font_path' => $fontNameToStoreWithUrl);
|
103 |
-
$updateFontData = json_encode($fontsData);
|
104 |
-
update_option('uaf_font_data',$updateFontData);
|
105 |
-
uaf_write_css();
|
106 |
-
endif;
|
107 |
-
} else {
|
108 |
-
$fontUploadFinalStatus = 'error';
|
109 |
-
$fontUploadFinalMsg = 'Only '.join(", ",$allowedFontFormats).' format and font less than '.$allowedFontSize.' Mb accepted';
|
110 |
}
|
|
|
|
|
111 |
}
|
112 |
-
|
113 |
-
if (isset($_GET['delete_font_key'])):
|
114 |
-
$fontsRawData = get_option('uaf_font_data');
|
115 |
-
$fontsData = json_decode($fontsRawData, true);
|
116 |
-
$key_to_delete = $_GET['delete_font_key'];
|
117 |
-
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.woff'));
|
118 |
-
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.eot'));
|
119 |
-
unset($fontsData[$key_to_delete]);
|
120 |
-
$updateFontData = json_encode($fontsData);
|
121 |
-
update_option('uaf_font_data',$updateFontData);
|
122 |
-
$fontUploadFinalStatus = 'updated';
|
123 |
-
$fontUploadFinalMsg = 'Font Deleted';
|
124 |
-
uaf_write_css();
|
125 |
-
endif;
|
126 |
?>
|
127 |
|
|
|
|
|
|
|
|
|
128 |
<table class="wp-list-table widefat fixed bookmarks">
|
129 |
<thead>
|
130 |
<tr>
|
@@ -134,16 +22,6 @@ endif;
|
|
134 |
<tbody>
|
135 |
<tr>
|
136 |
<td>
|
137 |
-
|
138 |
-
<?php if (!empty($fontUploadFinalMsg)):?>
|
139 |
-
<div class="<?php echo $fontUploadFinalStatus; ?>" id="message"><p><?php echo $fontUploadFinalMsg ?></p></div>
|
140 |
-
<?php endif; ?>
|
141 |
-
|
142 |
-
<?php
|
143 |
-
$fontsRawData = get_option('uaf_font_data');
|
144 |
-
$fontsData = json_decode($fontsRawData, true);
|
145 |
-
?>
|
146 |
-
|
147 |
<p align="right"><input type="button" name="open_add_font" onClick="open_add_font();" class="button-primary" value="Add Fonts" /><br/></p>
|
148 |
|
149 |
<div id="font-upload" style="display:none;">
|
@@ -159,7 +37,7 @@ $fontsData = json_decode($fontsRawData, true);
|
|
159 |
<?php
|
160 |
|
161 |
?>
|
162 |
-
<em>Accepted Font Format : <?php echo join(", ",$allowedFontFormats); ?> | Font Size: Upto <?php echo
|
163 |
|
164 |
</td>
|
165 |
</tr>
|
@@ -171,7 +49,7 @@ $fontsData = json_decode($fontsRawData, true);
|
|
171 |
|
172 |
<input type="hidden" name="url" value="<?php echo home_url(); ?>" />
|
173 |
<input type="hidden" name="api_key" value="<?php echo $uaf_api_key; ?>" />
|
174 |
-
<input type="hidden" name="font_count" value="<?php echo
|
175 |
<input type="submit" name="submit-uaf-font" class="button-primary" value="Upload" />
|
176 |
|
177 |
|
@@ -183,36 +61,7 @@ $fontsData = json_decode($fontsRawData, true);
|
|
183 |
<br/><br/>
|
184 |
</div>
|
185 |
|
186 |
-
|
187 |
-
<thead>
|
188 |
-
<tr>
|
189 |
-
<th width="20">Sn</th>
|
190 |
-
<th>Font</th>
|
191 |
-
<th width="100">Delete</th>
|
192 |
-
</tr>
|
193 |
-
</thead>
|
194 |
-
|
195 |
-
<tbody>
|
196 |
-
<?php if (!empty($fontsData)): ?>
|
197 |
-
<?php
|
198 |
-
$sn = 0;
|
199 |
-
foreach ($fontsData as $key=>$fontData):
|
200 |
-
$sn++
|
201 |
-
?>
|
202 |
-
<tr>
|
203 |
-
<td><?php echo $sn; ?></td>
|
204 |
-
<td><?php echo $fontData['font_name'] ?></td>
|
205 |
-
<td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="admin.php?page=uaf_settings_page&delete_font_key=<?php echo $key; ?>">Delete</a></td>
|
206 |
-
</tr>
|
207 |
-
<?php endforeach; ?>
|
208 |
-
<?php else: ?>
|
209 |
-
<tr>
|
210 |
-
<td colspan="3">No font found. Please click on Add Fonts to add font</td>
|
211 |
-
</tr>
|
212 |
-
<?php endif; ?>
|
213 |
-
</tbody>
|
214 |
-
|
215 |
-
</table>
|
216 |
|
217 |
<script>
|
218 |
function open_add_font(){
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
if (isset($_POST['submit-uaf-font'])){
|
3 |
+
$fontUploadResponse = uaf_upload_font_to_server();
|
4 |
+
if ($fontUploadResponse['status'] == 'success'){
|
5 |
+
$fontUploadResponse = uaf_save_font_files($_POST['font_name'], $fontUploadResponse['body']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
+
$operationStatus = $fontUploadResponse['status'];
|
8 |
+
$operationMsg = $fontUploadResponse['body'];
|
9 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
?>
|
11 |
|
12 |
+
<?php if (!empty($operationMsg)):?>
|
13 |
+
<div class="updated <?php echo $operationStatus; ?>" id="message"><p><?php echo $operationMsg ?></p></div>
|
14 |
+
<?php endif; ?>
|
15 |
+
|
16 |
<table class="wp-list-table widefat fixed bookmarks">
|
17 |
<thead>
|
18 |
<tr>
|
22 |
<tbody>
|
23 |
<tr>
|
24 |
<td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
<p align="right"><input type="button" name="open_add_font" onClick="open_add_font();" class="button-primary" value="Add Fonts" /><br/></p>
|
26 |
|
27 |
<div id="font-upload" style="display:none;">
|
37 |
<?php
|
38 |
|
39 |
?>
|
40 |
+
<em>Accepted Font Format : <?php echo join(", ",$GLOBALS['allowedFontFormats']); ?> | Font Size: Upto <?php echo uaf_max_upload_size_for_php(); ?>MB</em><br/>
|
41 |
|
42 |
</td>
|
43 |
</tr>
|
49 |
|
50 |
<input type="hidden" name="url" value="<?php echo home_url(); ?>" />
|
51 |
<input type="hidden" name="api_key" value="<?php echo $uaf_api_key; ?>" />
|
52 |
+
<input type="hidden" name="font_count" value="<?php echo count_uploaded_fonts(); ?>" />
|
53 |
<input type="submit" name="submit-uaf-font" class="button-primary" value="Upload" />
|
54 |
|
55 |
|
61 |
<br/><br/>
|
62 |
</div>
|
63 |
|
64 |
+
<?php include('uaf_uploaded_font_list.php'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
<script>
|
67 |
function open_add_font(){
|
includes/uaf_footer.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
-
$server_status =
|
3 |
if (isset($_POST['test_server']) || empty($server_status)){
|
4 |
if (in_array ('curl', get_loaded_extensions())) {
|
5 |
$test_code = date('ymdhis');
|
6 |
$ch_test = curl_init();
|
7 |
curl_setopt($ch_test, CURLOPT_RETURNTRANSFER, true);
|
8 |
-
curl_setopt($ch_test, CURLOPT_URL,
|
9 |
curl_setopt($ch_test, CURLOPT_POST, true);
|
10 |
$post = array(
|
11 |
'test_code' => $test_code
|
@@ -37,10 +37,9 @@ if (isset($_POST['test_server']) || empty($server_status)){
|
|
37 |
}
|
38 |
update_option('uaf_server_status', $server_err_stat);
|
39 |
update_option('uaf_server_msg', $server_err_msg);
|
|
|
|
|
40 |
}
|
41 |
-
$server_status = get_option('uaf_server_status');
|
42 |
-
$server_message = get_option('uaf_server_msg');
|
43 |
-
|
44 |
?>
|
45 |
|
46 |
<?php if (!empty($settings_message)):?>
|
@@ -59,25 +58,25 @@ $server_message = get_option('uaf_server_msg');
|
|
59 |
<form method="post" action="">
|
60 |
<tr>
|
61 |
<td>
|
62 |
-
<input type="checkbox" name="uaf_use_alternative_server" value="1" <?php echo $uaf_use_alternative_server == 1?'checked=checked':''; ?> /> Use alternative server. <em>Only use when you are unable to upload the font using both Default Js and PHP Uploader or verify API key.</em>
|
63 |
</td>
|
64 |
</tr>
|
65 |
|
66 |
<tr>
|
67 |
<td>
|
68 |
-
<input type="checkbox" name="uaf_use_curl_uploader" value="1" <?php echo $
|
69 |
</td>
|
70 |
</tr>
|
71 |
|
72 |
<tr>
|
73 |
<td>
|
74 |
-
<input type="checkbox" name="uaf_use_absolute_font_path" value="1" <?php echo $uaf_use_absolute_font_path == 1?'checked=checked':''; ?> /> Use absolute path for font.
|
75 |
</td>
|
76 |
</tr>
|
77 |
|
78 |
<tr>
|
79 |
<td>
|
80 |
-
<input type="checkbox" name="uaf_disbale_editor_font_list" value="1" <?php echo $
|
81 |
</td>
|
82 |
</tr>
|
83 |
|
@@ -129,7 +128,7 @@ $server_message = get_option('uaf_server_msg');
|
|
129 |
</td>
|
130 |
<td width="15"> </td>
|
131 |
<td width="250" valign="top">
|
132 |
-
<?php if ($
|
133 |
<table class="wp-list-table widefat fixed bookmarks">
|
134 |
<thead>
|
135 |
<tr>
|
@@ -139,12 +138,12 @@ $server_message = get_option('uaf_server_msg');
|
|
139 |
<tbody>
|
140 |
<tr>
|
141 |
<td>
|
142 |
-
<div id="server_status" class="<?php echo $
|
143 |
-
<?php echo str_replace('_',' ',$
|
144 |
</div>
|
145 |
|
146 |
-
<?php if ($
|
147 |
-
<div class="uaf_test_msg"><?php echo $
|
148 |
<?php endif; ?>
|
149 |
|
150 |
|
@@ -172,8 +171,7 @@ $server_message = get_option('uaf_server_msg');
|
|
172 |
<li><a href="http://goo.gl/NYtZsX" target="_blank">Setup Instructions</a></li>
|
173 |
<li><a href="http://goo.gl/FcC7EL" target="_blank">Quick Virtual Support</a></li>
|
174 |
<li><a href="http://goo.gl/XgEqzn" target="_blank">Support Forum</a></li>
|
175 |
-
<li><a href="http://goo.gl/MKg7VS" target="_blank">Rectify My Problem</a></li>
|
176 |
-
<li><a href="http://goo.gl/Id7yAo" target="_blank">Contact Us</a></li>
|
177 |
</ul>
|
178 |
</td>
|
179 |
</tr>
|
@@ -183,7 +181,7 @@ $server_message = get_option('uaf_server_msg');
|
|
183 |
<table class="wp-list-table widefat fixed bookmarks">
|
184 |
<thead>
|
185 |
<tr>
|
186 |
-
<th>
|
187 |
</tr>
|
188 |
</thead>
|
189 |
<tbody>
|
@@ -238,4 +236,4 @@ $server_message = get_option('uaf_server_msg');
|
|
238 |
</td>
|
239 |
</tr>
|
240 |
</table>
|
241 |
-
</div>
|
1 |
<?php
|
2 |
+
$server_status = $GLOBALS['uaf_server_status'];
|
3 |
if (isset($_POST['test_server']) || empty($server_status)){
|
4 |
if (in_array ('curl', get_loaded_extensions())) {
|
5 |
$test_code = date('ymdhis');
|
6 |
$ch_test = curl_init();
|
7 |
curl_setopt($ch_test, CURLOPT_RETURNTRANSFER, true);
|
8 |
+
curl_setopt($ch_test, CURLOPT_URL, uaf_get_server_url().'/uaf_convertor/php_server_check.php');
|
9 |
curl_setopt($ch_test, CURLOPT_POST, true);
|
10 |
$post = array(
|
11 |
'test_code' => $test_code
|
37 |
}
|
38 |
update_option('uaf_server_status', $server_err_stat);
|
39 |
update_option('uaf_server_msg', $server_err_msg);
|
40 |
+
$GLOBALS['uaf_server_status'] = $server_err_stat;
|
41 |
+
$GLOBALS['uaf_server_msg'] = $server_err_msg;
|
42 |
}
|
|
|
|
|
|
|
43 |
?>
|
44 |
|
45 |
<?php if (!empty($settings_message)):?>
|
58 |
<form method="post" action="">
|
59 |
<tr>
|
60 |
<td>
|
61 |
+
<input type="checkbox" name="uaf_use_alternative_server" value="1" <?php echo $GLOBALS['uaf_use_alternative_server'] == 1?'checked=checked':''; ?> /> Use alternative server. <em>Only use when you are unable to upload the font using both Default Js and PHP Uploader or verify API key.</em>
|
62 |
</td>
|
63 |
</tr>
|
64 |
|
65 |
<tr>
|
66 |
<td>
|
67 |
+
<input type="checkbox" name="uaf_use_curl_uploader" value="1" <?php echo $GLOBALS['uaf_use_curl_uploader'] == 1?'checked=checked':''; ?> /> Use PHP uploader. <em>Need PHP Curl.</em>
|
68 |
</td>
|
69 |
</tr>
|
70 |
|
71 |
<tr>
|
72 |
<td>
|
73 |
+
<input type="checkbox" name="uaf_use_absolute_font_path" value="1" <?php echo $GLOBALS['uaf_use_absolute_font_path'] == 1?'checked=checked':''; ?> /> Use absolute path for font.
|
74 |
</td>
|
75 |
</tr>
|
76 |
|
77 |
<tr>
|
78 |
<td>
|
79 |
+
<input type="checkbox" name="uaf_disbale_editor_font_list" value="1" <?php echo $GLOBALS['uaf_disbale_editor_font_list'] == 1?'checked=checked':''; ?> /> Disable Font list in wordpress editor. <em>When you have conflict with wordpress editor.</em>
|
80 |
</td>
|
81 |
</tr>
|
82 |
|
128 |
</td>
|
129 |
<td width="15"> </td>
|
130 |
<td width="250" valign="top">
|
131 |
+
<?php if ($GLOBALS['uaf_use_curl_uploader'] == 1): ?>
|
132 |
<table class="wp-list-table widefat fixed bookmarks">
|
133 |
<thead>
|
134 |
<tr>
|
138 |
<tbody>
|
139 |
<tr>
|
140 |
<td>
|
141 |
+
<div id="server_status" class="<?php echo $GLOBALS['uaf_server_status']; ?>">
|
142 |
+
<?php echo str_replace('_',' ',$GLOBALS['uaf_server_status']); ?>
|
143 |
</div>
|
144 |
|
145 |
+
<?php if ($GLOBALS['uaf_server_status'] == 'test_error'): ?>
|
146 |
+
<div class="uaf_test_msg"><?php echo $GLOBALS['uaf_server_msg']; ?></div>
|
147 |
<?php endif; ?>
|
148 |
|
149 |
|
171 |
<li><a href="http://goo.gl/NYtZsX" target="_blank">Setup Instructions</a></li>
|
172 |
<li><a href="http://goo.gl/FcC7EL" target="_blank">Quick Virtual Support</a></li>
|
173 |
<li><a href="http://goo.gl/XgEqzn" target="_blank">Support Forum</a></li>
|
174 |
+
<li><a href="http://goo.gl/MKg7VS" target="_blank">Rectify My Problem / Contact Us</a></li>
|
|
|
175 |
</ul>
|
176 |
</td>
|
177 |
</tr>
|
181 |
<table class="wp-list-table widefat fixed bookmarks">
|
182 |
<thead>
|
183 |
<tr>
|
184 |
+
<th>Some Other Plugins</th>
|
185 |
</tr>
|
186 |
</thead>
|
187 |
<tbody>
|
236 |
</td>
|
237 |
</tr>
|
238 |
</table>
|
239 |
+
</div>
|
includes/uaf_functions.php
ADDED
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// MOVING OLD FONTFILE PATH TO NEW PATH
|
3 |
+
function uaf_move_file_to_newPath(){
|
4 |
+
$uaf_upload = wp_upload_dir();
|
5 |
+
$uaf_upload_dir = $uaf_upload['basedir'];
|
6 |
+
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
7 |
+
$fontsRawData = get_option('uaf_font_data');
|
8 |
+
$fontsData = json_decode($fontsRawData, true);
|
9 |
+
if (!empty($fontsData)):
|
10 |
+
foreach ($fontsData as $key=>$fontData):
|
11 |
+
|
12 |
+
$oldFilePathInfo = pathinfo($fontData['font_path']);
|
13 |
+
$parsedPath = parse_url($fontData['font_path']);
|
14 |
+
$relativeFilePath = $_SERVER['DOCUMENT_ROOT'].$parsedPath['path'];
|
15 |
+
$oldfilename = $oldFilePathInfo['filename'];
|
16 |
+
|
17 |
+
if (file_exists($relativeFilePath.'.woff')){
|
18 |
+
|
19 |
+
$woffFileContent = file_get_contents($relativeFilePath.'.woff');
|
20 |
+
$eotFileContent = file_get_contents($relativeFilePath.'.eot');
|
21 |
+
|
22 |
+
$fhWoff = fopen($uaf_upload_dir.'/'.$oldfilename.'.woff' , 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
23 |
+
fwrite($fhWoff, $woffFileContent);
|
24 |
+
fclose($fhWoff);
|
25 |
+
|
26 |
+
$fhEot = fopen($uaf_upload_dir.'/'.$oldfilename.'.eot' , 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
27 |
+
fwrite($fhEot, $eotFileContent);
|
28 |
+
fclose($fhEot);
|
29 |
+
|
30 |
+
$fontsData[$key]['font_path'] = $oldfilename;
|
31 |
+
}
|
32 |
+
endforeach;
|
33 |
+
endif;
|
34 |
+
|
35 |
+
$updateFontData = json_encode($fontsData);
|
36 |
+
update_option('uaf_font_data',$updateFontData);
|
37 |
+
}
|
38 |
+
|
39 |
+
function uaf_write_css(){
|
40 |
+
$uaf_use_absolute_font_path = $GLOBALS['uaf_use_absolute_font_path']; // Check if user want to use absolute font path.
|
41 |
+
|
42 |
+
if (empty($uaf_use_absolute_font_path)){
|
43 |
+
$uaf_use_absolute_font_path = 0;
|
44 |
+
}
|
45 |
+
|
46 |
+
$uaf_upload_path = uaf_path_details();
|
47 |
+
$uaf_upload_dir = $uaf_upload_path['dir'];
|
48 |
+
$uaf_upload_url = preg_replace('#^https?:#', '', $uaf_upload_path['url']);
|
49 |
+
|
50 |
+
if ($uaf_use_absolute_font_path == 0){ // If user use relative path
|
51 |
+
$url_parts = parse_url($uaf_upload_url);
|
52 |
+
@$uaf_upload_url = "$url_parts[path]$url_parts[query]$url_parts[fragment]";
|
53 |
+
}
|
54 |
+
|
55 |
+
ob_start();
|
56 |
+
$fontsData = get_uploaded_font_list();
|
57 |
+
if (!empty($fontsData)):
|
58 |
+
foreach ($fontsData as $key=>$fontData): ?>
|
59 |
+
@font-face {
|
60 |
+
font-family: '<?php echo $fontData['font_name'] ?>';
|
61 |
+
src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff2') format('woff2'),
|
62 |
+
<?php } ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
|
63 |
+
}
|
64 |
+
|
65 |
+
.<?php echo $fontData['font_name'] ?>{font-family: '<?php echo $fontData['font_name'] ?>' !important;}
|
66 |
+
|
67 |
+
<?php
|
68 |
+
endforeach;
|
69 |
+
endif;
|
70 |
+
|
71 |
+
$fontsImplementRawData = get_option('uaf_font_implement');
|
72 |
+
$fontsImplementData = json_decode($fontsImplementRawData, true);
|
73 |
+
if (!empty($fontsImplementData)):
|
74 |
+
foreach ($fontsImplementData as $key=>$fontImplementData): ?>
|
75 |
+
<?php echo $fontImplementData['font_elements']; ?>{
|
76 |
+
font-family: '<?php echo $fontsData[$fontImplementData['font_key']]['font_name']; ?>' !important;
|
77 |
+
}
|
78 |
+
<?php
|
79 |
+
endforeach;
|
80 |
+
endif;
|
81 |
+
$uaf_style = ob_get_contents();
|
82 |
+
$uafStyleSheetPath = $uaf_upload_path['dir'].'/uaf.css';
|
83 |
+
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
84 |
+
fwrite($fh, $uaf_style);
|
85 |
+
fclose($fh);
|
86 |
+
ob_end_clean();
|
87 |
+
|
88 |
+
ob_start();
|
89 |
+
$fontsData = get_uploaded_font_list();
|
90 |
+
if (!empty($fontsData)):
|
91 |
+
foreach ($fontsData as $key=>$fontData): ?>
|
92 |
+
@font-face {
|
93 |
+
font-family: '<?php echo $fontData['font_name'] ?>';
|
94 |
+
src: <?php if (file_exists($uaf_upload_dir.$fontData['font_path'].'.woff2')){ ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff2') format('woff2'),
|
95 |
+
<?php } ?>url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
|
96 |
+
}
|
97 |
+
|
98 |
+
.et_gf_<?php echo $fontData['font_name'] ?>{background:none !important;font-family:<?php echo $fontData['font_name'] ?>;text-indent:0 !important;font-size:25px;}
|
99 |
+
|
100 |
+
<?php
|
101 |
+
endforeach;
|
102 |
+
endif;
|
103 |
+
$uaf_style = ob_get_contents();
|
104 |
+
$uafStyleSheetPath = $uaf_upload_path['dir'].'/admin-uaf.css';
|
105 |
+
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
106 |
+
fwrite($fh, $uaf_style);
|
107 |
+
fclose($fh);
|
108 |
+
|
109 |
+
$uafStyleSheetPath = $uaf_upload_path['dir'].'/admin-uaf-rtl.css';
|
110 |
+
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
111 |
+
fwrite($fh, $uaf_style);
|
112 |
+
fclose($fh);
|
113 |
+
ob_end_clean();
|
114 |
+
update_option('uaf_css_updated_timestamp', time()); // Time entry for stylesheet version
|
115 |
+
}
|
116 |
+
|
117 |
+
function uaf_update_check() { // MUST CHANGE WITH EVERY VERSION
|
118 |
+
$uaf_version_check = get_option('uaf_current_version');
|
119 |
+
if ($uaf_version_check != '5.4'):
|
120 |
+
update_option('uaf_current_version', '5.4');
|
121 |
+
if ($uaf_version_check < 4.0):
|
122 |
+
uaf_create_folder();
|
123 |
+
uaf_move_file_to_newPath();
|
124 |
+
endif;
|
125 |
+
uaf_write_css();
|
126 |
+
endif;
|
127 |
+
}
|
128 |
+
|
129 |
+
function uaf_get_server_url(){
|
130 |
+
$uaf_use_alternative_server = $GLOBALS['uaf_use_alternative_server'];
|
131 |
+
if ($uaf_use_alternative_server == 1){
|
132 |
+
return $GLOBALS['serverUrl']['alternative'];
|
133 |
+
} else {
|
134 |
+
return $GLOBALS['serverUrl']['default'];
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
function uaf_create_folder() {
|
139 |
+
$uaf_upload_path = uaf_path_details();
|
140 |
+
if (! is_dir($uaf_upload_path['dir'])) {
|
141 |
+
mkdir( $uaf_upload_path['dir'], 0755 );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
function uaf_max_upload_size_for_php($sendinbytes = false){
|
146 |
+
$maxUploadSizeForPHP = $GLOBALS['allowedFontSize'];
|
147 |
+
$wpAllowedMaxSize = wp_max_upload_size();
|
148 |
+
$wpAllowedMaxSizeToMB = $wpAllowedMaxSize / 1048576 ;
|
149 |
+
if ($wpAllowedMaxSizeToMB < $GLOBALS['allowedFontSize']){
|
150 |
+
$maxUploadSizeForPHP = $wpAllowedMaxSizeToMB;
|
151 |
+
}
|
152 |
+
if ($sendinbytes) {
|
153 |
+
return $maxUploadSizeForPHP * 1048576;
|
154 |
+
} else {
|
155 |
+
return $maxUploadSizeForPHP;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
function uaf_path_details(){
|
160 |
+
$uaf_upload = wp_upload_dir();
|
161 |
+
$uaf_upload_dir = $uaf_upload['basedir'];
|
162 |
+
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
163 |
+
$uaf_upload_url = $uaf_upload['baseurl'];
|
164 |
+
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
165 |
+
|
166 |
+
$pathReturn['dir'] = $uaf_upload_dir;
|
167 |
+
$pathReturn['url'] = $uaf_upload_url;
|
168 |
+
return $pathReturn;
|
169 |
+
}
|
170 |
+
|
171 |
+
function uaf_upload_font_to_server(){
|
172 |
+
$font_file_details = pathinfo($_FILES['font_file']['name']);
|
173 |
+
$file_extension = strtolower($font_file_details['extension']);
|
174 |
+
$font_size = $_FILES['font_file']['size'];
|
175 |
+
|
176 |
+
if ((in_array($file_extension, $GLOBALS['allowedFontFormats'])) && ($font_size <= uaf_max_upload_size_for_php(true))){
|
177 |
+
@set_time_limit(0);
|
178 |
+
$ch = curl_init();
|
179 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
180 |
+
curl_setopt($ch, CURLOPT_URL, uaf_get_server_url().'/uaf_convertor/convert.php');
|
181 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
182 |
+
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
|
183 |
+
$post = array(
|
184 |
+
'fontfile' => new CURLFile($_FILES['font_file']['tmp_name']),
|
185 |
+
'fontfileext' => pathinfo($_FILES['font_file']['name'], PATHINFO_EXTENSION),
|
186 |
+
'api_key' => $GLOBALS['uaf_api_key'],
|
187 |
+
'url' => $_POST['url'],
|
188 |
+
'font_count' => $_POST['font_count']
|
189 |
+
);
|
190 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
191 |
+
$convertResponse = curl_exec($ch);
|
192 |
+
if(curl_errno($ch)) {
|
193 |
+
$fontUploadResponse['status'] = 'error';
|
194 |
+
$fontUploadResponse['body'] = 'Error: ' . curl_error($ch);
|
195 |
+
} else {
|
196 |
+
$CrulStatinfo = curl_getinfo($ch);
|
197 |
+
if ($CrulStatinfo['http_code'] == '200'):
|
198 |
+
$convertResponseArray = json_decode($convertResponse, true);
|
199 |
+
if ($convertResponseArray['global']['status'] == 'error'):
|
200 |
+
$fontUploadResponse['status'] = 'error';
|
201 |
+
$fontUploadResponse['body'] = $convertResponseArray['global']['msg'];
|
202 |
+
else:
|
203 |
+
$fontUploadResponse['status'] = 'success';
|
204 |
+
$fontUploadResponse['body'] = $convertResponse;
|
205 |
+
endif;
|
206 |
+
else:
|
207 |
+
$fontUploadResponse['status'] = 'error';
|
208 |
+
$fontUploadResponse['body'] = $convertResponse;
|
209 |
+
endif;
|
210 |
+
}
|
211 |
+
} else {
|
212 |
+
$fontUploadResponse['status'] = 'error';
|
213 |
+
$fontUploadResponse['body'] = 'Only '.join(", ",$GLOBALS['allowedFontFormats']).' format and font less than '.uaf_max_upload_size_for_php().' MB accepted';
|
214 |
+
}
|
215 |
+
return $fontUploadResponse;
|
216 |
+
}
|
217 |
+
|
218 |
+
function uaf_save_font_files($font_name, $convertResponse){
|
219 |
+
$uafPath = uaf_path_details();
|
220 |
+
$fontNameToStore = sanitize_file_name(date('ymdhis').$font_name);
|
221 |
+
|
222 |
+
$convertResponseArray = json_decode(stripslashes($convertResponse), true);
|
223 |
+
if ($convertResponseArray['global']['status'] == 'ok'):
|
224 |
+
$neededFontFormats = array('woff2','woff');
|
225 |
+
foreach ($neededFontFormats as $neededFontFormat):
|
226 |
+
if ($convertResponseArray[$neededFontFormat]['status'] == 'ok'):
|
227 |
+
$fontFileContent = wp_safe_remote_get($convertResponseArray[$neededFontFormat]['filename'], array('timeout'=>'300'));
|
228 |
+
|
229 |
+
if ( is_wp_error( $fontFileContent ) ) {
|
230 |
+
$fontUploadFinalResponse['status'] = 'error';
|
231 |
+
$fontUploadFinalResponse['body'] = $fontFileContent->get_error_message();
|
232 |
+
return $fontUploadFinalResponse;
|
233 |
+
}
|
234 |
+
|
235 |
+
if ( $fontFileContent['response']['code'] == '200') :
|
236 |
+
$fontFileContent = wp_remote_retrieve_body( $fontFileContent );
|
237 |
+
if (!empty($fontFileContent)):
|
238 |
+
$newFileName = $fontNameToStore.'.'.$neededFontFormat;
|
239 |
+
$newFilePath = $uafPath['dir'].$newFileName;
|
240 |
+
$fh = fopen($newFilePath, 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
241 |
+
fwrite($fh, $fontFileContent);
|
242 |
+
fclose($fh);
|
243 |
+
else:
|
244 |
+
$fontSaveMsg[$neededFontFormat]['status'] = 'error';
|
245 |
+
$fontSaveMsg[$neededFontFormat]['body'] = "Couldn't receive $neededFontFormat file";
|
246 |
+
endif;
|
247 |
+
else:
|
248 |
+
$fontSaveMsg[$neededFontFormat]['status'] = 'error';
|
249 |
+
$fontSaveMsg[$neededFontFormat]['body'] = $neededFontFormat.' : '.$fontFileContent['response']['code'].' '.$fontFileContent['response']['message'];
|
250 |
+
endif;
|
251 |
+
else:
|
252 |
+
$fontSaveMsg[$neededFontFormat]['status'] = 'error';
|
253 |
+
$fontSaveMsg[$neededFontFormat]['body'] = "Problem converting to $neededFontFormat format";
|
254 |
+
endif;
|
255 |
+
endforeach;
|
256 |
+
|
257 |
+
if (!empty($fontSaveMsg)):
|
258 |
+
$fontUploadFinalResponse['body'] = '';
|
259 |
+
foreach ($fontSaveMsg as $formatKey => $formatData):
|
260 |
+
if ($fontSaveMsg[$formatKey]['status'] == 'error'):
|
261 |
+
$fontUploadFinalResponse['status'] = 'error';
|
262 |
+
$fontUploadFinalResponse['body'] .= $formatData['body'].'<br/>';
|
263 |
+
endif;
|
264 |
+
endforeach;
|
265 |
+
else:
|
266 |
+
save_font_entry_to_db($font_name, $fontNameToStore);
|
267 |
+
$fontUploadFinalResponse['status'] = 'success';
|
268 |
+
$fontUploadFinalResponse['body'] = 'Font Uploaded';
|
269 |
+
endif;
|
270 |
+
else:
|
271 |
+
$fontUploadFinalResponse['status'] = 'error';
|
272 |
+
$fontUploadFinalResponse['body'] = $convertResponseArray['global']['msg'];
|
273 |
+
endif;
|
274 |
+
|
275 |
+
return $fontUploadFinalResponse;
|
276 |
+
}
|
277 |
+
|
278 |
+
function save_font_entry_to_db($font_name, $font_path){
|
279 |
+
$fontsRawData = get_option('uaf_font_data');
|
280 |
+
$fontsData = json_decode($fontsRawData, true);
|
281 |
+
if (empty($fontsData)):
|
282 |
+
$fontsData = array();
|
283 |
+
endif;
|
284 |
+
|
285 |
+
$fontsData[date('ymdhis')] = array('font_name' => sanitize_title($font_name), 'font_path' => $font_path);
|
286 |
+
$updateFontData = json_encode($fontsData);
|
287 |
+
update_option('uaf_font_data',$updateFontData);
|
288 |
+
uaf_write_css();
|
289 |
+
}
|
290 |
+
|
291 |
+
function get_uploaded_font_list(){
|
292 |
+
$fontsRawData = get_option('uaf_font_data');
|
293 |
+
return json_decode($fontsRawData, true);
|
294 |
+
}
|
295 |
+
|
296 |
+
function count_uploaded_fonts(){
|
297 |
+
$fontsRawData = get_option('uaf_font_data');
|
298 |
+
$fontsData = json_decode($fontsRawData, true);
|
299 |
+
return count($fontsData);
|
300 |
+
}
|
301 |
+
|
302 |
+
function uaf_key_activate(){
|
303 |
+
$uaf_api_key = trim($_POST['uaf_api_key']);
|
304 |
+
$api_key_return = wp_remote_get( uaf_get_server_url().'/uaf_convertor/validate_key.php?license_key='.$uaf_api_key.'&url='.home_url(), array('timeout'=>300,'sslverify'=>false,'user-agent'=>get_bloginfo( 'url' )));
|
305 |
+
if ( is_wp_error( $api_key_return ) ) {
|
306 |
+
$error_message = $api_key_return->get_error_message();
|
307 |
+
$return['body'] = "Something went wrong: $error_message";
|
308 |
+
$return['status'] = 'error';
|
309 |
+
} else {
|
310 |
+
$api_key_return = json_decode($api_key_return['body']);
|
311 |
+
if ($api_key_return->status == 'success'){
|
312 |
+
update_option('uaf_api_key', $uaf_api_key);
|
313 |
+
$GLOBALS['uaf_api_key'] = $uaf_api_key;
|
314 |
+
}
|
315 |
+
$return['body'] = $api_key_return->msg;
|
316 |
+
$return['status'] = $api_key_return->status;
|
317 |
+
}
|
318 |
+
return $return;
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
function uaf_key_deactivate(){
|
323 |
+
$uaf_api_key = $GLOBALS['uaf_api_key'];
|
324 |
+
$api_key_return = wp_remote_get( uaf_get_server_url().'/uaf_convertor/deactivate_key.php?license_key='.$uaf_api_key.'&url='.home_url(), array('timeout'=>300,'sslverify'=>false,'user-agent'=>get_bloginfo( 'url' )));
|
325 |
+
if ( is_wp_error( $api_key_return ) ) {
|
326 |
+
$error_message = $api_key_return->get_error_message();
|
327 |
+
$return['body'] = "Something went wrong: $error_message";
|
328 |
+
$return['status'] = 'error';
|
329 |
+
} else {
|
330 |
+
$api_key_return = json_decode($api_key_return['body']);
|
331 |
+
if ($api_key_return->status == 'success'){
|
332 |
+
delete_option('uaf_api_key');
|
333 |
+
$GLOBALS['uaf_api_key'] = '';
|
334 |
+
}
|
335 |
+
$return['status'] = $api_key_return->status;
|
336 |
+
$return['body'] = $api_key_return->msg;
|
337 |
+
}
|
338 |
+
return $return;
|
339 |
+
}
|
340 |
+
|
341 |
+
function uaf_delete_font(){
|
342 |
+
$uaf_paths = uaf_path_details();
|
343 |
+
|
344 |
+
$fontsData = get_uploaded_font_list();
|
345 |
+
$key_to_delete = $_GET['delete_font_key'];
|
346 |
+
@unlink(realpath($uaf_paths['dir'].$fontsData[$key_to_delete]['font_path'].'.woff2'));
|
347 |
+
@unlink(realpath($uaf_paths['dir'].$fontsData[$key_to_delete]['font_path'].'.woff'));
|
348 |
+
@unlink(realpath($uaf_paths['dir'].$fontsData[$key_to_delete]['font_path'].'.eot'));
|
349 |
+
unset($fontsData[$key_to_delete]);
|
350 |
+
$updateFontData = json_encode($fontsData);
|
351 |
+
update_option('uaf_font_data',$updateFontData);
|
352 |
+
$return['status'] = 'success';
|
353 |
+
$return['body'] = 'Font Deleted';
|
354 |
+
uaf_write_css();
|
355 |
+
return $return;
|
356 |
+
}
|
includes/uaf_header.php
CHANGED
@@ -1,48 +1,24 @@
|
|
1 |
-
<?php
|
2 |
if (isset($_POST['ucf_api_key_submit'])){
|
3 |
-
$
|
4 |
-
$
|
5 |
-
|
6 |
-
$error_message = $api_key_return->get_error_message();
|
7 |
-
$api_message = "Something went wrong: $error_message";
|
8 |
-
$api_msg_type = 'error';
|
9 |
-
} else {
|
10 |
-
$api_key_return = json_decode($api_key_return['body']);
|
11 |
-
if ($api_key_return->status == 'success'){
|
12 |
-
update_option('uaf_api_key', $uaf_api_key);
|
13 |
-
update_option('uaf_api_package', $api_key_return->package);
|
14 |
-
}
|
15 |
-
$api_msg_type = $api_key_return->status;
|
16 |
-
$api_message = $api_key_return->msg;
|
17 |
-
}
|
18 |
}
|
19 |
|
20 |
if (isset($_POST['ucf_api_key_remove'])){
|
21 |
-
$
|
22 |
-
$
|
23 |
-
|
24 |
-
$error_message = $api_key_return->get_error_message();
|
25 |
-
$api_message = "Something went wrong: $error_message";
|
26 |
-
$api_msg_type = 'error';
|
27 |
-
} else {
|
28 |
-
$api_key_return = json_decode($api_key_return['body']);
|
29 |
-
if ($api_key_return->status == 'success'){
|
30 |
-
delete_option('uaf_api_key');
|
31 |
-
delete_option('uaf_api_package');
|
32 |
-
}
|
33 |
-
$api_msg_type = $api_key_return->status;
|
34 |
-
$api_message = $api_key_return->msg;
|
35 |
-
}
|
36 |
}
|
37 |
|
38 |
-
$
|
39 |
-
$
|
40 |
-
$
|
41 |
-
|
|
|
42 |
?>
|
43 |
-
|
44 |
-
|
45 |
-
<?php endif; ?>
|
46 |
<div class="wrap">
|
47 |
<h2>Use Any Font</h2>
|
48 |
<table width="100%">
|
@@ -59,7 +35,7 @@ $delete_confirmation_msg = 'Are you sure ?';
|
|
59 |
<td>
|
60 |
<form action="admin.php?page=uaf_settings_page" method="post" id="uaf_api_key_form" >
|
61 |
API KEY :
|
62 |
-
<?php if (empty($uaf_api_key)): ?>
|
63 |
<input name="uaf_api_key" id="uaf_api_key" type="text" style="width:350px; margin-left:50px;" />
|
64 |
<input type="submit" name="ucf_api_key_submit" class="button-primary" value="Verify" style="padding:2px;" />
|
65 |
<input type="button" name="uaf_api_key_generate" id="uaf_api_key_generate" class="button-primary" value="Generate Test API Key" style="padding:2px;" onclick="uaf_lite_api_key_generate();" />
|
@@ -67,7 +43,7 @@ $delete_confirmation_msg = 'Are you sure ?';
|
|
67 |
Use Any Font need API key to upload the font. You can get the premium key from <a href="https://dineshkarki.com.np/use-any-font/api-key" target="_blank">here</a>. You can also generate Lite / Test API key from button above. <strong>Note : </strong> Lite / Test API only allow single font conversion.
|
68 |
<br/>
|
69 |
<?php else: ?>
|
70 |
-
<span class="active_key"><?php echo $uaf_api_key; ?> - Active</span> <input type="submit" name="ucf_api_key_remove" class="button-primary" value="Remove Key" style="padding:2px; margin-left:20px;" onclick="if(!confirm('
|
71 |
<?php endif;?>
|
72 |
</form>
|
73 |
<br/>
|
@@ -81,12 +57,12 @@ $delete_confirmation_msg = 'Are you sure ?';
|
|
81 |
<br/>
|
82 |
<script>
|
83 |
function uaf_lite_api_key_generate(){
|
84 |
-
jQuery.ajax({url: "<?php echo
|
85 |
beforeSend : function(){
|
86 |
jQuery('#uaf_api_key_generate').val('Generating...');
|
87 |
},
|
88 |
error: function(){
|
89 |
-
jQuery('#uaf_api_key_generate').val('Error!');
|
90 |
},
|
91 |
success: function(result){
|
92 |
var dataReturn = JSON.parse(result);
|
1 |
+
<?php
|
2 |
if (isset($_POST['ucf_api_key_submit'])){
|
3 |
+
$activationRetun = uaf_key_activate();
|
4 |
+
$operationMsg = $activationRetun['body'];
|
5 |
+
$operationStatus = $activationRetun['status'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
|
8 |
if (isset($_POST['ucf_api_key_remove'])){
|
9 |
+
$deactivationRetun = uaf_key_deactivate();
|
10 |
+
$operationMsg = $deactivationRetun['body'];
|
11 |
+
$operationStatus = $deactivationRetun['status'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
13 |
|
14 |
+
if (isset($_GET['delete_font_key'])):
|
15 |
+
$fontDeleteRetun = uaf_delete_font();
|
16 |
+
$operationMsg = $fontDeleteRetun['body'];
|
17 |
+
$operationStatus = $fontDeleteRetun['status'];
|
18 |
+
endif;
|
19 |
?>
|
20 |
+
|
21 |
+
|
|
|
22 |
<div class="wrap">
|
23 |
<h2>Use Any Font</h2>
|
24 |
<table width="100%">
|
35 |
<td>
|
36 |
<form action="admin.php?page=uaf_settings_page" method="post" id="uaf_api_key_form" >
|
37 |
API KEY :
|
38 |
+
<?php if (empty($GLOBALS['uaf_api_key'])): ?>
|
39 |
<input name="uaf_api_key" id="uaf_api_key" type="text" style="width:350px; margin-left:50px;" />
|
40 |
<input type="submit" name="ucf_api_key_submit" class="button-primary" value="Verify" style="padding:2px;" />
|
41 |
<input type="button" name="uaf_api_key_generate" id="uaf_api_key_generate" class="button-primary" value="Generate Test API Key" style="padding:2px;" onclick="uaf_lite_api_key_generate();" />
|
43 |
Use Any Font need API key to upload the font. You can get the premium key from <a href="https://dineshkarki.com.np/use-any-font/api-key" target="_blank">here</a>. You can also generate Lite / Test API key from button above. <strong>Note : </strong> Lite / Test API only allow single font conversion.
|
44 |
<br/>
|
45 |
<?php else: ?>
|
46 |
+
<span class="active_key"><?php echo $GLOBALS['uaf_api_key']; ?> - Active</span> <input type="submit" name="ucf_api_key_remove" class="button-primary" value="Remove Key" style="padding:2px; margin-left:20px;" onclick="if(!confirm('Are you sure ?')){return false;}" />
|
47 |
<?php endif;?>
|
48 |
</form>
|
49 |
<br/>
|
57 |
<br/>
|
58 |
<script>
|
59 |
function uaf_lite_api_key_generate(){
|
60 |
+
jQuery.ajax({url: "<?php echo uaf_get_server_url().'/uaf_convertor/generate_lite_key.php'; ?>",
|
61 |
beforeSend : function(){
|
62 |
jQuery('#uaf_api_key_generate').val('Generating...');
|
63 |
},
|
64 |
error: function(){
|
65 |
+
jQuery('#uaf_api_key_generate').val(' Error ! ');
|
66 |
},
|
67 |
success: function(result){
|
68 |
var dataReturn = JSON.parse(result);
|
includes/uaf_uploaded_font_list.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $fontsData = get_uploaded_font_list(); ?>
|
2 |
+
<table cellspacing="0" class="wp-list-table widefat fixed bookmarks">
|
3 |
+
<thead>
|
4 |
+
<tr>
|
5 |
+
<th width="20">Sn</th>
|
6 |
+
<th>Font</th>
|
7 |
+
<th width="100">Delete</th>
|
8 |
+
</tr>
|
9 |
+
</thead>
|
10 |
+
|
11 |
+
<tbody>
|
12 |
+
<?php if (!empty($fontsData)): ?>
|
13 |
+
<?php
|
14 |
+
$sn = 0;
|
15 |
+
foreach ($fontsData as $key=>$fontData):
|
16 |
+
$sn++
|
17 |
+
?>
|
18 |
+
<tr>
|
19 |
+
<td><?php echo $sn; ?></td>
|
20 |
+
<td><?php echo $fontData['font_name'] ?></td>
|
21 |
+
<td><a onclick="if (!confirm('Are you sure ?')){return false;}" href="admin.php?page=uaf_settings_page&delete_font_key=<?php echo $key; ?>">Delete</a></td>
|
22 |
+
</tr>
|
23 |
+
<?php endforeach; ?>
|
24 |
+
<?php else: ?>
|
25 |
+
<tr>
|
26 |
+
<td colspan="3">No font found. Please click on Add Fonts to add font</td>
|
27 |
+
</tr>
|
28 |
+
<?php endif; ?>
|
29 |
+
</tbody>
|
30 |
+
</table>
|
plugin_interface.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
// SETTINGS
|
3 |
if (isset($_POST['submit-uaf-settings'])){
|
4 |
if (isset($_POST['uaf_disbale_editor_font_list'])){
|
5 |
$uaf_disbale_editor_font_list = 1;
|
@@ -94,52 +93,14 @@ function uaf_create_menu() {
|
|
94 |
add_menu_page( 'Use Any Font', 'Use Any Font', 'manage_options', 'uaf_settings_page', 'uaf_settings_page', 'dashicons-editor-textcolor');
|
95 |
}
|
96 |
|
97 |
-
function uaf_create_folder() {
|
98 |
-
$uaf_upload = wp_upload_dir();
|
99 |
-
$uaf_upload_dir = $uaf_upload['basedir'];
|
100 |
-
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
101 |
-
if (! is_dir($uaf_upload_dir)) {
|
102 |
-
mkdir( $uaf_upload_dir, 0755 );
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
function uaf_activate(){
|
107 |
uaf_create_folder(); // CREATE FOLDER
|
108 |
uaf_write_css(); //rewrite css when plugin is activated after update or somethingelse......
|
109 |
}
|
110 |
|
111 |
-
function uaf_update_check() { // MUST CHANGE WITH EVERY VERSION
|
112 |
-
$uaf_version_check = get_option('uaf_current_version');
|
113 |
-
if ($uaf_version_check != '5.3'):
|
114 |
-
update_option('uaf_current_version', '5.3');
|
115 |
-
if ($uaf_version_check < 4.0):
|
116 |
-
uaf_create_folder();
|
117 |
-
uaf_move_file_to_newPath();
|
118 |
-
endif;
|
119 |
-
uaf_write_css();
|
120 |
-
endif;
|
121 |
-
}
|
122 |
-
|
123 |
function uaf_settings_page() {
|
124 |
-
$uaf_upload = wp_upload_dir();
|
125 |
-
$uaf_upload_dir = $uaf_upload['basedir'];
|
126 |
-
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
127 |
-
$uaf_upload_url = $uaf_upload['baseurl'];
|
128 |
-
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
129 |
-
|
130 |
-
$uaf_disbale_editor_font_list_value = get_option('uaf_disbale_editor_font_list');
|
131 |
-
$uaf_use_curl_uploader_value = get_option('uaf_use_curl_uploader');
|
132 |
-
$uaf_use_absolute_font_path = get_option('uaf_use_absolute_font_path');
|
133 |
-
$uaf_use_alternative_server = get_option('uaf_use_alternative_server');
|
134 |
-
|
135 |
-
if ($uaf_use_alternative_server == 1){
|
136 |
-
$uaf_font_convert_server_url = 'https://dnesscarkey.com';
|
137 |
-
} else {
|
138 |
-
$uaf_font_convert_server_url = 'https://dnesscarkey.xyz';
|
139 |
-
}
|
140 |
-
|
141 |
include('includes/uaf_header.php');
|
142 |
-
if ($
|
143 |
include('includes/uaf_font_upload_php.php');
|
144 |
} else {
|
145 |
include('includes/uaf_font_upload_js.php');
|
@@ -148,128 +109,7 @@ function uaf_settings_page() {
|
|
148 |
include('includes/uaf_footer.php');
|
149 |
}
|
150 |
|
151 |
-
// MOVING OLD FONTFILE PATH TO NEW PATH
|
152 |
-
function uaf_move_file_to_newPath(){
|
153 |
-
$uaf_upload = wp_upload_dir();
|
154 |
-
$uaf_upload_dir = $uaf_upload['basedir'];
|
155 |
-
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
156 |
-
$fontsRawData = get_option('uaf_font_data');
|
157 |
-
$fontsData = json_decode($fontsRawData, true);
|
158 |
-
if (!empty($fontsData)):
|
159 |
-
foreach ($fontsData as $key=>$fontData):
|
160 |
-
|
161 |
-
$oldFilePathInfo = pathinfo($fontData['font_path']);
|
162 |
-
$parsedPath = parse_url($fontData['font_path']);
|
163 |
-
$relativeFilePath = $_SERVER['DOCUMENT_ROOT'].$parsedPath['path'];
|
164 |
-
$oldfilename = $oldFilePathInfo['filename'];
|
165 |
-
|
166 |
-
if (file_exists($relativeFilePath.'.woff')){
|
167 |
-
|
168 |
-
$woffFileContent = file_get_contents($relativeFilePath.'.woff');
|
169 |
-
$eotFileContent = file_get_contents($relativeFilePath.'.eot');
|
170 |
-
|
171 |
-
$fhWoff = fopen($uaf_upload_dir.'/'.$oldfilename.'.woff' , 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
172 |
-
fwrite($fhWoff, $woffFileContent);
|
173 |
-
fclose($fhWoff);
|
174 |
-
|
175 |
-
$fhEot = fopen($uaf_upload_dir.'/'.$oldfilename.'.eot' , 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
176 |
-
fwrite($fhEot, $eotFileContent);
|
177 |
-
fclose($fhEot);
|
178 |
-
|
179 |
-
$fontsData[$key]['font_path'] = $oldfilename;
|
180 |
-
}
|
181 |
-
endforeach;
|
182 |
-
endif;
|
183 |
-
|
184 |
-
$updateFontData = json_encode($fontsData);
|
185 |
-
update_option('uaf_font_data',$updateFontData);
|
186 |
-
}
|
187 |
-
|
188 |
-
function uaf_write_css(){
|
189 |
-
$uaf_use_absolute_font_path = get_option('uaf_use_absolute_font_path'); // Check if user want to use absolute font path.
|
190 |
-
|
191 |
-
if (empty($uaf_use_absolute_font_path)){
|
192 |
-
$uaf_use_absolute_font_path = 0;
|
193 |
-
}
|
194 |
-
|
195 |
-
$uaf_upload = wp_upload_dir();
|
196 |
-
$uaf_upload_dir = $uaf_upload['basedir'];
|
197 |
-
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
198 |
-
$uaf_upload_url = $uaf_upload['baseurl'];
|
199 |
-
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
200 |
-
$uaf_upload_url = preg_replace('#^https?:#', '', $uaf_upload_url);
|
201 |
-
|
202 |
-
if ($uaf_use_absolute_font_path == 0){ // If user use relative path
|
203 |
-
$url_parts = parse_url($uaf_upload_url);
|
204 |
-
@$uaf_upload_url = "$url_parts[path]$url_parts[query]$url_parts[fragment]";
|
205 |
-
}
|
206 |
-
|
207 |
-
ob_start();
|
208 |
-
$fontsRawData = get_option('uaf_font_data');
|
209 |
-
$fontsData = json_decode($fontsRawData, true);
|
210 |
-
if (!empty($fontsData)):
|
211 |
-
foreach ($fontsData as $key=>$fontData): ?>
|
212 |
-
@font-face {
|
213 |
-
font-family: '<?php echo $fontData['font_name'] ?>';
|
214 |
-
font-style: normal;
|
215 |
-
src: url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.eot');
|
216 |
-
src: local('<?php echo $fontData['font_name'] ?>'), url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.eot') format('embedded-opentype'), url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
|
217 |
-
}
|
218 |
-
|
219 |
-
.<?php echo $fontData['font_name'] ?>{font-family: '<?php echo $fontData['font_name'] ?>' !important;}
|
220 |
-
|
221 |
-
<?php
|
222 |
-
endforeach;
|
223 |
-
endif;
|
224 |
-
|
225 |
-
$fontsImplementRawData = get_option('uaf_font_implement');
|
226 |
-
$fontsImplementData = json_decode($fontsImplementRawData, true);
|
227 |
-
if (!empty($fontsImplementData)):
|
228 |
-
foreach ($fontsImplementData as $key=>$fontImplementData): ?>
|
229 |
-
<?php echo $fontImplementData['font_elements']; ?>{
|
230 |
-
font-family: '<?php echo $fontsData[$fontImplementData['font_key']]['font_name']; ?>' !important;
|
231 |
-
}
|
232 |
-
<?php
|
233 |
-
endforeach;
|
234 |
-
endif;
|
235 |
-
$uaf_style = ob_get_contents();
|
236 |
-
$uafStyleSheetPath = $uaf_upload_dir.'/uaf.css';
|
237 |
-
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
238 |
-
fwrite($fh, $uaf_style);
|
239 |
-
fclose($fh);
|
240 |
-
ob_end_clean();
|
241 |
-
|
242 |
-
ob_start();
|
243 |
-
$fontsRawData = get_option('uaf_font_data');
|
244 |
-
$fontsData = json_decode($fontsRawData, true);
|
245 |
-
if (!empty($fontsData)):
|
246 |
-
foreach ($fontsData as $key=>$fontData): ?>
|
247 |
-
@font-face {
|
248 |
-
font-family: '<?php echo $fontData['font_name'] ?>';
|
249 |
-
font-style: normal;
|
250 |
-
src: url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.eot');
|
251 |
-
src: local('<?php echo $fontData['font_name'] ?>'), url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.eot') format('embedded-opentype'), url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.woff') format('woff');
|
252 |
-
}
|
253 |
-
|
254 |
-
.et_gf_<?php echo $fontData['font_name'] ?>{background:none !important;font-family:<?php echo $fontData['font_name'] ?>;text-indent:0 !important;font-size:25px;}
|
255 |
-
|
256 |
-
<?php
|
257 |
-
endforeach;
|
258 |
-
endif;
|
259 |
-
$uaf_style = ob_get_contents();
|
260 |
-
$uafStyleSheetPath = $uaf_upload_dir.'/admin-uaf.css';
|
261 |
-
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
262 |
-
fwrite($fh, $uaf_style);
|
263 |
-
fclose($fh);
|
264 |
-
|
265 |
-
$uafStyleSheetPath = $uaf_upload_dir.'/admin-uaf-rtl.css';
|
266 |
-
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
267 |
-
fwrite($fh, $uaf_style);
|
268 |
-
fclose($fh);
|
269 |
-
ob_end_clean();
|
270 |
-
update_option('uaf_css_updated_timestamp', time()); // Time entry for stylesheet version
|
271 |
-
}
|
272 |
|
273 |
function uaf_editor_setup(){
|
274 |
-
include('includes/uaf_editor_setup.php');
|
275 |
}
|
1 |
<?php
|
|
|
2 |
if (isset($_POST['submit-uaf-settings'])){
|
3 |
if (isset($_POST['uaf_disbale_editor_font_list'])){
|
4 |
$uaf_disbale_editor_font_list = 1;
|
93 |
add_menu_page( 'Use Any Font', 'Use Any Font', 'manage_options', 'uaf_settings_page', 'uaf_settings_page', 'dashicons-editor-textcolor');
|
94 |
}
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
function uaf_activate(){
|
97 |
uaf_create_folder(); // CREATE FOLDER
|
98 |
uaf_write_css(); //rewrite css when plugin is activated after update or somethingelse......
|
99 |
}
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
function uaf_settings_page() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
include('includes/uaf_header.php');
|
103 |
+
if ($GLOBALS['uaf_use_curl_uploader'] == 1){
|
104 |
include('includes/uaf_font_upload_php.php');
|
105 |
} else {
|
106 |
include('includes/uaf_font_upload_js.php');
|
109 |
include('includes/uaf_footer.php');
|
110 |
}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
function uaf_editor_setup(){
|
114 |
+
include('includes/uaf_editor_setup.php');
|
115 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: dnesscarkey
|
3 |
Tags: custom fonts, font embed, font uploader, any font, embed any font, font uploader, css3 font embed, @font-face embed, font conversion, webfont, ttf, opentype
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 5.2
|
6 |
-
Stable tag: 5.
|
7 |
|
8 |
Embed any custom font in your website. #1 Rated custom fonts plugin by WPMUDev.org.
|
9 |
|
@@ -27,8 +27,8 @@ Use Any Font gives you freedom to use custom fonts in your website. It is not li
|
|
27 |
<a href="https://themify.me/member/aff/go/dnesscarkey/?cr=aHR0cHM6Ly90aGVtaWZ5Lm1lL2J1aWxkZXI=" target="_blank">Themify Builder</a>, and any visual builder using the class.
|
28 |
* Custom fonts uploaded can be directly used from Theme options panel for major themeforest themes like <a href="https://goo.gl/Oy6tvt" target="_blank">Avada, X Theme, Salient, Oshine, KLEO, ShopKeeper, SimpleMag, Porto and many more (540+). Check out full list here.</a>
|
29 |
* Supports font format including ttf, otf, woff. The required fonts are converted automatically.
|
30 |
-
* Accepts custom font file upto
|
31 |
-
* Embed fonts using @font-face css. SEO friendly and quick loading.
|
32 |
* Multiple custom fonts can be used.
|
33 |
* Faster load time as your custom fonts are stored on your own server.
|
34 |
|
@@ -113,6 +113,10 @@ No, our server is needed during font conversion only. After that all fonts are s
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
|
|
116 |
= 5.3 =
|
117 |
* Fixed domain verification issue.
|
118 |
|
2 |
Contributors: dnesscarkey
|
3 |
Tags: custom fonts, font embed, font uploader, any font, embed any font, font uploader, css3 font embed, @font-face embed, font conversion, webfont, ttf, opentype
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 5.3.2
|
6 |
+
Stable tag: 5.4
|
7 |
|
8 |
Embed any custom font in your website. #1 Rated custom fonts plugin by WPMUDev.org.
|
9 |
|
27 |
<a href="https://themify.me/member/aff/go/dnesscarkey/?cr=aHR0cHM6Ly90aGVtaWZ5Lm1lL2J1aWxkZXI=" target="_blank">Themify Builder</a>, and any visual builder using the class.
|
28 |
* Custom fonts uploaded can be directly used from Theme options panel for major themeforest themes like <a href="https://goo.gl/Oy6tvt" target="_blank">Avada, X Theme, Salient, Oshine, KLEO, ShopKeeper, SimpleMag, Porto and many more (540+). Check out full list here.</a>
|
29 |
* Supports font format including ttf, otf, woff. The required fonts are converted automatically.
|
30 |
+
* Accepts custom font file upto 25 MB.
|
31 |
+
* Embed fonts using @font-face css. SEO friendly and quick loading due to woff2 compression.
|
32 |
* Multiple custom fonts can be used.
|
33 |
* Faster load time as your custom fonts are stored on your own server.
|
34 |
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
= 5.4 =
|
117 |
+
* Font upload supported upto 25 MB.
|
118 |
+
* Use of woff2 compression for better and faster font loading.
|
119 |
+
|
120 |
= 5.3 =
|
121 |
* Fixed domain verification issue.
|
122 |
|
uaf_config.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$GLOBALS['allowedFontFormats'] = array ('ttf','otf','woff');
|
3 |
+
$GLOBALS['allowedFontSize'] = 25;
|
4 |
+
$GLOBALS['serverUrl']['default'] = 'https://server2.dnesscarkey.org';
|
5 |
+
$GLOBALS['serverUrl']['alternative'] = 'https://server3.dnesscarkey.org';
|
6 |
+
|
7 |
+
|
8 |
+
// FROM DATABASE RECORDS
|
9 |
+
$GLOBALS['uaf_api_key'] = get_option('uaf_api_key');
|
10 |
+
$GLOBALS['uaf_disbale_editor_font_list'] = get_option('uaf_disbale_editor_font_list');
|
11 |
+
$GLOBALS['uaf_use_curl_uploader'] = get_option('uaf_use_curl_uploader');
|
12 |
+
$GLOBALS['uaf_use_absolute_font_path'] = get_option('uaf_use_absolute_font_path');
|
13 |
+
$GLOBALS['uaf_use_alternative_server'] = get_option('uaf_use_alternative_server');
|
14 |
+
$GLOBALS['uaf_server_status'] = get_option('uaf_server_status');
|
15 |
+
$GLOBALS['uaf_server_msg'] = get_option('uaf_server_msg');
|
16 |
+
?>
|
use-any-font.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Use Any Font
|
|
4 |
Plugin URI: http://dineshkarki.com.np/use-any-font
|
5 |
Description: Embed any font in your website
|
6 |
Author: Dinesh Karki
|
7 |
-
Version: 5.
|
8 |
Author URI: http://www.dineshkarki.com.np
|
9 |
*/
|
10 |
|
@@ -23,6 +23,9 @@ Author URI: http://www.dineshkarki.com.np
|
|
23 |
along with this program; if not, write to the Free Software
|
24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
|
|
|
|
|
|
26 |
include('plugin_interface.php');
|
27 |
register_activation_hook( __FILE__, 'uaf_activate' );
|
28 |
?>
|
4 |
Plugin URI: http://dineshkarki.com.np/use-any-font
|
5 |
Description: Embed any font in your website
|
6 |
Author: Dinesh Karki
|
7 |
+
Version: 5.4
|
8 |
Author URI: http://www.dineshkarki.com.np
|
9 |
*/
|
10 |
|
23 |
along with this program; if not, write to the Free Software
|
24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
25 |
*/
|
26 |
+
|
27 |
+
include('uaf_config.php');
|
28 |
+
include('includes/uaf_functions.php');
|
29 |
include('plugin_interface.php');
|
30 |
register_activation_hook( __FILE__, 'uaf_activate' );
|
31 |
?>
|