'array', 'sanitize_callback' => array( $this, 'sanitize_options' ), 'default' => accessibar_get_defaults(), ) ); } /** * Enqueues admin CSS and JS on the plugin settings page only. * * @param string $hook Current admin page hook suffix. * @return void */ public function enqueue_assets( $hook ) { if ( 'settings_page_accessibar' !== $hook ) { return; } wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style( 'accessibar-admin', ACCESSIBAR_PLUGIN_URL . 'assets/css/accessibar-admin.css', array(), ACCESSIBAR_VERSION ); wp_enqueue_script( 'accessibar-admin', ACCESSIBAR_PLUGIN_URL . 'assets/js/accessibar-admin.js', array( 'wp-color-picker' ), ACCESSIBAR_VERSION, true ); } /** * Sanitizes all option values before saving. * * @param mixed $input Raw form input. * @return array Sanitized options. */ public function sanitize_options( $input ) { if ( ! is_array( $input ) ) { return accessibar_get_defaults(); } $defaults = accessibar_get_defaults(); $positions = array( 'bottom-right', 'bottom-left', 'top-right', 'top-left' ); $sizes = array( 'small', 'medium', 'large' ); $clean = array(); $pos = isset( $input['position'] ) ? $input['position'] : ''; $clean['position'] = in_array( $pos, $positions, true ) ? $pos : $defaults['position']; $color = isset( $input['color'] ) ? $input['color'] : ''; $clean['color'] = sanitize_hex_color( $color ) ? sanitize_hex_color( $color ) : $defaults['color']; $size = isset( $input['size'] ) ? $input['size'] : ''; $clean['size'] = in_array( $size, $sizes, true ) ? $size : $defaults['size']; $clean['button_text'] = sanitize_text_field( isset( $input['button_text'] ) ? $input['button_text'] : '' ); $clean['hide_mobile'] = ! empty( $input['hide_mobile'] ); $clean['tools'] = array(); foreach ( array_keys( $defaults['tools'] ) as $tool ) { $clean['tools'][ $tool ] = ! empty( $input['tools'][ $tool ] ); } return $clean; } /** * Renders the settings page HTML. * * @return void */ public function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $options = accessibar_get_options(); $tool_labels = array( 'font_size' => __( 'Font Size Controls', 'accessibar' ), 'high_contrast' => __( 'High Contrast Mode', 'accessibar' ), 'highlight_links' => __( 'Highlight Links', 'accessibar' ), 'readable_font' => __( 'Readable Font (OpenDyslexic)', 'accessibar' ), 'stop_animations' => __( 'Stop Animations', 'accessibar' ), 'big_cursor' => __( 'Large Cursor', 'accessibar' ), ); ?>