PluginProbe
Assistant – Every Day Productivity Apps / 0.3.1
Assistant – Every Day Productivity Apps v0.3.1
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
assistant / backend / src / System / Util / PhpVersionCheck.php

PhpVersionCheck.php in Assistant – Every Day Productivity Apps 0.3.1, at backend/src/System/Util/PhpVersionCheck.php

71 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace FL\Assistant\System\Util;
5
6
7 class PhpVersionCheck {
8
9 public function check() {
10 if ( ! $this->is_minimum_php_version() ) {
11 $this->admin_notice_hooks();
12 return;
13 }
14 }
15
16 /**
17 * Initializes actions for the admin notice if the plugin can't load.
18 */
19 protected function admin_notice_hooks() {
20 global $pagenow;
21
22 if ( 'plugins.php' === $pagenow ) {
23 add_action( 'admin_notices', [ $this, 'admin_notice' ] );
24 add_action( 'network_admin_notices', [ $this, 'admin_notice' ] );
25 }
26 }
27
28 /**
29 * Shows an admin notice if the plugin can't load.
30 */
31 protected function admin_notice() {
32 if ( ! is_admin() ) {
33 return;
34 } elseif ( ! is_user_logged_in() ) {
35 return;
36 } elseif ( ! current_user_can( 'update_core' ) ) {
37 return;
38 }
39
40 $message = $this->get_loading_error();
41
42 if ( $message ) {
43 echo '<div class="error">';
44 echo '<p>' . sprintf( $message ) . '</p>';
45 echo '</div>';
46 }
47 }
48
49 /**
50 * @return bool
51 */
52 protected function is_minimum_php_version() {
53 return ! version_compare( phpversion(), '5.6', '<' );
54 }
55
56 /**
57 * Returns a plugin loading error if there is one.
58 */
59 protected function get_loading_error() {
60
61 $url = 'http://www.wpupdatephp.com/contact-host/';
62
63 /* translators: php upgrade url. */
64
65 return sprintf(
66 __( 'Assistant requires PHP 5.6 or above. Please <a href="%s">update your PHP version</a> before continuing.', 'fl-assistant' ),
67 $url
68 );
69 }
70 }
71