diff --git a/.gitignore b/.gitignore index 188eaa4..9caadfd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ composer.phar *vendor/ .htaccess .php-cs-fixer.cache -FontManager.zip +font-manager.zip # Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control diff --git a/FontManager.php b/FontManager.php deleted file mode 100644 index 8372777..0000000 --- a/FontManager.php +++ /dev/null @@ -1,17 +0,0 @@ - **Customize folder prefix (optional):** `../fonts/%FontName%/` +> **Customize folder prefix (optional):** `../fonts/%fontname%/` ### Installing []() @@ -33,11 +32,11 @@ What things you need to install the software and how to install them. - Run `composer update` and `composer install` in the '/tools/php-csfixer' folder. -- Delete the fonts in '/assets/fonts/[Dosis, Exo2, Iceberg, Lato]' and create new folders to represent your font-families. +- Delete the fonts in '/assets/fonts/[dosis, exo2, iceberg]' and create new folders to represent your font-families. - Unzip the `.zip` files from Google Webfonts Helper into their respective directories. -- Delete the CSS in '/assets/css/FontManager.css' and replace it with the applicable CSS you copied earlier. +- Delete the CSS in '/assets/css/font-manager.css' and replace it with the applicable CSS you copied earlier. ### Formatting @@ -45,7 +44,7 @@ What things you need to install the software and how to install them. ## Usage []() -- Once you have added the fonts you need and the CSS, compress the files in the assets folder along with the FontManager.php file into a `.zip` and FontManager is ready for installation. +- Once you have added the fonts you need and the CSS, compress the files in the assets folder along with the font-manager.php file into a `.zip` and font-manager is ready for installation. - Consider testing functionality in a WP dev enviroment before installing the plugin on a live website if at all possible. diff --git a/assets/css/FontManager.css b/assets/css/font-manager.css similarity index 62% rename from assets/css/FontManager.css rename to assets/css/font-manager.css index 1a1b220..68081d1 100644 --- a/assets/css/FontManager.css +++ b/assets/css/font-manager.css @@ -6,8 +6,8 @@ font-style: normal; font-weight: 300; src: local(''), - url('../fonts/Dosis/dosis-v19-latin-300.woff2') format('woff2'), - url('../fonts/Dosis/dosis-v19-latin-300.woff') format('woff'), + url('../fonts/dosis/dosis-v19-latin-300.woff2') format('woff2'), + url('../fonts/dosis/dosis-v19-latin-300.woff') format('woff'), } /* dosis-regular - latin */ @@ -16,8 +16,8 @@ font-style: normal; font-weight: 400; src: local(''), - url('../fonts/Dosis/dosis-v19-latin-regular.woff2') format('woff2'), - url('../fonts/Dosis/dosis-v19-latin-regular.woff') format('woff'), + url('../fonts/dosis/dosis-v19-latin-regular.woff2') format('woff2'), + url('../fonts/dosis/dosis-v19-latin-regular.woff') format('woff'), } /* dosis-500 - latin */ @@ -26,8 +26,8 @@ font-style: normal; font-weight: 500; src: local(''), - url('../fonts/Dosis/dosis-v19-latin-500.woff2') format('woff2'), - url('../fonts/Dosis/dosis-v19-latin-500.woff') format('woff'), + url('../fonts/dosis/dosis-v19-latin-500.woff2') format('woff2'), + url('../fonts/dosis/dosis-v19-latin-500.woff') format('woff'), } /* dosis-700 - latin */ @@ -36,8 +36,8 @@ font-style: normal; font-weight: 700; src: local(''), - url('../fonts/Dosis/dosis-v19-latin-700.woff2') format('woff2'), - url('../fonts/Dosis/dosis-v19-latin-700.woff') format('woff'), + url('../fonts/dosis/dosis-v19-latin-700.woff2') format('woff2'), + url('../fonts/dosis/dosis-v19-latin-700.woff') format('woff'), } /* exo-2-300 - latin */ @@ -46,8 +46,8 @@ font-style: normal; font-weight: 300; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-300.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-300.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-300.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-300.woff') format('woff'), } /*exo-2-regular - latin */ @@ -56,8 +56,8 @@ font-style: normal; font-weight: 400; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-regular.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-regular.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-regular.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-regular.woff') format('woff'), } /* exo-2-500 - latin */ @@ -66,8 +66,8 @@ font-style: normal; font-weight: 500; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-500.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-500.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-500.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-500.woff') format('woff'), } /* exo-2-700 - latin */ @@ -76,8 +76,8 @@ font-style: normal; font-weight: 700; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-700.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-700.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-700.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-700.woff') format('woff'), } /*exo-2-300italic - latin */ @@ -86,8 +86,8 @@ font-style: italic; font-weight: 300; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-300italic.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-300italic.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-300italic.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-300italic.woff') format('woff'), } /* exo-2-italic - latin */ @@ -96,8 +96,8 @@ font-style: italic; font-weight: 400; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-italic.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-italic.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-italic.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-italic.woff') format('woff'), } /* exo-2-500italic - latin */ @@ -106,8 +106,8 @@ font-style: italic; font-weight: 500; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-500italic.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-500italic.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-500italic.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-500italic.woff') format('woff'), } /* exo-2-700italic - latin */ @@ -116,8 +116,8 @@ font-style: italic; font-weight: 700; src: local(''), - url('../fonts/Exo2/exo-2-v10-latin-700italic.woff2') format('woff2'), - url('../fonts/Exo2/exo-2-v10-latin-700italic.woff') format('woff'), + url('../fonts/exo2/exo-2-v10-latin-700italic.woff2') format('woff2'), + url('../fonts/exo2/exo-2-v10-latin-700italic.woff') format('woff'), } /* iceberg-regular - latin */ @@ -126,8 +126,8 @@ font-style: normal; font-weight: 400; src: local(''), - url('../fonts/Iceberg/iceberg-v10-latin-regular.woff2') format('woff2'), - url('../fonts/Iceberg/iceberg-v10-latin-regular.woff') format('woff'), + url('../fonts/iceberg/iceberg-v10-latin-regular.woff2') format('woff2'), + url('../fonts/iceberg/iceberg-v10-latin-regular.woff') format('woff'), } /* ff-tisa-sans-web-pro-300 - latin */ @@ -172,7 +172,7 @@ /* ff-tisa-sans-web-pro-300italic - latin */ @font-face { - font-family: 'ff-tisa-sans-web-pro'; + font-family: 'ff-tisa-sans-web-pro'; font-style: italic; font-weight: 300; src: url('https://use.typekit.net/xjz8xzq.css'); diff --git a/assets/fonts/Iceberg/iceberg-v10-latin-regular.ttf b/assets/fonts/Iceberg/iceberg-v10-latin-regular.ttf deleted file mode 100644 index 5df1b23..0000000 Binary files a/assets/fonts/Iceberg/iceberg-v10-latin-regular.ttf and /dev/null differ diff --git a/assets/fonts/Dosis/LICENSE b/assets/fonts/dosis/LICENSE similarity index 100% rename from assets/fonts/Dosis/LICENSE rename to assets/fonts/dosis/LICENSE diff --git a/assets/fonts/Dosis/dosis-v19-latin-300.woff b/assets/fonts/dosis/dosis-v19-latin-300.woff similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-300.woff rename to assets/fonts/dosis/dosis-v19-latin-300.woff diff --git a/assets/fonts/Dosis/dosis-v19-latin-300.woff2 b/assets/fonts/dosis/dosis-v19-latin-300.woff2 similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-300.woff2 rename to assets/fonts/dosis/dosis-v19-latin-300.woff2 diff --git a/assets/fonts/Dosis/dosis-v19-latin-500.woff b/assets/fonts/dosis/dosis-v19-latin-500.woff similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-500.woff rename to assets/fonts/dosis/dosis-v19-latin-500.woff diff --git a/assets/fonts/Dosis/dosis-v19-latin-500.woff2 b/assets/fonts/dosis/dosis-v19-latin-500.woff2 similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-500.woff2 rename to assets/fonts/dosis/dosis-v19-latin-500.woff2 diff --git a/assets/fonts/Dosis/dosis-v19-latin-700.woff b/assets/fonts/dosis/dosis-v19-latin-700.woff similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-700.woff rename to assets/fonts/dosis/dosis-v19-latin-700.woff diff --git a/assets/fonts/Dosis/dosis-v19-latin-700.woff2 b/assets/fonts/dosis/dosis-v19-latin-700.woff2 similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-700.woff2 rename to assets/fonts/dosis/dosis-v19-latin-700.woff2 diff --git a/assets/fonts/Dosis/dosis-v19-latin-regular.woff b/assets/fonts/dosis/dosis-v19-latin-regular.woff similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-regular.woff rename to assets/fonts/dosis/dosis-v19-latin-regular.woff diff --git a/assets/fonts/Dosis/dosis-v19-latin-regular.woff2 b/assets/fonts/dosis/dosis-v19-latin-regular.woff2 similarity index 100% rename from assets/fonts/Dosis/dosis-v19-latin-regular.woff2 rename to assets/fonts/dosis/dosis-v19-latin-regular.woff2 diff --git a/assets/fonts/Exo2/LICENSE b/assets/fonts/exo2/LICENSE similarity index 100% rename from assets/fonts/Exo2/LICENSE rename to assets/fonts/exo2/LICENSE diff --git a/assets/fonts/Exo2/exo-2-v10-latin-300.woff b/assets/fonts/exo2/exo-2-v10-latin-300.woff similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-300.woff rename to assets/fonts/exo2/exo-2-v10-latin-300.woff diff --git a/assets/fonts/Exo2/exo-2-v10-latin-300.woff2 b/assets/fonts/exo2/exo-2-v10-latin-300.woff2 similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-300.woff2 rename to assets/fonts/exo2/exo-2-v10-latin-300.woff2 diff --git a/assets/fonts/Exo2/exo-2-v10-latin-300italic.woff b/assets/fonts/exo2/exo-2-v10-latin-300italic.woff similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-300italic.woff rename to assets/fonts/exo2/exo-2-v10-latin-300italic.woff diff --git a/assets/fonts/Exo2/exo-2-v10-latin-300italic.woff2 b/assets/fonts/exo2/exo-2-v10-latin-300italic.woff2 similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-300italic.woff2 rename to assets/fonts/exo2/exo-2-v10-latin-300italic.woff2 diff --git a/assets/fonts/Exo2/exo-2-v10-latin-500.woff b/assets/fonts/exo2/exo-2-v10-latin-500.woff similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-500.woff rename to assets/fonts/exo2/exo-2-v10-latin-500.woff diff --git a/assets/fonts/Exo2/exo-2-v10-latin-500.woff2 b/assets/fonts/exo2/exo-2-v10-latin-500.woff2 similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-500.woff2 rename to assets/fonts/exo2/exo-2-v10-latin-500.woff2 diff --git a/assets/fonts/Exo2/exo-2-v10-latin-500italic.woff b/assets/fonts/exo2/exo-2-v10-latin-500italic.woff similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-500italic.woff rename to assets/fonts/exo2/exo-2-v10-latin-500italic.woff diff --git a/assets/fonts/Exo2/exo-2-v10-latin-500italic.woff2 b/assets/fonts/exo2/exo-2-v10-latin-500italic.woff2 similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-500italic.woff2 rename to assets/fonts/exo2/exo-2-v10-latin-500italic.woff2 diff --git a/assets/fonts/Exo2/exo-2-v10-latin-italic.woff b/assets/fonts/exo2/exo-2-v10-latin-italic.woff similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-italic.woff rename to assets/fonts/exo2/exo-2-v10-latin-italic.woff diff --git a/assets/fonts/Exo2/exo-2-v10-latin-italic.woff2 b/assets/fonts/exo2/exo-2-v10-latin-italic.woff2 similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-italic.woff2 rename to assets/fonts/exo2/exo-2-v10-latin-italic.woff2 diff --git a/assets/fonts/Exo2/exo-2-v10-latin-regular.woff b/assets/fonts/exo2/exo-2-v10-latin-regular.woff similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-regular.woff rename to assets/fonts/exo2/exo-2-v10-latin-regular.woff diff --git a/assets/fonts/Exo2/exo-2-v10-latin-regular.woff2 b/assets/fonts/exo2/exo-2-v10-latin-regular.woff2 similarity index 100% rename from assets/fonts/Exo2/exo-2-v10-latin-regular.woff2 rename to assets/fonts/exo2/exo-2-v10-latin-regular.woff2 diff --git a/assets/fonts/Iceberg/LICENSE b/assets/fonts/iceberg/LICENSE similarity index 100% rename from assets/fonts/Iceberg/LICENSE rename to assets/fonts/iceberg/LICENSE diff --git a/assets/fonts/Iceberg/iceberg-v10-latin-regular.woff b/assets/fonts/iceberg/iceberg-v10-latin-regular.woff similarity index 100% rename from assets/fonts/Iceberg/iceberg-v10-latin-regular.woff rename to assets/fonts/iceberg/iceberg-v10-latin-regular.woff diff --git a/assets/fonts/Iceberg/iceberg-v10-latin-regular.woff2 b/assets/fonts/iceberg/iceberg-v10-latin-regular.woff2 similarity index 100% rename from assets/fonts/Iceberg/iceberg-v10-latin-regular.woff2 rename to assets/fonts/iceberg/iceberg-v10-latin-regular.woff2 diff --git a/font-manager.php b/font-manager.php new file mode 100644 index 0000000..3b104af --- /dev/null +++ b/font-manager.php @@ -0,0 +1,60 @@ + + * @copyright 2021-2022 STHCoders + * @license GPLv3 or later + * + * Plugin Name: Font Manager + * Description: A Simple Way to Host Google Fonts Locally & Reduce Page Load Speed. + * Version: 2.1.0 + * Plugin URI: https://github.com/STH-Coders/font-manager/ + * Author: STHCoders + * Author URI: https://www.linkedin.com/showcase/sthcoders/ + * + * Portions copyright 2011-22 Michael Rehnert (@killshot13) + * Other portions copyright as indicated by authors in the relevant files + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * 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 + */ +if (!defined('ABSPATH')) { + exit; +} + +define('FONT_MANAGER_VERSION', '2.1.0'); + +// add or update plugin version to database. +function fm_font_save_manager_version() +{ + $font_manager_version = get_option('font_manager_version'); + if (!$font_manager_version) { + add_option('font_manager_version', FONT_MANAGER_VERSION); + } else { + update_option('font_manager_version', FONT_MANAGER_VERSION); + } +} + +// primary function call +function font_manager_styles() +{ + $fm_dir = dirname(__FILE__); + // Apply CSS in Turn + wp_enqueue_style('font_manager_css', "{$fm_dir}/assets/css/font-manager.css"); +} +// Render Fonts Usable/Visible to WordPress/Browser +add_action('wp_enqueue_scripts', 'font_manager_styles');