PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / requirement.php

requirement.php in Depicter — Popup & Slider Builder trunk, at app/requirement.php

95 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle checking requirements.
4 *
5 * @package Depicter
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 if ( ! function_exists( 'depicter_requirements_satisfied' ) ) {
13
14 /**
15 * Whether required php version is available or not.
16 *
17 * @param string $name Project name.
18 * @param string $min Minimum PHP version.
19 *
20 * @return bool
21 */
22 function depicter_requirements_satisfied( $name, $min ) {
23
24 if ( version_compare( PHP_VERSION, $min, '>=' ) ) {
25 return depicter_check_opcache( $name );
26 }
27
28 add_action(
29 'admin_notices',
30 function () use ( $name, $min ) {
31 /* translators: 1: name of plugin, 2: minimum php version required, 3: current php version */
32 $message = __( '%1$s plugin requires PHP version %2$s but current version is %3$s. Please contact your host provider and ask them to upgrade PHP version.', 'depicter' );
33 ?>
34 <div class="notice notice-error">
35 <p><?php echo wp_kses( sprintf(
36 $message,
37 '<strong>' . $name . '</strong>',
38 '<strong>' . $min . '</strong>',
39 '<strong>' . PHP_VERSION . '</strong>'
40 ), ['strong' => [] ] ); ?></p>
41 </div>
42 <?php
43 }
44 );
45
46 // An incompatible version is already loaded.
47 return false;
48 }
49
50 /**
51 * Check opcache config
52 *
53 * @param $name
54 *
55 * @return bool
56 */
57 function depicter_check_opcache( $name ) {
58
59 set_error_handler(function(){});
60 $has_opcache_status = function_exists('opcache_get_status') && opcache_get_status();
61 restore_error_handler();
62
63 if ( $has_opcache_status ) {
64 if ( ! function_exists('opcache_get_configuration') ){
65 return true;
66 }
67 // Some security settings in OpCache can prevent calling `opcache_get_status()` and `opcache_get_configuration()`
68 // To prevent any unwanted warnings, we buffer the output here
69 ob_start();
70 $config = opcache_get_configuration();
71 ob_get_clean();
72
73 if ( empty( $config['directives']['opcache.save_comments'] ) ) {
74 add_action(
75 'admin_notices',
76 function () use ( $name ) {
77 /* translators: 1: depicter plugin name */
78 $message = __( 'Your website uses OpCache but requires the "opcache.save_comments" option enabled for %1$s plugin to work correctly. Please ask your hosting provider to turn on this setting.', 'depicter' );
79 ?>
80 <div class="notice notice-error">
81 <p><?php echo wp_kses( sprintf( $message, '<strong>'. $name .'</strong>' ), ['strong' => [] ] ); ?></p>
82 </div>
83 <?php
84 }
85 );
86
87 return false;
88 }
89 }
90
91 return true;
92 }
93
94 }
95