Press This (發佈至網站)

外掛說明

[發佈至網站] 書籤小工具能夠輕鬆擷取網頁內容並建立新文章,它還提供選擇頁面上圖片或影片的功能,以便在文章中使用。使用 [發佈至網站] 書籤小工具,就能夠以快速簡便的方式摘錄網路上其他頁面的內容。

2.0 版開始支援區塊編輯器

Press This 2.0 為書籤小工具彈出式訊息導入了新式 WordPress 區塊編輯器體驗,使用者現在可以使用 [段落]、[標題]、[圖片]、[引文]、[清單] 及 [嵌入內容] 等熟習的區塊撰寫文章。

全新功能:

  • 區塊編輯器:完整的區塊編輯器整合,提供一致的 WordPress 編輯體驗
  • 智慧型文章格式建議:依據內容自動建議視訊、引文或連結等文章格式
  • 經過強化的內容擷取:使用支援 JSON-LD 結構資料的加強式擷取
  • 僅用戶端擷取:全部內容擷取僅會在使用者瀏覽器中進行,以便獲得更好的隱私權及安全性
  • 支援精選圖片:可將擷取內容中的任何圖片設定為文章的精選圖片
  • 改進的媒體格狀排列:對嵌入內容中支援的視訊及音訊提供更好的縮圖顯示

開發者需要了解的篩選器

Press This 2.0 用於自訂的全新篩選器:

  • press_this_allowed_blocks:自訂編輯器中可用的區塊
  • press_this_post_format_suggestion:修改自動建議的文章格式

參閱下方的〈開發者說明文件〉以進一步了解。

為外掛貢獻心力

如需提報程式碼錯誤及提取要求,請前往這個外掛的 GitHub 存放庫

開發者說明文件

2.0 版中的全新勾點及篩選器

press_this_allowed_blocks

在 Press This 編輯器中自訂可用哪些區塊。

add_filter( 'press_this_allowed_blocks', function( $blocks ) {
    // Add the gallery block
    $blocks[] = 'core/gallery';

    // Remove the embed block
    $blocks = array_filter( $blocks, function( $block ) {
        return $block !== 'core/embed';
    } );

    return $blocks;
} );

預設區塊:core/paragraphcore/headingcore/imagecore/quotecore/listcore/list-itemcore/embed

press_this_post_format_suggestion

修改或覆寫依據內容自動建議的文章格式。

add_filter( 'press_this_post_format_suggestion', function( $suggested_format, $data ) {
    // If the URL contains 'podcast', suggest audio format
    if ( ! empty( $data['u'] ) && strpos( $data['u'], 'podcast' ) !== false ) {
        return 'audio';
    }

    return $suggested_format;
}, 10, 2 );

$data 陣列所擷取的內容包含下列項目:
u:來源網址
s:選取的文字
t:頁面標題
_images:圖片網址陣列
_embeds:嵌入內容網址陣列
_meta:中繼資料標籤資料
_jsonld:JSON-LD 結構化資料

保留自之前 1.x 版中的勾點

現有可繼續使用的全部勾點:

  • press_this_redirect_in_parent:控制文章儲存重新導向行為
  • press_this_save_post:儲存前篩選文章資料
  • press_this_save_redirect:儲存後篩選重新導向網址
  • enable_press_this_media_discovery:開啟/關閉媒體擷取
  • press_this_data:篩選完整擷取的資料陣列
  • press_this_suggested_html:篩選預設內容範本
  • shortcut_link:自訂書籤小工具網址

外掛開發源由

WordPress 從相當早期的版本開始,就提供了擷取其他網站內容片段供網站作者發佈新文章的方式。

在 WordPress 2.5 版移除舊版的 [發佈至網誌] 功能後,隨即在 WordPress 2.6 版加入新版的 [發佈至網誌] 功能。一直到 WordPress 4.2 版這個重大更新前,這個功能幾乎沒有任何改進。

