| 1 |
<?php |
| 2 |
|
| 3 |
namespace BBlocks\Inc; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class RegisterSettings |
| 10 |
{ |
| 11 |
function __construct() |
| 12 |
{ |
| 13 |
add_action( 'admin_init', [$this, 'registerSettings'] ); |
| 14 |
add_action( 'rest_api_init', [$this, 'registerSettings'] ); |
| 15 |
} |
| 16 |
|
| 17 |
function registerSettings() |
| 18 |
{ |
| 19 |
register_setting('bBlocksUtils', 'bBlocksUtils', [ |
| 20 |
'show_in_rest' => [ |
| 21 |
'name' => 'bBlocksUtils', |
| 22 |
'schema' => ['type' => 'string'] |
| 23 |
], |
| 24 |
'type' => 'string', |
| 25 |
'default' => wp_json_encode(['nonce' => wp_create_nonce('wp_ajax')]), |
| 26 |
'sanitize_callback' => 'sanitize_text_field' |
| 27 |
]); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
new RegisterSettings(); |
| 32 |
|