
內容簡介
URL Shortener by Melk 是一款輕量且高效的 WordPress 外掛,能自動為您的文章、頁面、分類、標籤及自訂文章類型生成短網址,特別適合用於社交媒體分享及行銷材料。
【主要功能】
• 自動生成短網址,發佈新文章時即時創建
• 支援文章、頁面、分類、標籤及自訂文章類型
• 控制台直接複製短網址的按鈕
• 一鍵批量生成舊內容的短網址
• 快速重定向,僅在 404 錯誤時處理
• 安全的程式碼,遵循 WordPress 最佳實踐
外掛標籤
開發者團隊
原文外掛簡介
URL Shortener by Melk is a lightweight and efficient WordPress plugin that allows you to automatically generate short URLs for your posts, pages, categories, tags, and Custom Post Types. Ideal for sharing on social media and marketing materials.
Features:
Automatic Generation: Automatically creates short URLs when publishing new posts.
Comprehensive Support: Works with Posts, Pages, Categories, Tags, and Custom Post Types.
Quick Copy: “Copy” button directly in the post/term listing in the admin panel.
Bulk Generation: Tool to generate short URLs for old content with one click.
Performance: Fast redirection resolved only on would-be 404s (no heavy queries), so your pages and posts are never affected.
Secure: Validated and secure code, following WordPress best practices.
Developer Notes
Namespace: Melk\\UrlShortenerByMelk.
Unique prefix: all functions, options, meta keys and hooks use the urlshbym_ prefix, following the WordPress Plugin Handbook recommendations to avoid naming collisions.
Options stored in the database:
urlshbym_enabled_post_types
urlshbym_enabled_taxonomies
Meta keys:
_urlshbym_short_code on posts
_urlshbym_short_code on terms (taxonomies)
Database table: {$wpdb->prefix}urlshbym_short_urls is created on activation to store the mapping between short codes and objects.
Main hook:
urlshbym_short_url_clicked — fired whenever a short URL is accessed, receiving the short code and the internal record ID.
Integration helper: urlshbym_get_short_url_for_post( $post_id ) — a global function other plugins (such as Social Kit by Melk) can call via function_exists() to reuse the short URL, with no hard dependency in either direction.
Resolution: on template_redirect (priority 1), only when the main query is a 404, a root-level path of 5-7 alphanumeric characters is looked up in the table and redirected with a 301. No rewrite rules are registered.
Options also stored: urlshbym_delete_data_on_uninstall, urlshbym_db_version.
