[WordPress] 外掛分享: Micropub

WordPress 外掛 Micropub 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Micropub」是 2015-02-12 上架。
  • 目前有 300 個安裝啟用數。
  • 上一次更新是 2024-06-13,距離現在已有 325 天。
  • 外掛最低要求 WordPress 4.9.9 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 4 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

snarfed | dshanske | indieweb |

外掛標籤

publish | indieweb | micropub | microformats |

內容簡介

Micropub 是一個開放的 API 標準,可用於使用第三方客戶端在您的網站上創建文章。Web 應用程序和本機應用程序(例如 iPhone、Android)可以使用 Micropub 向您自己的網站發布短訊、照片、事件或其他文章,就像 Twitter 客戶端發布推文一樣。需要 IndieAuth 插件進行身份驗證。

安裝並啟用插件後,可以嘗試使用 Quill 等客戶端在您的網站上創建新文章。該客戶端將引導您完成步驟,並在您遇到任何問題時提供幫助。已知的 Micropub 客戶端列表可在此處找到。

根據完整的 Micropub 規範支援。

由於它允許在不進入 WordPress 管理員的情況下創建文章,因此本插件本身並不涉及任何對 Gutenberg 的兼容性問題。由於這些發帖不是使用 Gutenberg 創建的,因此它們不包含 Gutenberg 區塊,但目前在其他方面應該沒有問題。

在 WordPress 插件目錄中提供,可在此處找到。

許可證:此項目已放置在公共領域中。您還可以在 CC0 許可下使用它。

WordPress 詳細信息:

增加了十個過濾器:

before_micropub($ input)
在處理 Micropub 請求之前調用。返回 $ input,可能已修改。

micropub_post_content($ post_content,$ input)
在處理 Micropub 請求期間調用。默認情況下,將內容生成函數附加到此過濾器。返回 $ post_content,可能已修改。

micropub_post_type($ post_type ='post',$ input)
在創建 Micropub 帖子期間調用。此默認為帖子,但允許將 Micropub 帖子設置為自定義帖子類型。

micropub_tax_input($ tax_input,$ input)
在創建 Micropub 帖子期間調用。此默認為無,但允許 Micropub 發布設置自定義分類法。

micropub_syndicate-to($ synd_urls,$ user_id,$ input)
調用以生成要在查詢的響應中返回的 syndicate-to 目標列表。返回 $ synd_urls,數組,可能已修改。此過濾器默認情況下為空。

micropub_query($ resp,$ input)
允許您使用自己的定制版本替換查詢響應以添加其他信息。

micropub_suggest_title($ mf2)
允許生成建議的標題。這可以用於生成帖子標題或用於想要將其用於設置 WordPress 標題的個人。

indieauth_scopes($ scopes)
從實現 IndieAuth 的插件返回範圍。此過濾器默認情況下為空。

indieauth_response($ response)
從實現 IndieAuth 的插件返回令牌驗證響應。此過濾器默認情況下為空。

pre_insert_micropub_post($ args)
在其插入之前一次篩選發送到 wp_insert_post 的引數。如果設置了 ID 鍵,則這將短路插入以允許自定義數據庫編程。

兩個鉤子:

after_micropub($ input,$ wp_args = null)
在處理 Micropub 請求之後調用。

原文外掛簡介

Micropub is an open API standard that is used to create posts on your site using third-party clients. Web apps and native apps (e.g. iPhone, Android) can use Micropub to post short notes, photos, events or other posts to your own site, similar to a Twitter client posting to Twitter.com. Requires the IndieAuth plugin for authentication.
Once you’ve installed and activated the plugin, try a client such as Quill to create a new post on your site. It walks you through the steps and helps you troubleshoot if you run into any problems. A list of known Micropub clients are available here
Supports the full Micropub spec
As this allows the creation of posts without entering the WordPress admin, it is not subject to any Gutenberg compatibility concerns per se. Posts created will not have Gutenberg blocks as they were not created with Gutenberg, but otherwise there should be no issues at this time.
Available in the WordPress plugin directory at wordpress.org/plugins/micropub.
License
This project is placed in the public domain. You may also use it under the CC0 license.
WordPress details
Filters and hooks
Adds ten filters:
before_micropub( $input )

Called before handling a Micropub request. Returns $input, possibly modified.
micropub_post_content( $post_content, $input )

Called during the handling of a Micropub request. The content generation function is attached to this filter by default. Returns $post_content, possibly modified.
micropub_post_type( $post_type = 'post', $input )

Called during the creation of a Micropub post. This defaults to post, but allows for setting Micropub posts to a custom post type.
micropub_tax_input( $tax_input, $input )

Called during the creation of a Micropub post. This defaults to nothing but allows for a Micropub post to set a custom taxonomy.
micropub_syndicate-to( $synd_urls, $user_id, $input )

Called to generate the list of syndicate-to targets to return in response to a query. Returns $synd_urls, an array, possibly modified. This filter is empty by default
micropub_query( $resp, $input )

