PluginProbe
Code Snippets / 3.2.1
Code Snippets v3.2.1
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / code-snippets.php

code-snippets.php in Code Snippets 3.2.1, at code-snippets.php

99 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Code Snippets - An easy, clean and simple way to add code snippets to your site.
4 *
5 * If you're interested in helping to develop Code Snippets, or perhaps contribute
6 * to the localization, please see https://github.com/sheabunge/code-snippets
7 *
8 * @package Code_Snippets
9 * @author Shea Bunge <shea@codesnippets.pro>
10 * @copyright 2012-2022 Shea Bunge
11 * @license GPL-2.0-or-later https://spdx.org/licenses/GPL-2.0-or-later.html
12 * @version 3.2.1
13 * @link https://github.com/sheabunge/code-snippets
14 */
15
16 /*
17 Plugin Name: Code Snippets
18 Plugin URI: https://codesnippets.pro
19 Description: An easy, clean and simple way to run code snippets on your site. No need to edit to your theme's functions.php file again!
20 Author: Code Snippets Pro
21 Author URI: https://codesnippets.pro
22 Version: 3.2.1
23 License: GPL-2.0-or-later
24 License URI: license.txt
25 Text Domain: code-snippets
26 Requires PHP: 5.6
27 Requires at least: 3.6
28 */
29
30 /* Exit if accessed directly */
31 if ( ! defined( 'ABSPATH' ) ) {
32 return;
33 }
34
35 /* If a version of code snippets has already been loaded, then deactivate this plugin. */
36 if ( defined( 'CODE_SNIPPETS_FILE' ) ) {
37 require_once ABSPATH . 'wp-admin/includes/plugin.php';
38 deactivate_plugins( array( 'code-snippets/code-snippets.php' ), true );
39
40 if ( ! function_exists( 'code_snippets_deactivated_old_version_notice' ) ) {
41 /**
42 * Display a message informing the user that this plugin has been deactivated.
43 */
44 function code_snippets_deactivated_old_version_notice() {
45 echo '<div class="error fade"><p>';
46 esc_html_e( 'Another version of Code Snippets appears to be installed. Deactivating this version.', 'code-snippets' );
47 echo '</p></div>';
48 }
49 }
50
51 add_action( 'admin_notices', 'code_snippets_deactivated_old_version_notice', 11 );
52 return;
53 }
54
55 /**
56 * The full path to the main file of this plugin
57 *
58 * This can later be passed to functions such as
59 * plugin_dir_path(), plugins_url() and plugin_basename()
60 * to retrieve information about plugin paths
61 *
62 * @since 2.0
63 * @var string
64 */
65 define( 'CODE_SNIPPETS_FILE', __FILE__ );
66
67 if ( version_compare( phpversion(), '5.6', '>=' ) ) {
68 require_once __DIR__ . '/php/load.php';
69
70 return;
71 }
72
73 if ( ! function_exists( 'code_snippets_php_version_notice' ) ) {
74
75 /**
76 * Display a warning message and deactivate the plugin if the user is using an incompatible version of PHP
77 *
78 * @since 3.0.0
79 */
80 function code_snippets_php_version_notice() {
81 echo '<div class="error fade"><p>';
82 echo '<p><strong>', esc_html__( 'Code Snippets requires PHP 5.6 or later.', 'code-snippets' ), '</strong><br>';
83
84 $update_url = function_exists( 'wp_get_default_update_php_url' ) ?
85 wp_get_default_update_php_url() :
86 'https://wordpress.org/support/update-php/';
87
88 /* translators: %s: Update PHP URL */
89 $text = __( 'Please <a href="%s">upgrade your server to the latest version of PHP</a> to continue using Code Snippets.', 'code-snippets' );
90
91 echo wp_kses( sprintf( $text, $update_url ), array( 'a' => array( 'href' => array() ) ) );
92 echo '</p></div>';
93
94 deactivate_plugins( plugin_basename( __FILE__ ) );
95 }
96
97 add_action( 'admin_notices', 'code_snippets_php_version_notice' );
98 }
99