PluginProbe ʕ •ᴥ•ʔ
WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager / 2.3.6
WPCode – Insert Headers and Footers + Custom Code Snippets – WordPress Code Manager v2.3.6
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 6 months ago build 1 week ago includes 1 week ago languages 1 week ago ihaf.php 1 week ago readme.txt 1 week ago uninstall.php 1 year ago
ihaf.php
462 lines
1 <?php
2 /**
3 * Plugin Name: WPCode Lite
4 * Plugin URI: https://www.wpcode.com/
5 * Version: 2.3.6
6 * Requires at least: 5.0
7 * Requires PHP: 7.0
8 * Tested up to: 7.0
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
299 /**
300 * Set up global constants.
301 *
302 * @return void
303 */
304 private function setup_constants() {
305
306 define( 'WPCODE_FILE', __FILE__ );
307
308 $plugin_headers = get_file_data( WPCODE_FILE, array( 'version' => 'Version' ) );
309
310 define( 'WPCODE_VERSION', $plugin_headers['version'] );
311 define( 'WPCODE_PLUGIN_BASENAME', plugin_basename( WPCODE_FILE ) );
312 define( 'WPCODE_PLUGIN_URL', plugin_dir_url( WPCODE_FILE ) );
313 define( 'WPCODE_PLUGIN_PATH', plugin_dir_path( WPCODE_FILE ) );
314
315 $this->version = WPCODE_VERSION;
316 }
317
318 /**
319 * Require the files needed for the plugin.
320 *
321 * @return void
322 */
323 private function includes() {
324 // Load the safe mode logic first.
325 require_once WPCODE_PLUGIN_PATH . 'includes/safe-mode.php';
326 // Plugin helper functions.
327 require_once WPCODE_PLUGIN_PATH . 'includes/helpers.php';
328 // Functions for global headers & footers output.
329 require_once WPCODE_PLUGIN_PATH . 'includes/global-output.php';
330 // Use the old class name for backwards compatibility.
331 require_once WPCODE_PLUGIN_PATH . 'includes/legacy.php';
332 // Add backwards compatibility for older versions of PHP or WP.
333 require_once WPCODE_PLUGIN_PATH . 'includes/compat.php';
334 // Register code snippets post type.
335 require_once WPCODE_PLUGIN_PATH . 'includes/post-type.php';
336 // The snippet class.
337 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet.php';
338 // Auto-insert options.
339 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-auto-insert.php';
340 // Execute snippets.
341 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet-execute.php';
342 // Handle PHP errors.
343 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-error.php';
344 // [wpcode] shortcode.
345 require_once WPCODE_PLUGIN_PATH . 'includes/shortcode.php';
346 // Conditional logic.
347 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-conditional-logic.php';
348 // Snippet Cache.
349 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-snippet-cache.php';
350 // Settings class.
351 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-settings.php';
352 // Custom capabilities.
353 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-capabilities.php';
354 // Map capabilities for backwards compatibility.
355 require_once WPCODE_PLUGIN_PATH . 'includes/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 // Admin bar info class.
363 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-admin-bar-info.php';
364 // Preview frame handler for live CSS preview.
365 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-preview-frame.php';
366 // Abilities API Integration (WordPress 6.9+).
367 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-abilities-api.php';
368
369 if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
370 require_once WPCODE_PLUGIN_PATH . 'includes/icons.php'; // This is not needed in the frontend atm.
371 // Code Editor class.
372 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-code-editor.php';
373 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-admin-page-loader.php';
374 require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-scripts.php';
375 require_once WPCODE_PLUGIN_PATH . 'includes/admin/admin-ajax-handlers.php';
376 // Always used just in the backend.
377 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-generator.php';
378 // Snippet Library.
379 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-library.php';
380 // Authentication for the library site.
381 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-library-auth.php';
382 // Importers.
383 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-importers.php';
384 // File cache.
385 require_once WPCODE_PLUGIN_PATH . 'includes/class-wpcode-file-cache.php';
386 // The docs.
387 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-docs.php';
388 // Notifications class.
389 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-notifications.php';
390 // Metabox class.
391 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-metabox-snippets.php';
392 // Metabox class.
393 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-admin-notice.php';
394 // Ask for some love.
395 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-review.php';
396 // Suggest free plugins.
397 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-suggested-plugins.php';
398 // Highlight features.
399 require_once WPCODE_PLUGIN_PATH . 'includes/admin/class-wpcode-features-notices.php';
400 }
401
402 // Load lite-specific files.
403 require_once WPCODE_PLUGIN_PATH . 'includes/lite/loader.php';
404 }
405
406 /**
407 * Load the Generator on demand.
408 *
409 * @return WPCode_Generator
410 */
411 public function generator() {
412 if ( ! isset( $this->generator ) ) {
413 $this->generator = new WPCode_Generator();
414 }
415 return $this->generator;
416 }
417
418 /**
419 * Load components in the main plugin instance.
420 *
421 * @return void
422 */
423 public function load_components() {
424 $this->auto_insert = new WPCode_Auto_Insert();
425 $this->execute = new WPCode_Snippet_Execute();
426 $this->error = new WPCode_Error();
427 $this->conditional_logic = new WPCode_Conditional_Logic();
428 $this->cache = new WPCode_Snippet_Cache();
429 $this->settings = new WPCode_Settings();
430 $this->logger = new WPCode_File_Logger();
431
432 if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
433 $this->file_cache = new WPCode_File_Cache();
434 $this->library = new WPCode_Library();
435 $this->library_auth = new WPCode_Library_Auth();
436 $this->importers = new WPCode_Importers();
437 $this->notifications = new WPCode_Notifications();
438 $this->admin_page_loader = new WPCode_Admin_Page_Loader_Lite();
439 $this->notice = new WPCode_Notice();
440 $this->smart_tags = new WPCode_Smart_Tags_Lite();
441
442 // Metabox class.
443 new WPCode_Metabox_Snippets_Lite();
444 // Usage tracking class.
445 new WPCode_Usage_Tracking_Lite();
446 // Suggested plugins.
447 new WPCode_Suggested_Plugins();
448 }
449
450 new WPCode_Admin_Bar_Info_Lite();
451
452 do_action( 'wpcode_loaded' );
453
454 // Load the pluggable functions late to allow plugins to hook in.
455 require_once WPCODE_PLUGIN_PATH . 'includes/pluggable.php';
456 }
457 }
458
459 require_once dirname( __FILE__ ) . '/includes/ihaf.php';
460
461 WPCode();
462