Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
CRAP | n/a |
0 / 0 |
|
| NewfoldLabs\WP\Module\Features\isEnabled | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| NewfoldLabs\WP\Module\Features\enable | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| NewfoldLabs\WP\Module\Features\disable | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\Features; |
| 3 | |
| 4 | use WP_Error; |
| 5 | use NewfoldLabs\WP\Module\Features\Features; |
| 6 | |
| 7 | /** |
| 8 | * Helper function to check if a feature is enabled by name |
| 9 | * |
| 10 | * @param string $name - the feature name |
| 11 | * @return bool indicating if the feature is enabled |
| 12 | */ |
| 13 | function isEnabled( $name ) { |
| 14 | if ( Features::getInstance()->hasFeature( $name ) ) { |
| 15 | return Features::getInstance()->getFeature( $name )->isEnabled(); |
| 16 | } else { |
| 17 | return new WP_Error( |
| 18 | 'nfd_features_error', |
| 19 | __( 'Feature not found', 'wp-module-features' ), |
| 20 | array( 'status' => 404 ) |
| 21 | ); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Helper function to enable a feature by name |
| 27 | * |
| 28 | * @param string $name - the feature name |
| 29 | * @return bool indicating if the feature was enabled |
| 30 | */ |
| 31 | function enable( $name ) { |
| 32 | if ( Features::getInstance()->hasFeature( $name ) ) { |
| 33 | return Features::getInstance()->getFeature( $name )->enable(); |
| 34 | } else { |
| 35 | return new WP_Error( |
| 36 | 'nfd_features_error', |
| 37 | __( 'Feature not found', 'wp-module-features' ), |
| 38 | array( 'status' => 404 ) |
| 39 | ); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Helper function to disable a feature by name |
| 45 | * |
| 46 | * @param string $name - the feature name |
| 47 | * @return bool indicating if the feature was disabled |
| 48 | */ |
| 49 | function disable( $name ) { |
| 50 | if ( Features::getInstance()->hasFeature( $name ) ) { |
| 51 | return Features::getInstance()->getFeature( $name )->disable(); |
| 52 | } else { |
| 53 | return new WP_Error( |
| 54 | 'nfd_features_error', |
| 55 | __( 'Feature not found', 'wp-module-features' ), |
| 56 | array( 'status' => 404 ) |
| 57 | ); |
| 58 | } |
| 59 | } |