PluginProbe
Polylang / 3.8.8
Polylang v3.8.8
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / src / install / usable.php

usable.php in Polylang 3.8.8, at src/install/usable.php

124 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 * @package Polylang
4 *
5 * /!\ THE CODE IN THIS FILE MUST BE COMPATIBLE WITH PHP 5.6.
6 *
7 * /!\ THE CONSTANTS `POLYLANG`, `PLL_MIN_PHP_VERSION`, AND `PLL_MIN_WP_VERSION` MUST BE DEFINED.
8 */
9
10 /**
11 * Class tat can tell if Polylang can be activated.
12 *
13 * @since 3.8
14 */
15 class PLL_Usable {
16 /**
17 * Checks min PHP and WP version, displays a notice if a requirement is not met.
18 *
19 * @since 2.6.7
20 * @since 3.8 Moved from the class `PLL_Install`.
21 * Made it `static`.
22 *
23 * @return bool
24 */
25 public static function can_activate() {
26 global $wp_version;
27
28 if ( version_compare( pll_get_constant( 'PHP_VERSION', '' ), static::get_min_php_version(), '<' ) ) {
29 add_action( 'admin_notices', array( static::class, 'php_version_notice' ) );
30 return false;
31 }
32
33 if ( version_compare( $wp_version, static::get_min_wp_version(), '<' ) ) {
34 add_action( 'admin_notices', array( static::class, 'wp_version_notice' ) );
35 return false;
36 }
37
38 return true;
39 }
40
41 /**
42 * Displays a notice if PHP min version is not met.
43 *
44 * @since 2.6.7
45 * @since 3.8 Moved from the class `PLL_Install`.
46 * Made it `static`.
47 *
48 * @return void
49 */
50 public static function php_version_notice() {
51 load_plugin_textdomain( 'polylang' ); // Plugin i18n.
52
53 printf(
54 '<div class="error"><p>%s</p></div>',
55 sprintf(
56 /* translators: 1: Plugin name 2: Current PHP version 3: Required PHP version */
57 esc_html__( '%1$s has deactivated itself because you are using an old version of PHP. You are using using PHP %2$s. %1$s requires PHP %3$s.', 'polylang' ),
58 esc_html( static::get_plugin_name() ),
59 esc_html( pll_get_constant( 'PHP_VERSION', '' ) ),
60 esc_html( static::get_min_php_version() )
61 )
62 );
63 }
64
65 /**
66 * Displays a notice if WP min version is not met.
67 *
68 * @since 2.6.7
69 * @since 3.8 Moved from the class `PLL_Install`.
70 * Made it `static`.
71 *
72 * @return void
73 */
74 public static function wp_version_notice() {
75 global $wp_version;
76
77 load_plugin_textdomain( 'polylang' ); // Plugin i18n.
78
79 printf(
80 '<div class="error"><p>%s</p></div>',
81 sprintf(
82 /* translators: 1: Plugin name 2: Current WordPress version 3: Required WordPress version */
83 esc_html__( '%1$s has deactivated itself because you are using an old version of WordPress. You are using using WordPress %2$s. %1$s requires at least WordPress %3$s.', 'polylang' ),
84 esc_html( static::get_plugin_name() ),
85 esc_html( $wp_version ),
86 esc_html( static::get_min_wp_version() )
87 )
88 );
89 }
90
91 /**
92 * Returns the minimal php version required to run the plugin.
93 *
94 * @since 3.8
95 *
96 * @return string
97 */
98 public static function get_min_php_version() {
99 return pll_get_constant( 'PLL_MIN_PHP_VERSION', '' );
100 }
101
102 /**
103 * Returns the minimal WP version required to run the plugin.
104 *
105 * @since 3.8
106 *
107 * @return string
108 */
109 public static function get_min_wp_version() {
110 return pll_get_constant( 'PLL_MIN_WP_VERSION', '' );
111 }
112
113 /**
114 * Returns the plugin's name.
115 *
116 * @since 3.8
117 *
118 * @return string
119 */
120 public static function get_plugin_name() {
121 return pll_get_constant( 'POLYLANG', '' );
122 }
123 }
124