Allows you to replace a query response with your own customized version to add additional information
micropub_suggest_title( $mf2 )

Allows a suggested title to be generated. This can be used either to generate the post slug or for individuals who want to use it to set a WordPress title
indieauth_scopes( $scopes )

This returns scopes from a plugin implementing IndieAuth. This filter is empty by default.
indieauth_response( $response )

This returns the token auth response from a plugin implementing IndieAuth. This filter is empty by default.
pre_insert_micropub_post( $args )

This filters the arguments sent to wp_insert_post just prior to its insertion. If the ID key is set, then this will short-circuit the insertion to allow for custom database coding.
…and two hooks:
after_micropub( $input, $wp_args = null)

Called after handling a Micropub request. Not called if the request fails (ie doesn’t return HTTP 2xx).
micropub_syndication( $ID, $syndicate_to )

Called only if there are syndication targets $syndicate_to for post $ID. $syndicate_to will be an array of UIDs that are verified as one or more of the UIDs added using the micropub_syndicate-to filter.
Arguments:

$input: associative array, the Micropub request in JSON format. If the request was form-encoded or a multipart file upload, it’s converted to JSON format.
$wp_args: optional associative array. For creates and updates, this is the arguments passed to wp_insert_post or wp_update_post. For deletes and undeletes, args['ID'] contains the post id to be (un)deleted. Null for queries.

Other
Stores microformats2 properties in post metadata with keys prefixed by mf2_. Details here. All values are arrays; use unserialize() to deserialize them.
Does not support multithreading. PHP doesn’t really either, so it generally won’t matter, but just for the record.
Supports Stable Extensions to Micropub:

Post Status – Either published or draft
Visibility – Either public or private.
Query for Category/Tag List – Supports querying for categories and tags.
Slug – Custom slug.
Query for Post List – Supports query for the last x number of posts.

Supports Proposed Extensions to Micropub:

Limit Parameter for Query – Supports adding limit to any query designed to return a list of options to limit it to that number.
Offset Parameter for Query – Supports adding offset to any query. Must be used with limit.
Filter Parameter for Query – Supported for the Category/Tag List query.
Location Visiblity – Either public, private, or protected
Query for Supported Queries – Returns a list of query parameters the endpoint supports
Query for Supported Properties – Returns a list of which supported experimental properties the endpoint supports so the client can choose to hide unsupported ones.
Discovery of Media Endpoint using Link Rel – Adds a link header for the media endpoint
Supports extended GEO URIs – Supports adding arbitrary parameters to the GEO URI. Micropub converts this into an mf2 object. Supported as built into the Indigenous client.
Supports deleting uploaded media – Supports action=delete&url=url on the media endpoint to delete files.
Supports querying for media on the media endpoint and optional URL parameter for same
Supports filtering media queries by mime-type
Return Visibility in q=config

Deprecated Extensions still Supported:

Last Media Uploaded – Supports querying for the last image uploaded …set to within the last hour. This was superseded by supporting q=source&limit=1 on the media endpoint.

Extensions Supported by Other Plugins:

Query for Location – Suported by Simple Location if installed.

If an experimental property is not set to one of the noted options, the plugin will return HTTP 400 with body:
{
"error": "invalid_request",
}

WordPress has a whitelist of file extensions that it allows in uploads. If you upload a file in a Micropub extension that doesn’t have an allowed extension, the plugin will return HTTP 400 with body:
{
"error": "invalid_request",
"error_description": "Sorry, this file is not permitted for security reasons."
}

Authentication and authorization

For reasons of security it is recommended that you only use this plugin on sites that implement HTTPS. Authentication is not built into this plugin.
In order to use this, the IndieAuth plugin is required. Other plugins may be written in future as alternatives and will be noted if they exist.
Configuration Options
These configuration options can be enabled by adding them to your wp-config.php

define('MICROPUB_NAMESPACE', 'micropub/1.0' ) – By default the namespace for micropub is micropub/1.0. This would allow you to change this for your endpoint
define('MICROPUB_DISABLE_NAG', 1 ) – Disable notices for insecure sites
define('MICROPUB_DRAFT_MODE', 1 ) – Override default post status and set to draft for debugging purposes.

Development
The canonical repo is http://github.com/indieweb/wordpress-micropub . Feedback and pull requests are welcome!
To add a new release to the WordPress plugin directory, tag it with the version number and push the tag. It will automatically deploy.
To set up your local environment to run the unit tests and set up PHPCodesniffer to test adherence to WordPress Coding Standards and PHP Compatibility:

Install Composer. Composer is only used for development and is not required to run the plugin.
Run composer install which will install PHP Codesniffer, PHPUnit, the standards required, and all dependencies.

To configure PHPUnit

Install and start MySQL. (You may already have it.)
Run ./bin/install-wp-tests.sh wordpress_micropub_test root '' localhost to download WordPress and its unit test library, into your systems tmp directory by default, and create a MySQL db to test against. Background here. Feel free to use a MySQL user other than root. You can set the WP_CORE_DIR and WP_TESTS_DIR environment variables to change where WordPress and its test library are installed. For example, I put them both in the repo dir.
Open wordpress-tests-lib/wp-tests-config.php and add a slash to the end of the ABSPATH value. No clue why it leaves off the slash; it doesn’t work without it.

