// Print template library tabs. add_filter( 'views_edit-' . self::CPT, [ $this, 'admin_print_tabs' ] ); // Show blank state. add_action( 'manage_posts_extra_tablenav', [ $this, 'maybe_render_blank_state' ] ); } add_action( 'template_redirect', [ $this, 'block_template_frontend' ] ); // Remove elementor library templates from WP Sitemap add_filter( 'wp_sitemaps_post_types', function( $post_types ) { return $this->remove_elementor_cpt_from_sitemap( $post_types ); } ); } /** * @since 2.0.6 * @access public */ public function admin_columns_content( $column_name, $post_id ) { if ( 'elementor_library_type' === $column_name ) { /** @var Document $document */ $document = Plugin::$instance->documents->get( $post_id ); if ( $document && $document instanceof Library_Document ) { $document->print_admin_column_type(); } } } /** * @since 2.0.6 * @access public */ public function admin_columns_headers( $posts_columns ) { // Replace original column that bind to the taxonomy - with another column. unset( $posts_columns['taxonomy-elementor_library_type'] ); $offset = 2; $posts_columns = array_slice( $posts_columns, 0, $offset, true ) + [ 'elementor_library_type' => esc_html__( 'Type', 'elementor' ), ] + array_slice( $posts_columns, $offset, null, true ); return $posts_columns; } public function get_current_tab_group( $default = '' ) { $current_tabs_group = $default; if ( ! empty( $_REQUEST[ self::TAXONOMY_TYPE_SLUG ] ) ) { $doc_type = Plugin::$instance->documents->get_document_type( $_REQUEST[ self::TAXONOMY_TYPE_SLUG ], '' ); if ( $doc_type ) { $current_tabs_group = $doc_type::get_property( 'admin_tab_group' ); } } elseif ( ! empty( $_REQUEST['tabs_group'] ) ) { $current_tabs_group = $_REQUEST['tabs_group']; } return $current_tabs_group; } private function get_library_title() { $title = ''; if ( $this->is_current_screen() ) { $current_tab_group = $this->get_current_tab_group(); if ( $current_tab_group ) { $titles = [ 'library' => esc_html__( 'Saved Templates', 'elementor' ), 'theme' => esc_html__( 'Theme Builder', 'elementor' ), 'popup' => esc_html__( 'Popups', 'elementor' ), ]; if ( ! empty( $titles[ $current_tab_group ] ) ) { $title = $titles[ $current_tab_group ]; } } } return $title; } private function is_current_screen() { global $pagenow, $typenow; return 'edit.php' === $pagenow && self::CPT === $typenow; } /** * @param array $post_types * * @return array */ private function remove_elementor_cpt_from_sitemap( array $post_types ) { unset( $post_types[ self::CPT ] ); return $post_types; } /** * Template library local source constructor. * * Initializing the template library local source base by registering custom * template data and running custom actions. * * @since 1.0.0 * @access public */ public function __construct() { parent::__construct(); $this->add_actions(); } }