-
Notifications
You must be signed in to change notification settings - Fork 3
/
vralle-lazyload.php
96 lines (83 loc) · 2.09 KB
/
vralle-lazyload.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* The plugin bootstrap file
*
* @link https://github.com/vralle/vralle-lazyload
* @package vralle-lazyload
*
* @wordpress-plugin
* Plugin Name: vralle.lazyload
* Plugin URI: https://github.com/vralle/vralle-lazyload
* Description: Brings lazySizes.js to WordPress
* Version: 1.1.0
* Author: V.Ralle
* Author URI: https://github.com/vralle
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: vralle-lazyload
* Domain Path: /languages
* GitHub Plugin URI: https://github.com/vralle/vralle-lazyload.git
* Requires WP: 4.9
* Requires PHP: 7.1
*/
namespace VRalleLazyLoad;
\defined( 'ABSPATH' ) || exit;
use function \add_action;
use function \define;
use function \plugin_basename;
use function \plugin_dir_path;
use function \plugin_dir_url;
define( 'VLL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'VLL_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'VLL_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'VLL_PLUGIN_VERSION', '1.1.0' );
/**
* Load the plugin dependencies and settings
*
* @return void
*/
function load_plugin() {
require_once __DIR__ . '/includes/class-base-settings.php';
require_once __DIR__ . '/includes/class-lazyload.php';
require_once __DIR__ . '/includes/class-frontend.php';
BaseSettings::init();
}
/**
* Init the plugin to frontend
*
* @return void
*/
function lazyload() {
Frontend::init();
}
/**
* Init the plugin to admin area
*
* @return void
*/
function admin_ui() {
if ( is_admin() ) {
require_once __DIR__ . '/includes/class-admin-ui.php';
Admin_UI::init();
}
}
/**
* Init the plugin parts latter
*
* @return void
*/
function init() {
load_plugin();
add_action( 'wp', __NAMESPACE__ . '\\lazyload' );
add_action( 'init', __NAMESPACE__ . '\\admin_ui' );
}
init();
/**
* Remove the plugin option on uninstall.
*
* @return void
*/
function uninstall() {
delete_option( 'vralle-lazyload' );
}
register_uninstall_hook( __FILE__, __NAMESPACE__ . '\\uninstall' );