-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbetter-resource-hints.php
78 lines (66 loc) · 1.91 KB
/
better-resource-hints.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Plugin Name: Better Resource Hints
* Description: Easy preloading, prefetching, HTTP/2 server pushing, and more for your CSS and JavaScript.
* Version: 1.1.3
* Author: Alex MacArthur
* Author URI: http://macarthur.me
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
namespace BetterResourceHints;
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
require_once 'src/Settings.php';
require_once 'src/Filters.php';
require_once 'src/Preconnector.php';
require_once 'src/Preloader.php';
require_once 'src/Prefetcher.php';
require_once 'src/Utilities.php';
if (!defined('WPINC')) {
die;
}
define('BETTER_RESOURCE_HINTS_OPTIONS_PREFIX', 'better_resource_hints');
define('BETTER_RESOURCE_HINTS_ADMIN_SETTINGS_PAGE_SLUG', 'better_resource_hints');
class App
{
/**
* Initialize the plugin.
*
* @return object App Instance of class.
*/
public static function go()
{
$GLOBALS[ __CLASS__ ] = new self;
return $GLOBALS[ __CLASS__ ];
}
/**
* Retrive array of plugin data.
*
* @return array
*/
public static function getPluginData()
{
return get_plugin_data(__FILE__);
}
public function __construct()
{
new Filters;
new Settings;
new Preloader;
new Prefetcher;
new Preconnector;
add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts' ));
}
/**
* Enqueue necessary admin scripts & styles.
*
* @return void
*/
public function enqueue_styles_and_scripts()
{
$plugin_data = self::getPluginData();
wp_enqueue_style('better-resource-hints', plugin_dir_url(__FILE__) . 'src/assets/css/style.css', [], $plugin_data['Version']);
wp_enqueue_script('better-resource-hints', plugin_dir_url(__FILE__) . 'src/assets/js/scripts.min.js', [], $plugin_data['Version'], true);
}
}
App::go();