| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * @package Fire Plugins Framework | |
| 4 | - * @version 1.0.7 | |
| 3 | + * @package FirePlugins Framework | |
| 4 | + * @version 1.1.132 | |
| 5 | 5 | * |
| 6 | - * @author Fire Plugins <[email protected]> | |
| 6 | + * @author FirePlugins <[email protected]> | |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 Fire Plugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2025 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FPFramework { |
| @@ -18,11 +18,12 @@ | ||
| 18 | 18 | |
| 19 | 19 | use FPFramework\API\API; |
| 20 | 20 | use FPFramework\Base\Renderer; |
| 21 | 21 | use FPFramework\Base\HelperMiddleware; |
| 22 | + use FPFramework\Base\Ajax; | |
| 22 | 23 | use FPFramework\Libs\Translations; |
| 23 | - use FPFramework\Libs\SearchDropdownAjax; | |
| 24 | 24 | use FPFramework\Libs\Media; |
| 25 | + use FPFramework\Libs\GoogleFontsRenderer; | |
| 25 | 26 | |
| 26 | 27 | final class Framework |
| 27 | 28 | { |
| 28 | 29 | /** |
| @@ -32,8 +33,15 @@ | ||
| 32 | 33 | */ |
| 33 | 34 | public static $instance = null; |
| 34 | 35 | |
| 35 | 36 | /** |
| 37 | + * AJAX | |
| 38 | + * | |
| 39 | + * @var AJAX $ajax | |
| 40 | + */ | |
| 41 | + public $ajax; | |
| 42 | + | |
| 43 | + /** | |
| 36 | 44 | * API |
| 37 | 45 | * |
| 38 | 46 | * @var API $api |
| 39 | 47 | */ |
| @@ -73,24 +81,15 @@ | ||
| 73 | 81 | * @var HelperMiddleware |
| 74 | 82 | */ |
| 75 | 83 | public $helper; |
| 76 | 84 | |
| 77 | - /** | |
| 78 | - * Handle Search Dropdown Ajax | |
| 79 | - * | |
| 80 | - * @var SearchDropdownAjax | |
| 81 | - */ | |
| 82 | - public $search_dropdown_ajax; | |
| 83 | - | |
| 84 | 85 | private function __construct($plugin_name) |
| 85 | 86 | { |
| 86 | 87 | $this->plugin_name = $plugin_name; |
| 87 | - | |
| 88 | + | |
| 88 | 89 | // Translations |
| 89 | 90 | $this->translations = new Translations(); |
| 90 | 91 | |
| 91 | - $this->initConstants(); | |
| 92 | - | |
| 93 | 92 | // run init |
| 94 | 93 | $this->init(); |
| 95 | 94 | $this->admin_init(); |
| 96 | 95 | } |
| @@ -101,9 +100,9 @@ | ||
| 101 | 100 | * @return string |
| 102 | 101 | */ |
| 103 | 102 | public function getPluginPage() |
| 104 | 103 | { |
| 105 | - return isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; | |
| 104 | + return isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 106 | 105 | } |
| 107 | 106 | |
| 108 | 107 | /** |
| 109 | 108 | * Returns the instance of the Framework given the ID |
| @@ -128,10 +127,9 @@ | ||
| 128 | 127 | * @return void |
| 129 | 128 | */ |
| 130 | 129 | public function initCommons() |
| 131 | 130 | { |
| 132 | - // Search Dropdown Ajax | |
| 133 | - $this->search_dropdown_ajax = new SearchDropdownAjax(); | |
| 131 | + $this->ajax = new Ajax(); | |
| 134 | 132 | |
| 135 | 133 | // API |
| 136 | 134 | $this->api = new API(); |
| 137 | 135 | |
| @@ -142,46 +140,12 @@ | ||
| 142 | 140 | $this->media = new Media(); |
| 143 | 141 | |
| 144 | 142 | // Helper |
| 145 | 143 | $this->helper = new HelperMiddleware(); |
| 146 | - } | |
| 147 | 144 | |
| 148 | - /** | |
| 149 | - * Initialize Framework Costants | |
| 150 | - * | |
| 151 | - * @return void | |
| 152 | - */ | |
| 153 | - public function initConstants() | |
| 154 | - { | |
| 155 | - // Framework Base | |
| 156 | - if (!defined('FPF_BASE')) | |
| 157 | - { | |
| 158 | - define('FPF_BASE', __FILE__); | |
| 159 | - } | |
| 145 | + new Includes\AllowedCSSTags(); | |
| 160 | 146 | |
| 161 | - // Framework Folder Path | |
| 162 | - if (!defined('FPF_DIR')) | |
| 163 | - { | |
| 164 | - define('FPF_DIR', plugin_dir_path(__FILE__)); | |
| 165 | - } | |
| 166 | - | |
| 167 | - // Framework Layouts Folder Path | |
| 168 | - if (!defined('FPF_LAYOUTS_DIR')) | |
| 169 | - { | |
| 170 | - define('FPF_LAYOUTS_DIR', plugin_dir_path(__FILE__) . 'Layouts/'); | |
| 171 | - } | |
| 172 | - | |
| 173 | - // Support URL | |
| 174 | - if (!defined('FPF_SUPPORT_URL')) | |
| 175 | - { | |
| 176 | - define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact'); | |
| 177 | - } | |
| 178 | - | |
| 179 | - // Framework Media URL | |
| 180 | - if (!defined('FPF_MEDIA_URL')) | |
| 181 | - { | |
| 182 | - define('FPF_MEDIA_URL', plugins_url(strtolower($this->plugin_name)) . '/Inc/Framework/media/'); | |
| 183 | - } | |
| 147 | + GoogleFontsRenderer::getInstance()->render(); | |
| 184 | 148 | } |
| 185 | 149 | |
| 186 | 150 | /** |
| 187 | 151 | * Initializes all components used by back-end. |
| @@ -202,26 +166,69 @@ | ||
| 202 | 166 | private function handleAdminActions() |
| 203 | 167 | { |
| 204 | 168 | // display admin notice |
| 205 | 169 | $adminNotice = new \FPFramework\Libs\AdminNotice(); |
| 206 | - add_action('admin_notices', [$adminNotice, 'displayAdminNotice']); | |
| 170 | + add_action('fpframework/admin/notices', [$adminNotice, 'displayAdminNotice']); | |
| 171 | + | |
| 172 | + add_action('admin_enqueue_scripts', [$this, 'registerMedia'], 20); | |
| 207 | 173 | } |
| 208 | 174 | |
| 175 | + public function registerMedia() | |
| 176 | + { | |
| 177 | + wp_register_style('fpframework_roboto_font', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap', [], null); | |
| 178 | + wp_enqueue_style('fpframework_roboto_font'); | |
| 179 | + } | |
| 180 | + | |
| 209 | 181 | /** |
| 210 | 182 | * Initializes Framework with the required components |
| 211 | 183 | * |
| 212 | 184 | * @return void |
| 213 | 185 | */ |
| 214 | - public function init() { | |
| 186 | + public function init() | |
| 187 | + { | |
| 188 | + $this->setConstants(); | |
| 215 | 189 | $this->initCommons(); |
| 216 | 190 | } |
| 217 | 191 | |
| 218 | 192 | /** |
| 193 | + * Sets constants. | |
| 194 | + * | |
| 195 | + * @return void | |
| 196 | + */ | |
| 197 | + public function setConstants() | |
| 198 | + { | |
| 199 | + /** | |
| 200 | + * Sets the FPF_MEDIA_URL to the Framework Media directory URL. | |
| 201 | + * | |
| 202 | + * The following will ensure we load the Framework Media URL from the plugin | |
| 203 | + * that has the latest framework version. | |
| 204 | + */ | |
| 205 | + // Get the plugin the framework is running from (its the plugin that has the latest framework version) | |
| 206 | + $latest_framework_plugin = basename(dirname(dirname(dirname(__DIR__)))); | |
| 207 | + | |
| 208 | + /** | |
| 209 | + * Set from which plugin we will actually be loading the framework media files. | |
| 210 | + * | |
| 211 | + * - If its fireplugins, we are developing locally, use the plugin name that called the framework, all are symlinked and have the latest version | |
| 212 | + * - If its any other plugin, use it as its the one that has the latest framework version. | |
| 213 | + */ | |
| 214 | + $plugin_slug = $latest_framework_plugin === 'fireplugins' ? $this->plugin_name : $latest_framework_plugin; | |
| 215 | + | |
| 216 | + // Framework Media URL | |
| 217 | + if (!defined('FPF_MEDIA_URL')) | |
| 218 | + { | |
| 219 | + define('FPF_MEDIA_URL', plugins_url(strtolower($plugin_slug)) . '/Inc/Framework/media/'); | |
| 220 | + } | |
| 221 | + } | |
| 222 | + | |
| 223 | + | |
| 224 | + /** | |
| 219 | 225 | * Initializes Framework with the required components for admins |
| 220 | 226 | * |
| 221 | 227 | * @return void |
| 222 | 228 | */ |
| 223 | - public function admin_init() { | |
| 229 | + public function admin_init() | |
| 230 | + { | |
| 224 | 231 | if (!is_admin()) |
| 225 | 232 | { |
| 226 | 233 | return; |
| 227 | 234 | } |
| @@ -251,8 +258,9 @@ | ||
| 251 | 258 | * @param string $plugin_slug |
| 252 | 259 | * |
| 253 | 260 | * @return Framework |
| 254 | 261 | */ |
| 255 | - function fpframework($plugin_slug = '') { | |
| 262 | + function fpframework($plugin_slug = '') | |
| 263 | + { | |
| 256 | 264 | return FPFramework\Framework::getInstance($plugin_slug); |
| 257 | 265 | } |
| 258 | 266 | } |