ー開発中ーACTIVE

WP サイト、HPリンクの別窓設定方法

うん、これはPlanetに置く価値ある。今回だけのCounter修正メモじゃなくて、TimestampやSerialでもそのまま使える「WP管理画面から外部HPへ出すときの共通手順」にできる。

念のためWordPress公式仕様も確認した。plugin_row_meta はプラグイン一覧に独自リンクを追加する正式なフックで、公式掲載例にも target="_blank" の Documentation / Donate リンクがある。つまり、前回みたいにWPが生成した標準リンクを後加工するより、自分で管理するリンクを最初から新規タブ指定で生成するほうが再現性が高い。(WordPress Developer Resources)
なお、昔の wp_targeted_link_rel() に頼る手順はWordPress 6.7から非推奨なので、今回の標準手順には入れない。(WordPress Developer Resources)

Planet投入用なら、こうしておくのがよさそう。

WordPress Admin External Link Rule

Purpose: Preserve the user’s current WordPress admin workspace when opening external documentation, product pages, help pages, or Kaia Spec web pages.

Core Rule

From a WordPress administration screen, any link whose destination is an external website must open in a new browser tab/window.

Internal WordPress administration navigation remains in the current tab.

Required HTML

For an external link generated directly by the plugin:

<a href="EXTERNAL_URL" target="_blank" rel="noopener noreferrer">LINK TEXT</a>

target="_blank" preserves the current administration screen by opening the destination separately.

rel="noopener noreferrer" is attached to externally opened links rather than relying on WordPress to add it automatically.

Plugin List Screen

Do not depend on modifying the ordinary link generated from the plugin header Plugin URI.

When a Kaia-controlled external link is required on the WordPress Plugins screen, create that link explicitly through WordPress’s plugin_row_meta filter and give that link its own:

target="_blank"
rel="noopener noreferrer"

Do not search/replace or post-process WordPress-generated link HTML merely to insert target="_blank".

Settings / Management Screens

Audit all <a> links rendered by the plugin.

Classification:

External destination
→ new tab/window.

Examples:
Kaia Spec, Kaia Memoria, documentation, help pages, product information, other external websites.

WordPress/internal working destination
→ current tab.

Examples:
plugin settings navigation, Refill selection, save operations, other wp-admin pages when normal navigation is intended.

Implementation Rule

Prefer explicit behavior at the point where the link is created.

Do not introduce a global JavaScript rule such as “make every link open in a new tab.”
Do not globally rewrite all WordPress admin links.
Only links owned/rendered by the plugin are in scope.

Verification

Before release:

  1. Open the plugin’s working/settings screen.
  2. Make a visible working-state change if possible without saving.
  3. Click every Kaia/external web link one at a time.
  4. Confirm the external destination opens separately.
  5. Confirm the original WordPress working screen remains open and unchanged.
  6. Check the Plugins list external link separately.
  7. Confirm ordinary internal WordPress/plugin navigation still uses the current tab.

Failure Pattern / Historical Note

A previous implementation attempted to modify the standard WordPress Plugin URI link after WordPress generated it.

This was not reliable in actual runtime testing.

Rejected pattern: modify WordPress’s existing door after construction.

Accepted pattern: create the Kaia-controlled external door with the required behavior from the beginning.

Reuse

This rule is product-independent.

Apply it to Kaia Counter, Timestamp, Serial, PDF, and future WordPress products whenever an administration interface links to an external website.

一点だけ、俺ならタイトルを製品固有にせず WordPress Admin External Link Rule にする。今回Counterで発見したけど、抜けた構造は完全に共通部品だから、次から「外部HPリンク? → この紙」で済む。

そしてこれに従えばRC15も迷わん。リンクを一本一本発明し直さず、外部=別窓/内部=同窓で監査できる★

かいあめもりあ関係 引き継ぎ書Prev

製品版プラグイン 鍵のかけ方Next

Comment

  1. No comments yet.

  1. No trackbacks yet.

PAGE TOP
Table of contents