| @@ -15,23 +15,14 @@ | ||
| 15 | 15 | /** |
| 16 | 16 | * Just an easy way to represent a feature requirements status |
| 17 | 17 | */ |
| 18 | 18 | class FeatureRequirementsStatus { |
| 19 | + const AUTO_ENABLED = 0; | |
| 20 | + const MANUALLY_ENABLED = 1; | |
| 21 | + const FORCE_DISABLED = 2; | |
| 22 | + const TEMPORARILY_DISABLED = 3; | |
| 19 | 23 | |
| 20 | 24 | /** |
| 21 | - * Initialize class | |
| 22 | - * | |
| 23 | - * @param int $code Status code. | |
| 24 | - * @param string|array $message Message describing status. | |
| 25 | - * @since 2.2 | |
| 26 | - */ | |
| 27 | - public function __construct( $code, $message = null ) { | |
| 28 | - $this->code = $code; | |
| 29 | - | |
| 30 | - $this->message = $message; | |
| 31 | - } | |
| 32 | - | |
| 33 | - /** | |
| 34 | 25 | * Returns the status of a feature |
| 35 | 26 | * |
| 36 | 27 | * 0 is no issues |
| 37 | 28 | * 1 is usable but there are warnings |
| @@ -48,5 +39,84 @@ | ||
| 48 | 39 | * @var string|array |
| 49 | 40 | * @since 2.2 |
| 50 | 41 | */ |
| 51 | 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 | + } | |
| 52 | 122 | } |