| 1 |
<?php |
| 2 |
namespace WPDeveloper\BetterDocs\Editors\Elementor\Conditions; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly |
| 6 |
} |
| 7 |
|
| 8 |
use ElementorPro\Modules\ThemeBuilder\Conditions\Taxonomy; |
| 9 |
use ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base; |
| 10 |
|
| 11 |
class ArchiveCondition extends Condition_Base { |
| 12 |
private $post_type = 'docs'; |
| 13 |
private $post_taxonomies; |
| 14 |
|
| 15 |
public function __construct( array $data = [] ) { |
| 16 |
$taxonomies = get_object_taxonomies( $this->post_type, 'objects' ); |
| 17 |
|
| 18 |
$this->post_taxonomies = wp_filter_object_list( |
| 19 |
$taxonomies, |
| 20 |
[ |
| 21 |
'public' => true, |
| 22 |
'show_in_nav_menus' => true |
| 23 |
] |
| 24 |
); |
| 25 |
|
| 26 |
parent::__construct( $data ); |
| 27 |
} |
| 28 |
|
| 29 |
public static function get_type() { |
| 30 |
return 'archive'; |
| 31 |
} |
| 32 |
|
| 33 |
public function get_name() { |
| 34 |
return 'doc_archive'; |
| 35 |
} |
| 36 |
|
| 37 |
public function get_label() { |
| 38 |
return __( 'Docs Archive', 'betterdocs' ); |
| 39 |
} |
| 40 |
|
| 41 |
public function get_all_label() { |
| 42 |
return __( 'All Docs Archive', 'betterdocs' ); |
| 43 |
} |
| 44 |
|
| 45 |
public function register_sub_conditions() { |
| 46 |
$this->register_sub_condition( new DocsPage() ); |
| 47 |
foreach ( $this->post_taxonomies as $slug => $object ) { |
| 48 |
$condition = new Taxonomy( |
| 49 |
[ |
| 50 |
'object' => $object |
| 51 |
] |
| 52 |
); |
| 53 |
$this->register_sub_condition( $condition ); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
public function check( $args ) { |
| 58 |
return is_post_type_archive( 'docs' ) || is_tax( 'knowledge_base' ) || is_tax( 'doc_category' ) || is_tax( 'doc_tag' ) || is_tax('glossaries'); |
| 59 |
} |
| 60 |
} |
| 61 |
|