Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ThemeColorsController | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| register_routes | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
2 | |||
| get_theme_colors | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace NewfoldLabs\WP\Module\Onboarding\RestApi\Themes; |
| 4 | |
| 5 | use NewfoldLabs\WP\Module\Onboarding\Permissions; |
| 6 | use NewfoldLabs\WP\Module\Onboarding\Data\Themes\Colors; |
| 7 | |
| 8 | /** |
| 9 | * Class ThemeColorsController |
| 10 | */ |
| 11 | class ThemeColorsController extends \WP_REST_Controller { |
| 12 | |
| 13 | |
| 14 | /** |
| 15 | * The namespace of this controller's route. |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | protected $namespace = 'newfold-onboarding/v1'; |
| 20 | |
| 21 | /** |
| 22 | * The base of this controller's route. |
| 23 | * |
| 24 | * @var string |
| 25 | */ |
| 26 | protected $rest_base = '/themes'; |
| 27 | |
| 28 | |
| 29 | /** |
| 30 | * The extended base of this controller's route. |
| 31 | * |
| 32 | * @var string |
| 33 | */ |
| 34 | protected $rest_extended_base = '/colors'; |
| 35 | |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * Registers routes for ThemeColorsController |
| 40 | */ |
| 41 | public function register_routes() { |
| 42 | \register_rest_route( |
| 43 | $this->namespace, |
| 44 | $this->rest_base . $this->rest_extended_base, |
| 45 | array( |
| 46 | array( |
| 47 | 'methods' => \WP_REST_Server::READABLE, |
| 48 | 'callback' => array( $this, 'get_theme_colors' ), |
| 49 | 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), |
| 50 | ), |
| 51 | ) |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Retrieves the active theme color variations. |
| 57 | * |
| 58 | * @return array|\WP_Error |
| 59 | */ |
| 60 | public function get_theme_colors() { |
| 61 | $theme_color_palettes = Colors::get_colors_from_theme(); |
| 62 | return $theme_color_palettes; |
| 63 | } |
| 64 | } |