從 WordPress 4.9 版起,[發佈至網站] 成為一個正規外掛,即 WordPress.org 的官方外掛。所有的網站都可以安裝及使用這個外掛,同時也簡化了 WordPress 核心之外的重要功能,就如同之前完成的各個匯入程式一樣。

Press This 2.0 已改用新式的區塊編輯器,以便與 WordPress 新式編輯體驗保持一致,同時與外掛過去產生的項目保持回溯相容性。

螢幕擷圖

安裝方式

  1. 在管理後台前往 [外掛]→[安裝外掛] 以安裝外掛。
  2. 前往管理後台的 [工具] 頁面以了解其他安裝步驟。

常見問題集

Press This 是否相容於已有的書籤小工具?

是。由 1.x 版產生的書籤小工具可以繼續執行,但是我們建議更新網站上已有的書籤小工具,以獲得 2.0 版更新所帶來的加強功能。使用舊版書籤小工具會出現更新提示。

Press This 可以使用哪些區塊?

Press This 預設包含 [段落]、[標題]、[圖片]、[引文]、[清單] 及 [嵌入內容] 區塊。開發者可以使用 press_this_allowed_blocks 篩選器加以自訂。

是否可以使用 WordPress 完整的編輯器功能?

絕對可以。在 [發佈] 下拉式選單中點擊 [標準編輯器] 選項並儲存成草稿,便能在 WordPress 區塊編輯器中繼續編輯。

使用者評論

2022 年 7 月 22 日
J’adore cette fonctionnalité de WP, pourquoi s’en passer si on partage des liens sur son site!?!?
2021 年 10 月 29 日
If you don’t have the scriptlet bookmarked already this plugin is WORTHLESS because there is literally NO PLACE to get the code for the bookmark ANYWHERE.
閱讀全部 25 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Press This (發佈至網站)〉的開發相關工作。

參與者

〈Press This (發佈至網站)〉外掛目前已有 24 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將〈Press This (發佈至網站)〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

2.0.2

  • New: Undo/redo support in the block editor (Ctrl+Z / Ctrl+Shift+Z)
  • New: Block transform keyboard shortcuts (e.g. heading, list, quote)
  • New: Rich text format keyboard shortcuts via format-library (bold, italic, link, etc.)
  • New: Bookmarklet now preserves HTML formatting in text selections
  • Fix: Critical error when saving posts with external images in REST context
  • Fix: Scraped media inserting at bottom of post instead of cursor position
  • Fix: Quote block unwrap losing nested inner blocks
  • Fix: Category panel styles not loading and stale search filter results
  • Fix: Stale state in category toggle handler
  • Change: Removed auto-suggestion of link post format
  • Change: Restored category search filter using Gutenberg components

2.0.1

  • New: Gutenberg block editor replaces TinyMCE for modern editing experience
  • New: Smart post format auto-suggestion based on content type
  • New: press_this_allowed_blocks filter for customizing available blocks
  • New: press_this_post_format_suggestion filter for customizing format suggestions
  • New: JSON-LD structured data extraction for better content discovery
  • New: Open Graph video metadata extraction for improved embed detection
  • New: Featured image selection from scraped images
  • New: Alternate canonical URL detection via hreflang
  • Improved: Client-side only content extraction (removed server-side scraping)
  • Improved: Media grid with video/audio type indicators
  • Improved: Bookmarklet version detection with upgrade prompts
  • Improved: Title extraction now checks JSON-LD headline
  • Improved: Description extraction now checks JSON-LD description
  • Compatibility: All 1.x hooks and filters preserved
  • Compatibility: Legacy bookmarklet URL format continues to work
  • Requires: WordPress 6.9 or higher
  • Requires: PHP 7.4 or higher

1.1.2

  • Fixes the styling of the .press-this .modal-close class (props https://github.com/crishnakh)
  • Bumps the Tested up to version to 6.7.1

1.1.1

  • Corrects an issue with the packaging of the plugin for SVN.

1.1.0

  • Restores the bookmarklet functionality previously found in WordPress 4.8 and prior verions.

1.0

  • Initial release as a plugin. Previously part of WordPress itself.