-
Notifications
You must be signed in to change notification settings - Fork 6
/
wp-nonstop-smushit.php
134 lines (118 loc) · 4.21 KB
/
wp-nonstop-smushit.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
/**
* WP Nonstop Smushit plugin
*
* Disable bulk smash limit and enjoy a premium feature of WP Smashit completely FREE!
*
* @link https://github.com/obiPlabon/wp-nonstop-smushit
* @since 1.0.0
* @package WP_Nonstop_Smushit
*
* Plugin Name: Smush Nonstop
* Plugin URI: https://github.com/obiPlabon/wp-nonstop-smushit
* Description: Disable bulk smash limit and enjoy one of the most exciting premium feature of <a href="https://wordpress.org/plugins/wp-smushit/" target="_blank">WP Smashit</a> completely FREE 😉
* Version: 2.1.0
* Author: obiPlabon
* Author URI: https://obiPlabon.im/
* License: GPLv2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-nonstop-smushit
* Domain Path: /languages/
*/
/*
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 2
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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
Copyright 2019 obiPlabon <https://obiPlabon.im>
*/
defined( 'ABSPATH' ) || die();
if ( ! class_exists( 'WP_Nonstop_Smushit' ) ) {
class WP_Nonstop_Smushit {
/**
* Plugin version number
*/
const VERSION = '2.1.0';
/**
* Plugin slug
*/
const SLUG = 'wp-nonstop-smushit';
/**
* WP_Nonstop_Smushit instance
*
* @var null
*/
protected static $instance = null;
/**
* Get instance
*
* @return null|WP_Nonstop_Smushit
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* WP_Nonstop_Smushit constructor.
*/
protected function __construct() {
if ( ! $this->has_wp_smushit() ) {
add_action( 'admin_notices', [ $this, 'show_dependency_missing_error' ] );
} else {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
}
}
/**
* Check the existence of WP Smushit plugin
* @return bool
*/
protected function has_wp_smushit() {
return defined( 'WP_SMUSH_VERSION' ) || class_exists( '\Smush\WP_Smush' ) || class_exists( 'WP_Smush' );
}
/**
* Show dependency missing error message.
*
* @return void
*/
public function show_dependency_missing_error() {
?>
<div class="notice notice-error is-dismissible">
<p><?php printf(
esc_html__( '%1$s requires %2$s to be installed. Please install %2$s otherwise there is no point in installing %1$s.', 'wp-nonstop-smushit' ),
'<strong>' . esc_html__( 'WP Nonstop Smushit', 'wp-nonstop-smushit' ) . '</strong>',
'<mark>' . esc_html__( 'WP Smushit', 'wp-nonstop-smushit' ) . '</mark>'
); ?></p>
</div>
<?php
}
/**
* Enqueue required assets.
*
* @param $page
*
* @return void
*/
public function enqueue_scripts( $page ) {
$white_list = array( 'toplevel_page_smush', 'smush_page_smush-bulk' );
if ( in_array( $page, $white_list, true ) ) {
wp_enqueue_script(
self::SLUG,
plugin_dir_url( __FILE__ ) . 'assets/js/main.js',
null,
self::VERSION,
true
);
}
}
}
}
add_action( 'plugins_loaded', [ 'WP_Nonstop_Smushit', 'get_instance' ], 20 );