| 1 |
<?php |
| 2 |
|
| 3 |
use ElementorPro\Modules\ThemeBuilder\Documents\Archive; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; // Exit if accessed directly |
| 7 |
} |
| 8 |
|
| 9 |
class Betterdocs_Doc_Archive extends Archive |
| 10 |
{ |
| 11 |
public static function get_properties() |
| 12 |
{ |
| 13 |
$properties = parent::get_properties(); |
| 14 |
|
| 15 |
$properties['location'] = 'archive'; |
| 16 |
$properties['condition_type'] = 'doc_archive'; |
| 17 |
|
| 18 |
return $properties; |
| 19 |
} |
| 20 |
|
| 21 |
public static function get_type() { |
| 22 |
return 'doc-archive'; |
| 23 |
} |
| 24 |
|
| 25 |
public static function get_title() |
| 26 |
{ |
| 27 |
return __('Docs Archive', 'betterdocs'); |
| 28 |
} |
| 29 |
|
| 30 |
public static function get_plural_title() { |
| 31 |
return esc_html__( 'Docs Archives', 'betterdocs' ); |
| 32 |
} |
| 33 |
|
| 34 |
protected static function get_site_editor_icon() { |
| 35 |
return 'eicon-products'; |
| 36 |
} |
| 37 |
|
| 38 |
public static function get_preview_as_default() { |
| 39 |
return 'post_type_archive/docs'; |
| 40 |
} |
| 41 |
|
| 42 |
public static function get_preview_as_options() { |
| 43 |
$post_type_archives = []; |
| 44 |
$taxonomies = []; |
| 45 |
$post_type = 'docs'; |
| 46 |
|
| 47 |
$post_type_object = get_post_type_object( $post_type ); |
| 48 |
|
| 49 |
$post_type_archives[ 'post_type_archive/' . $post_type ] = $post_type_object->label . ' ' . esc_html__( 'Archive', 'elementor-pro' ); |
| 50 |
|
| 51 |
$post_type_taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
| 52 |
|
| 53 |
$post_type_taxonomies = wp_filter_object_list( $post_type_taxonomies, [ |
| 54 |
'public' => true, |
| 55 |
'show_in_nav_menus' => true, |
| 56 |
] ); |
| 57 |
|
| 58 |
foreach ( $post_type_taxonomies as $slug => $object ) { |
| 59 |
$taxonomies[ 'taxonomy/' . $slug ] = $object->label . ' ' . esc_html__( 'Archive', 'elementor-pro' ); |
| 60 |
} |
| 61 |
|
| 62 |
$options = [ |
| 63 |
'search' => esc_html__( 'Search Results', 'elementor-pro' ), |
| 64 |
]; |
| 65 |
|
| 66 |
$options += $taxonomies + $post_type_archives; |
| 67 |
|
| 68 |
return [ |
| 69 |
'archive' => [ |
| 70 |
'label' => esc_html__( 'Archive', 'elementor-pro' ), |
| 71 |
'options' => $options, |
| 72 |
], |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
protected static function get_editor_panel_categories() |
| 77 |
{ |
| 78 |
$categories = [ |
| 79 |
'docs-archive' => [ |
| 80 |
'title' => __('Docs Archive', 'betterdocs'), |
| 81 |
], |
| 82 |
]; |
| 83 |
$categories += parent::get_editor_panel_categories(); |
| 84 |
unset($categories['theme-elements-archive']); |
| 85 |
return $categories; |
| 86 |
} |
| 87 |
|
| 88 |
public static function get_editor_panel_config() |
| 89 |
{ |
| 90 |
$config = parent::get_editor_panel_config(); |
| 91 |
$config['widgets_settings']['theme-archive-title']['categories'][] = 'docs-archive'; |
| 92 |
return $config; |
| 93 |
} |
| 94 |
|
| 95 |
protected function register_controls() { |
| 96 |
parent::register_controls(); |
| 97 |
|
| 98 |
$this->update_control( |
| 99 |
'preview_type', |
| 100 |
[ |
| 101 |
'default' => 'post_type_archive/docs', |
| 102 |
] |
| 103 |
); |
| 104 |
} |
| 105 |
|
| 106 |
protected function get_remote_library_config() |
| 107 |
{ |
| 108 |
$config = parent::get_remote_library_config(); |
| 109 |
|
| 110 |
$config['category'] = 'Docs Archive'; |
| 111 |
|
| 112 |
return $config; |
| 113 |
} |
| 114 |
} |
| 115 |
|