friends_browser_extension_actions - akirk/friends GitHub Wiki

Allows plugins to register actions for the Friends browser extension.

Each action is an associative array with:

  • name (string, required) — label shown in the extension popup.
  • url (string, required) — target URL; may contain {current_url} which the extension substitutes with the current page URL (URL-encoded).
  • method (string, optional) — if "POST", the extension submits a form instead of opening a link.
  • fields (object, optional) — for POST actions, key/value pairs of form fields; values may contain {current_url} (raw) and {page_html} placeholders.
  • run (string, optional) — if "inline", the extension handles the response in place instead of opening a new tab.
  • inputs (array, optional) — user-editable fields for inline actions.
  • category (string, optional) — groups actions under a named header; actions without a category appear under the default "Actions" header.

Example

add_filter( 'friends_browser_extension_actions', function ( $actions, $current_user, $context ) {
    $actions[] = array(
        'name' => 'Save to Collection',
        'url'  => home_url( '/collect/?url={current_url}' ),
    );
    return $actions;
}, 10, 3 );

Parameters

  • array $actions The array of actions.
  • WP_User $current_user The current user.
  • array $context Browser extension request context: key, version, user, and request.

Returns

array The modified array of actions.

Files

apply_filters( 'friends_browser_extension_actions', array(), $current_user, $context )

← All Hooks