| 开发者 | mansoormunib |
|---|---|
| 更新时间 | 2026年6月9日 11:39 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
final classes under includes/, every superglobal sanitised, every echoed value escaped, every DB call prepared.[alphabetical_pagination] shortcode, alphabetical_pagination() template tag, and a native Gutenberg block (wp-snap-ext/index).woocommerce_before_shop_loop action. No DOM hacks, no posts_where SQL filter injection.GET /wp-json/wp-snap-ext/v1/letters and /posts for headless / React / app integrations.do_action/apply_filters at every render path so agencies can customise without forking.save_post. Configurable TTL.get_fields() walk.<nav aria-label>, aria-current="page", aria-disabled on empty letters, explicit role="list" / role="listitem" (Safari + VoiceOver list-stripping fix), descriptive per-letter aria-label, visible focus outlines.wp-snap-ext/index block (no JS build pipeline required). Renders identically to the shortcode + template tag.woocommerce_before_shop_loop (default), woocommerce_archive_description, or woocommerce_before_main_content./wp-json/wp-snap-ext/v1/letters returns [{ letter, count, href }]; /wp-json/wp-snap-ext/v1/posts returns paginated post payloads.do_action( 'wp_snap_ext/before_render', $context )apply_filters( 'wp_snap_ext/pre_render', $html, $post_type, $display, $args ) — short-circuitapply_filters( 'wp_snap_ext/query_args', $args, $context )apply_filters( 'wp_snap_ext/letter_href', $href, $letter, $base )apply_filters( 'wp_snap_ext/excerpt', $excerpt, $post_id )apply_filters( 'wp_snap_ext/render', $html, $post_type, $display, $args )do_action( 'wp_snap_ext/after_render', $html, $context )save_post, deleted_post, trashed_post, untrashed_post, and switch_blog. Default TTL 1 hour, configurable.wpml_current_language or pll_current_language(); WP_Query runs with suppress_filters => false so translated post sets get filtered.aria-disabled), Hide Pagination If One Page.{ post_id => items_per_page } so /glossary can render 50 items per page while /products renders 20.wp_snap() template tag is preserved as a thin alias.?snap=, ?cp=, and ?snap_paged= continue to be honoured alongside the canonical ?alpha_order= and ?alpha_paged=.key_snap_* option keys are migrated to wp_snap_ext_* automatically on activation.wp-snap-extended directory to /wp-content/plugins/.wp_snap() from my theme?Yes. wp_snap() is kept as a thin alias for alphabetical_pagination() with the same parameter list, so existing themes continue to work unchanged.
Use the native Alphabetical Pagination block (added in 2.3.0) from the block inserter under the Widgets category — it's fully server-rendered and supports wide / full alignment. The block sidebar exposes post type, menu style, firstload, category, taxonomy + term, and display attributes. The legacy approach (Shortcode block with [alphabetical_pagination]) still works.
Yes. Enable Settings → Alphabetical Pagination → WooCommerce → Auto-mount on Shop and the index renders above the WooCommerce shop loop and product category archives automatically. The mount uses native WooCommerce action hooks (woocommerce_before_shop_loop, woocommerce_archive_description, or woocommerce_before_main_content — pick from the dropdown) so it never collides with caching / SEO / multilingual plugins that filter WP_Query.
Yes. The transient letter-availability cache keys on the current language (via wpml_current_language filter or pll_current_language() function), and WP_Query runs with suppress_filters => false, so translated post sets are filtered and cached per-language automatically. Switching language busts the cache for that language only.
Yes. Two read-only public endpoints under /wp-json/wp-snap-ext/v1/: GET /letters returns [{ letter, count, href }], GET /posts returns paginated post payloads filtered by letter. Toggle on / off under Settings → Alphabetical Pagination → REST API & Cache.
Go to Settings → Alphabetical Pagination → Content Fallback, enable ACF Excerpt Fallback, and enter the ACF Field Name (e.g. summary). The plugin tries get_field() first, then get_sub_field(), then walks the entire get_fields() tree recursively to find the field even when it lives inside an ACF flexible-content layout, repeater row, or group. Falls back to a trimmed extract of the post content if ACF returns nothing.
Enable Settings → Alphabetical Pagination → DOM Injection → Enable DOM Injection and provide a CSS selector (e.g. .entry-content, #primary > article:first-child). The plugin renders the index into a hidden <template> element in the footer and a ~300-byte vanilla-JS snippet moves it into the matched element on DOMContentLoaded. No jQuery, no dependencies.
Under Settings → Alphabetical Pagination → Sorting, set Meta Key to your post meta key and Meta Order to ASC or DESC. The letter buckets still derive from post_title, but the order of posts within each bucket follows the meta value. Useful for sorting glossary terms by importance, products by SKU, etc.
Yes. Pick the script from Settings → Alphabetical Pagination → Language → Alphabet Pack. 15 packs are bundled: English, Arabic, Chinese (Pinyin A–Z), German (with Umlauts), Spanish (with Ñ), French, Greek, Hebrew, Hindi (Devanagari), Hungarian, Korean (Hangul Jamo), Russian (Cyrillic), Thai, Turkish, Urdu. Selecting a pack overwrites the freeform Local Alphabet field on save. You can also type a fully custom alphabet directly.
Yes. Letter availability is stored as a transient keyed by post_type / taxonomy / term / current language / alphabet pack / menumisc setting. Default TTL is 1 hour (configurable under REST API & Cache → Cache TTL). The cache is invalidated automatically on save_post, deleted_post, trashed_post, untrashed_post, and switch_blog — so editing a post immediately reflects in the index.
Yes — every render path fires hooks (added in 2.3.0):
wp_snap_ext/before_render, wp_snap_ext/after_render — actions.wp_snap_ext/pre_render — short-circuit filter (return a string to replace the HTML).wp_snap_ext/query_args — mutate WP_Query args before the query runs.wp_snap_ext/letter_href — rewrite letter link hrefs (useful for SPA routers).wp_snap_ext/excerpt — post-process the resolved excerpt.wp_snap_ext/render — final filter on the rendered HTML.?alpha_paged= instead of ?paged=?So they don't collide with WordPress's own paged query variable on category, tag, or archive templates. You can paginate the alphabetical list independently of the surrounding archive.
Yes — the markup targets WCAG 2.1 AA. The letter navigation is wrapped in a semantic <nav aria-label="Alphabetical Navigation">, the active letter carries aria-current="page", empty letters carry aria-disabled="true", every link has a descriptive aria-label, and the stylesheet provides visible :focus-visible outlines. Explicit role="list" / role="listitem" are emitted because Safari + VoiceOver strip the implicit list role when list-style:none is applied.
nav-tab UI: General, Styling, Integrations, and Developer. After saving, you are returned to the tab you were editing (Post/Redirect/Get), not the first one.snap-style-default.css skin (styled letter strip, post cards, pagination buttons) that mirrors the plugin's preview.snap-style.css so the output inherits your theme's typography, colours, and button styles. This remains the default, so existing sites are unchanged on update.<pre><code> snippets for the [alphabetical_pagination] shortcode, the alphabetical_pagination() template tag (with a function_exists() guard and the wp_snap() alias note), and the wp_snap_ext/* action/filter hooks.wp-snap-ext/index block. Drop the alphabetical index into any post, page, or Site Editor template with one click. No JS build pipeline required; block.json + render.php only.woocommerce_before_shop_loop (or woocommerce_archive_description / woocommerce_before_main_content) action. No DOM hacks, no posts_where SQL injection./wp-json/wp-snap-ext/v1/:GET /letters?post_type=…&taxonomy=…&term=… → [ { letter, count, href } ]GET /posts?post_type=…&letter=A&page=1&per_page=10 → { posts, total, total_pages }do_action( 'wp_snap_ext/before_render', $context )apply_filters( 'wp_snap_ext/pre_render', $html, $post_type, $display, $args ) (short-circuit)apply_filters( 'wp_snap_ext/query_args', $args, $context )apply_filters( 'wp_snap_ext/letter_href', $href, $letter, $base )apply_filters( 'wp_snap_ext/excerpt', $excerpt, $post_id )apply_filters( 'wp_snap_ext/render', $html, $post_type, $display, $args )do_action( 'wp_snap_ext/after_render', $html, $context )save_post, deleted_post, trashed_post, untrashed_post, switch_blog. Default TTL 1 hour (configurable).wpml_current_language or pll_current_language()) and WP_Query runs with suppress_filters => false, so translated post sets are filtered and cached per-language.aria-disabled), "Hide pagination if one page".{ post_id => items_per_page } array so /glossary can render 50 items per page while /products renders 20.<template> in the footer and move it into a CSS selector via ~300 bytes of vanilla JS. No jQuery dependency.<nav aria-label>, aria-current="page", explicit role="list" / role="listitem", descriptive aria-label per letter link, aria-disabled on empty letters, visible focus outlines.?alpha_order= and ?alpha_paged= (legacy ?snap= / ?cp= / ?snap_paged= still honoured).<nav aria-label="Alphabetical Navigation">, every letter link carries a descriptive aria-label, the active letter is exposed via aria-current="page", and visible focus outlines are provided in the stylesheet.aria-label that includes the post title.get_field() for posts without a native excerpt.alphabetical_pagination() (the legacy wp_snap() is kept as a backwards-compatible alias).[alphabetical_pagination] shortcode lets the index be embedded in any post or page. Attributes mirror the template tag arguments (cat, child, menu, firstload, post_parent, post_type, display).register_setting, add_settings_section, add_settings_field) and sanitised with absint(). Defaults to 10 if unset.paginate_links() below the alphabetised post list.includes/.$_GET / $_POST / $_SERVER reads, escaped output, nonce + manage_options capability check on the settings page (was the deprecated numeric level "8").wp_snap_ext_* option prefix. Legacy key_snap_* values are migrated automatically on activation.wp_enqueue_scripts and only enqueued on pages that actually call wp_snap().WP_Query instead of a hand-rolled SQL string.wp_snap() template tag retained.