id !== 'edit-ogf_custom_fonts' ) { return; } wp_enqueue_style( 'olympus-google-fonts-admin', plugins_url( 'admin/style.css', __DIR__ ), false, '1.0.0' ); wp_enqueue_media(); wp_enqueue_script( 'olympus-google-fonts-upload', plugins_url( 'assets/js/uploadFonts.js', __DIR__ ), array(), '1.0.1' ); } /** * Register custom font menu */ public function register_custom_fonts_menu() { $title = apply_filters( 'ogf_custom_fonts_menu_title', __( 'Upload Fonts', 'olympus-google-fonts' ) ); add_submenu_page( $this->parent_menu_slug, $title, $title, OGF_Fonts_Taxonomy::$capability, 'edit-tags.php?taxonomy=' . OGF_Fonts_Taxonomy::$taxonomy_slug ); } /** * Modify taxonomy output. */ public function customize_output() { global $parent_file, $submenu_file; if ( 'edit-tags.php?taxonomy=' . OGF_Fonts_Taxonomy::$taxonomy_slug === $submenu_file ) { $parent_file = $this->parent_menu_slug; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited } if ( get_current_screen()->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { return; } ?>

base ) && 'edit-tags' == $screen->base ) { $old_columns = $columns; $columns = array( 'cb' => $old_columns['cb'], 'name' => $old_columns['name'], ); } return $columns; } /** * Add options page */ public function intro_text() { echo '>Documentation for this feature is available here: Upload Fonts to WordPress.font_family_new_field( 'family', __( 'Font Family', 'olympus-google-fonts' ), __( 'The name of the font family. For example, Helvetica or Proxima Nova.', 'olympus-google-fonts' ) ); $this->font_file_new_field( 'woff', __( 'WOFF Font File', 'olympus-google-fonts' ), '' ); $this->font_file_new_field( 'woff2', __( 'WOFF2 Font File', 'olympus-google-fonts' ), '' ); $this->font_file_new_field( 'otf', __( 'OpenType (.otf) Font File', 'olympus-google-fonts' ), '' ); $this->font_file_new_field( 'ttf', __( 'TrueType (.ttf) Font File', 'olympus-google-fonts' ), '' ); $this->font_weight_new_field( 'weight', __( 'Font Weight', 'olympus-google-fonts' ), '' ); $this->font_style_new_field( 'style', __( 'Font Style', 'olympus-google-fonts' ), '' ); } /** * Edit Taxonomy data * * @param object $term taxonomy terms. */ public function edit_taxonomy_data( $term ) { $data = OGF_Fonts_Taxonomy::get_font_data( $term->term_id ); $this->font_family_edit_field( 'family', __( 'Font Family', 'olympus-google-fonts' ), $data['family'], __( 'The name of the font family. For example, Helvetica or Proxima Nova.', 'olympus-google-fonts' ) ); $this->font_file_edit_field( 'woff', __( 'Font .woff', 'olympus-google-fonts' ), $data['woff'], __( 'Upload the font\'s .woff file or enter the URL.', 'olympus-google-fonts' ) ); $this->font_file_edit_field( 'woff2', __( 'Font .woff2', 'olympus-google-fonts' ), $data['woff2'], __( 'Upload the font\'s .woff2 file or enter the URL.', 'olympus-google-fonts' ) ); $this->font_file_edit_field( 'ttf', __( 'Font .ttf', 'olympus-google-fonts' ), $data['ttf'], __( 'Upload the font\'s .ttf file or enter the URL.', 'olympus-google-fonts' ) ); $this->font_file_edit_field( 'otf', __( 'Font .otf', 'olympus-google-fonts' ), $data['otf'], __( 'Upload the font\'s .otf file or enter the URL.', 'olympus-google-fonts' ) ); $this->font_weight_edit_field( 'weight', __( 'Font Weight', 'olympus-google-fonts' ), $data['weight'] ); $this->font_style_edit_field( 'style', __( 'Font Weight', 'olympus-google-fonts' ), $data['style'] ); $this->font_preload_edit_field( 'preload', __( 'Preload Font', 'olympus-google-fonts' ), $data['preload'], __( 'Preloading is a Fonts Plugin Pro feature.', 'olympus-google-fonts' ) ); } /** * Add Taxonomy data field * * @param string $id current term id. * @param string $title font type title. * @param string $description title font type description. */ protected function font_family_new_field( $id, $title, $description = '' ) { ?>

value="1">

= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf'; $mimes['otf'] = 'application/vnd.ms-opentype'; $mimes['ttf'] = PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type; $mimes['woff'] = PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff'; $mimes['woff2'] = PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2'; return $mimes; } /** * Correct the mime types and extension for the font types. * * @param array $defaults File data array containing 'ext', 'type', and * 'proper_filename' keys. * @param string $file Full path to the file. * @param string $filename The name of the file (may differ from $file due to * $file being in a tmp directory). * @return Array File data array containing 'ext', 'type', and */ public function update_mime_types( $defaults, $file, $filename ) { if ( 'ttf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) { $defaults['type'] = 'application/x-font-ttf'; $defaults['ext'] = 'ttf'; } if ( 'otf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) { $defaults['type'] = 'application/x-font-otf'; $defaults['ext'] = 'otf'; } return $defaults; } } OGF_Upload_Fonts_Screen::get_instance();