Run phpunit in the repo root dir. If you set WP_CORE_DIR and WP_TESTS_DIR above, you’ll need to set them for this too. You should see output like this:
Installing…

1 / 1 (100%)
Time: 703 ms, Memory: 33.75Mb
OK (1 test, 3 assertions)

To set up PHPCodesniffer to test adherence to WordPress Coding Standards and PHP 5.6 Compatibility:

To list coding standard issues in a file, run composer phpcs
If you want to try to automatically fix issues, run `composer phpcbf“.

To automatically convert the readme.txt file to readme.md, you may, if you have installed composer as noted in the previous section, enter composer update-readme to have the .txt file converted
into markdown and saved to readme.md.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Micropub」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.3 | 1.4 | 1.4.1 | 1.4.3 | 2.0.0 | 2.0.1 | 2.0.2 | 2.0.3 | 2.0.4 | 2.0.5 | 2.0.6 | 2.0.7 | 2.0.8 | 2.0.9 | 2.1.0 | 2.2.0 | 2.2.1 | 2.2.2 | 2.2.3 | 2.2.4 | 2.2.5 | 2.3.0 | 2.3.1 | 2.3.2 | 2.3.3 | 2.4.0 | trunk | 2.0.10 | 2.0.11 |

延伸相關外掛(你可能也想知道)

  • Rich Contact Widget 》這個聯絡小工具附帶有微資料和微格式的標記,以便搜尋引擎可以在他們的搜尋結果中使用它。它可以幫助在搜尋結果中顯示您的業務或個人聯絡資訊,甚至包含您的...。
  • Semantic-Linkbacks 》此外掛能夠從像Webmention或傳統的Trackback或Pingback等回想鏈接產生更豐富的WordPress評論。, 這個限制顯示的回想和鏈接被取代成簡潔的完整句子,例如“Bob...。
  • Microformats 2 》這僅是一個非常基本的實現,因為並非每個元素都可以透過動作或過濾器存取。最好使用完全支持Microformats 2的佈景主題。。
  • MF2 Feeds 》提供每個 WordPress URL 的 Microformats2 JSON「Feed」,並協助允許其他網站即使該主題不支援 Microformats2,也能夠取得預解析的Microformats-JSON。, Micr...。
  • image_src 》社交媒體網站通常使用 image_src 微格式來顯示鏈接縮略圖。此簡單的外掛會將 image_src rel 值添加到您網站的代碼中。默認情況下,這個外掛僅應用於單個視圖...。
  • Ticketsolve Shows 》Ticketsolve 是一個網上票務系統,用於出售活動門票。此外掛會解析該系統上任何帳戶的公共XML餵,並顯示一個簡單的即將舉行的活動列表,您可以在您的WordPres...。
  • Wikidata References for WordPress 》Wikidata References 是一個 WordPress 外掛,可以新增一個欄位到標籤和分類中,以將 Wikidata 條目 ID 與這些標籤和分類結合。, 此外,此外掛也提供網站管理...。
  • LouderVoice Reviews 》這個外掛讓 LouderVoice 的客戶可以快速且容易地在 WordPress 網站上顯示客戶評論。。
  • Geo Mark 》Geo Mark 是一個 WordPress 外掛,利用 Yahoo Placemaker 和 YQL API 展示 WordPress 文章內容的地理資訊。, 當地理位置被找到後,外掛會將此訊息作為自訂欄...。
  • Extended Profile 》此外掛擴展了 WordPress 基本配置文件,包含額外的屬性如照片、組織、地址、電話號碼等等。個, 用戶的完整配置文件可以透過使用簡碼或使用提供的小工具在任何...。
  • WP-Oomph 》這個外掛可以在 WordPress 生成的頁面上加上 Oomph Microformats toolkit 的微格式疊加層(當然,頁面中必須有微格式)。, 這個外掛非常易用(我的意思是非常...。
  • Videntity 》, 允許您在 WordPress 上顯示來自您的 videntity.org 個人檔案的元素。, 允許您將 Videntity 好友導入 WordPress。, 允許您將您的 Videntity profile 導入 Wo...。
  • GeoDirectory – X Theme Compatibility Pack 》此外掛已不再需要,GeoDirectory 現已與 X 主題兼容。, 透過GeoDirectory 外掛和相容套件,您可以將您的 X 主題網站轉換成互動式商業目錄!, 鑑於使用此主題...。
  • GeoDirectory – Genesis Compatibility Pack 》這個外掛現在已經不需要了。GeoDirectory 現在可以直接與 Genesis 兼容, 透過 GeoDirectory 外掛 和相容性包,您可以將 Genesis 基礎的網站轉換成互動式的商...。

文章
Filter
Apply Filters
Mastodon