settings = $settings; } /** * Define ordered editor sections and their accessible navigation labels. * * @return array Ordered section presentation metadata. */ public function sections() { return array( 'general' => array( 'title' => __( 'General', 'login-brush' ), 'icon' => 'admin-settings', ), 'background' => array( 'title' => __( 'Background', 'login-brush' ), 'icon' => 'format-image', ), 'logo' => array( 'title' => __( 'Logo', 'login-brush' ), 'icon' => 'format-gallery', ), 'form' => array( 'title' => __( 'Login Form', 'login-brush' ), 'icon' => 'feedback', ), 'labels' => array( 'title' => __( 'Labels', 'login-brush' ), 'icon' => 'editor-textcolor', ), 'fields' => array( 'title' => __( 'Input Fields', 'login-brush' ), 'icon' => 'editor-table', ), 'button' => array( 'title' => __( 'Button', 'login-brush' ), 'icon' => 'button', ), 'links' => array( 'title' => __( 'Links', 'login-brush' ), 'icon' => 'admin-links', ), 'messages' => array( 'title' => __( 'Messages', 'login-brush' ), 'icon' => 'info-outline', ), 'remember_me' => array( 'title' => __( 'Remember Me', 'login-brush' ), 'icon' => 'yes-alt', ), ); } /** * Render controls for the selected field state. * * @param string $group Schema group. * @param string $state Normal, focus or hover presentation state. */ public function render_group( $group, $state = 'normal' ) { foreach ( Settings_Schema::fields()[ $group ] as $key => $rule ) { $field_state = str_starts_with( $key, 'focus_' ) && in_array( $group, array( 'fields', 'button' ), true ) ? 'focus' : ( str_starts_with( $key, 'hover_' ) && 'button' === $group ? 'hover' : 'normal' ); if ( $field_state !== $state || ( 'button' === $group && 'text' === $key ) ) { continue; } $this->render( $group, $key ); } } /** * Render any schema field using the same reusable template. * * @param string $group Group key. * @param string $key Field key. */ public function render( $group, $key ) { $schema = Settings_Schema::fields(); if ( ! isset( $schema[ $group ][ $key ] ) ) { return; } $rule = $schema[ $group ][ $key ]; $value = $this->settings[ $group ][ $key ]; $id = 'loginstudio-' . $group . '-' . $key; $name = Settings::OPTION . '[' . $group . '][' . $key . ']'; $label = $this->label( $group, $key ); $choices = $this->choices(); if ( 'general' !== $group && in_array( $key, array( 'font_family', 'text_align' ), true ) ) { $choices['inherit'] = __( 'Inherit global typography', 'login-brush' ); } if ( 'logo' === $group && 'link_mode' === $key ) { $choices['core'] = __( 'Automatic (custom logo links home)', 'login-brush' ); } $image = 'image' === $rule['type'] && $value ? wp_get_attachment_image_url( $value, 'thumbnail' ) : ''; include __DIR__ . '/views/control.php'; } /** * Resolve a schema field to its translated control label. * * @param string $group Group. * @param string $key Field. * @return string Translated visible label. */ private function label( $group, $key ) { if ( 'logo' === $group && 'border_radius' === $key ) { return __( 'Logo border radius', 'login-brush' ); } $labels = array( 'enabled' => __( 'Enable login customization', 'login-brush' ), 'font_family' => __( 'Font family', 'login-brush' ), 'text_color' => __( 'Text color', 'login-brush' ), 'color' => __( 'Text color', 'login-brush' ), 'background_color' => __( 'Background color', 'login-brush' ), 'image_id' => __( 'Image', 'login-brush' ), 'position' => __( 'Image position', 'login-brush' ), 'size' => __( 'Image size', 'login-brush' ), 'repeat' => __( 'Image repeat', 'login-brush' ), 'width' => __( 'Width', 'login-brush' ), 'spacing' => __( 'Spacing below logo', 'login-brush' ), 'link_mode' => __( 'Logo link', 'login-brush' ), 'custom_url' => __( 'Custom logo link URL', 'login-brush' ), 'padding' => __( 'Padding', 'login-brush' ), 'border_width' => __( 'Border width', 'login-brush' ), 'border_color' => __( 'Border color', 'login-brush' ), 'border_radius' => __( 'Border radius', 'login-brush' ), 'shadow' => __( 'Box shadow', 'login-brush' ), 'font_size' => __( 'Font size', 'login-brush' ), 'font_weight' => __( 'Font weight', 'login-brush' ), 'height' => __( 'Minimum height', 'login-brush' ), 'focus_border_color' => __( 'Focus border color', 'login-brush' ), 'focus_background_color' => __( 'Focus background color', 'login-brush' ), 'focus_shadow' => __( 'Focus shadow', 'login-brush' ), 'placeholder_color' => __( 'Placeholder color', 'login-brush' ), 'text' => __( 'Button text', 'login-brush' ), 'hover_background_color' => __( 'Hover background color', 'login-brush' ), 'hover_color' => __( 'Hover text color', 'login-brush' ), 'hover_border_color' => __( 'Hover border color', 'login-brush' ), 'accent_color' => __( 'Checkbox accent color', 'login-brush' ), 'line_height' => __( 'Line height', 'login-brush' ), 'letter_spacing' => __( 'Letter spacing', 'login-brush' ), 'text_align' => __( 'Text alignment', 'login-brush' ), 'attachment' => __( 'Background attachment', 'login-brush' ), 'content_alignment' => __( 'Form column alignment', 'login-brush' ), 'vertical_position' => __( 'Form vertical position', 'login-brush' ), 'page_spacing' => __( 'Page top spacing', 'login-brush' ), 'alignment' => __( 'Logo alignment', 'login-brush' ), 'padding_x' => __( 'Horizontal padding', 'login-brush' ), 'padding_y' => __( 'Vertical padding', 'login-brush' ), 'focus_color' => __( 'Focus text color', 'login-brush' ), 'error_color' => __( 'Error text color', 'login-brush' ), 'error_background_color' => __( 'Error background color', 'login-brush' ), 'error_border_color' => __( 'Error border color', 'login-brush' ), 'success_color' => __( 'Success text color', 'login-brush' ), 'success_background_color' => __( 'Success background color', 'login-brush' ), 'success_border_color' => __( 'Success border color', 'login-brush' ), ); if ( 'form' === $group && 'spacing' === $key ) { return __( 'Spacing above form', 'login-brush' ); } if ( 'background' === $group && 'color' === $key ) { return __( 'Background color', 'login-brush' ); } if ( 'links' === $group && 'hover_color' === $key ) { return __( 'Hover link color', 'login-brush' ); } if ( 'image_id' === $key ) { return 'logo' === $group ? __( 'Logo image', 'login-brush' ) : __( 'Background image', 'login-brush' ); } return $labels[ $key ]; } /** * Define human-readable labels for allowed enum values. * * @return array Human-readable enum options; validation remains in the schema. */ private function choices() { return array( 'inherit' => __( 'WordPress default', 'login-brush' ), 'core' => __( 'WordPress default', 'login-brush' ), 'system' => __( 'System font', 'login-brush' ), 'sans' => __( 'Sans serif', 'login-brush' ), 'serif' => __( 'Serif', 'login-brush' ), 'monospace' => __( 'Monospace', 'login-brush' ), 'left-top' => __( 'Top left', 'login-brush' ), 'center-top' => __( 'Top center', 'login-brush' ), 'right-top' => __( 'Top right', 'login-brush' ), 'left-center' => __( 'Center left', 'login-brush' ), 'center-center' => __( 'Center', 'login-brush' ), 'right-center' => __( 'Center right', 'login-brush' ), 'left-bottom' => __( 'Bottom left', 'login-brush' ), 'center-bottom' => __( 'Bottom center', 'login-brush' ), 'right-bottom' => __( 'Bottom right', 'login-brush' ), 'auto' => __( 'Original size', 'login-brush' ), 'cover' => __( 'Cover', 'login-brush' ), 'contain' => __( 'Contain', 'login-brush' ), 'no-repeat' => __( 'No repeat', 'login-brush' ), 'repeat' => __( 'Repeat', 'login-brush' ), 'repeat-x' => __( 'Repeat horizontally', 'login-brush' ), 'repeat-y' => __( 'Repeat vertically', 'login-brush' ), 'home' => __( 'Site homepage', 'login-brush' ), 'custom' => __( 'Custom URL', 'login-brush' ), 'left' => __( 'Left', 'login-brush' ), 'center' => __( 'Center', 'login-brush' ), 'right' => __( 'Right', 'login-brush' ), 'top' => __( 'Top', 'login-brush' ), 'bottom' => __( 'Bottom', 'login-brush' ), 'scroll' => __( 'Scroll with page', 'login-brush' ), 'fixed' => __( 'Fixed', 'login-brush' ), 'none' => __( 'None', 'login-brush' ), 'subtle' => __( 'Subtle', 'login-brush' ), 'medium' => __( 'Medium', 'login-brush' ), 'strong' => __( 'Strong', 'login-brush' ), ); } }