21,998 downloads - November 30, 2015
We have switched to admin only, please email markwdilley@gmail if you would like to edit.

WordPress plugin

From Universal Edit Button

Revision as of 14:39, 1 May 2011 by Audriusa (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Here's a simple WordPress plugin. Save the following as universal-edit-button.php and place it in the /plugins/ folder, then activate it in admin.

Plugin Name: Universal Edit Button
Plugin URI: http://universaleditbutton.org/Wordpress_plugin
Description: Adds a link in the head of the page that will activate the <a href="http://universaleditbutton.org/">Universal Edit Button</a> if the user has it installed. The button is an icon in the URL bar that indicates a web page is editable, and takes the user directly to the edit view.
Version: 1.0.1
Author: UniversalEditButton.org
Author URI: http://universaleditbutton.org/

function ueb_add_head_link() {
	if( is_single() || is_page() ) {
		global $post;
		switch ($post->post_type) {
			case 'attachment':
			case 'page':
				if( !current_user_can( 'edit_page', $post->ID ) ) return;
			case 'post':
				if ( !current_user_can( 'edit_post', $post->ID ) ) return;

		echo '<link rel="alternate" type="application/x-wiki" title="Edit this page" href="' . get_edit_post_link($post->ID) . "\" />\n";

add_action( 'wp_head', 'ueb_add_head_link' );

Version History:

1.0: Initial release by Alan J Castonguay

1.0.1: Main function wrapped in conditional clause so that edit link only appears on single posts or pages. Improved plugin Description, including link to UEB site. By Stephen Rider

Thread reference on wp-hackers: wp-hackers: Universal Edit Button

Personal tools