Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| WP_Config | |
0.00% |
0 / 4 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| add_constant | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| update_constant | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| constant_exists | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\Onboarding; |
| 3 | |
| 4 | /** |
| 5 | * Access and Modify WordPress Configuration (wp-config.php). |
| 6 | */ |
| 7 | class WP_Config { |
| 8 | |
| 9 | /** |
| 10 | * WordPress Configuration |
| 11 | * |
| 12 | * @var \WPConfigTransformer |
| 13 | */ |
| 14 | protected $wp_config; |
| 15 | |
| 16 | /** |
| 17 | * WP_Config constructor. |
| 18 | */ |
| 19 | public function __construct() { |
| 20 | $this->wp_config = new \WPConfigTransformer( ABSPATH . 'wp-config.php' ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Adds a new constant to WordPress Configuration. |
| 25 | * |
| 26 | * @param mixed $name Name of the constant |
| 27 | * @param mixed $value Value of the constant |
| 28 | * |
| 29 | * @return boolean |
| 30 | */ |
| 31 | public function add_constant( $name, $value ) { |
| 32 | return $this->wp_config->add( 'constant', $name, $value, array( 'raw' => true ) ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Updates an existing constant in WordPress Configuration. |
| 37 | * |
| 38 | * @param mixed $name Name of the constant |
| 39 | * @param mixed $value Value of the constant |
| 40 | * |
| 41 | * @return boolean |
| 42 | */ |
| 43 | public function update_constant( $name, $value ) { |
| 44 | return $this->wp_config->update( 'constant', $name, $value, array( 'raw' => true ) ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Checks if the constant already exists in the WordPress Configuration. |
| 49 | * |
| 50 | * @param mixed $name Name of the constant. |
| 51 | * |
| 52 | * @return boolean |
| 53 | */ |
| 54 | public function constant_exists( $name ) { |
| 55 | return $this->wp_config->exists( 'constant', $name ); |
| 56 | } |
| 57 | } |