Submit
Path:
~
/
home
/
getwphos
/
public_html
/
deerguard
/
wp-content
/
plugins
/
garland-addon
/
admin
/
extension
/
File Content:
class.custom-fonts.php
<?php class Garland_Custom_Fonts { private static $_instance = null; public function __construct() { add_action( 'admin_menu', array( $this, 'garland_addon_admin_menu' ) ); } public static function garland_addon_admin_menu(){ add_submenu_page( 'garland-welcome', esc_html__( 'Custom Fonts', 'garland-addon' ), esc_html__( 'Custom Fonts', 'garland-addon' ), 'manage_options', 'garland-fonts', array( 'Garland_Custom_Fonts', 'garland_fonts_admin_page' ) ); } public static function garland_fonts_admin_page(){ $garland_theme = wp_get_theme(); ?> <div class="garland-settings-wrap"> <div class="garland-header-bar"> <div class="garland-header-left"> <div class="garland-admin-logo-inline"> <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/brand-logo.png' ); ?>" alt="garland-logo"> </div><!-- .garland-admin-logo-inline --> <h2 class="title"><?php esc_html_e( 'Garland Custom Fonts', 'garland-addon' ); ?><span class="garland-version"><?php echo esc_attr( $garland_theme->get( 'Version' ) ); ?></span></h2> </div><!-- .garland-header-left --> <div class="garland-header-right"> <a href="<?php echo esc_url( 'https://wordpress.zozothemes.com/garland/' ); ?>" class="button garland-btn"><?php esc_html_e( 'Live Demo', 'garland-addon' ); ?></a> </div><!-- .garland-header-right --> </div><!-- .garland-header-bar --> <div class="garland-settings-tabs garland-custom-sidebar-wrap"> <div id="garland-general" class="garland-settings-tab active"> <div class="container"> <div class="row"> <div class="col-4"> <div class="media admin-box"> <div class="admin-box-icon mr-3"> <span class="dashicons dashicons-welcome-widgets-menus"></span> </div> <div class="media-body admin-box-info"> <h3 class="admin-box-title"><?php esc_html_e( 'Add Custom Fonts', 'garland-addon' ); ?></h3> <div class="admin-box-content"> <?php esc_html_e( 'You can add custom fonts here. Also we give you option to remove or delete custom fonts.', 'garland-addon' ); ?> </div> <form action="" method="post" enctype="multipart/form-data"> <?php wp_nonce_field( 'garland-)(&(*@#*%@*', 'garland_custom_font_nonce' ); ?> <input type="file" name="garland_custom_fonts" id="garland-custom-fonts" class="garland-custom-fonts" /> </form> <a href="#" class="garland-btn btn-default garland-custom-fonts-upload"><?php esc_html_e( 'Upload Font', 'garland-addon' ); ?></a> <ol class="admin-instruction-list"> <li><?php esc_html_e( 'Notes: Custom fonts should be in this following format. .eot, .otf, .svg, .ttf, .wof', 'garland-addon' ) ?></li> <li><?php esc_html_e( 'Font folder name only show as font name in theme option. So make folder name and font name are should be the same but font name like slug type.', 'garland-addon' ) ?></li> <li><?php printf( '%1$s <strong>%2$s</strong> %3$s <strong>%4$s</strong>', esc_html__( 'Eg: Font folder name is -', 'garland-addon' ), esc_html__( 'Wonder Land', 'garland-addon' ), esc_html__( ' font name like', 'garland-addon' ), esc_html__( ' wonder-land.eot, wonder-land.otf ...', 'garland-addon' ) ); ?></li> </ol> </div> </div> </div> <div class="col-8"> <div class="admin-box"> <h3 class="admin-box-title font-title"><?php esc_html_e( 'Custom Fonts', 'garland-addon' ); ?></h3> <?php //delete_option( 'garland_custom_fonts' ); if (isset($_POST['garland_custom_font_nonce']) && wp_verify_nonce($_POST['garland_custom_font_nonce'], 'garland-)(&(*@#*%@*')) { Garland_Custom_Fonts::garland_upload_font(); } if (isset($_POST['garland_custom_font_remove_nonce']) && wp_verify_nonce($_POST['garland_custom_font_remove_nonce'], 'garland-(*&^&%^%@!')) { Garland_Custom_Fonts::garland_font_delete(); } $custom_fonts = get_option('garland_custom_fonts'); ?> <?php if (!empty($custom_fonts)) : ?> <form action="" method="post" enctype="multipart/form-data"> <?php wp_nonce_field('garland-(*&^&%^%@!', 'garland_custom_font_remove_nonce'); ?> <input type="hidden" name="garland_font_remove_name" id="garland-font-remove-name" value="" /> <table class="garland-admin-table garland-custom-font-table"> <thead> <tr> <td><?php echo esc_html__('Font Name', 'garland-addon'); ?></td> <td><?php echo esc_html__('CSS', 'garland-addon'); ?></td> <td><?php echo esc_html__('Delete', 'garland-addon'); ?></td> </tr> </thead> <tbody> <?php foreach ($custom_fonts as $font_slug => $font_name) { ?> <tr> <td><?php echo esc_html($font_name); ?></td> <td>font-family: '<?php echo esc_html($font_name); ?>';</td> <td class="text-center"><a href="#" data-font="<?php echo esc_attr($font_slug); ?>" class="garland-font-remove"><span class="dashicons dashicons-trash"></span></a></td> </tr> <?php } ?> </tbody> </table> </form> <?php else: ?> <p><?php esc_html_e( 'Sorry! No custom fonts available.', 'garland-addon' ); ?></p> <?php endif; ?> </div> </div> </div> </div> </div> </div> </div> <?php } public static function garland_upload_font(){ if ( isset( $_FILES['garland_custom_fonts'] ) ) { // The nonce was valid and the user has the capabilities, it is safe to continue. $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/octet-stream', 'application/x-rar-compressed'); $file_type = $_FILES['garland_custom_fonts']['type']; if( in_array( $file_type, $accepted_types ) ){ // These files need to be included as dependencies when on the front end. require_once( ABSPATH . 'wp-admin/includes/image.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); // Let WordPress handle the upload. //delete_option( 'garland_custom_fonts' ); // Remember, 'pharmy_image_upload' is the name of our file input in our form above. $font_name = pathinfo($_FILES['garland_custom_fonts']['name'], PATHINFO_FILENAME); $font_slug = sanitize_title( $font_name ); if ( get_option( 'garland_custom_fonts' ) ) { $custom_fonts_names = get_option( 'garland_custom_fonts' ); $custom_fonts_names = array_merge( $custom_fonts_names, array( $font_slug => $font_name ) ); }else{ $custom_fonts_names = array( $font_slug => $font_name ); } WP_Filesystem(); $destination = wp_upload_dir(); $destination_path = $destination['basedir'] . '/custom-fonts/'; $unzipfile = unzip_file( $_FILES['garland_custom_fonts']['tmp_name'], $destination_path); update_option( 'garland_custom_fonts', $custom_fonts_names ); }else{ echo esc_html__( 'Invalid File Type', 'garland-addon' ); } } } public static function garland_font_delete(){ $font_id = esc_attr( $_POST['garland_font_remove_name'] ); $destination = wp_upload_dir(); $custom_fonts = get_option( 'garland_custom_fonts' ); if ( array_key_exists( $font_id, $custom_fonts ) ){ $font_name = $custom_fonts[$font_id]; $destination_path = $destination['basedir'] . '/custom-fonts/' . $font_name; unset($custom_fonts[$font_id]); update_option( 'garland_custom_fonts', $custom_fonts ); self::rmdir_recurse( $destination_path ); } } public static function rmdir_recurse($path) { $path = rtrim($path, '/').'/'; $handle = opendir($path); while(false !== ($file = readdir($handle))) { if($file != '.' and $file != '..' ) { $fullpath = $path.$file; if(is_dir($fullpath)) self::rmdir_recurse($fullpath); else unlink($fullpath); } } closedir($handle); rmdir($path); } public static function get_instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } } Garland_Custom_Fonts::get_instance();
Submit
FILE
FOLDER
Name
Size
Permission
Action
demo-importer
---
0755
mega-menu
---
0755
metabox
---
0755
theme-options
---
0755
class.custom-fonts.php
8642 bytes
0644
class.custom-sidebars.php
7237 bytes
0644
N4ST4R_ID | Naxtarrr