| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPDeveloper\BetterDocs\Shortcodes; |
| 4 |
|
| 5 |
use WPDeveloper\BetterDocs\Core\Shortcode; |
| 6 |
|
| 7 |
class FaqList extends Shortcode { |
| 8 |
protected $layout = 'modern'; |
| 9 |
protected $icon_hook = 'betterdocs_faq_post_after'; |
| 10 |
|
| 11 |
public function get_name() { |
| 12 |
return 'betterdocs_faq_list_modern'; |
| 13 |
} |
| 14 |
|
| 15 |
public function get_style_depends() { |
| 16 |
return ['betterdocs-faq']; |
| 17 |
} |
| 18 |
|
| 19 |
public function get_script_depends() { |
| 20 |
return ['betterdocs-faq']; |
| 21 |
} |
| 22 |
|
| 23 |
protected $map_view_vars = [ |
| 24 |
'class' => 'faq_heading_class' |
| 25 |
]; |
| 26 |
|
| 27 |
/** |
| 28 |
* Summary of default_attributes |
| 29 |
* @return array |
| 30 |
*/ |
| 31 |
public function default_attributes() { |
| 32 |
return [ |
| 33 |
'groups' => '', |
| 34 |
'class' => '', |
| 35 |
'group_exclude' => '', |
| 36 |
'faq_heading' => __( 'Frequently Asked Questions', 'betterdocs' ), |
| 37 |
'faq_schema' => false |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
public function icons() { |
| 42 |
$faq_markup = '<svg class="betterdocs-faq-iconminus" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="2"><g fill="none" stroke="#528ffe" stroke-linecap="round" stroke-miterlimit="10" stroke-linejoin="round"><path d="M17 12H7"></path><circle cx="12" cy="12" r="11"></circle></g></svg>'; |
| 43 |
$faq_markup .= '<svg class="betterdocs-faq-iconplus" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g stroke-width="2" fill="none" stroke="#528ffe" stroke-linecap="square" stroke-miterlimit="10"><path d="M12 7v10M17 12H7"></path><circle cx="12" cy="12" r="11"></circle></g></svg>'; |
| 44 |
|
| 45 |
echo $faq_markup; |
| 46 |
} |
| 47 |
|
| 48 |
public function render( $atts, $content = null ) { |
| 49 |
add_action( $this->icon_hook, [$this, 'icons'] ); |
| 50 |
|
| 51 |
$this->views( 'shortcodes/faq' ); |
| 52 |
|
| 53 |
remove_action( $this->icon_hook, [$this, 'icons'] ); |
| 54 |
} |
| 55 |
|
| 56 |
public function view_params() { |
| 57 |
$terms_query = $this->query->faq_terms_query_args( $this->attributes['groups'], $this->attributes['group_exclude'] ); |
| 58 |
|
| 59 |
$wrapper_attr = [ |
| 60 |
'class' => [ |
| 61 |
'betterdocs-faq-wrapper', |
| 62 |
'layout-' . $this->layout, |
| 63 |
$this->attributes['class'], |
| 64 |
] |
| 65 |
]; |
| 66 |
|
| 67 |
return wp_parse_args( [ |
| 68 |
'wrapper_attr' => $wrapper_attr, |
| 69 |
'widget' => $this, |
| 70 |
'layout' => 'list', |
| 71 |
'terms_query_args' => $terms_query |
| 72 |
] ); |
| 73 |
} |
| 74 |
} |
| 75 |
|