name = esc_html__( 'Accordion FAQ', 'accordion-faq-plugin' ); } /** * Configurable fields. * * @return array */ public function get_fields() { $categories = array( '' => esc_html__( 'All categories', 'accordion-faq-plugin' ) ); $terms = get_terms( array( 'taxonomy' => \AccordionFaq\Setup\Taxonomy::TAXONOMY, 'hide_empty' => false ) ); if ( ! is_wp_error( $terms ) ) { foreach ( $terms as $term ) { $categories[ $term->slug ] = $term->name; } } $yesno = array( 'off' => esc_html__( 'No', 'accordion-faq-plugin' ), 'on' => esc_html__( 'Yes', 'accordion-faq-plugin' ), ); return array( 'faq_category' => array( 'label' => esc_html__( 'Category', 'accordion-faq-plugin' ), 'type' => 'select', 'options' => $categories, 'default' => '', ), 'faq_style' => array( 'label' => esc_html__( 'Style', 'accordion-faq-plugin' ), 'type' => 'select', 'options' => array( '' => esc_html__( 'Default (from settings)', 'accordion-faq-plugin' ), 'modern' => esc_html__( 'Modern', 'accordion-faq-plugin' ), 'card' => esc_html__( 'Card', 'accordion-faq-plugin' ), 'bordered' => esc_html__( 'Bordered', 'accordion-faq-plugin' ), 'filled' => esc_html__( 'Filled', 'accordion-faq-plugin' ), 'separated' => esc_html__( 'Separated', 'accordion-faq-plugin' ), 'minimal' => esc_html__( 'Minimal', 'accordion-faq-plugin' ), ), 'default' => '', ), 'faq_search' => array( 'label' => esc_html__( 'Show search', 'accordion-faq-plugin' ), 'type' => 'yes_no_button', 'options' => $yesno, 'default' => 'off' ), 'faq_filter' => array( 'label' => esc_html__( 'Show category filter', 'accordion-faq-plugin' ), 'type' => 'yes_no_button', 'options' => $yesno, 'default' => 'off' ), 'faq_expand_all' => array( 'label' => esc_html__( 'Show expand / collapse all', 'accordion-faq-plugin' ), 'type' => 'yes_no_button', 'options' => $yesno, 'default' => 'off' ), 'faq_toc' => array( 'label' => esc_html__( 'Show table of contents', 'accordion-faq-plugin' ), 'type' => 'yes_no_button', 'options' => $yesno, 'default' => 'off' ), ); } /** * Render the module. * * @param array $attrs Attributes. * @param string $content Inner content. * @param string $render_slug Render slug. * @return string */ public function render( $attrs, $content, $render_slug ) { $args = array( 'category' => isset( $this->props['faq_category'] ) ? (string) $this->props['faq_category'] : '', 'style' => isset( $this->props['faq_style'] ) ? (string) $this->props['faq_style'] : '', 'search' => isset( $this->props['faq_search'] ) && 'on' === $this->props['faq_search'], 'filter' => isset( $this->props['faq_filter'] ) && 'on' === $this->props['faq_filter'], 'expand_all' => isset( $this->props['faq_expand_all'] ) && 'on' === $this->props['faq_expand_all'], 'toc' => isset( $this->props['faq_toc'] ) && 'on' === $this->props['faq_toc'], ); return accordion_faq()->renderer()->render( $args ); } }