'boolean', 'description' => __('Enable or disable the scroll to top button', 'axvart'), 'single' => true, 'show_in_rest' => true, 'default' => false, )); register_meta('', 'axvart_hover_effects', array( 'type' => 'boolean', 'description' => __('Enable or disable hover effects for interactive elements', 'axvart'), 'single' => true, 'show_in_rest' => true, 'default' => true, )); } add_action('init', 'axvart_register_theme_settings'); /** * Add theme settings to the site REST API response */ function axvart_register_site_settings() { register_rest_field( 'site', 'axvart_scroll_top', array( 'get_callback' => function() { return (bool) get_option('axvart_scroll_top', false); }, 'update_callback' => function($value) { // Explicitly convert to boolean $bool_value = (bool) $value; // Always update the option, even if false // Use update_option which will add if doesn't exist update_option('axvart_scroll_top', $bool_value ? 1 : 0); return true; }, 'schema' => array( 'type' => 'boolean', 'description' => __('Enable or disable the scroll to top button', 'axvart'), ), ) ); register_rest_field( 'site', 'axvart_hover_effects', array( 'get_callback' => function() { return (bool) get_option('axvart_hover_effects', true); }, 'update_callback' => function($value) { // Explicitly convert to boolean $bool_value = (bool) $value; // Always update the option, even if false update_option('axvart_hover_effects', $bool_value ? 1 : 0); return true; }, 'schema' => array( 'type' => 'boolean', 'description' => __('Enable or disable hover effects for interactive elements', 'axvart'), ), ) ); } add_action('rest_api_init', 'axvart_register_site_settings');