-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocket-async-css.php
134 lines (118 loc) · 3.25 KB
/
rocket-async-css.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link http://www.derrickhammer.com
* @since 0.1.0
* @package Rocket_Async_Css
*
* @wordpress-plugin
* Plugin Name: WP Rocket ASYNC CSS
* Plugin URI: https://github.com/pcfreak30/rocket-async-css
* Description: WordPress plugin to combine all CSS load async including inline scripts. Extends WP-Rocket
* Version: 0.7.1.3
* Author: Derrick Hammer
* Author URI: http://www.derrickhammer.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: rocket-async-css
*/
use Dice\Dice;
/**
* @SuppressWarnings(PHPMD.StaticAccess)
* @return \Rocket\Async\CSS
*/
function rocket_async_css_instance() {
return rocket_async_css_container()->create( '\\Rocket\\Async\\CSS' );
}
/**
* @param string $env
*
* @return Dice
*/
function rocket_async_css_container( $env = 'prod' ) {
static $container;
if ( empty( $container ) ) {
$container = new Dice();
include __DIR__ . "/config_{$env}.php";
}
return $container;
}
/**
* Init function shortcut
*/
function rocket_async_css_init() {
rocket_async_css_instance()->init();
}
/**
* Activate function shortcut
*/
function rocket_async_css_activate() {
rocket_async_css_instance()->activate();
}
/**
* Deactivate function shortcut
*/
function rocket_async_css_deactivate() {
rocket_async_css_instance()->deactivate();
}
if ( ! function_exists( '__return_one' ) ) {
function __return_one() {
return 1;
}
}
/**
* Error for older php
*/
function rocket_async_css_php_upgrade_notice() {
$info = get_plugin_data( __FILE__ );
_e(
sprintf(
'
<div class="error notice">
<p>Opps! %s requires a minimum PHP version of 5.4.0. Your current version is: %s. Please contact your host to upgrade.</p>
</div>', $info['Name'], PHP_VERSION
)
);
}
/**
* Error if vendors autoload is missing
*/
function rocket_async_css_php_vendor_missing() {
$info = get_plugin_data( __FILE__ );
_e(
sprintf(
'
<div class="error notice">
<p>Opps! %s is corrupted it seems, please re-install the plugin.</p>
</div>', $info['Name']
)
);
}
if ( version_compare( PHP_VERSION, '5.4.0' ) < 0 ) {
add_action( 'admin_notices', 'rocket_async_css_php_upgrade_notice' );
} else {
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
include_once __DIR__ . '/vendor/autoload.php';
add_action( 'plugins_loaded', 'rocket_async_css_init', 11 );
register_activation_hook( __FILE__, 'rocket_async_css_activate' );
register_deactivation_hook( __FILE__, 'rocket_async_css_deactivate' );
} else {
add_action( 'admin_notices', 'rocket_async_css_php_vendor_missing' );
}
}
if ( ! function_exists( 'avada_revslider' ) ):
function avada_revslider( $name ) {
if ( function_exists( 'putRevSlider' ) ) {
ob_start();
putRevSlider( $name );
$slider = ob_get_clean();
echo str_replace( 'tpj(document).ready(function() {', 'tpj(window).load(function() {', $slider );
}
}
endif;