Ticket #8827 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

Add 'app_create_post' and 'app_put_post' hooks in Atompub backend.

Reported by: znarfor Owned by: anonymous
Priority: normal Milestone: 2.8
Component: General Version: 2.7
Severity: normal Keywords: has-patch
Cc:

Description

wp-app.php is not extensible at the moment, by adding this hooks, a plugin may be able to do some extra processing once a post is updated or created.

Use case: an Atom client may use an extension not supported in Wordpress core. With this patch, we may be able to support it through a plugin. Sample plugin code following.

function app_handle_license($post_ID, $entry)
{
	foreach ($entry->links as $link) {
		if ($link['rel'] == 'license') {
			update_post_meta($post_ID, 'license', $link['href']);
		}
	}
}

add_action('app_create_post', 'bm_app_handle_post', 10, /* 2 arguments */ 2);

add_action('app_put_post', 'bm_app_handle_post', 10, /* 2 arguments */ 2);

Attachments

wp-app-post-hooks.diff Download (673 bytes) - added by znarfor 3 years ago.
wp-app.php.diff Download (688 bytes) - added by josephscott 3 years ago.

Change History

znarfor3 years ago

Typo, it should be

add_action('app_create_post', 'app_handle_license', 10, /* 2 arguments */ 2);
add_action('app_put_post', 'app_handle_license', 10, /* 2 arguments */ 2);
  • Keywords has-patch added

New version of the patch:

  • small WP coding style changes
  • change names to prefixed with 'atompub_*' instead of 'app_*' (AtomPub has replaced APP as the standard name for AtomPub)
  • moved the atompub_put_post action below the post update error check.
  • Status changed from new to closed
  • Resolution set to fixed

(In [10750]) Add hooks to allow plugins to extend AtomPub support. Fixes #8827 props znarfor and josephscott.

Note: See TracTickets for help on using tickets.