PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / includes / classes / FeatureRequirementsStatus.php

FeatureRequirementsStatus.php in ElasticPress 5.3.5, at includes/classes/FeatureRequirementsStatus.php

123 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Simple class for tracking a features requirement status
4 *
5 * @since 2.1
6 * @package elasticpress
7 */
8
9 namespace ElasticPress;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Just an easy way to represent a feature requirements status
17 */
18 class FeatureRequirementsStatus {
19 const AUTO_ENABLED = 0;
20 const MANUALLY_ENABLED = 1;
21 const FORCE_DISABLED = 2;
22 const TEMPORARILY_DISABLED = 3;
23
24 /**
25 * Returns the status of a feature
26 *
27 * 0 is no issues
28 * 1 is usable but there are warnings
29 * 2 is not usable
30 *
31 * @var int
32 * @since 2.2
33 */
34 public $code;
35
36 /**
37 * Optional message to describe status code
38 *
39 * @var string|array
40 * @since 2.2
41 */
42 public $message;
43
44 /**
45 * Optional feature object
46 *
47 * @var Feature|null
48 * @since 5.3.3
49 */
50 public $feature;
51
52 /**
53 * Initialize class
54 *
55 * @param int $code Status code.
56 * @param string|array $message Message describing status.
57 * @param Feature $feature Feature object.
58 * @since 2.2
59 */
60 public function __construct( $code, $message = null, $feature = null ) {
61 $this->code = $code;
62 $this->message = $message;
63 $this->feature = $feature;
64 }
65
66 /**
67 * Get the message for the feature requirements status
68 *
69 * @return array The message to display
70 * @since 5.3.3
71 */
72 public function get_message() {
73 /**
74 * Filter the feature requirements status message
75 *
76 * @hook ep_feature_requirements_status_message
77 * @param {array} $message The message to display
78 * @param {FeatureRequirementsStatus} $status The feature requirements status object
79 * @since 5.3.3
80 * @return array The message to display
81 */
82 return apply_filters( 'ep_feature_requirements_status_message', (array) $this->message, $this );
83 }
84
85 /**
86 * Get the code for the feature requirements status
87 *
88 * @return int The code to display
89 * @since 5.3.3
90 */
91 public function get_code() {
92 /**
93 * Filter the feature requirements status code
94 *
95 * @hook ep_feature_requirements_status_code
96 * @param {int} $code The code to display
97 * @param {FeatureRequirementsStatus} $status The feature requirements status object
98 * @since 5.3.3
99 * @return int The code to display
100 */
101 return apply_filters( 'ep_feature_requirements_status_code', (int) $this->code, $this );
102 }
103
104 /**
105 * Get the feature object
106 *
107 * @return Feature|null The feature object
108 * @since 5.3.3
109 */
110 public function get_feature() {
111 /**
112 * Filter the feature object
113 *
114 * @hook ep_feature_requirements_status_feature
115 * @param {Feature|null} $feature The feature object
116 * @param {FeatureRequirementsStatus} $status The feature requirements status object
117 * @since 5.3.3
118 * @return Feature|null The feature object
119 */
120 return apply_filters( 'ep_feature_requirements_status_feature', $this->feature, $this );
121 }
122 }
123