'array', 'sanitize_callback' => array( Sanitizer::class, 'settings' ), 'default' => Options::defaults(), ) ); } /** * Settings link on the plugins list. * * @param array $links Links. * @return array */ public function action_links( $links ) { $url = admin_url( 'admin.php?page=' . Menu::SLUG . '-settings' ); $link = '' . esc_html__( 'Settings', 'accordion-faq-plugin' ) . ''; array_unshift( $links, $link ); return $links; } /** * Render the settings page. * * @return void */ public function render() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to access this page.', 'accordion-faq-plugin' ) ); } $o = Options::all(); $n = Options::OPTION_KEY; AdminUi::header( __( 'Configure global defaults for every FAQ.', 'accordion-faq-plugin' ) ); ?>

seg( "{$n}[default_mode]", __( 'Mode', 'accordion-faq-plugin' ), $o['default_mode'], array( 'accordion' => __( 'Accordion', 'accordion-faq-plugin' ), 'toggle' => __( 'Toggle', 'accordion-faq-plugin' ), ) ); $this->select( "{$n}[default_style]", __( 'Style', 'accordion-faq-plugin' ), $o['default_style'], array( 'modern' => __( 'Modern', 'accordion-faq-plugin' ), 'card' => __( 'Card', 'accordion-faq-plugin' ), 'bordered' => __( 'Bordered', 'accordion-faq-plugin' ), 'filled' => __( 'Filled', 'accordion-faq-plugin' ), 'separated' => __( 'Separated', 'accordion-faq-plugin' ), 'minimal' => __( 'Minimal', 'accordion-faq-plugin' ), ) ); $this->seg( "{$n}[engine]", __( 'Engine', 'accordion-faq-plugin' ), $o['engine'], array( 'aria' => __( 'ARIA (animated)', 'accordion-faq-plugin' ), 'details' => __( 'Native (0 JS)', 'accordion-faq-plugin' ), ) ); $this->select( "{$n}[heading_level]", __( 'Heading level', 'accordion-faq-plugin' ), $o['heading_level'], array( 'h2' => 'H2', 'h3' => 'H3', 'h4' => 'H4', 'h5' => 'H5', 'h6' => 'H6', ) ); $this->seg( "{$n}[icon_position]", __( 'Icon position', 'accordion-faq-plugin' ), $o['icon_position'], array( 'right' => __( 'Right', 'accordion-faq-plugin' ), 'left' => __( 'Left', 'accordion-faq-plugin' ), ) ); $this->color( "{$n}[accent_color]", __( 'Accent color', 'accordion-faq-plugin' ), $o['accent_color'] ); ?>

switch_field( "{$n}[default_open_first]", __( 'Open the first FAQ by default', 'accordion-faq-plugin' ), $o['default_open_first'] ); $this->switch_field( "{$n}[show_search]", __( 'Show a search box', 'accordion-faq-plugin' ), $o['show_search'] ); $this->switch_field( "{$n}[show_filter]", __( 'Show category filter tabs', 'accordion-faq-plugin' ), $o['show_filter'] ); $this->switch_field( "{$n}[show_expand_all]", __( 'Show expand / collapse all', 'accordion-faq-plugin' ), $o['show_expand_all'] ); $this->switch_field( "{$n}[show_toc]", __( 'Show a sticky table-of-contents sidebar', 'accordion-faq-plugin' ), $o['show_toc'] ); $this->number( "{$n}[per_page]", __( 'FAQs per page (0 = show all)', 'accordion-faq-plugin' ), (int) $o['per_page'], __( 'Paginate long FAQ lists. A “Load more” button appears when there are more.', 'accordion-faq-plugin' ) ); ?>

switch_field( "{$n}[enable_views]", __( 'Track FAQ views', 'accordion-faq-plugin' ), $o['enable_views'] ); $this->switch_field( "{$n}[enable_voting]", __( 'Show “Was this helpful?” voting', 'accordion-faq-plugin' ), $o['enable_voting'] ); $this->switch_field( "{$n}[enable_submissions]", __( 'Allow visitors to submit questions', 'accordion-faq-plugin' ), $o['enable_submissions'] ); $this->term_select( "{$n}[submissions_cat]", __( 'Category for submitted questions', 'accordion-faq-plugin' ), (int) $o['submissions_cat'] ); $this->switch_field( "{$n}[notify_submissions]", __( 'Email me when a question is submitted', 'accordion-faq-plugin' ), $o['notify_submissions'] ); $this->switch_field( "{$n}[enable_search_analytics]", __( 'Record what visitors search for', 'accordion-faq-plugin' ), $o['enable_search_analytics'] ); $this->switch_field( "{$n}[enable_ai]", __( 'Enable AI FAQ generation', 'accordion-faq-plugin' ), $o['enable_ai'] ); ?>

switch_field( "{$n}[enable_schema]", __( 'Output FAQ schema (JSON-LD) for rich results', 'accordion-faq-plugin' ), $o['enable_schema'] ); $this->switch_field( "{$n}[public_faq_pages]", __( 'Enable public single/archive FAQ pages', 'accordion-faq-plugin' ), $o['public_faq_pages'] ); $this->switch_field( "{$n}[delete_data]", __( 'Delete all data when uninstalling', 'accordion-faq-plugin' ), $o['delete_data'] ); ?>

'; echo ''; } /** * Term select. * * @param string $name Name. * @param string $label Label. * @param int $current Current term id. * @return void */ private function term_select( $name, $label, $current ) { $terms = get_terms( array( 'taxonomy' => Taxonomy::TAXONOMY, 'hide_empty' => false ) ); echo '
'; echo '
'; } /** * Segmented control (radios). * * @param string $name Name. * @param string $label Label. * @param string $current Current value. * @param array $choices Choices. * @return void */ private function seg( $name, $label, $current, array $choices ) { echo '
' . esc_html( $label ) . ''; echo ''; foreach ( $choices as $value => $text ) { echo ''; } echo '
'; } /** * Toggle switch (checkbox). * * @param string $name Name. * @param string $label Label. * @param bool $current Current value. * @return void */ private function switch_field( $name, $label, $current ) { echo '
'; } /** * Number field. * * @param string $name Name. * @param string $label Label. * @param int $current Current value. * @param string $help Help text. * @return void */ private function number( $name, $label, $current, $help = '' ) { echo '
'; echo ''; if ( '' !== $help ) { echo '' . esc_html( $help ) . ''; } echo '
'; } /** * Color field. * * @param string $name Name. * @param string $label Label. * @param string $current Current value. * @return void */ private function color( $name, $label, $current ) { echo '
'; echo ''; echo '' . esc_html__( 'Hex color. Leave blank to inherit the theme.', 'accordion-faq-plugin' ) . '
'; } }