%s', esc_url( admin_url( 'options-general.php?page=ablewidget-accessibility-toolbar' ) ), esc_html__( 'Settings', 'ablewidget-accessibility-toolbar' ) ); array_unshift( $links, $settings_link ); return $links; } // Register settings. add_action( 'admin_init', 'ablewidget_register_settings' ); function ablewidget_register_settings() { register_setting( 'ablewidget_group', ABLEWIDGET_OPTION, array( 'type' => 'array', 'default' => ablewidget_default_settings(), 'show_in_rest' => false, 'sanitize_callback' => 'ablewidget_sanitize_settings', ) ); } function ablewidget_sanitize_settings( $input ) { $defaults = ablewidget_default_settings(); // Anything other than an array (e.g. a tampered request) falls back to defaults. if ( ! is_array( $input ) ) { return $defaults; } $clean = array(); $clean['enabled'] = ! empty( $input['enabled'] ) ? 1 : 0; $allowed_positions = array( 'bottom-right', 'bottom-left' ); $position = ( isset( $input['position'] ) && is_string( $input['position'] ) ) ? $input['position'] : ''; $clean['position'] = in_array( $position, $allowed_positions, true ) ? $position : $defaults['position']; $color = ( isset( $input['color'] ) && is_string( $input['color'] ) ) ? $input['color'] : ''; $clean['color'] = preg_match( '/^#[0-9A-Fa-f]{6}$/', $color ) ? $color : $defaults['color']; $clean['branding'] = ! empty( $input['branding'] ) ? 1 : 0; return $clean; } // Settings page HTML. function ablewidget_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $settings = ablewidget_get_settings(); ?>
true, 'strategy' => 'async', ) ); } // Add the data-* attributes widget.js reads from its own