| @@ -1,14 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace WPDeveloper\BetterDocs\Shortcodes; |
| 3 | 4 | |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | - exit; | |
| 6 | -} | |
| 7 | - | |
| 8 | - | |
| 9 | 5 | use WPDeveloper\BetterDocs\Core\Shortcode; |
| 10 | -use WPDeveloper\BetterDocs\Utils\Helper; | |
| 11 | 6 | |
| 12 | 7 | class FaqList extends Shortcode { |
| 13 | 8 | protected $layout = 'modern'; |
| 14 | 9 | protected $icon_hook = 'betterdocs_faq_post_after'; |
| @@ -40,10 +35,8 @@ | ||
| 40 | 35 | 'groups' => '', |
| 41 | 36 | 'class' => '', |
| 42 | 37 | 'group_exclude' => '', |
| 43 | 38 | 'faq_heading' => __( 'Frequently Asked Questions', 'betterdocs' ), |
| 44 | - 'faq_section_title_tag' => 'h2', | |
| 45 | - 'faq_group_title_tag' => 'h3', | |
| 46 | 39 | 'faq_schema' => false, |
| 47 | 40 | 'faq_layout' => 'layout-1', |
| 48 | 41 | 'faq_section_title_color' => null, |
| 49 | 42 | 'include_faq_group' => '', |
| @@ -57,24 +50,12 @@ | ||
| 57 | 50 | 'faq_per_page' => 9, |
| 58 | 51 | 'show_button_icon' => true, |
| 59 | 52 | 'button_icon_position' => 'after', |
| 60 | 53 | 'button_color' => '#528ffe', |
| 61 | - 'is_gutenberg' => false, | |
| 62 | - 'faq_taxonomy' => 'betterdocs_faq_category', | |
| 63 | - // Per-placement order override. Empty = use the global FAQ Builder | |
| 64 | - // order (`betterdocs_faq_order` option). One of: default, | |
| 65 | - // most_recent, least_recent, a_to_z, z_to_a, most_questions. | |
| 66 | - 'order' => '' | |
| 54 | + 'is_gutenberg' => false | |
| 67 | 55 | ]; |
| 68 | 56 | } |
| 69 | 57 | |
| 70 | - /** | |
| 71 | - * Allowed per-placement order keys, mirroring the FAQ Builder header dropdown. | |
| 72 | - * | |
| 73 | - * @var string[] | |
| 74 | - */ | |
| 75 | - protected $allowed_order_keys = [ 'default', 'most_recent', 'least_recent', 'a_to_z', 'z_to_a', 'most_questions' ]; | |
| 76 | - | |
| 77 | 58 | public function icons( $faq_toggle ) { |
| 78 | 59 | $faq_markup = '<svg class="betterdocs-faq-iconminus" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"' .($faq_toggle ? " style='display:inline;'" : ""). 'stroke-width="2"><g fill="none" stroke="' . esc_attr( $this->attributes['button_color'] ) . '" stroke-linecap="round" stroke-miterlimit="10" stroke-linejoin="round"><path d="M17 12H7"></path><circle cx="12" cy="12" r="11"></circle></g></svg>'; |
| 79 | 60 | $faq_markup .= '<svg class="betterdocs-faq-iconplus" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"'.($faq_toggle ? " style='display:none;'" : "").'><g stroke-width="2" fill="none" stroke="' . esc_attr( $this->attributes['button_color'] ) . '" stroke-linecap="square" stroke-miterlimit="10"><path d="M12 7v10M17 12H7"></path><circle cx="12" cy="12" r="11"></circle></g></svg>'; |
| 80 | 61 | |
| @@ -92,32 +73,15 @@ | ||
| 92 | 73 | } else { |
| 93 | 74 | add_action( $this->icon_hook, [ $this, 'icons' ] ); |
| 94 | 75 | } |
| 95 | 76 | |
| 96 | - // When this placement sets a valid `order`, scope it to this render only | |
| 97 | - // (via the existing `betterdocs_faq_order_key` filter) so it overrides | |
| 98 | - // the global FAQ Builder order without affecting other placements. | |
| 99 | - $order_override = is_string( $this->attributes['order'] ) ? trim( $this->attributes['order'] ) : ''; | |
| 100 | - $order_filter = null; | |
| 101 | - if ( $order_override && in_array( $order_override, $this->allowed_order_keys, true ) ) { | |
| 102 | - $order_filter = function () use ( $order_override ) { | |
| 103 | - return $order_override; | |
| 104 | - }; | |
| 105 | - add_filter( 'betterdocs_faq_order_key', $order_filter, 20 ); | |
| 106 | - } | |
| 107 | - | |
| 108 | 77 | $this->views( 'shortcodes/faq' ); |
| 109 | 78 | |
| 110 | - if ( $order_filter ) { | |
| 111 | - remove_filter( 'betterdocs_faq_order_key', $order_filter, 20 ); | |
| 112 | - } | |
| 113 | - | |
| 114 | 79 | remove_action( $this->icon_hook, [ $this, 'icons' ] ); |
| 115 | 80 | } |
| 116 | 81 | |
| 117 | 82 | public function view_params() { |
| 118 | - $taxonomy = sanitize_key( $this->attributes['faq_taxonomy'] ); | |
| 119 | - $terms_query = $this->query->faq_terms_query_args( $this->attributes['groups'], $this->attributes['group_exclude'], [], $taxonomy ); | |
| 83 | + $terms_query = $this->query->faq_terms_query_args( $this->attributes['groups'], $this->attributes['group_exclude'] ); | |
| 120 | 84 | |
| 121 | 85 | $wrapper_attr = [ |
| 122 | 86 | 'class' => [ |
| 123 | 87 | 'betterdocs-faq-wrapper', |
| @@ -131,10 +95,9 @@ | ||
| 131 | 95 | [ |
| 132 | 96 | 'wrapper_attr' => $wrapper_attr, |
| 133 | 97 | 'widget' => $this, |
| 134 | 98 | 'layout' => 'list', |
| 135 | - 'terms_query_args' => $terms_query, | |
| 136 | - 'faq_schema' => $this->attributes['faq_schema'] && ! Helper::seo_plugin_outputs_faq_schema() | |
| 99 | + 'terms_query_args' => $terms_query | |
| 137 | 100 | ] |
| 138 | 101 | ); |
| 139 | 102 | } |
| 140 | 103 | } |