-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin-survey-stopper.php
238 lines (187 loc) · 6.01 KB
/
plugin-survey-stopper.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**
* Plugin Name: Plugin Survey Stopper
* Plugin URI: http://davidbisset.com
* Description: Stop annoying plugin surveys and popups when you deactivate plugins.
* Author: David Bisset
* Author URI: http://davidbisset.com
* Version: 1.0.0
* Text Domain: plugin-survey-stopper
* Domain Path: languages
*
* Plugin Survey Stopper 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
* any later version.
*
* Plugin Survey Stopper 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 Envira Gallery. If not, see <http://www.gnu.org/licenses/>.
*
* @category Plugin
* @copyright Copyright © 2018 David Bisset
* @author David Bisset
* @package PluginSurveyStopper
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( !class_exists( 'Plugin_Survey_Stopper' ) ) :
/**
* Main plugin class.
*
* @since 1.0.0
*
* @package Plugin_Survey_Stopper
* @author David Bisset
*/
class Plugin_Survey_Stopper {
/**
* Holds the class object.
*
* @since 1.0.0
*
* @var object
*/
public static $instance;
/**
* Plugin version, used for cache-busting of style and script file references.
*
* @since 1.0.0
*
* @var string
*/
public $version = '1.0.0';
/**
* The name of the plugin.
*
* @since 1.0.0
*
* @var string
*/
public $plugin_name = 'Plugin Survey Stopper';
/**
* Unique plugin slug identifier.
*
* @since 1.0.0
*
* @var string
*/
public $plugin_slug = 'plugin-survey-stoppers';
/**
* Plugin file.
*
* @since 1.0.0
*
* @var string
*/
public $file = __FILE__;
/**
* Primary class constructor.
*
* @since 1.0.0
*/
public function __construct() {
// Load the plugin textdomain.
add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) );
// Load the plugin.
add_action( 'init', array( $this, 'init' ), 99 );
}
/**
* setup_constants function.
*
* @since 1.0.0
*
* @access public
* @return void
*/
public function setup_constants() {
if ( ! defined( 'PLUGIN_SURVEY_STOPPER_VERSION' ) ){
define( 'PLUGIN_SURVEY_STOPPER_VERSION', $this->version );
}
if ( ! defined( 'PLUGIN_SURVEY_STOPPER_SLUG' ) ){
define( 'PLUGIN_SURVEY_STOPPER_SLUG', $this->plugin_slug );
}
if ( ! defined( 'PLUGIN_SURVEY_STOPPER_FILE' ) ){
define( 'PLUGIN_SURVEY_STOPPER_FILE', $this->file );
}
if ( ! defined( 'PLUGIN_SURVEY_STOPPER_DIR' ) ){
define( 'PLUGIN_SURVEY_STOPPER_DIR', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'PLUGIN_SURVEY_STOPPER_URL' ) ){
define( 'PLUGIN_SURVEY_STOPPER_URL', plugin_dir_url( __FILE__ ) );
}
}
/**
* Loads the plugin textdomain for translation.
*
* @since 1.0.0
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( $this->plugin_slug, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Loads the plugin into WordPress.
*
* @since 1.0.0
*/
public function init() {
// Run hook once the plugin has been initialized.
do_action( 'ps_stopper_videos_init' );
// Load admin only components.
if ( is_admin() ) {
$admin = new \Plugin_Survey_Stopper\Admin\Admin_Container();
}
// $frontend = new \Envira\Videos\Frontend\Frontend_Container();
}
/**
* autoload function.
*
* @access public
* @static
* @param mixed $class
* @return void
*/
public static function autoload( $class ){
// Prepare variables.
$prefix = 'Plugin_Survey_Stopper\\';
$baseDir = __DIR__ . '/src/';
$length = mb_strlen( $prefix );
// If the class is not using the namespace prefix, return.
if ( 0 !== strncmp( $prefix, $class, $length ) ) {
return;
}
// Prepare classes to be autoloaded.
$relativeClass = mb_substr( $class, $length );
$file = $baseDir . str_replace( '\\', '/', $relativeClass ) . '.php';
// If the file exists, load it.
if ( file_exists( $file ) ) {
require $file;
}
}
/**
* Returns the singleton instance of the class.
*
* @since 1.4.1
*
* @return object The Envira_Videos object.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Plugin_Survey_Stopper ) ) {
self::$instance = new self();
self::$instance->setup_constants();
}
return self::$instance;
}
}
spl_autoload_register( 'Plugin_Survey_Stopper::autoload' );
add_action( 'init', 'ps_stopper_init' );
function ps_stopper_init(){
return Plugin_Survey_Stopper::get_instance();
}
endif;