Sorry. It looks like you have not yet setup AirfieldHub!
Please go to the admin section and enter your AirfieldHub key.
';
return ($airfieldhub == "") ? $output_error : $output;
}
/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
register_block_type( __DIR__ . '/public/ppr/build', array(
'render_callback' => 'airfieldhub_display_ppr'
) );
//END OF BLOCK
//START OF BOOKOUT BLOCK
function airfieldhub_display_bookout( $attr ) {
$airfieldhub = get_option('airfieldhub_key');
$output = '
Sorry. It looks like you have not yet setup AirfieldHub!
Please go to the admin section and enter your AirfieldHub key.
';
return ($airfieldhub == "") ? $output_error : $output;
}
/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
register_block_type( __DIR__ . '/public/bookout/build', array(
'render_callback' => 'airfieldhub_display_bookout'
) );
//END OF BLOCK
//RESTFUL API TO OBTAIN THE SECRET KEY ENTERED IN THE ADMIN SECTION
add_action( 'rest_api_init', 'airfieldhub_settings_api_init', 10, 1 );
function airfieldhub_settings_api_init() {
register_rest_route( 'airfieldhub/v1', '/settings', array(
'methods' => 'GET',
'permission_callback' => '__return_true', // *always set a permission callback
'callback' => function ( $request ) {
return array(
'secret' => "random_assortment", 'airfieldhub_key' => get_option('airfieldhub_key')
);
},
) );
}
//START OF THE ADMIN SECTION
/**
* custom option and settings FOR AIRFIELD HUB
*/
function airfieldhub_settings_init() {
// Register a new setting for "wporg" page.
register_setting( 'airfieldhub_settings', 'airfieldhub_options' );
register_setting( 'airfieldhub_settings', 'airfieldhub_key' );
// Register a new section in the "wporg" page.
add_settings_section(
'airfieldhub_section_developers',
__( 'Welcome to the AirfieldHub settings for WordPress!', 'airfieldhub_settings' ), 'airfieldhub_section_developers_callback',
'airfieldhub_settings'
);
// Register a new field in the "wporg_section_developers" section, inside the "wporg" page.
add_settings_field(
'airfieldhub_field_pill', // As of WP 4.6 this value is used only internally. // Use $args' label_for to populate the id inside the callback.
__( 'AirfieldHub Key', 'airfieldhub' ),
// 'airfieldhub_field_pill_cb',
'airfieldhub_settings_field_callback',
'airfieldhub_settings',
'airfieldhub_section_developers',
array(
'label_for' => 'airfieldhub_field_pill',
'class' => 'airfieldhub_row',
'airfieldhub_custom_data' => 'custom',
)
);
}
/**
* Register our wporg_settings_init to the admin_init action hook.
*/
add_action( 'admin_init', 'airfieldhub_settings_init' );
/**
* Custom option and settings:
* - callback functions
*/
/**
* Developers section callback function.
*
* @param array $args The settings array, defining title, id, callback.
*/
function airfieldhub_section_developers_callback( $args ) {
?>
.
* - the "class" key value is used for the "class" attribute of the
containing the field.
* Note: you can add custom key value pairs to be used inside your callbacks.
*
* @param array $args
*/
function airfieldhub_field_pill_cb( $args ) {
// Get the value of the setting we've registered with register_setting()
$options = get_option( 'airfieldhub_options' );
?>