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