Initial commit. State 04.2021.
0
wp-content/plugins/use-any-font/css/uaf.css
Normal file
11
wp-content/plugins/use-any-font/css/uaf_admin.css
Normal file
@@ -0,0 +1,11 @@
|
||||
table.uaf_form td{ border:none !important;}
|
||||
table.uaf_form td label.error{ color:#900; padding-left:5px;}
|
||||
span.active_key{ padding-left:50px; font-weight:bold; color:#060;}
|
||||
#server_status{text-align:center; font-size:14px;-webkit-border-radius: 3px;border-radius: 3px; text-transform:capitalize; padding:5px; margin-bottom:10px;}
|
||||
#server_status.test_successfull{ background-color:#090; color:#fff; }
|
||||
#server_status.test_error{ background-color:#900; color:#fff; }
|
||||
.uaf_test_msg{ font-size:11px; padding-bottom:10px; color:#454545;}
|
||||
ul.uaf_list{ list-style-type:square;margin-left: 2em;}
|
||||
|
||||
#font_upload_message.ok{ background:#060 url(../images/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;}
|
||||
#font_upload_message.error{background:#900; color:#fff;padding:5px 10px; border:none;margin:5px 0px;-webkit-border-radius: 3px;border-radius: 3px;}
|
||||
BIN
wp-content/plugins/use-any-font/images/ajax-loader.gif
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
wp-content/plugins/use-any-font/images/wp_masonry_layout.gif
Normal file
|
After Width: | Height: | Size: 108 KiB |
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
function uaf_mce_before_init( $init_array ) {
|
||||
$theme_advanced_fonts = '';
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
if (!empty($fontsData)):
|
||||
foreach ($fontsData as $key=>$fontData):
|
||||
$theme_advanced_fonts .= ucfirst(str_replace('_',' ', $fontData['font_name'])) .'='.$fontData['font_name'].';';
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
$init_array['font_formats'] = $theme_advanced_fonts.'Andale Mono=Andale Mono, Times;Arial=Arial, Helvetica, sans-serif;Arial Black=Arial Black, Avant Garde;Book Antiqua=Book Antiqua, Palatino;Comic Sans MS=Comic Sans MS, sans-serif;Courier New=Courier New, Courier;Georgia=Georgia, Palatino;Helvetica=Helvetica;Impact=Impact, Chicago;Symbol=Symbol;Tahoma=Tahoma, Arial, Helvetica, sans-serif;Terminal=Terminal, Monaco;Times New Roman=Times New Roman, Times;Trebuchet MS=Trebuchet MS, Geneva;Verdana=Verdana, Geneva;Webdings=Webdings;Wingdings=Wingdings';
|
||||
return $init_array;
|
||||
}
|
||||
|
||||
function wp_editor_fontsize_filter( $options ) {
|
||||
array_unshift( $options, 'fontsizeselect');
|
||||
array_unshift( $options, 'fontselect');
|
||||
return $options;
|
||||
}
|
||||
168
wp-content/plugins/use-any-font/includes/uaf_font_implement.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
if (isset($_POST['submit-uaf-implement'])){
|
||||
$fontsImplementRawData = get_option('uaf_font_implement');
|
||||
$fontsImplementData = json_decode($fontsImplementRawData, true);
|
||||
if (empty($fontsImplementData)):
|
||||
$fontsImplementData = array();
|
||||
endif;
|
||||
|
||||
$fontElements = array();
|
||||
$fontElements[] = @join(', ',$_POST['elements']);
|
||||
$fontElements[] = @join(', ',array_filter(array_map('trim',explode("\n", trim($_POST['custom_elements'])))));
|
||||
$fontElements = array_filter(array_map('trim',$fontElements));
|
||||
$finalElements = join(', ', $fontElements);
|
||||
|
||||
if (!empty($finalElements)){
|
||||
$fontsImplementData[date('ymdhis')] = array(
|
||||
'font_key' => $_POST['font_key'],
|
||||
'font_elements' => $finalElements
|
||||
);
|
||||
$updateFontsImplementData = json_encode($fontsImplementData);
|
||||
update_option('uaf_font_implement',$updateFontsImplementData);
|
||||
uaf_write_css();
|
||||
$implementMsg = 'Font Assigned';
|
||||
|
||||
} else {
|
||||
$implementMsg = "Couldn't assign font. Please select atleast one element or add a custom element";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_implement_key'])):
|
||||
$fontsImplementRawData = get_option('uaf_font_implement');
|
||||
$fontsImplementData = json_decode($fontsImplementRawData, true);
|
||||
$key_to_delete = $_GET['delete_implement_key'];
|
||||
unset($fontsImplementData[$key_to_delete]);
|
||||
$updateFontsImplementData = json_encode($fontsImplementData);
|
||||
update_option('uaf_font_implement',$updateFontsImplementData);
|
||||
uaf_write_css();
|
||||
$implementMsg = 'Font assign removed';
|
||||
endif;
|
||||
?>
|
||||
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Assign Font</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<?php if (!empty($implementMsg)):?>
|
||||
<div class="updated" id="message"><p><?php echo $implementMsg ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
?>
|
||||
|
||||
<p align="right"><input type="button" name="open_assign_font" onClick="open_assign_font();" class="button-primary" value="Assign Font" /><br/></p>
|
||||
|
||||
<div id="open_assign_font" style="display:none;">
|
||||
<form action="admin.php?page=uaf_settings_page" id="open_assign_font_form" method="post">
|
||||
<table class="uaf_form">
|
||||
<tr>
|
||||
<td width="175">Select Font</td>
|
||||
<td>
|
||||
<select name="font_key" class="required" style="width:200px;">
|
||||
<option value="">- Select -</option>
|
||||
<?php
|
||||
if (!empty($fontsData)):
|
||||
foreach ($fontsData as $key=>$fontData) : ?>
|
||||
<option value="<?php echo $key ?>"><?php echo $fontData['font_name']; ?></option>
|
||||
<?php endforeach;
|
||||
endif;
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Select elements to assign</td>
|
||||
<td>
|
||||
<input name="elements[]" value="body" type="checkbox" /> All (body tags)<br/>
|
||||
<input name="elements[]" value="h1" type="checkbox" /> Headline 1 (h1 tags)<br/>
|
||||
<input name="elements[]" value="h2" type="checkbox" /> Headline 2 (h2 tags)<br/>
|
||||
<input name="elements[]" value="h3" type="checkbox" /> Headline 3 (h3 tags)<br/>
|
||||
<input name="elements[]" value="h4" type="checkbox" /> Headline 4 (h4 tags)<br/>
|
||||
<input name="elements[]" value="h5" type="checkbox" /> Headline 5 (h5 tags)<br/>
|
||||
<input name="elements[]" value="h6" type="checkbox" /> Headline 6 (h6 tags)<br/>
|
||||
<input name="elements[]" value="p" type="checkbox" /> Paragraphs (p tags)<br/>
|
||||
<input name="elements[]" value="blockquote" type="checkbox" /> Blockquotes<br/>
|
||||
<input name="elements[]" value="li" type="checkbox" /> Lists (li tags)<br/>
|
||||
<input name="elements[]" value="a" type="checkbox" /> Hyperlink (a tags)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Custom Elements</td>
|
||||
<td><textarea name="custom_elements" style="width:400px; height:150px;"></textarea><br/>
|
||||
<br/>
|
||||
<strong>Note</strong><br/>
|
||||
Each line indicate one css element. You don't need to use any css.<br />
|
||||
<strong>Example:</strong><br/>
|
||||
<em>#content .wrap</em><br/>
|
||||
<em>#content p </em>
|
||||
<br/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type="submit" name="submit-uaf-implement" class="button-primary" value="Assign Font" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$fontsImplementRawData = get_option('uaf_font_implement');
|
||||
$fontsImplementData = json_decode($fontsImplementRawData, true);
|
||||
|
||||
?>
|
||||
<table cellspacing="0" class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20">Sn</th>
|
||||
<th>Font</th>
|
||||
<th>Applied To</th>
|
||||
<th width="100">Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php if (!empty($fontsImplementData)): ?>
|
||||
<?php
|
||||
$sn = 0;
|
||||
foreach ($fontsImplementData as $key=>$fontImplementData):
|
||||
$sn++
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $sn; ?></td>
|
||||
<td><?php echo $fontsData[$fontImplementData['font_key']]['font_name']; ?></td>
|
||||
<td><?php echo $fontImplementData['font_elements'] ?></td>
|
||||
<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>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="4">No font assign yet. Click on Assign Font to start.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function open_assign_font(){
|
||||
jQuery('#open_assign_font').toggle('fast');
|
||||
jQuery("#open_assign_font_form").validate();
|
||||
}
|
||||
</script>
|
||||
|
||||
<br/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
247
wp-content/plugins/use-any-font/includes/uaf_font_upload_js.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
$allowedFontFormats = array ('ttf','otf','woff');
|
||||
$uaf_api_key = get_option('uaf_api_key');
|
||||
|
||||
if (isset($_POST['submit-uaf-font'])){
|
||||
$fontUploadFinalMsg = '';
|
||||
$fontUploadFinalStatus = 'updated';
|
||||
|
||||
if (!empty($_POST['font_name'])):
|
||||
$fontNameToStore = sanitize_file_name(date('ymdhis').$_POST['font_name']);
|
||||
$fontNameToStoreWithUrl = $fontNameToStore;
|
||||
if (!empty($_POST['convert_response'])):
|
||||
$convertResponseArray = json_decode(stripslashes($_POST['convert_response']), true);
|
||||
if ($convertResponseArray['global']['status'] == 'ok'):
|
||||
$neededFontFormats = array('woff','eot');
|
||||
foreach ($neededFontFormats as $neededFontFormat):
|
||||
if ($convertResponseArray[$neededFontFormat]['status'] == 'ok'):
|
||||
$fontFileContent = '';
|
||||
$fontFileContent = wp_remote_fopen($convertResponseArray[$neededFontFormat]['filename']);
|
||||
if (!empty($fontFileContent)):
|
||||
$newFileName = $fontNameToStore.'.'.$neededFontFormat;
|
||||
$newFilePath = $uaf_upload_dir.$newFileName;
|
||||
$fh = fopen($newFilePath, 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
||||
fwrite($fh, $fontFileContent);
|
||||
fclose($fh);
|
||||
$fontUploadMsg[$neededFontFormat]['status'] = 'ok';
|
||||
$fontUploadMsg[$neededFontFormat]['text'] = "Done";
|
||||
else:
|
||||
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
||||
$fontUploadMsg[$neededFontFormat]['text'] = "Couldn't receive $neededFontFormat file";
|
||||
endif;
|
||||
else:
|
||||
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
||||
$fontUploadMsg[$neededFontFormat]['text'] = "Problem converting to $neededFontFormat format";
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg .= $convertResponseArray['global']['msg'].'<br/>';
|
||||
endif;
|
||||
else:
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg = "Convert Response is Empty. Please try again enabling alternative uploader from Additional settings below.";
|
||||
endif;
|
||||
else:
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg = "Font Name is empty";
|
||||
endif;
|
||||
|
||||
|
||||
if (!empty($fontUploadMsg)):
|
||||
foreach ($fontUploadMsg as $formatKey => $formatData):
|
||||
if ($formatData['status'] == 'error'):
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg .= $formatData['text'].'<br/>';
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
if ($fontUploadFinalStatus != 'error'):
|
||||
$fontUploadFinalMsg = 'Font Uploaded';
|
||||
endif;
|
||||
|
||||
if ($fontUploadFinalStatus != 'error'):
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
if (empty($fontsData)):
|
||||
$fontsData = array();
|
||||
endif;
|
||||
|
||||
$fontsData[date('ymdhis')] = array('font_name' => sanitize_title($_POST['font_name']), 'font_path' => $fontNameToStoreWithUrl);
|
||||
$updateFontData = json_encode($fontsData);
|
||||
update_option('uaf_font_data',$updateFontData);
|
||||
uaf_write_css();
|
||||
endif;
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_font_key'])):
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
$key_to_delete = $_GET['delete_font_key'];
|
||||
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.woff'));
|
||||
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.eot'));
|
||||
unset($fontsData[$key_to_delete]);
|
||||
$updateFontData = json_encode($fontsData);
|
||||
update_option('uaf_font_data',$updateFontData);
|
||||
$fontUploadFinalStatus = 'updated';
|
||||
$fontUploadFinalMsg = 'Font Deleted';
|
||||
uaf_write_css();
|
||||
endif;
|
||||
?>
|
||||
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Upload Fonts</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<?php if (!empty($fontUploadFinalMsg)):?>
|
||||
<div class="<?php echo $fontUploadFinalStatus; ?>" id="message"><p><?php echo $fontUploadFinalMsg ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
?>
|
||||
|
||||
<p align="right"><input type="button" name="open_add_font" onClick="open_add_font();" class="button-primary" value="Add Fonts" /><br/></p>
|
||||
|
||||
<div id="font-upload" style="display:none;">
|
||||
<form action="admin.php?page=uaf_settings_page" id="open_add_font_form" method="post" enctype="multipart/form-data">
|
||||
<table class="uaf_form">
|
||||
<tr>
|
||||
<td width="175">Font Name</td>
|
||||
<td><input type="text" name="font_name" value="" maxlength="20" class="required" style="width:200px;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Font File</td>
|
||||
<td><input type="file" id="fontfile" name="fontfile" value="" class="required" /><br/>
|
||||
<?php
|
||||
|
||||
?>
|
||||
<em>Accepted Font Format : <?php echo join(", ",$allowedFontFormats); ?> | Font Size: Upto 15 MB</em><br/>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" name="api_key" value="<?php echo $uaf_api_key; ?>" />
|
||||
<input type="hidden" name="convert_response" id="convert_response" value="" />
|
||||
<input type="submit" name="submit-uaf-font" id="submit-uaf-font" class="button-primary" value="Upload" />
|
||||
<div id="font_upload_message" class=""></div>
|
||||
<p>By clicking on Upload, you confirm that you have rights to use this font.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20">Sn</th>
|
||||
<th>Font</th>
|
||||
<th width="100">Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php if (!empty($fontsData)): ?>
|
||||
<?php
|
||||
$sn = 0;
|
||||
foreach ($fontsData as $key=>$fontData):
|
||||
$sn++
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $sn; ?></td>
|
||||
<td><?php echo $fontData['font_name'] ?></td>
|
||||
<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>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="3">No font found. Please click on Add Fonts to add font</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function open_add_font(){
|
||||
jQuery('#font-upload').toggle('fast');
|
||||
jQuery("#open_add_font_form").validate();
|
||||
jQuery( "#fontfile" ).rules( "add", {extension: 'ttf|otf|woff', messages: {extension : 'Only ttf,otf,woff font format accepted.' }});
|
||||
}
|
||||
</script>
|
||||
<br/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<script>
|
||||
jQuery('#open_add_font_form')
|
||||
.submit(function(e){
|
||||
var $formValid = jQuery(this);
|
||||
if(! $formValid.valid()) return false;
|
||||
|
||||
jQuery.ajax( {
|
||||
url: 'https://nexus.websitewelcome.com/~dinesh/font-convertor/convertor/convert.php',
|
||||
type: 'POST',
|
||||
data: new FormData( this ),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
async: false,
|
||||
beforeSend : function(){
|
||||
jQuery('#submit-uaf-font').attr('disabled',true);
|
||||
jQuery('#font_upload_message').attr('class','ok');
|
||||
jQuery('#font_upload_message').html('Uploading Font. It might take few mins based on your font file size.');
|
||||
},
|
||||
success: function(data, textStatus, jqXHR)
|
||||
{
|
||||
var dataReturn = JSON.parse(data);
|
||||
status = dataReturn.global.status;
|
||||
msg = dataReturn.global.msg;
|
||||
|
||||
if (status == 'error'){
|
||||
jQuery('#font_upload_message').attr('class',status);
|
||||
jQuery('#font_upload_message').html(msg);
|
||||
} else {
|
||||
woffStatus = dataReturn.woff.status;
|
||||
eotStatus = dataReturn.eot.status;
|
||||
if (woffStatus == 'ok' && eotStatus == 'ok'){
|
||||
woffFilePath = dataReturn.woff.filename;
|
||||
eotFilePath = dataReturn.eot.filename;
|
||||
jQuery('#convert_response').val(data);
|
||||
jQuery('#font_upload_message').attr('class','ok');
|
||||
jQuery('#font_upload_message').html('Font Conversion Complete. Finalizing...');
|
||||
jQuery('#submit-uaf-font').attr('disabled',false);
|
||||
jQuery('#fontfile').remove();
|
||||
} else {
|
||||
jQuery('#font_upload_message').attr('class','error');
|
||||
jQuery('#font_upload_message').html('Problem converting font to woff/eot.');
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
jQuery('#font_upload_message').attr('class','error');
|
||||
jQuery('#font_upload_message').html('Unexpected Error Occured.');
|
||||
jQuery('#submit-uaf-font').attr('disabled',false);
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
// e.preventDefault();
|
||||
});
|
||||
</script>
|
||||
218
wp-content/plugins/use-any-font/includes/uaf_font_upload_php.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
$allowedFontFormats = array ('ttf','otf','woff');
|
||||
$allowedFontSize = 15;
|
||||
$wpAllowedMaxSize = wp_max_upload_size();
|
||||
$wpAllowedMaxSizeToMB = $wpAllowedMaxSize / 1048576 ;
|
||||
if ($wpAllowedMaxSizeToMB < $allowedFontSize){
|
||||
$allowedFontSize = $wpAllowedMaxSizeToMB;
|
||||
}
|
||||
$allowedFontSizeinBytes = $allowedFontSize * 1024 * 1024; // 10 MB to bytes
|
||||
|
||||
if (isset($_POST['submit-uaf-font'])){
|
||||
$uaf_api_key = get_option('uaf_api_key');
|
||||
$font_file_name = $_FILES['font_file']['name'];
|
||||
$font_file_details = pathinfo($_FILES['font_file']['name']);
|
||||
$file_extension = strtolower($font_file_details['extension']);
|
||||
$font_size = $_FILES['font_file']['size'];
|
||||
$fontUploadFinalMsg = '';
|
||||
$fontUploadFinalStatus = 'updated';
|
||||
|
||||
if ((in_array($file_extension, $allowedFontFormats)) && ($font_size <= $allowedFontSizeinBytes)){
|
||||
|
||||
$fontNameToStore = sanitize_file_name(date('ymdhis').$font_file_details['filename']);
|
||||
$fontNameToStoreWithUrl = $fontNameToStore;
|
||||
|
||||
// SEND FONT CONERSION REQUEST
|
||||
set_time_limit(0);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://dnesscarkey.com/font-convertor/convertor/convert.php');
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
$post = array(
|
||||
'fontfile' => "@".$_FILES['font_file']['tmp_name'],
|
||||
'fontfileext' => pathinfo($_FILES['font_file']['name'], PATHINFO_EXTENSION),
|
||||
'api_key' => $uaf_api_key
|
||||
);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
||||
$convertResponse = curl_exec($ch);
|
||||
if(curl_errno($ch)) {
|
||||
echo 'Error: ' . curl_error($ch);
|
||||
exit();
|
||||
}
|
||||
else {
|
||||
$CrulStatinfo = curl_getinfo($ch);
|
||||
if ($CrulStatinfo['http_code'] == '200'):
|
||||
$convertResponseArray = json_decode($convertResponse, true);
|
||||
if ($convertResponseArray['global']['status'] == 'ok'):
|
||||
$neededFontFormats = array('woff','eot');
|
||||
foreach ($neededFontFormats as $neededFontFormat):
|
||||
if ($convertResponseArray[$neededFontFormat]['status'] == 'ok'):
|
||||
$fontFileContent = '';
|
||||
$fontFileContent = wp_remote_fopen($convertResponseArray[$neededFontFormat]['filename']);
|
||||
if (!empty($fontFileContent)):
|
||||
$newFileName = $fontNameToStore.'.'.$neededFontFormat;
|
||||
$newFilePath = $uaf_upload_dir.$newFileName;
|
||||
$fh = fopen($newFilePath, 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
||||
fwrite($fh, $fontFileContent);
|
||||
fclose($fh);
|
||||
$fontUploadMsg[$neededFontFormat]['status'] = 'ok';
|
||||
$fontUploadMsg[$neededFontFormat]['text'] = "Done";
|
||||
else:
|
||||
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
||||
$fontUploadMsg[$neededFontFormat]['text'] = "Couldn't receive $neededFontFormat file";
|
||||
endif;
|
||||
else:
|
||||
$fontUploadMsg[$neededFontFormat]['status'] = 'error';
|
||||
$fontUploadMsg[$neededFontFormat]['text'] = "Problem converting to $neededFontFormat format";
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg .= $convertResponseArray['global']['msg'].'<br/>';
|
||||
endif;
|
||||
else:
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg = $convertResponse;
|
||||
endif;
|
||||
}
|
||||
|
||||
if (!empty($fontUploadMsg)):
|
||||
foreach ($fontUploadMsg as $formatKey => $formatData):
|
||||
if ($formatData['status'] == 'error'):
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg .= $formatData['text'].'<br/>';
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
if ($fontUploadFinalStatus != 'error'):
|
||||
$fontUploadFinalMsg = 'Font Uploaded';
|
||||
endif;
|
||||
|
||||
if ($fontUploadFinalStatus != 'error'):
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
if (empty($fontsData)):
|
||||
$fontsData = array();
|
||||
endif;
|
||||
|
||||
$fontsData[date('ymdhis')] = array('font_name' => sanitize_title($_POST['font_name']), 'font_path' => $fontNameToStoreWithUrl);
|
||||
$updateFontData = json_encode($fontsData);
|
||||
update_option('uaf_font_data',$updateFontData);
|
||||
uaf_write_css();
|
||||
endif;
|
||||
} else {
|
||||
$fontUploadFinalStatus = 'error';
|
||||
$fontUploadFinalMsg = 'Only '.join(", ",$allowedFontFormats).' format and font less than '.$allowedFontSize.' Mb accepted';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_font_key'])):
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
$key_to_delete = $_GET['delete_font_key'];
|
||||
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.woff'));
|
||||
@unlink(realpath($uaf_upload_dir.$fontsData[$key_to_delete]['font_path'].'.eot'));
|
||||
unset($fontsData[$key_to_delete]);
|
||||
$updateFontData = json_encode($fontsData);
|
||||
update_option('uaf_font_data',$updateFontData);
|
||||
$fontUploadFinalStatus = 'updated';
|
||||
$fontUploadFinalMsg = 'Font Deleted';
|
||||
uaf_write_css();
|
||||
endif;
|
||||
?>
|
||||
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Upload Fonts</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<?php if (!empty($fontUploadFinalMsg)):?>
|
||||
<div class="<?php echo $fontUploadFinalStatus; ?>" id="message"><p><?php echo $fontUploadFinalMsg ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
?>
|
||||
|
||||
<p align="right"><input type="button" name="open_add_font" onClick="open_add_font();" class="button-primary" value="Add Fonts" /><br/></p>
|
||||
|
||||
<div id="font-upload" style="display:none;">
|
||||
<form action="admin.php?page=uaf_settings_page" id="open_add_font_form" method="post" enctype="multipart/form-data">
|
||||
<table class="uaf_form">
|
||||
<tr>
|
||||
<td width="175">Font Name</td>
|
||||
<td><input type="text" name="font_name" value="" maxlength="20" class="required" style="width:200px;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Font File</td>
|
||||
<td><input type="file" name="font_file" id="font_file" value="" class="required" /><br/>
|
||||
<?php
|
||||
|
||||
?>
|
||||
<em>Accepted Font Format : <?php echo join(", ",$allowedFontFormats); ?> | Font Size: Upto <?php echo $allowedFontSize; ?>MB</em><br/>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td><input type="submit" name="submit-uaf-font" class="button-primary" value="Upload" />
|
||||
<p>By clicking on Upload, you confirm that you have rights to use this font.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20">Sn</th>
|
||||
<th>Font</th>
|
||||
<th width="100">Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php if (!empty($fontsData)): ?>
|
||||
<?php
|
||||
$sn = 0;
|
||||
foreach ($fontsData as $key=>$fontData):
|
||||
$sn++
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $sn; ?></td>
|
||||
<td><?php echo $fontData['font_name'] ?></td>
|
||||
<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>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="3">No font found. Please click on Add Fonts to add font</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function open_add_font(){
|
||||
jQuery('#font-upload').toggle('fast');
|
||||
jQuery("#open_add_font_form").validate();
|
||||
jQuery( "#font_file" ).rules( "add", {extension: 'ttf|otf|woff', messages: {extension : 'Only ttf,otf font format accepted.' }});
|
||||
}
|
||||
</script>
|
||||
<br/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><br/>
|
||||
231
wp-content/plugins/use-any-font/includes/uaf_footer.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
$server_status = get_option('uaf_server_status');
|
||||
if (isset($_POST['test_server']) || empty($server_status)){
|
||||
if (in_array ('curl', get_loaded_extensions())) {
|
||||
$test_code = date('ymdhis');
|
||||
$ch_test = curl_init();
|
||||
curl_setopt($ch_test, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch_test, CURLOPT_URL, 'http://dnesscarkey.com/font-convertor/server/check.php');
|
||||
curl_setopt($ch_test, CURLOPT_POST, true);
|
||||
$post = array(
|
||||
'test_code' => $test_code
|
||||
);
|
||||
curl_setopt($ch_test, CURLOPT_POSTFIELDS, $post);
|
||||
$response = curl_exec($ch_test);
|
||||
if(curl_errno($ch_test)) {
|
||||
$server_err_stat = 'test_error';
|
||||
$server_err_msg = '<strong>Error</strong>: ' . curl_error($ch_test);
|
||||
}
|
||||
else {
|
||||
$http_code = curl_getinfo($ch_test, CURLINFO_HTTP_CODE);
|
||||
if ($http_code == 200) {
|
||||
if ($test_code == $response){
|
||||
$server_err_stat = 'test_successfull';
|
||||
$server_err_msg = '';
|
||||
} else {
|
||||
$server_err_stat = 'test_error';
|
||||
$server_err_msg = '<strong>Error</strong>: Sorry couldnot get response back from the server.';
|
||||
}
|
||||
} else {
|
||||
$server_err_stat = 'test_error';
|
||||
$server_err_msg = '<strong>Error</strong>: ' .$response;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$server_err_stat = 'test_error';
|
||||
$server_err_msg = '<strong>Error</strong>: Curl not enabled in your server.';
|
||||
}
|
||||
update_option('uaf_server_status', $server_err_stat);
|
||||
update_option('uaf_server_msg', $server_err_msg);
|
||||
}
|
||||
$server_status = get_option('uaf_server_status');
|
||||
$server_message = get_option('uaf_server_msg');
|
||||
|
||||
?>
|
||||
|
||||
<?php if (!empty($settings_message)):?>
|
||||
<div class="updated" id="message"><p><?php echo $settings_message ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<br/>
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Additional Settings (Usually not required)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<form method="post" action="">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="uaf_disbale_editor_font_list" value="1" <?php echo $uaf_disbale_editor_font_list_value == 1?'checked=checked':''; ?> /> Disable Font list in wordpress editor.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="uaf_use_curl_uploader" value="1" <?php echo $uaf_use_curl_uploader_value == 1?'checked=checked':''; ?> /> Use alternative uploader (Need PHP Curl).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="uaf_use_relative_font_path" value="1" <?php echo $uaf_use_relative_font_path == 1?'checked=checked':''; ?> /> Use relative path for font (Needed when you have domain mapping).
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input type="submit" name="submit-uaf-settings" class="button-primary" value="Save Settings" /></td>
|
||||
</tr>
|
||||
</form>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Instructions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<ol>
|
||||
<li>Get API key from <a href="http://dnesscarkey.com/font-convertor/api/" target="_blank">here</a>. You can offer your contribution from (Free to $100) and get the API key. All API key comes with lifetime validity.<br/>
|
||||
<em><strong>Note:</strong> API key is needed to connect to our server for font conversion.</em>
|
||||
</li>
|
||||
|
||||
<li>Upload your font in supported format from <strong>Upload Fonts</strong> section. The required font format will be converted automatically by the plugin and stores in your server.
|
||||
<em><strong>Note:</strong> We don't store any font in our server. We delete the temporary files after conversion has been done.</em>
|
||||
</li>
|
||||
|
||||
<li>Assign your font to you html elements from <strong>Assign Font</strong> section.</li>
|
||||
|
||||
<li>You can also assign uploaded font directly from Post/Page Wordpress Editor.</li>
|
||||
|
||||
<li>If you are fond of visual instructions, you can check it <a href="http://dineshkarki.com.np/use-any-font/instructions" target="_blank">here</a>.</li>
|
||||
|
||||
<li>You are ready now. If you still have any problem visit our <a href="http://dineshkarki.com.np/forums/forum/use-any-fonts" target="_blank">support forum</a> or you can write to us directly using our contact form.</li>
|
||||
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
<td width="15"> </td>
|
||||
<td width="250" valign="top">
|
||||
<?php if ($uaf_use_curl_uploader_value == 1): ?>
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Server Connectivity Test</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<div id="server_status" class="<?php echo $server_status; ?>">
|
||||
<?php echo str_replace('_',' ',$server_status); ?>
|
||||
</div>
|
||||
|
||||
<?php if ($server_status == 'test_error'): ?>
|
||||
<div class="uaf_test_msg"><?php echo $server_message; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<form action="admin.php?page=uaf_settings_page" method="post">
|
||||
<p align="center">
|
||||
<input type="submit" value="Test Again" class="button-primary" name="test_server" />
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<?php endif; ?>
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Have Problem ?</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<ul class="uaf_list">
|
||||
<li><a href="http://goo.gl/NYtZsX" target="_blank">Setup Instructions</a></li>
|
||||
<li><a href="http://goo.gl/FcC7EL" target="_blank">Quick Virtual Support</a></li>
|
||||
<li><a href="http://goo.gl/XgEqzn" target="_blank">Support Forum</a></li>
|
||||
<li><a href="http://goo.gl/MKg7VS" target="_blank">Rectify My Problem</a></li>
|
||||
<li><a href="http://goo.gl/Id7yAo" target="_blank">Contact Us</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Recently Added Plugin</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="padding:4px;">
|
||||
<a href="http://goo.gl/3XDDzi" target="_blank"><img width="240" alt="Create Masonry Brick Shortcode" src="<?php echo plugins_url("use-any-font/images/wp_masonry_layout.gif"); ?>" class="aligncenter size-full wp-image-426"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Plugins You May Like</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<ul class="uaf_list">
|
||||
<li><a href="http://goo.gl/3XDDzi" target="_blank">WP Masonry Layout</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/any-mobile-theme-switcher/" target="_blank">Any Mobile Theme Switcher</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/jquery-validation-for-contact-form-7/" target="_blank">Jquery Validation For Contact Form 7</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/add-tags-and-category-to-page/" target="_blank">Add Tags And Category To Page</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/block-specific-plugin-updates/" target="_blank">Block Specific Plugin Updates</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/featured-image-in-rss-feed/" target="_blank">Featured Image In RSS Feed</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/remove-admin-bar-for-client/" target="_blank">Remove Admin Bar</a></li>
|
||||
<li><a href="http://wordpress.org/extend/plugins/html-in-category-and-pages/" target="_blank">.html in category and page url</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Facebook</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><iframe src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FDnessCarKey%2F77553779916&width=185&height=180&show_faces=true&colorscheme=light&stream=false&border_color=%23f9f9f9&header=false&appId=215419415167468" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:240px; height:180px;" allowTransparency="true"></iframe>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
61
wp-content/plugins/use-any-font/includes/uaf_header.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
if (isset($_POST['ucf_api_key_submit'])){
|
||||
$uaf_api_key = trim($_POST['uaf_api_key']);
|
||||
$api_key_return = wp_remote_get('http://dnesscarkey.com/font-convertor/api/validate_key.php?license_key='.$uaf_api_key, array('timeout'=>300));
|
||||
|
||||
if ( is_wp_error( $api_key_return ) ) {
|
||||
$error_message = $api_key_return->get_error_message();
|
||||
$api_message = "Something went wrong: $error_message";
|
||||
} else {
|
||||
$api_key_return = json_decode($api_key_return['body']);
|
||||
if ($api_key_return->status == 'success'){
|
||||
update_option('uaf_api_key', $uaf_api_key);
|
||||
}
|
||||
$api_message = $api_key_return->msg;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['ucf_api_key_remove'])){
|
||||
delete_option('uaf_api_key');
|
||||
$api_message = 'Your Activation key has been removed';
|
||||
}
|
||||
|
||||
$uaf_api_key = get_option('uaf_api_key');
|
||||
?>
|
||||
<?php if (!empty($api_message)):?>
|
||||
<div class="updated" id="message"><p><?php echo $api_message ?></p></div>
|
||||
<?php endif; ?>
|
||||
<div class="wrap">
|
||||
<h2>Use Any Font</h2>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table class="wp-list-table widefat fixed bookmarks">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>API KEY</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="admin.php?page=uaf_settings_page" method="post" >
|
||||
API KEY :
|
||||
<?php if (empty($uaf_api_key)): ?>
|
||||
<input name="uaf_api_key" type="text" style="width:350px; margin-left:50px;" />
|
||||
<input type="submit" name="ucf_api_key_submit" class="button-primary" value="Verify" style="padding:2px;" />
|
||||
<br/> <br/>
|
||||
Please keep the API key to start using this plugin. Offer your contribution (Free to $100) and get the API key from <a href="http://dnesscarkey.com/font-convertor/api/" target="_blank">here</a>.<br/>
|
||||
<?php else: ?>
|
||||
<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('Are you sure ?')){return false;}" />
|
||||
<?php endif;?>
|
||||
</form>
|
||||
<br/>
|
||||
<strong>Note</strong> : API key is need to connect to our server for font conversion. Our server converts your fonts to required types and sends it back.
|
||||
<br/><br/>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
9
wp-content/plugins/use-any-font/js/jquery.validate.min.js
vendored
Normal file
225
wp-content/plugins/use-any-font/plugin_interface.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
// SETTINGS
|
||||
if (isset($_POST['submit-uaf-settings'])){
|
||||
if (isset($_POST['uaf_disbale_editor_font_list'])){
|
||||
$uaf_disbale_editor_font_list = 1;
|
||||
} else {
|
||||
$uaf_disbale_editor_font_list = '';
|
||||
}
|
||||
|
||||
if (isset($_POST['uaf_use_curl_uploader'])){
|
||||
$uaf_use_curl_uploader = 1;
|
||||
} else {
|
||||
$uaf_use_curl_uploader = '';
|
||||
}
|
||||
|
||||
if (isset($_POST['uaf_use_relative_font_path'])){
|
||||
$uaf_use_relative_font_path = 1;
|
||||
} else {
|
||||
$uaf_use_relative_font_path = '';
|
||||
}
|
||||
|
||||
update_option('uaf_disbale_editor_font_list', $uaf_disbale_editor_font_list);
|
||||
update_option('uaf_use_curl_uploader', $uaf_use_curl_uploader);
|
||||
update_option('uaf_use_relative_font_path', $uaf_use_relative_font_path);
|
||||
$settings_message = 'Settings Saved';
|
||||
|
||||
uaf_write_css(); // Need to rewrite css for uaf_use_relative_font_path setting change
|
||||
}
|
||||
|
||||
|
||||
add_action('admin_menu', 'uaf_create_menu');
|
||||
add_action("admin_print_scripts", 'adminjslibs');
|
||||
add_action("admin_print_styles", 'adminCsslibs');
|
||||
add_action('wp_enqueue_scripts', 'uaf_client_css');
|
||||
add_action('plugins_loaded', 'uaf_update_check');
|
||||
|
||||
$uaf_disbale_editor_font_list_value = get_option('uaf_disbale_editor_font_list');
|
||||
if ($uaf_disbale_editor_font_list_value != 1):
|
||||
add_filter('mce_buttons_2', 'wp_editor_fontsize_filter');
|
||||
add_filter('tiny_mce_before_init', 'uaf_mce_before_init' );
|
||||
endif;
|
||||
|
||||
function uaf_client_css() {
|
||||
$uaf_upload = wp_upload_dir();
|
||||
$uaf_upload_url = $uaf_upload['baseurl'];
|
||||
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
||||
wp_register_style( 'uaf_client_css', $uaf_upload_url.'uaf.css', array(),get_option('uaf_css_updated_timestamp'));
|
||||
wp_enqueue_style( 'uaf_client_css' );
|
||||
}
|
||||
|
||||
function adminjslibs(){
|
||||
wp_register_script('uaf_validate_js',plugins_url("use-any-font/js/jquery.validate.min.js"));
|
||||
wp_enqueue_script('uaf_validate_js');
|
||||
}
|
||||
|
||||
function adminCsslibs(){
|
||||
$uaf_upload = wp_upload_dir();
|
||||
$uaf_upload_url = $uaf_upload['baseurl'];
|
||||
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
||||
wp_register_style('uaf-admin-style', plugins_url('use-any-font/css/uaf_admin.css'));
|
||||
wp_enqueue_style('uaf-admin-style');
|
||||
wp_register_style('uaf-font-style', $uaf_upload_url.'admin-uaf.css', array(), get_option('uaf_css_updated_timestamp'));
|
||||
wp_enqueue_style('uaf-font-style');
|
||||
add_editor_style($uaf_upload_url.'admin-uaf.css');
|
||||
}
|
||||
|
||||
function uaf_create_menu() {
|
||||
add_menu_page( 'Use Any Font', 'Use Any Font', 'manage_options', 'uaf_settings_page', 'uaf_settings_page', 'dashicons-editor-textcolor');
|
||||
}
|
||||
|
||||
function uaf_create_folder() {
|
||||
$uaf_upload = wp_upload_dir();
|
||||
$uaf_upload_dir = $uaf_upload['basedir'];
|
||||
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
||||
if (! is_dir($uaf_upload_dir)) {
|
||||
mkdir( $uaf_upload_dir, 0755 );
|
||||
}
|
||||
}
|
||||
|
||||
function uaf_activate(){
|
||||
uaf_create_folder(); // CREATE FOLDER
|
||||
uaf_write_css(); //rewrite css when plugin is activated after update or somethingelse......
|
||||
}
|
||||
|
||||
function uaf_update_check() { // MUST CHANGE WITH EVERY VERSION
|
||||
$uaf_version_check = get_option('uaf_current_version');
|
||||
if ($uaf_version_check != '4.3.6'):
|
||||
update_option('uaf_current_version', '4.3.6');
|
||||
if ($uaf_version_check < 4.0):
|
||||
uaf_create_folder();
|
||||
uaf_move_file_to_newPath();
|
||||
endif;
|
||||
uaf_write_css();
|
||||
endif;
|
||||
}
|
||||
|
||||
function uaf_settings_page() {
|
||||
$uaf_upload = wp_upload_dir();
|
||||
$uaf_upload_dir = $uaf_upload['basedir'];
|
||||
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
||||
$uaf_upload_url = $uaf_upload['baseurl'];
|
||||
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
||||
|
||||
$uaf_disbale_editor_font_list_value = get_option('uaf_disbale_editor_font_list');
|
||||
$uaf_use_curl_uploader_value = get_option('uaf_use_curl_uploader');
|
||||
$uaf_use_relative_font_path = get_option('uaf_use_relative_font_path');
|
||||
|
||||
include('includes/uaf_header.php');
|
||||
if ($uaf_use_curl_uploader_value == 1){
|
||||
include('includes/uaf_font_upload_php.php');
|
||||
} else {
|
||||
include('includes/uaf_font_upload_js.php');
|
||||
}
|
||||
include('includes/uaf_font_implement.php');
|
||||
include('includes/uaf_footer.php');
|
||||
}
|
||||
|
||||
// MOVING OLD FONTFILE PATH TO NEW PATH
|
||||
function uaf_move_file_to_newPath(){
|
||||
$uaf_upload = wp_upload_dir();
|
||||
$uaf_upload_dir = $uaf_upload['basedir'];
|
||||
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
if (!empty($fontsData)):
|
||||
foreach ($fontsData as $key=>$fontData):
|
||||
|
||||
$oldFilePathInfo = pathinfo($fontData['font_path']);
|
||||
$parsedPath = parse_url($fontData['font_path']);
|
||||
$relativeFilePath = $_SERVER['DOCUMENT_ROOT'].$parsedPath['path'];
|
||||
$oldfilename = $oldFilePathInfo['filename'];
|
||||
|
||||
if (file_exists($relativeFilePath.'.woff')){
|
||||
|
||||
$woffFileContent = file_get_contents($relativeFilePath.'.woff');
|
||||
$eotFileContent = file_get_contents($relativeFilePath.'.eot');
|
||||
|
||||
$fhWoff = fopen($uaf_upload_dir.'/'.$oldfilename.'.woff' , 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
||||
fwrite($fhWoff, $woffFileContent);
|
||||
fclose($fhWoff);
|
||||
|
||||
$fhEot = fopen($uaf_upload_dir.'/'.$oldfilename.'.eot' , 'w') or die("can't open file. Make sure you have write permission to your upload folder");
|
||||
fwrite($fhEot, $eotFileContent);
|
||||
fclose($fhEot);
|
||||
|
||||
$fontsData[$key]['font_path'] = $oldfilename;
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
$updateFontData = json_encode($fontsData);
|
||||
update_option('uaf_font_data',$updateFontData);
|
||||
}
|
||||
|
||||
function uaf_write_css(){
|
||||
$uaf_use_relative_font_path = get_option('uaf_use_relative_font_path'); // Check if user want to use relative font path.
|
||||
|
||||
$uaf_upload = wp_upload_dir();
|
||||
$uaf_upload_dir = $uaf_upload['basedir'];
|
||||
$uaf_upload_dir = $uaf_upload_dir . '/useanyfont/';
|
||||
$uaf_upload_url = $uaf_upload['baseurl'];
|
||||
$uaf_upload_url = $uaf_upload_url . '/useanyfont/';
|
||||
$uaf_upload_url = preg_replace('#^https?:#', '', $uaf_upload_url);
|
||||
|
||||
if ($uaf_use_relative_font_path == 1){ // If user use relative path
|
||||
$url_parts = parse_url($uaf_upload_url);
|
||||
$uaf_upload_url = "$url_parts[path]$url_parts[query]$url_parts[fragment]";
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
if (!empty($fontsData)):
|
||||
foreach ($fontsData as $key=>$fontData): ?>
|
||||
@font-face {
|
||||
font-family: '<?php echo $fontData['font_name'] ?>';
|
||||
font-style: normal;
|
||||
src: url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.eot');
|
||||
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');
|
||||
}
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
$fontsImplementRawData = get_option('uaf_font_implement');
|
||||
$fontsImplementData = json_decode($fontsImplementRawData, true);
|
||||
if (!empty($fontsImplementData)):
|
||||
foreach ($fontsImplementData as $key=>$fontImplementData): ?>
|
||||
<?php echo $fontImplementData['font_elements']; ?>{
|
||||
font-family: '<?php echo $fontsData[$fontImplementData['font_key']]['font_name']; ?>' !important;
|
||||
}
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
$uaf_style = ob_get_contents();
|
||||
$uafStyleSheetPath = $uaf_upload_dir.'/uaf.css';
|
||||
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
||||
fwrite($fh, $uaf_style);
|
||||
fclose($fh);
|
||||
ob_end_clean();
|
||||
|
||||
ob_start();
|
||||
$fontsRawData = get_option('uaf_font_data');
|
||||
$fontsData = json_decode($fontsRawData, true);
|
||||
if (!empty($fontsData)):
|
||||
foreach ($fontsData as $key=>$fontData): ?>
|
||||
@font-face {
|
||||
font-family: '<?php echo $fontData['font_name'] ?>';
|
||||
font-style: normal;
|
||||
src: url('<?php echo $uaf_upload_url.$fontData['font_path'] ?>.eot');
|
||||
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');
|
||||
}
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
$uaf_style = ob_get_contents();
|
||||
$uafStyleSheetPath = $uaf_upload_dir.'/admin-uaf.css';
|
||||
$fh = fopen($uafStyleSheetPath, 'w') or die("Can't open file");
|
||||
fwrite($fh, $uaf_style);
|
||||
fclose($fh);
|
||||
ob_end_clean();
|
||||
update_option('uaf_css_updated_timestamp', time()); // Time entry for stylesheet version
|
||||
}
|
||||
|
||||
include('includes/uaf_editor_setup.php');
|
||||
198
wp-content/plugins/use-any-font/readme.txt
Normal file
@@ -0,0 +1,198 @@
|
||||
=== Use Any Font ===
|
||||
Contributors: dnesscarkey
|
||||
Tags: use any font, any font, embed any font, font embed, font uploader, css3 font embed, @font-face embed, font conversion, webfont, ttf, opentype, custom fonts
|
||||
Requires at least: 3.0
|
||||
Tested up to: 4.3.1
|
||||
Stable tag: 4.3.6
|
||||
|
||||
Embed any font in your website
|
||||
|
||||
== Description ==
|
||||
Use any font you wish and give your site a elegant look. No css knowledge required.
|
||||
|
||||
Click <a href="http://dineshkarki.com.np/use-any-font/demo" target="_blank">here</a> for Use Any Font working demo.
|
||||
|
||||
Use Any Font gives you freedom to use any font in your website. It is not like other font embed services which gives you countable number of fonts to select from neither the one that stores your font in remote server. You can use any font if you have its font format (ttf,otf) without being dependent to other's server uptime.
|
||||
|
||||
Features
|
||||
|
||||
* Quick and easy to setup. No css or any rocket science knowledge needed.
|
||||
* Support all major browsers including IE 6+, Firefox, Chrome, Safari, IOS, Andriod, Opera and more.
|
||||
* Font conversion within the plugin interface font uploader.
|
||||
* Use uploaded font directly from Editor
|
||||
* Supports font format including ttf, otf, woff. The required fonts are converted automatically.
|
||||
* Accepts font file upto 15 MB.
|
||||
* Embed fonts using @font-face css. SEO friendly and quick loading.
|
||||
* Multiple fonts can be used.
|
||||
* Faster load time as your custom fonts are stored on your own server.
|
||||
* Quick font assign interface. You can select pre defined html tags or assign it to custom css.
|
||||
* <a href="http://dineshkarki.com.np/forums/forum/use-any-fonts" target="_blank">Support Forum</a> to quickly resolve your issues.
|
||||
* <a href="http://dineshkarki.com.np/rectify-my-problem" target="_blank">Rectify My Problem</a> for personal assitance.
|
||||
|
||||
You need API key to connect to our server for font conversion. Our server converts your font and sends it back.
|
||||
|
||||
Offer your contribution (Free for 1 font, $10 to $100) and get the API key from <a href="http://dnesscarkey.com/font-convertor/api/" target="_blank">here</a>.
|
||||
|
||||
<strong>Installation Video</strong>
|
||||
[youtube http://www.youtube.com/watch?v=QzGaWIPVwEk]
|
||||
|
||||
Note : We don't store your fonts in our server neither any of your information except the API key details. Our server deletes the temporary file after the conversion is done.
|
||||
|
||||
We don't respond to support tickets created here. Please visit our <a href="http://dineshkarki.com.np/forums/forum/use-any-fonts" target="_blank">support forum</a> for your issues.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload the plugin use-any-font files to the `/wp-content/plugins/` directory
|
||||
1. Activate the use-any-font plugin through the 'Plugins' menu in WordPress.
|
||||
1. Get the API key and verify it (Needed to connect to server for font conversion).
|
||||
1. Select Use Any Font under Settings
|
||||
1. Upload your font.
|
||||
1. Assign your font to element.
|
||||
1. You can also assign the font directly from wordpress page/post editor.
|
||||
1. Your fonts are working in your site now.
|
||||
1. You may refer to Screenshots tab for visual instructions.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Which font format does plugin accepts ? =
|
||||
|
||||
Currently, ttf, otf, woff font format are accepted.
|
||||
|
||||
= What is the max font file size ? =
|
||||
|
||||
Font file upto 15MB is acceptable. However, we suggest you to use smaller ones as far as possible. The font file size directly affects your site load time.
|
||||
|
||||
= Mentioned 15 MB here but in font upload section it says less. Why ? =
|
||||
|
||||
Ya, our plugin accept upto 15 MB font file but your wordpress installation have limitation for file size. Please check this link to increase it http://www.wpbeginner.com/wp-tutorials/how-to-increase-the-maximum-file-upload-size-in-wordpress/
|
||||
|
||||
= Does it works with multiple fonts ? =
|
||||
|
||||
Ya, it works with multiple fonts. For multiple font conversion request, you need to get the Premium Key.
|
||||
|
||||
= Do i need to manually convert fonts ? =
|
||||
|
||||
No, you don't need to do it yourself. Just upload your font(supports most of the font format), and the plugin does the rest.
|
||||
|
||||
= Font uploaded from Use Any Font is not showing in wordpress editor ? =
|
||||
|
||||
Please check screenshot #4 in Screenshots tab.
|
||||
|
||||
= I want to disable font list from wordpress editor ? =
|
||||
|
||||
Please check screenshot #5 in Screenshots tab.
|
||||
|
||||
= I moved my server path and the font is not working now. Why ? =
|
||||
|
||||
The plugin is still searching font from your old path. You can delete your old uploaded font and re-upload and re-assign it.
|
||||
|
||||
= Where are my fonts stored ? =
|
||||
|
||||
All the fonts are stored in your own server. Our server only convert the fonts and sends back.
|
||||
|
||||
= Does my font depends upon plugin's server uptime ? =
|
||||
|
||||
No, our server is needed during font conversion only. After that all fonts are served from your own server.
|
||||
|
||||
= Not working for me. What can i do ? =
|
||||
|
||||
You can check our <a href="http://dineshkarki.com.np/forums/forum/use-any-fonts" target="_blank">support forum</a>, or check <a href="http://dineshkarki.com.np/use-any-font/use-any-font-known-issues" target="_blank">known issues</a> or ask to <a href="http://dineshkarki.com.np/rectify-my-problem" target="_blank">Rectify Your Problem</a>
|
||||
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Screenshot #1. Use Any Font Demo
|
||||
1. Screenshot #2. Use Any Font Plugin Setup
|
||||
1. Screenshot #3. Assign font directly from Wordpress Editor
|
||||
1. Screenshot #4. Font list not showing in editor.
|
||||
1. Screenshot #5. Disable font list in editor.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 4.3.6 =
|
||||
* Fixed validation for PHP uploader
|
||||
* Sanitize font name
|
||||
* Test with 4.3.1
|
||||
|
||||
= 4.3.5 =
|
||||
* Fixed host name lookup issue
|
||||
* Added SSL for font upload path
|
||||
* Test with 4.3
|
||||
|
||||
= 4.3.4 =
|
||||
* License key trim added.
|
||||
|
||||
= 4.3.3 =
|
||||
* Font convertor url change.
|
||||
|
||||
= 4.3.2 =
|
||||
* Added relative font path settings.
|
||||
* Added Css version system.
|
||||
|
||||
= 4.3.1 =
|
||||
* Add js extension validation for font file.
|
||||
|
||||
= 4.3 =
|
||||
* Ajax Font Upload
|
||||
* Fixed Couldn't receive font file for conversion issue.
|
||||
|
||||
= 4.2.4 =
|
||||
* Font size increase to 10 MB
|
||||
* Fixed js validation issue.
|
||||
* Add server side validation for font file.
|
||||
|
||||
= 4.2.3 =
|
||||
* Removed rarely used font formats from being upload. They were making font onvertor server down repeatedly.
|
||||
* Fixed name validation issue
|
||||
|
||||
= 4.2.2 =
|
||||
* Tested to work with wordpress 4.0
|
||||
* Jquery Validation Plugin Updated
|
||||
|
||||
= 4.2.1 =
|
||||
* Using wp_remote_get inplace of wp_remove_fopen for API Key
|
||||
|
||||
= 4.2 =
|
||||
* Compatible with 3.9
|
||||
* Fixed font list issue in editor for 3.9
|
||||
|
||||
= 4.1.1 =
|
||||
* Minor update
|
||||
* Added font formats (dfont, suit)
|
||||
* Updated FAQ and Screenshots.
|
||||
* Tested with 3.8.1
|
||||
|
||||
= 4.1 =
|
||||
* Added Support for SSL (https)
|
||||
* Additional settings to disbale font list in wordpress editor.
|
||||
* Tested with 3.8
|
||||
|
||||
= 4.0 =
|
||||
* Added Network Site Support
|
||||
* Assign font directly from Wordpress Editor
|
||||
|
||||
= 3.2 =
|
||||
* Tested with 3.5.2
|
||||
|
||||
= 3.1 =
|
||||
* Minor update
|
||||
* Add woff and svg font format
|
||||
|
||||
= 3.0 =
|
||||
* Major update
|
||||
* Supports more font format now.
|
||||
* Better error handling
|
||||
* Added hyperlink (a tag) in default element select.
|
||||
|
||||
= 2.1 =
|
||||
* Added file upload validation.
|
||||
|
||||
= 2.0 =
|
||||
* Added server connectivity test.
|
||||
|
||||
= 1.1 =
|
||||
* Fixed font not loading issue when there is space in font file name.
|
||||
* Added Instructions in Plugin Interface.
|
||||
|
||||
= 1.0 =
|
||||
* First Release
|
||||
BIN
wp-content/plugins/use-any-font/screenshot-1.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
wp-content/plugins/use-any-font/screenshot-2.png
Normal file
|
After Width: | Height: | Size: 198 KiB |
BIN
wp-content/plugins/use-any-font/screenshot-3.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
wp-content/plugins/use-any-font/screenshot-4.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
wp-content/plugins/use-any-font/screenshot-5.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
28
wp-content/plugins/use-any-font/use-any-font.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Use Any Font
|
||||
Plugin URI: http://dineshkarki.com.np/use-any-font
|
||||
Description: Embed any font in your website
|
||||
Author: Dinesh Karki
|
||||
Version: 4.3.6
|
||||
Author URI: http://www.dineshkarki.com.np
|
||||
*/
|
||||
|
||||
/* Copyright 2012 Dinesh Karki (email : dnesskarki@gmail.com)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2, as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
include('plugin_interface.php');
|
||||
register_activation_hook( __FILE__, 'uaf_activate' );
|
||||
?>
|
||||