Digital Sovereignty for everyone

Blocks, hooks and filters

Blocks

  • lh-html-sitemap/sitemap: dynamic block, one per page. Attribute showTaxonomies (boolean, default false). Logged-out visitors get a render of the public statuses, stored in the object cache (group lh_html_sitemap) under a key built from the attributes, the public statuses, the per-type cap and wp_cache_get_last_changed( 'posts' ) (plus 'terms' when taxonomies are shown), so it refreshes itself when content changes. Logged-in users get a live render on every request, never cached, and the block fires litespeed_control_set_nocache so LiteSpeed does not cache that page.
  • lh-html-sitemap/sitemap-link: dynamic Navigation child block (parent core/navigation, listed through block_core_navigation_listable_blocks). Attribute label (default “Sitemap”). Links to the sitemap page and renders nothing while there is none.

Sitemap page

When a published post containing the Sitemap block is saved (wp_after_insert_post), its ID is stored in the option lh_html_sitemap-page_id; it is removed when that post is saved without the block or unpublished. Every read re-checks that the stored post is still published and still has the block.

Filters

  • lh_html_sitemap_return_public_statuses: statuses listed for logged-out visitors (default publish). A plugin that registers a status visitors can view, such as an archived status, adds it here.
  • lh_html_sitemap_return_logged_in_statuses: statuses queried for logged-in users (default: every non-internal, non-protected status plus the public ones). Posts outside the public statuses must also pass current_user_can( 'read_post' ).
  • lh_html_sitemap_return_post_types: post types listed, applied after core’s wp_sitemaps_post_types.
  • lh_html_sitemap_return_taxonomies: taxonomies listed when enabled, applied after core’s wp_sitemaps_taxonomies.
  • lh_html_sitemap_return_items_per_type_cap: items per post type or taxonomy before an archive link is shown (default 200).
  • lh_html_sitemap_get_excluded_post_ids: post IDs never listed (default: WooCommerce cart, checkout and account pages).
  • lh_html_sitemap_post_type_query_args: the get_posts() arguments per post type; also receives the post type object and whether the render is for a logged-in user.
  • lh_html_sitemap_get_sitemap_page_id: the sitemap page ID used by the link block and menus.
  • lh_html_sitemap_sitemap_block_name, lh_html_sitemap_sitemap_link_block_name: the block names.
  • lh_html_sitemap_init_plugin: return false to stop the plugin loading.

Classic menus

With LH Dynamic Menu Items active, an “HTML Sitemap” item (#lh_html_sitemap-site_map-link#) is offered for classic menus, through lh_dmis_return_menu_array and lh_dmis_switch_item. It points to the sitemap page, and is left unchanged while there is none.

If you like this plugin please consider making a donation to further development

Install LHero.org

lhero.org

Open it straight from your home screen, full screen and quicker to load.

  1. Tap the Share button . If you cannot see it, tap ••• first.
  2. Scroll down and tap Add to Home Screen.
  3. Tap Add.
  1. Tap the browser menu â‹®.
  2. Tap Install app or Add to Home screen.
  1. In the menu bar, choose File, then Add to Dock.

Use your browser's menu to install this site or add it to your home screen.