Changeset 3129913
- Timestamp:
- 08/02/2024 09:11:15 AM (19 months ago)
- Location:
- fontier/trunk
- Files:
-
- 77 added
- 6 edited
-
admin/partials/fontier-admin-options.php (modified) (2 diffs)
-
fontier.php (modified) (2 diffs)
-
public/class-fontier-public.php (modified) (9 diffs)
-
public/css/fontier-public.css (modified) (1 diff)
-
public/partials/fontier-public-display.php (modified) (6 diffs)
-
public/vendor (added)
-
public/vendor/php-font-lib (added)
-
public/vendor/php-font-lib/AUTHORS.md (added)
-
public/vendor/php-font-lib/Autoloader.php (added)
-
public/vendor/php-font-lib/LICENSE (added)
-
public/vendor/php-font-lib/README.md (added)
-
public/vendor/php-font-lib/composer.json (added)
-
public/vendor/php-font-lib/maps (added)
-
public/vendor/php-font-lib/maps/adobe-standard-encoding.map (added)
-
public/vendor/php-font-lib/maps/cp1250.map (added)
-
public/vendor/php-font-lib/maps/cp1251.map (added)
-
public/vendor/php-font-lib/maps/cp1252.map (added)
-
public/vendor/php-font-lib/maps/cp1253.map (added)
-
public/vendor/php-font-lib/maps/cp1254.map (added)
-
public/vendor/php-font-lib/maps/cp1255.map (added)
-
public/vendor/php-font-lib/maps/cp1257.map (added)
-
public/vendor/php-font-lib/maps/cp1258.map (added)
-
public/vendor/php-font-lib/maps/cp874.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-1.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-11.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-15.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-16.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-2.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-4.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-5.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-7.map (added)
-
public/vendor/php-font-lib/maps/iso-8859-9.map (added)
-
public/vendor/php-font-lib/maps/koi8-r.map (added)
-
public/vendor/php-font-lib/maps/koi8-u.map (added)
-
public/vendor/php-font-lib/src (added)
-
public/vendor/php-font-lib/src/FontLib (added)
-
public/vendor/php-font-lib/src/FontLib/AdobeFontMetrics.php (added)
-
public/vendor/php-font-lib/src/FontLib/BinaryStream.php (added)
-
public/vendor/php-font-lib/src/FontLib/EOT (added)
-
public/vendor/php-font-lib/src/FontLib/EOT/File.php (added)
-
public/vendor/php-font-lib/src/FontLib/EOT/Header.php (added)
-
public/vendor/php-font-lib/src/FontLib/EncodingMap.php (added)
-
public/vendor/php-font-lib/src/FontLib/Exception (added)
-
public/vendor/php-font-lib/src/FontLib/Exception/FontNotFoundException.php (added)
-
public/vendor/php-font-lib/src/FontLib/Font.php (added)
-
public/vendor/php-font-lib/src/FontLib/Glyph (added)
-
public/vendor/php-font-lib/src/FontLib/Glyph/Outline.php (added)
-
public/vendor/php-font-lib/src/FontLib/Glyph/OutlineComponent.php (added)
-
public/vendor/php-font-lib/src/FontLib/Glyph/OutlineComposite.php (added)
-
public/vendor/php-font-lib/src/FontLib/Glyph/OutlineSimple.php (added)
-
public/vendor/php-font-lib/src/FontLib/Header.php (added)
-
public/vendor/php-font-lib/src/FontLib/OpenType (added)
-
public/vendor/php-font-lib/src/FontLib/OpenType/File.php (added)
-
public/vendor/php-font-lib/src/FontLib/OpenType/TableDirectoryEntry.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table (added)
-
public/vendor/php-font-lib/src/FontLib/Table/DirectoryEntry.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Table.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/cmap.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/cvt.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/fpgm.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/glyf.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/head.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/hhea.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/hmtx.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/kern.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/loca.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/maxp.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/name.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/nameRecord.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/os2.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/post.php (added)
-
public/vendor/php-font-lib/src/FontLib/Table/Type/prep.php (added)
-
public/vendor/php-font-lib/src/FontLib/TrueType (added)
-
public/vendor/php-font-lib/src/FontLib/TrueType/Collection.php (added)
-
public/vendor/php-font-lib/src/FontLib/TrueType/File.php (added)
-
public/vendor/php-font-lib/src/FontLib/TrueType/Header.php (added)
-
public/vendor/php-font-lib/src/FontLib/TrueType/TableDirectoryEntry.php (added)
-
public/vendor/php-font-lib/src/FontLib/WOFF (added)
-
public/vendor/php-font-lib/src/FontLib/WOFF/File.php (added)
-
public/vendor/php-font-lib/src/FontLib/WOFF/Header.php (added)
-
public/vendor/php-font-lib/src/FontLib/WOFF/TableDirectoryEntry.php (added)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fontier/trunk/admin/partials/fontier-admin-options.php
r3114702 r3129913 76 76 'default' => 'A Quick Brown Fox Jump Over a Lazy Dog' 77 77 ), 78 79 array( 80 'id' => 'fontier_glyph_ebl', 81 'type' => 'switcher', 82 'title' => 'Glyph Section', 83 'text_on' => 'Enabled', 84 'text_off' => 'Disabled', 85 'text_width' => 100, 86 'default' => true 87 ), 88 89 array( 90 'id' => 'fontier_glyph_text', 91 'type' => 'text', 92 'title' => 'Glyph Section Title', 93 'default' => 'Glyph List', 94 'dependency' => array( 'fontier_glyph_ebl', '==', 'true' ) 95 ), 96 78 97 79 98 array( … … 135 154 'output' =>'.fontier-list li:after', 136 155 ), 156 157 158 159 array( 160 'id' => 'fontier_glyph_ttl_color', 161 'type' => 'color', 162 'title' => 'Glyph Title Color', 163 'default' =>'#164a41', 164 'output' => '#fontier-glyph-generate h3', 165 'output_mode' => 'color', 166 'dependency' => array( 'fontier_glyph_ebl', '==', 'true' ) 167 ), 168 169 array( 170 'id' => 'fontier_glyph_border_color', 171 'type' => 'color', 172 'title' => 'Glyph Border Color', 173 'default' =>'#ccc', 174 'output' => '.fontier-glyph-list li,.fontier-glyph-list', 175 'output_mode' => 'border-color', 176 'dependency' => array( 'fontier_glyph_ebl', '==', 'true' ) 177 ), 178 137 179 )), 138 180 -
fontier/trunk/fontier.php
r3114702 r3129913 17 17 * Plugin URI: https://teconce.com 18 18 * Description: Fontier is a auto font preview genration plugin for EDD 19 * Version: 1. 119 * Version: 1.2 20 20 * Author: Teconce 21 21 * Author URI: https://teconce.com/about/ … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'FONTIER_VERSION', '1. 1' );38 define( 'FONTIER_VERSION', '1.2' ); 39 39 40 40 /** -
fontier/trunk/public/class-fontier-public.php
r3114702 r3129913 21 21 * @author Teconce <[email protected]> 22 22 */ 23 class Fontier_Public 24 { 23 // Custom Autoloader for FontLib 24 spl_autoload_register(function ($class) { 25 $prefix = 'FontLib\\'; 26 $base_dir = __DIR__ . '/vendor/php-font-lib/src/FontLib/'; 27 28 // Does the class use the namespace prefix? 29 $len = strlen($prefix); 30 if (strncmp($prefix, $class, $len) !== 0) { 31 // No, move to the next registered autoloader 32 return; 33 } 34 35 // Get the relative class name 36 $relative_class = substr($class, $len); 37 38 // Replace the namespace prefix with the base directory, replace namespace 39 // separators with directory separators in the relative class name, append 40 // with .php 41 $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; 42 43 // If the file exists, require it 44 if (file_exists($file)) { 45 require $file; 46 } 47 }); 48 49 use FontLib\Font; 50 51 52 class Fontier_Public { 25 53 private $fontier_product_type = 'download'; 26 54 private $fontier_product_taxonomy = 'download_category'; … … 29 57 public $slug = 'font_preview'; 30 58 31 function __construct() 32 { 59 function __construct() { 33 60 define('FONTIER_PATH', plugin_dir_path(__FILE__)); 34 61 $this->layout = FONTIER_PATH . '/partials/fontier-public-display.php'; … … 43 70 add_action('wp_ajax_nopriv_fontGenrate', array($this, 'fontier_font_preview_generator')); 44 71 add_action('wp_enqueue_scripts', array($this, 'fontier_enqueue_styles')); 45 } 46 47 public function fontier_before_post_content($content) 48 { 72 add_action('wp_ajax_fetchGlyphList', array($this, 'fetch_glyph_list')); 73 add_action('wp_ajax_nopriv_fetchGlyphList', array($this, 'fetch_glyph_list')); 74 75 } 76 77 public function fontier_before_post_content($content) { 49 78 if (is_singular($this->fontier_product_type)) { 50 79 $fontier_layout = $this->layout; … … 65 94 } 66 95 67 public function fontier_copy_zip($zip_file, $targetFolder, $id)68 { 69 $output = array();70 if (!empty($zip_file)) {71 $zip = new ZipArchive;72 if ($zip->open($zip_file) === true) {73 for ($i = 0; $i < $zip->numFiles; $i++) {74 $OnlyFileName = $zip->getNameIndex($i);75 $FullFileName = $zip->statIndex($i); 76 77 if (!($FullFileName['name'][strlen($FullFileName['name']) - 1] == "/")) {78 if (preg_match('#\.(ttf|otf)$#i', $OnlyFileName)) {79 $name = basename($FullFileName['name']);80 $zip->extractTo($targetFolder, $FullFileName['name']);81 $extractedFile = $targetFolder . DIRECTORY_SEPARATOR . $name;82 if (rename($targetFolder . DIRECTORY_SEPARATOR . $FullFileName['name'], $extractedFile)) {83 $output[] = $extractedFile;84 error_log('Extracted font file: ' . $extractedFile);85 } else {86 error_log('Failed to rename file: ' . $targetFolder . DIRECTORY_SEPARATOR . $FullFileName['name']);96 public function fontier_copy_zip($zip_file, $targetFolder, $id) { 97 $output = array(); 98 if (!empty($zip_file)) { 99 $zip = new ZipArchive; 100 if ($zip->open($zip_file) === true) { 101 for ($i = 0; $i < $zip->numFiles; $i++) { 102 $OnlyFileName = $zip->getNameIndex($i); 103 $FullFileName = $zip->statIndex($i); 104 105 if (!($FullFileName['name'][strlen($FullFileName['name']) - 1] == "/")) { 106 if (preg_match('#\.(ttf|otf)$#i', $OnlyFileName)) { 107 $name = basename($FullFileName['name']); 108 $zip->extractTo($targetFolder, $FullFileName['name']); 109 $extractedFile = $targetFolder . DIRECTORY_SEPARATOR . $name; 110 if (rename($targetFolder . DIRECTORY_SEPARATOR . $FullFileName['name'], $extractedFile)) { 111 $output[] = $extractedFile; 112 error_log('Extracted font file: ' . $extractedFile); 113 } else { 114 error_log('Failed to rename file: ' . $targetFolder . DIRECTORY_SEPARATOR . $FullFileName['name']); 115 } 87 116 } 88 117 } 89 118 } 90 } 91 $zip->close(); 92 } else { 93 error_log('Failed to open zip file: ' . $zip_file); 94 } 95 } else { 96 error_log('Zip file is empty: ' . $zip_file); 97 } 98 return $output; 99 } 100 101 102 public function fontierCheckFont($path) 103 { 119 $zip->close(); 120 } else { 121 error_log('Failed to open zip file: ' . $zip_file); 122 } 123 } else { 124 error_log('Zip file is empty: ' . $zip_file); 125 } 126 return $output; 127 } 128 129 public function fontierCheckFont($path) { 104 130 if (file_exists($path)) { 105 131 $folder = opendir($path); … … 125 151 } 126 152 127 public function fontierGetFontFiles($id) 128 { 129 $download_files = get_post_meta($id, 'edd_download_files', true); 130 error_log('Download files for post ID ' . $id . ': ' . print_r($download_files, true)); 131 132 $result = array(); 133 if (isset($download_files) && is_array($download_files)) { 134 foreach ($download_files as $fi) { 135 $getAID = attachment_url_to_postid($fi['file']); 136 $zipfile = get_attached_file($getAID); 137 138 $Fetchinfo = pathinfo($zipfile); 139 $getDirectory = $Fetchinfo['dirname']; 140 $targetFolder = $getDirectory . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . $id; 141 error_log('Target folder for fonts: ' . $targetFolder); 142 143 if (!file_exists($targetFolder)) { 144 mkdir($targetFolder, 0777, true); 145 $result = $this->fontier_copy_zip($zipfile, $targetFolder, $id); 146 error_log('Copied font files: ' . print_r($result, true)); 147 } else { 148 $result = $this->fontierCheckFont($targetFolder); 149 error_log('Existing font files: ' . print_r($result, true)); 150 } 151 } 152 } 153 return $result; 154 } 155 156 157 public function fontier_is_font_enable($id) 158 { 153 public function fontierGetFontFiles($id) { 154 $download_files = get_post_meta($id, 'edd_download_files', true); 155 error_log('Download files for post ID ' . $id . ': ' . print_r($download_files, true)); 156 157 $result = array(); 158 if (isset($download_files) && is_array($download_files)) { 159 foreach ($download_files as $fi) { 160 $getAID = attachment_url_to_postid($fi['file']); 161 $zipfile = get_attached_file($getAID); 162 163 $Fetchinfo = pathinfo($zipfile); 164 $getDirectory = $Fetchinfo['dirname']; 165 $targetFolder = $getDirectory . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . $id; 166 error_log('Target folder for fonts: ' . $targetFolder); 167 168 if (!file_exists($targetFolder)) { 169 mkdir($targetFolder, 0777, true); 170 $result = $this->fontier_copy_zip($zipfile, $targetFolder, $id); 171 error_log('Copied font files: ' . print_r($result, true)); 172 } else { 173 $result = $this->fontierCheckFont($targetFolder); 174 error_log('Existing font files: ' . print_r($result, true)); 175 } 176 } 177 } 178 return $result; 179 } 180 181 public function fontier_is_font_enable($id) { 159 182 $output = false; 160 183 if ($id) { 161 184 $fontier_metabox = get_post_meta(get_the_ID(), 'fontier_post_option', true); 162 $enable_check = get_post_meta( get_the_ID(), 'font_preview_enable', true);185 $enable_check = get_post_meta(get_the_ID(), 'font_preview_enable', true); 163 186 $this->options = get_option('fontier_option_name'); 164 187 $fontieroptions = get_option('fontier_options'); … … 193 216 } 194 217 195 public function fontierCalculateTextBox($text, $fontFile, $fontSize, $fontAngle) 196 { 218 public function fontierCalculateTextBox($text, $fontFile, $fontSize, $fontAngle) { 197 219 $rect = imagettfbbox($fontSize, $fontAngle, $fontFile, $text); 198 220 $minX = min(array($rect[0], $rect[2], $rect[4], $rect[6])); … … 210 232 } 211 233 212 public function fontier_font_preview_generator() 213 { 234 public function fontier_font_preview_generator() { 214 235 $retArr = array('status' => 0, 'msg' => '', 'images' => array()); 215 236 $nonce = sanitize_text_field($_REQUEST['auth']); … … 234 255 } 235 256 } 257 258 // Retrieve glyph list from cache or generate if not available 259 $glyphList = get_post_meta($pid, '_glyph_list', true); 260 if (empty($glyphList)) { 261 $glyphList = $this->generate_glyph_list($font_Files[0], $size); // Assuming first font file for glyphs 262 update_post_meta($pid, '_glyph_list', $glyphList); 263 } 264 $retArr['glyphs'] = $glyphList; 236 265 } else { 237 266 $retArr['msg'] = 'Font Files are not found'; … … 246 275 247 276 248 public function fontier_create_image($width, $height, $text, $fontsize, $font_file) 249 { 250 ob_start(); 251 252 // Ensure text is in UTF-8 encoding 253 $text = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text)); 254 255 // Calculate the text box size 256 $the_box = $this->fontierCalculateTextBox($text, $font_file, $fontsize, 0); 257 $imageWidth = $the_box["width"] + 10; 258 $imageHeight = $the_box["height"] + 10; 259 if ($imageWidth > 900) { 260 $imageWidth = 900; 261 $x = 0; 262 $y = $the_box["top"] + ($imageHeight / 2) - ($the_box["height"] / 2); 277 278 public function fontier_create_image($width, $height, $text, $fontsize, $font_file) { 279 ob_start(); 280 281 // Ensure text is in UTF-8 encoding 282 $text = mb_convert_encoding($text, 'UTF-8', mb_detect_encoding($text)); 283 284 // Calculate the text box size 285 $the_box = $this->fontierCalculateTextBox($text, $font_file, $fontsize, 0); 286 $imageWidth = $the_box["width"] + 10; 287 $imageHeight = $the_box["height"] + 10; 288 if ($imageWidth > 900) { 289 $imageWidth = 900; 290 $x = 0; 291 $y = $the_box["top"] + ($imageHeight / 2) - ($the_box["height"] / 2); 292 } else { 293 $x = $the_box["left"] + ($imageWidth / 2) - ($the_box["width"] / 2); 294 $y = $the_box["top"] + ($imageHeight / 2) - ($the_box["height"] / 2); 295 } 296 297 // Create the image with transparency 298 $logoimg = imagecreatetruecolor($imageWidth, $imageHeight); 299 imagealphablending($logoimg, false); 300 imagesavealpha($logoimg, true); 301 $col = imagecolorallocatealpha($logoimg, 255, 255, 255, 127); 302 imagefill($logoimg, 0, 0, $col); // for transparent background 303 $black = imagecolorallocate($logoimg, 0, 0, 0); // for font color 304 305 // Render the text on the image 306 imagettftext($logoimg, $fontsize, 0, $x, $y, $black, $font_file, $text); 307 308 // Output the image 309 imagepng($logoimg); 310 $image_data = ob_get_contents(); 311 ob_end_clean(); 312 imagedestroy($logoimg); // Free memory 313 314 return "data:image/png;base64," . base64_encode($image_data); 315 } 316 317 public function generate_glyph_list($font_file, $fontsize) { 318 $glyphs = array(); 319 320 // Load the font file 321 $font = Font::load($font_file); 322 $font->parse(); 323 324 // Get the list of glyphs 325 $glyphList = $font->getUnicodeCharMap(); 326 foreach ($glyphList as $code => $glyph) { 327 $char = mb_convert_encoding(pack('N', $code), 'UTF-8', 'UCS-4BE'); 328 $image = $this->fontier_create_image(100, 100, $char, $fontsize, $font_file); 329 $glyphs[] = array('char' => $char, 'image' => $image); 330 } 331 332 return $glyphs; 333 } 334 335 public function fetch_glyph_list() { 336 $retArr = array('status' => 0, 'msg' => '', 'glyphs' => array()); 337 $nonce = sanitize_text_field($_REQUEST['auth']); 338 if (wp_verify_nonce($nonce, '_prevnounce')) { 339 $pid = sanitize_text_field($_REQUEST['pid']); 340 // Retrieve glyph list from cache or generate if not available 341 $glyphList = get_post_meta($pid, '_glyph_list', true); 342 if (!empty($glyphList)) { 343 $retArr['glyphs'] = $glyphList; 344 $retArr['status'] = 1; 345 $retArr['msg'] = 'successfully'; 346 } else { 347 $retArr['msg'] = 'Glyph list not found'; 348 } 263 349 } else { 264 $x = $the_box["left"] + ($imageWidth / 2) - ($the_box["width"] / 2); 265 $y = $the_box["top"] + ($imageHeight / 2) - ($the_box["height"] / 2); 266 } 267 268 // Create the image with transparency 269 $logoimg = imagecreatetruecolor($imageWidth, $imageHeight); 270 imagealphablending($logoimg, false); 271 imagesavealpha($logoimg, true); 272 $col = imagecolorallocatealpha($logoimg, 255, 255, 255, 127); 273 imagefill($logoimg, 0, 0, $col); // for transparent background 274 $black = imagecolorallocate($logoimg, 0, 0, 0); // for font color 275 276 // Render the text on the image 277 imagettftext($logoimg, $fontsize, 0, $x, $y, $black, $font_file, $text); 278 279 // Output the image 280 imagepng($logoimg); 281 $image_data = ob_get_contents(); 282 ob_end_clean(); 283 imagedestroy($logoimg); // Free memory 284 285 return "data:image/png;base64," . base64_encode($image_data); 350 $retArr['msg'] = 'Auth Failed!'; 351 } 352 error_log('Glyph List Fetch Response: ' . print_r($retArr, true)); // Add logging 353 wp_send_json($retArr); 354 wp_die(); 286 355 } 287 356 288 357 289 public function fontier_enqueue_styles() 290 {358 359 public function fontier_enqueue_styles() { 291 360 wp_enqueue_style('fontier-public', plugin_dir_url(__FILE__) . 'css/fontier-public.css', array(), $this->version, 'all'); 292 361 } -
fontier/trunk/public/css/fontier-public.css
r3114702 r3129913 262 262 margin:0; 263 263 } 264 #fontier-glyph-generate h3{ 265 font-size: 24px; 266 line-height: 1.4; 267 margin-bottom: 20px; 268 } 269 .fontier-glyph-list{ 270 margin:0; 271 padding:0; 272 list-style:none; 273 display: grid; 274 grid-template-columns: repeat(10, 1fr); 275 grid-template-rows: repeat(10, 1fr); 276 grid-column-gap: 0px; 277 grid-row-gap: 0px; 278 border: .5px solid #ccc; 279 border-radius: 3px; 280 } 281 .fontier-glyph-list li{ 282 width: 100% !important; 283 height: auto !important; 284 padding: 15px; 285 border: .5px solid #ccc; 286 min-height:140px; 287 display: flex; 288 flex-wrap: wrap; 289 align-items: center; 290 justify-content: center; 291 border-radius: 3px; 292 } 293 #fontier-glyph-generate{ 294 margin-bottom:30px; 295 } 296 297 /* Mobile view: 2 columns */ 298 @media (max-width: 600px) { 299 .fontier-glyph-list { 300 grid-template-columns: repeat(3, 1fr); 301 } 302 .font-settings .text{ 303 width:100%; 304 } 305 .fontier-font-preview{ 306 width:100%; 307 float:left; 308 } 309 } 310 311 /* Tablet view: 3 columns */ 312 @media (min-width: 601px) and (max-width: 900px) { 313 .fontier-glyph-list { 314 grid-template-columns: repeat(4, 1fr); 315 } 316 .font-settings .text{ 317 width:100%; 318 } 319 .fontier-font-preview{ 320 width:100%; 321 float:left; 322 } 323 } 324 325 /* Larger screens: 10 columns */ 326 @media (min-width: 901px) { 327 .fontier-glyph-list { 328 grid-template-columns: repeat(10, 1fr); 329 } 330 } -
fontier/trunk/public/partials/fontier-public-display.php
r3114702 r3129913 26 26 } 27 27 28 $fontier_glyph_ebl = $fontieroptions['fontier_glyph_ebl']; 29 $fontier_glyph_text = $fontieroptions['fontier_glyph_text']; 30 28 31 ?> 29 32 <div class="clearfix"> 30 <div class="font-settings" data-settings="">31 <div class="text">32 <div id="fontier-font-loading" style="display: none;"><i class="zil zi-settings zi-spin"></i></div>33 <input class="settings-input" type="text" name="text" value="" data-default="<?php echo esc_html_e($previewtitle);?>" placeholder="Type here to preview text...">34 </div>35 <div class="font-settings-size">36 <a href="javascript:void(0)" data-size="24" class="s24">24pt</a>37 <a href="javascript:void(0)" data-size="36" class="s36 active">36pt</a>38 <a href="javascript:void(0)" data-size="48" class="s48">48pt</a>39 <a href="javascript:void(0)" data-size="72" class="s72">72pt</a>40 </div>41 </div>33 <div class="font-settings" data-settings=""> 34 <div class="text"> 35 <div id="fontier-font-loading" style="display: none;"><i class="zil zi-settings zi-spin"></i></div> 36 <input class="settings-input" type="text" name="text" value="" data-default="<?php echo esc_html_e($previewtitle);?>" placeholder="Type here to preview text..."> 37 </div> 38 <div class="font-settings-size"> 39 <a href="javascript:void(0)" data-size="24" class="s24">24pt</a> 40 <a href="javascript:void(0)" data-size="36" class="s36 active">36pt</a> 41 <a href="javascript:void(0)" data-size="48" class="s48">48pt</a> 42 <a href="javascript:void(0)" data-size="72" class="s72">72pt</a> 43 </div> 44 </div> 42 45 </div> 43 46 <div class="clearfix"> 44 <div class="fontier-font-preview" style="visibility: visible;">45 <ul class="fontier-list">46 <li>47 <span></span>48 <div class="text-center"><i class="zil zi-settings zi-spin"></i> Loading preview, please wait...</div>49 </li>50 </ul>51 </div>47 <div class="fontier-font-preview" style="visibility: visible;"> 48 <ul class="fontier-list"> 49 <li> 50 <span></span> 51 <div class="text-center"><i class="zil zi-settings zi-spin"></i> Loading preview, please wait...</div> 52 </li> 53 </ul> 54 </div> 52 55 </div> 56 <?php if ($fontier_glyph_ebl){ ?> 57 <div id="fontier-glyph-generate"> 58 59 </div> 60 <?php } ?> 53 61 <script> 62 54 63 (function($) { 55 64 'use strict'; … … 72 81 returnTypingPreview(storedText, size); 73 82 } 83 84 // Retrieve and display glyph list from the initial load 85 fetchGlyphList(); 74 86 }); 75 87 … … 82 94 jQuery('.settings-input').on("keyup paste", throttle(function() { 83 95 var text = jQuery(this).val(); 96 if (text.trim().length === 0) { 97 text = jQuery('.settings-input').data('default'); 98 jQuery(this).val(text); // Set input value back to default 99 } 84 100 localStorage.setItem('fontierInputText', text); // Save input value to local storage 85 if (text.trim().length > 0) { 86 jQuery("#fontier-font-loading").show(); 87 var size = jQuery(".font-settings-size a.active").data("size"); 88 returnTypingPreview(text, size); 89 } else { 90 text = jQuery('.settings-input').data('default'); 91 } 101 jQuery("#fontier-font-loading").show(); 102 var size = jQuery(".font-settings-size a.active").data("size"); 103 returnTypingPreview(text, size); 92 104 })); 93 105 … … 140 152 'font_loader_field': jQuery('#font_loader_field').val() 141 153 }; 142 console.log('Sending AJAX request with data:', data); 154 console.log('Sending AJAX request with data:', data); // Add logging 143 155 jQuery.ajax({ 144 156 type: 'POST', … … 163 175 } 164 176 jQuery('.fontier-font-preview ul').html(image_html); 177 165 178 } else { 166 179 jQuery('.fontier-font-preview ul').html('<li>No preview available.</li>'); … … 174 187 }); 175 188 } 189 190 function fetchGlyphList() { 191 var pid = '<?php echo esc_html($id); ?>'; 192 var data = { 193 'auth': '<?php echo wp_create_nonce('_prevnounce'); ?>', 194 'pid': pid, 195 'action': 'fetchGlyphList' 196 }; 197 console.log('Fetching glyph list with data:', data); // Add logging 198 jQuery.ajax({ 199 type: 'POST', 200 url: '<?php echo admin_url('admin-ajax.php'); ?>', 201 dataType: 'json', 202 data: data, 203 error: function(data, transport) { 204 console.log('Error fetching glyph list:', data); // Add logging 205 }, 206 success: function(result) { 207 console.log('Fetched glyph list successfully. Result:', result); // Add logging 208 if (result.status === 1) { 209 displayGlyphList(result.glyphs); 210 } 211 } 212 }); 213 } 214 215 function displayGlyphList(glyphList) { 216 if (glyphList && glyphList.length > 0) { 217 var glyph_html = '<h3><?php echo esc_html($fontier_glyph_text);?></h3><ul class="fontier-glyph-list">'; 218 for (var j = 0; j < glyphList.length; j++) { 219 glyph_html += '<li><img src="' + glyphList[j].image + '" alt="' + glyphList[j].char + '" /></li>'; 220 } 221 glyph_html += '</ul>'; 222 console.log('Displaying glyph list:', glyph_html); // Add logging 223 jQuery('#fontier-glyph-generate').html(glyph_html); 224 } 225 } 176 226 })(jQuery); 177 227 -
fontier/trunk/readme.txt
r3115108 r3129913 1 1 === Fontier -Font Preview Plugin for Easy Digital Downloads === 2 2 Contributors: Teconce, nstuhin, apuzaman 3 Tags: elementor, elements, font preview, elementor addon, elementor widget3 Tags: elementor, elements, addons, elementor addon, elementor widget, page-builder, wordpress page builder 4 4 Requires at least: 5.6 5 5 Requires PHP:7.4 6 Tested up to: 6.5 7 Stable tag: 1. 16 Tested up to: 6.5.5 7 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 18 18 19 19 Built-in font preview features. It will take font from your EDD downloadable file. First, unzip it & create a folder inside WP Upload & Render it from the frontend. 20 Take a look at the demo: [demo preview](https://mayo .teconcetheme.com/mayofont/downloads/pt-serif-font-family/).20 Take a look at the demo: [demo preview](https://mayosis.themepreview.xyz/mayofont/downloads/chewy-font-family-typeface/). 21 21 22 22 … … 50 50 == Changelog == 51 51 52 = 1.2 = 53 * Glyph list system added 54 * Glyph enable disable option added 55 * Other Improvement 56 52 57 = 1.1 = 53 58 * OTF Supports added … … 58 63 * CSS Issues Fixed 59 64 * Bug fixed 60 61 62 65 63 66 = 1.0.4 =
Note: See TracChangeset
for help on using the changeset viewer.