PluginProbe
Code Snippets / 3.10.1
Code Snippets v3.10.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 / php / Core / deactivation-notice.php

deactivation-notice.php in Code Snippets 3.10.1, at php/Core/deactivation-notice.php

67 lines 2.2 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 *
11 * phpcs:disable Modernize.FunctionCalls.Dirname.FileConstant
12 */
13
14 if ( ! defined( 'ABSPATH' ) || function_exists( 'code_snippets_deactivation_notice' ) ) {
15 return;
16 }
17
18 /**
19 * Deactivate the plugin and display a notice informing the user that this has happened.
20 *
21 * @return void
22 *
23 * @since 3.3.0
24 */
25 function code_snippets_deactivation_notice() {
26 $plugins = array();
27 $required_php_version = '7.4';
28
29 if ( version_compare( phpversion(), $required_php_version, '<' ) ) {
30 $plugins[] = plugin_basename( dirname( dirname( __FILE__ ) ) . '/code-snippets.php' );
31
32 printf(
33 '<div class="code-snippets-notice error fade" role="region" aria-label="%s"><p><strong>%s</strong>',
34 esc_attr__( 'Code Snippets PHP version notice', 'code-snippets' ),
35 // translators: %s: required PHP version number.
36 esc_html( sprintf( __( 'Code Snippets requires PHP %s or later.', 'code-snippets' ), $required_php_version ) )
37 );
38
39 $update_url = function_exists( 'wp_get_default_update_php_url' ) ?
40 wp_get_default_update_php_url() :
41 'https://wordpress.org/support/update-php/';
42
43 // translators: %s: Update PHP URL.
44 $update_text = __( 'Please <a href="%s">upgrade your server to the latest version of PHP</a> to continue using Code Snippets.', 'code-snippets' );
45
46 echo '<br>', wp_kses( sprintf( $update_text, $update_url ), array( 'a' => array( 'href' => array() ) ) );
47 echo '</p></div>';
48 }
49
50 if ( defined( 'CODE_SNIPPETS_FILE' ) ) {
51 $plugins[] = 'code-snippets/code-snippets.php';
52
53 printf(
54 '<div class="code-snippets-notice error fade" role="region" aria-label="%s"><p>%s</p></div>',
55 esc_attr__( 'Code Snippets duplicate plugin notice', 'code-snippets' ),
56 esc_html__( 'Another version of Code Snippets appears to be installed. Deactivating this version.', 'code-snippets' )
57 );
58 }
59
60 if ( $plugins ) {
61 require_once ABSPATH . 'wp-admin/includes/plugin.php';
62 deactivate_plugins( array_unique( $plugins ) );
63 }
64 }
65
66 add_action( 'admin_notices', 'code_snippets_deactivation_notice' );
67