PluginProbe ʕ •ᴥ•ʔ
WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager / 2.0.13
WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager v2.0.13
2.3.6 trunk 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.5.0 1.6.0 1.6.1 1.6.2 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.13.1 2.0.2 2.0.3 2.0.4 2.0.4.1 2.0.4.2 2.0.4.3 2.0.4.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.2 2.1.3 2.1.3.1 2.1.4 2.1.4.1 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.2.4 2.2.4.1 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.2.1 2.3.3 2.3.4 2.3.5
insert-headers-and-footers / ihaf.php
insert-headers-and-footers Last commit date
admin 3 years ago build 2 years ago includes 2 years ago languages 2 years ago ihaf.php 2 years ago readme.txt 2 years ago uninstall.php 3 years ago
ihaf.php
449 lines
1 <?php
2 /**
3 * Plugin Name: WPCode Lite
4 * Plugin URI: https://www.wpcode.com/
5 * Version: 2.0.13
6 * Requires at least: 4.6
7 * Requires PHP: 5.5
8 * Tested up to: 6.1
9 * Author: WPCode
10 * Author URI: https://www.wpcode.com/
11 * Description: Easily add code snippets in WordPress. Insert scripts to the header and footer, add PHP code snippets with conditional logic, insert ads pixel, custom content, and more.
12 * License: GPLv2 or later
13 *
14 * Text Domain: insert-headers-and-footers
15 * Domain Path: /languages
16 *
17 * @package WPCode
18 */
19
20 /*
21 Copyright 2019 WPBeginner
22
23 This program is free software; you can redistribute it and/or modify
24 it under the terms of the GNU General Public License, version 2, as
25 published by the Free Software Foundation.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public License
33 along with this program; if not, write to the Free Software
34 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 */
36
37 if ( ! defined( 'ABSPATH' ) ) {
38 exit;
39 }
40
41 // Don't allow multiple versions to be active.
42 if ( function_exists( 'WPCode' ) ) {
43
44 if ( ! function_exists( 'wpcode_pro_just_activated' ) ) {
45 /**
46 * When we activate a Pro version, we need to do additional operations:
47 * 1) deactivate a Lite version;
48 * 2) register option which help to run all activation process for Pro version (custom tables creation, etc.).
49 */
50 function wpcode_pro_just_activated() {
51 wpcode_deactivate();
52 add_option( 'wpcode_install', 1 );
53 }
54 }
55 add_action( 'activate_wpcode-premium/wpcode.php', 'wpcode_pro_just_activated' );
56
57 if ( ! function_exists( 'wpcode_lite_just_activated' ) ) {
58 /**
59 * Store temporarily that the Lite version of the plugin was activated.
60 * This is needed because WP does a redirect after activation and
61 * we need to preserve this state to know whether user activated Lite or not.
62 */
63 function wpcode_lite_just_activated() {
64
65 set_transient( 'wpcode_lite_just_activated', true );
66 }
67 }
68 add_action( 'activate_insert-headers-and-footers/ihaf.php', 'wpcode_lite_just_activated' );
69
70 if ( ! function_exists( 'wpcode_lite_just_deactivated' ) ) {
71 /**
72 * Store temporarily that Lite plugin was deactivated.
73 * Convert temporary "activated" value to a global variable,
74 * so it is available through the request. Remove from the storage.
75 */
76 function wpcode_lite_just_deactivated() {
77
78 global $wpcode_lite_just_activated, $wpcode_lite_just_deactivated;
79
80 $wpcode_lite_just_activated = (bool) get_transient( 'wpcode_lite_just_activated' );
81 $wpcode_lite_just_deactivated = true;
82
83 delete_transient( 'wpcode_lite_just_activated' );
84 }
85 }
86 add_action( 'deactivate_insert-headers-and-footers/ihaf.php', 'wpcode_lite_just_deactivated' );
87
88 if ( ! function_exists( 'wpcode_deactivate' ) ) {
89 /**
90 * Deactivate Lite if WPCode already activated.
91 */
92 function wpcode_deactivate() {
93
94 $plugin = 'insert-headers-and-footers/ihaf.php';
95
96 deactivate_plugins( $plugin );
97
98 do_action( 'wpcode_plugin_deactivated', $plugin );
99 }
100 }
101 add_action( 'admin_init', 'wpcode_deactivate' );
102
103 if ( ! function_exists( 'wpcode_lite_notice' ) ) {
104 /**
105 * Display the notice after deactivation when Pro is still active
106 * and user wanted to activate the Lite version of the plugin.
107 */
108 function wpcode_lite_notice() {
109
110 global $wpcode_lite_just_activated, $wpcode_lite_just_deactivated;
111
112 if (
113 empty( $wpcode_lite_just_activated ) ||
114 empty( $wpcode_lite_just_deactivated )
115 ) {
116 return;
117 }
118
119 // Currently tried to activate Lite with Pro still active, so display the message.
120 printf(
121 '<div class="notice notice-warning">
122 <p>%1$s</p>
123 <p>%2$s</p>
124 </div>',
125 esc_html__( 'Heads up!', 'insert-headers-and-footers' ),
126 esc_html__( 'Your site already has WPCode Pro activated. If you want to switch to WPCode Lite, please first go to Plugins → Installed Plugins and deactivate WPCode. Then, you can activate WPCode Lite.', 'insert-headers-and-footers' )
127 );
128
129 if ( isset( $_GET['activate'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
130 unset( $_GET['activate'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
131 }
132
133 unset( $wpcode_lite_just_activated, $wpcode_lite_just_deactivated );
134 }
135 }
136 add_action( 'admin_notices', 'wpcode_lite_notice' );
137
138 // Do not process the plugin code further.
139 return;
140 }
141
142 /**
143 * Main WPCode Class
144 */
145 class WPCode {
146
147 /**
148 * Holds the instance of the plugin.
149 *
150 * @since 2.0.0
151 *
152 * @var WPCode The one true WPCode
153 */
154 private static $instance;
155
156 /**
157 * Plugin version.
158 *
159 * @since 2.0.0
160 *
161 * @var string
162 */
163 public $version = '';
164
165 /**
166 * The auto-insert instance.
167 *
168 * @var WPCode_Auto_Insert
169 */
170 public $auto_insert;
171
172 /**
173 * The snippet execution instance.
174 *
175 * @var WPCode_Snippet_Execute
176 */
177 public $execute;
178
179 /**
180 * The error handling instance.
181 *
182 * @var WPCode_Error
183 */
184 public $error;
185
186 /**
187 * The conditional logic instance.
188 *
189 * @var WPCode_Conditional_Logic
190 */
191 public $conditional_logic;
192
193 /**
194 * The conditional logic instance.
195 *
196 * @var WPCode_Snippet_Cache
197 */
198 public $cache;
199
200 /**
201 * The snippet library.
202 *
203 * @var WPCode_Library
204 */
205 public $library;
206
207 /**
208 * The Snippet Generator.
209 *
210 * @var WPCode_Generator
211 */
212 public $generator;
213
214 /**
215 * The plugin settings.
216 *
217 * @var WPCode_Settings
218 */
219 public $settings;
220
221 /**
222 * The plugin importers.
223 *
224 * @var WPCode_Importers
225 */
226 public $importers;
227 /**
228 * The file cache class.
229 *
230 * @var WPCode_File_Cache
231 */
232 public $file_cache;
233
234 /**
235 * The notifications instance (admin-only).
236 *
237 * @var WPCode_Notifications
238 */
239 public $notifications;
240
241 /**
242 * The admin page loader.
243 *
244 * @var WPCode_Admin_Page_Loader
245 */
246 public $admin_page_loader;
247
248 /**
249 * The library auth instance.
250 *
251 * @var WPCode_Library_Auth
252 */
253 public $library_auth;
254
255 /**
256 * The admin notices instance.
257 *
258 * @var WPCode_Notice
259 */
260 public $notice;
261
262 /**
263 * Instance for logging errors.
264 *
265 * @var WPCode_File_Logger
266 */
267 public $logger;
268
269 /**
270 * Load the smart tags.
271 *
272 * @var WPCode_Smart_Tags
273 */
274 public $smart_tags;
275
276 /**
277 * Main instance of WPCode.
278 *
279 * @return WPCode
280 * @since 2.0.0
281 */
282 public static function instance() {
283 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPCode ) ) {
284 self::$instance = new WPCode();
285 }
286
287 return self::$instance;
288 }
289
290 /**
291 * Constructor.
292 */
293 private function __construct() {
294 $this->setup_constants();
295 $this->includes();
296 add_action( 'plugins_loaded', array( $this, 'load_components' ), - 1 );
297
298 add_action( 'init', array( $this, 'load_plugin_textdomain' ), 15 );
299 }
300
301 /**
302 * Set up global constants.
303 *
304 * @return void
305 */
306 private function setup_constants() {
307
308 define( 'WPCODE_FILE', __FILE__ );
309
310 $plugin_headers = get_file_data( WPCODE_FILE, array( 'version' => 'Version' ) );
311
312 define( 'WPCODE_VERSION', $plugin_headers['version'] );
313 define( 'WPCODE_PLUGIN_BASENAME', plugin_basename( WPCODE_FILE ) );
314 define( 'WPCODE_PLUGIN_URL', plugin_dir_url( WPCODE_FILE ) );
315 define( 'WPCODE_PLUGIN_PATH', plugin_dir_path( WPCODE_FILE ) );
316
317 $this->version = WPCODE_VERSION;
318 }
319
320 /**
321 * Require the files needed for the plugin.
322 *
323 * @return void
324 */
325 private function includes() {
326 // Load the safe mode logic first.
327 require_once WPCODE_PLUGIN_PATH . 'includes/safe-mode.php';
328 // Plugin helper functions.
329 require_once WPCODE_PLUGIN_PATH . 'includes/helpers.php';
330 // Functions for global headers & footers output.
331 require_once WPCODE_PLUGIN_PATH . 'includes/global-output.php';
332 // Use the old class name for backwards compatibility.
333 require_once WPCODE_PLUGIN_PATH . 'includes/legacy.php';
334 // Add backwards compatibility for older versions of PHP or WP.
335 require_once WPCODE_PLUGIN_PATH . 'includes/compat.php';
336 // Register code snippets post type.
337 require_once WPCODE_PLUGIN_PATH . 'includes/post-type.php';
338 // The snippet class.
339 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet.php';
340 // Auto-insert options.
341 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-auto-insert.php';
342 // Execute snippets.
343 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet-execute.php';
344 // Handle PHP errors.
345 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-error.php';
346 // [wpcode] shortcode.
347 require_once WPCODE_PLUGIN_PATH . 'includes/shortcode.php';
348 // Conditional logic.
349 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-conditional-logic.php';
350 // Snippet Cache.
351 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet-cache.php';
352 // Settings class.
353 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-settings.php';
354 // Custom capabilities.
355 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-capabilities.php';
356 // Install routines.
357 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-install.php';
358 // Logging class.
359 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-file-logger.php';
360 // Smart tags class.
361 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-smart-tags.php';
362
363 if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
364 require_once WPCODE_PLUGIN_PATH . 'includes/icons.php'; // This is not needed in the frontend atm.
365 // Code Editor class.
366 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-code-editor.php';
367 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-admin-page-loader.php';
368 require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-scripts.php';
369 require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-ajax-handlers.php';
370 // Always used just in the backend.
371 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-generator.php';
372 // Snippet Library.
373 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-library.php';
374 // Authentication for the library site.
375 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-library-auth.php';
376 // Importers.
377 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-importers.php';
378 // File cache.
379 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-file-cache.php';
380 // The docs.
381 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-docs.php';
382 // Notifications class.
383 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-notifications.php';
384 // Upgrade page.
385 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-upgrade-welcome.php';
386 // Metabox class.
387 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-metabox-snippets.php';
388 // Metabox class.
389 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-admin-notice.php';
390 // Ask for some love.
391 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-review.php';
392 }
393
394 // Load lite-specific files.
395 require_once WPCODE_PLUGIN_PATH . 'includes/lite/loader.php';
396 }
397
398 /**
399 * Load components in the main plugin instance.
400 *
401 * @return void
402 */
403 public function load_components() {
404 $this->auto_insert = new WPCode_Auto_Insert();
405 $this->execute = new WPCode_Snippet_Execute();
406 $this->error = new WPCode_Error();
407 $this->conditional_logic = new WPCode_Conditional_Logic();
408 $this->cache = new WPCode_Snippet_Cache();
409 $this->settings = new WPCode_Settings();
410 $this->logger = new WPCode_File_Logger();
411
412 if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
413 $this->file_cache = new WPCode_File_Cache();
414 $this->library = new WPCode_Library();
415 $this->library_auth = new WPCode_Library_Auth();
416 $this->generator = new WPCode_Generator();
417 $this->importers = new WPCode_Importers();
418 $this->notifications = new WPCode_Notifications();
419 $this->admin_page_loader = new WPCode_Admin_Page_Loader_Lite();
420 $this->notice = new WPCode_Notice();
421 $this->smart_tags = new WPCode_Smart_Tags_Lite();
422
423 // Metabox class.
424 new WPCode_Metabox_Snippets_Lite();
425 // Usage tracking class.
426 new WPCode_Usage_Tracking_Lite();
427 }
428
429 do_action( 'wpcode_loaded' );
430 }
431
432 /**
433 * Load the plugin translations.
434 *
435 * @return void
436 */
437 public function load_plugin_textdomain() {
438 if ( is_user_logged_in() ) {
439 unload_textdomain( 'insert-headers-and-footers' );
440 }
441
442 load_plugin_textdomain( 'insert-headers-and-footers', false, dirname( plugin_basename( WPCODE_FILE ) ) . '/languages/' );
443 }
444 }
445
446 require_once dirname( __FILE__ ) . '/includes/ihaf.php';
447
448 WPCode();
449