| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') or die; |
| 4 |
|
| 5 |
add_action('rest_api_init', function () { |
| 6 |
CBPRouter::post('/settings', function ($payload) { |
| 7 |
if (isset($payload['code_block_pro_settings'])) { |
| 8 |
update_option('code_block_pro_settings', $payload['code_block_pro_settings']); |
| 9 |
} |
| 10 |
if (isset($payload['code_block_pro_settings_2'])) { |
| 11 |
update_option('code_block_pro_settings_2', $payload['code_block_pro_settings_2']); |
| 12 |
} |
| 13 |
return new WP_REST_Response( |
| 14 |
[ |
| 15 |
'code_block_pro_settings' => get_option('code_block_pro_settings'), |
| 16 |
'code_block_pro_settings_2' => get_option('code_block_pro_settings_2'), |
| 17 |
] |
| 18 |
); |
| 19 |
}); |
| 20 |
|
| 21 |
CBPRouter::get('/settings', function () { |
| 22 |
return new WP_REST_Response( |
| 23 |
[ |
| 24 |
'code_block_pro_settings' => get_option('code_block_pro_settings'), |
| 25 |
'code_block_pro_settings_2' => get_option('code_block_pro_settings_2'), |
| 26 |
] |
| 27 |
); |
| 28 |
}); |
| 29 |
|
| 30 |
CBPRouter::get('/can-save-html', function () { |
| 31 |
return new WP_REST_Response(current_user_can('unfiltered_html')); |
| 32 |
}); |
| 33 |
}); |
| 34 |
|