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

(Difference between revisions)
Jump to: navigation, search
(cat)
(jrdjwineCm)
Line 1: Line 1:
-
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.
+
THX that's a great asnwer!
-
 
+
-
<pre><?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' );
+
-
?>
+
-
</pre>
+
-
 
+
-
Version History:
+
-
 
+
-
1.0: Initial release by [http://verselogic.net/ 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 [http://striderweb.com/ Stephen Rider]
+
-
 
+
-
----
+
-
 
+
-
Thread reference on wp-hackers: [http://comox.textdrive.com/pipermail/wp-hackers/2008-June/020722.html wp-hackers: Universal Edit Button]
+
-
 
+
-
[[Category:Howto]]
+

Revision as of 22:36, 30 April 2011

THX that's a great asnwer!

Personal tools