20,268 downloads - November 27, 2013
We are switched to admin only, please email markdilley@gmail if you would like to edit.

WordPress plugin

From Universal Edit Button

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.

<?php
/*
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':
				return;
			case 'page':
				if( !current_user_can( 'edit_page', $post->ID ) ) return;
				break;
			case 'post':
			default:
				if ( !current_user_can( 'edit_post', $post->ID ) ) return;
				break;
		}

		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