PluginProbe ʕ •ᴥ•ʔ
AlphaListing / 4.5.0
AlphaListing v4.5.0
4.5.0 trunk 4.3.4 4.3.5 4.3.6 4.3.7 4.4.0
alphalisting / functions / health-check.php
alphalisting / functions Last commit date
enqueues.php 2 weeks ago health-check.php 2 weeks ago helpers.php 2 weeks ago scripts.php 2 weeks ago styles.php 2 weeks ago
health-check.php
85 lines
1 <?php
2 /**
3 * Health Check functionality
4 *
5 * @package alphalisting
6 * @since 2.3.0
7 */
8
9 declare(strict_types=1);
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Add AlphaListing Health Checks
17 *
18 * @since 2.3.0
19 *
20 * @param array<string,mixed> $tests The health checks.
21 * @return array<string,mixed> The health checks.
22 */
23 function alphalisting_add_health_check( array $tests ): array {
24 $tests['direct']['alphalisting_mbstring'] = array(
25 'label' => __( 'A to Z Listing plugin', 'alphalisting' ),
26 'test' => 'alphalisting_mbstring_health_check',
27 );
28 return $tests;
29 }
30 add_filter( 'site_status_tests', 'alphalisting_add_health_check' );
31
32 /**
33 * The mbstring health check
34 *
35 * @since 2.3.0
36 *
37 * @return array<string,mixed> The health check results.
38 */
39 function alphalisting_mbstring_health_check(): array {
40 $result = array(
41 'label' => __( 'AlphaListing: PHP mbstring module is enabled', 'alphalisting' ),
42 'status' => 'good',
43 'badge' => array(
44 'label' => __( 'Compatibility', 'alphalisting' ),
45 'color' => 'green',
46 ),
47 'description' => sprintf(
48 '<p>%s</p>',
49 __( 'The mbstring PHP module improves support for non-latin languages in the AlphaListing plugin.', 'alphalisting' )
50 ),
51 'actions' => '',
52 'test' => 'alphalisting_mbstring_health_check',
53 );
54
55 if ( ! extension_loaded( 'mbstring' ) ) {
56 $result['status'] = 'recommended';
57 $result['label'] = __( 'AlphaListing: PHP mbstring module is not enabled', 'alphalisting' );
58 $result['badge']['color'] = 'orange';
59 $result['description'] = sprintf(
60 '<p>%s</p>',
61 __( 'The mbstring PHP module is not enabled on your server. This module improves support for non-latin languages in the AlphaListing plugin.', 'alphalisting' )
62 );
63 $result['actions'] = __( 'Contact your web host to request that the mbstring PHP module is enabled for your site.', 'alphalisting' );
64 }
65
66 return $result;
67 }
68
69 /**
70 * Add mbstring to the recommended modules section of the health-check feature
71 *
72 * @since 2.3.0
73 *
74 * @param array<string,mixed> $modules An associated array of module properties used during testing.
75 * @return array<string,mixed> The `$modules` array with `mbstring` added.
76 */
77 function alphalisting_php_modules_health_check( array $modules ): array {
78 $modules['mbstring']['extension'] = 'mbstring';
79 if ( ! isset( $modules['mbstring']['required'] ) ) {
80 $modules['mbstring']['required'] = false;
81 }
82 return $modules;
83 }
84 add_filter( 'site_status_test_php_modules', 'alphalisting_php_modules_health_check' );
85