PluginProbe
Code Snippets / 3.5.0
Code Snippets v3.5.0
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 / php / deactivation-notice.php

deactivation-notice.php in Code Snippets 3.5.0, at php/deactivation-notice.php

62 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * File loaded when the plugin cannot be activated.
4 *
5 * All code in this file should be compatible with PHP 5.2 or later.
6 *
7 * @package Code_Snippets
8 *
9 * @noinspection PhpNestedDirNameCallsCanBeReplacedWithLevelParameterInspection
10 * phpcs:disable Modernize.FunctionCalls.Dirname.FileConstant
11 */
12
13 if ( ! defined( 'ABSPATH' ) || function_exists( 'code_snippets_deactivation_notice' ) ) {
14 return;
15 }
16
17 /**
18 * Deactivate the plugin and display a notice informing the user that this has happened.
19 *
20 * @return void
21 *
22 * @since 3.3.0
23 */
24 function code_snippets_deactivation_notice() {
25 $plugins = array();
26 $required_php_version = '7.0';
27
28 if ( version_compare( phpversion(), $required_php_version, '<' ) ) {
29 echo '<div class="error fade"><p><strong>';
30 // translators: %s: required PHP version number.
31 echo esc_html( sprintf( __( 'Code Snippets requires PHP %s or later.', 'code-snippets' ), $required_php_version ) );
32 echo '</strong><br>';
33
34 $update_url = function_exists( 'wp_get_default_update_php_url' ) ?
35 wp_get_default_update_php_url() :
36 'https://wordpress.org/support/update-php/';
37
38 // translators: %s: Update PHP URL.
39 $text = __( 'Please <a href="%s">upgrade your server to the latest version of PHP</a> to continue using Code Snippets.', 'code-snippets' );
40
41 echo wp_kses( sprintf( $text, $update_url ), array( 'a' => array( 'href' => array() ) ) );
42 echo '</p></div>';
43
44 $plugins[] = plugin_basename( dirname( dirname( __FILE__ ) ) . '/code-snippets.php' );
45 }
46
47 if ( defined( 'CODE_SNIPPETS_FILE' ) ) {
48 echo '<div class="error fade"><p>';
49 esc_html_e( 'Another version of Code Snippets appears to be installed. Deactivating this version.', 'code-snippets' );
50 echo '</p></div>';
51
52 $plugins[] = 'code-snippets/code-snippets.php';
53 }
54
55 if ( $plugins ) {
56 require_once ABSPATH . 'wp-admin/includes/plugin.php';
57 deactivate_plugins( array_unique( $plugins ) );
58 }
59 }
60
61 add_action( 'admin_notices', 'code_snippets_deactivation_notice' );
62