print_blank_state_template(
esc_html__( 'Links Page', 'elementor' ),
$this->get_add_new_links_page_url(),
esc_html__( 'Build Effective Landing Pages for your business\' marketing campaigns.', 'elementor' )
);
if ( ! empty( $trashed_posts ) ) : ?>
',
''
);
?>
base ) {
return $this->is_elementor_links_page( get_post() );
}
return false;
}
private function admin_localize_settings( $settings ) {
$additional_settings = [
'urls' => [
'addNewLinkUrl' => $this->get_add_new_links_page_url(),
],
'linksPages' => [
'hasPages' => $this->has_links_pages(),
'isAdminEdit' => $this->is_links_page_admin_edit(),
],
];
return array_replace_recursive( $settings, $additional_settings );
}
private function register_links_pages_cpt() {
$labels = [
'name' => esc_html__( 'Links Pages', 'elementor' ),
'singular_name' => esc_html__( 'Links Page', 'elementor' ),
'add_new' => esc_html__( 'Add New', 'elementor' ),
'add_new_item' => esc_html__( 'Add New Links Page', 'elementor' ),
'edit_item' => esc_html__( 'Edit Links Page', 'elementor' ),
'new_item' => esc_html__( 'New Links Page', 'elementor' ),
'all_items' => esc_html__( 'All Links Pages', 'elementor' ),
'view_item' => esc_html__( 'View Links Page', 'elementor' ),
'search_items' => esc_html__( 'Search Links Pages', 'elementor' ),
'not_found' => esc_html__( 'No Links Pages found', 'elementor' ),
'not_found_in_trash' => esc_html__( 'No Links Pages found in trash', 'elementor' ),
'parent_item_colon' => '',
'menu_name' => esc_html__( 'Links Pages', 'elementor' ),
];
$args = [
'labels' => $labels,
'public' => true,
'show_in_menu' => 'edit.php?post_type=elementor_library&tabs_group=library',
'capability_type' => 'page',
'taxonomies' => [ Source_Local::TAXONOMY_TYPE_SLUG ],
'supports' => [
'title',
'editor',
'comments',
'revisions',
'trackbacks',
'author',
'excerpt',
'page-attributes',
'thumbnail',
'custom-fields',
'post-formats',
'elementor',
],
];
register_post_type( self::CPT_LINKS_PAGES, $args );
}
private function has_links_pages(): bool {
if ( null !== $this->has_links_pages ) {
return $this->has_links_pages;
}
$posts_query = new \WP_Query( [
'no_found_rows' => true,
'post_type' => self::CPT_LINKS_PAGES,
'post_status' => 'any',
'posts_per_page' => 1,
'meta_key' => '_elementor_template_type',
'meta_value' => self::DOCUMENT_TYPE,
] );
$this->has_links_pages = $posts_query->post_count > 0;
return $this->has_links_pages;
}
public function is_elementor_links_page( \WP_Post $post ): bool {
return self::CPT_LINKS_PAGES === $post->post_type;
}
private function get_menu_args(): array {
if ( $this->has_links_pages() ) {
$menu_slug = self::ADMIN_PAGE_SLUG_LIB;
$function = null;
} else {
$menu_slug = self::CPT_LINKS_PAGES;
$function = [ $this, 'print_empty_links_pages_page' ];
}
return [
'menu_slug' => $menu_slug,
'function' => $function,
];
}
}