<?php/*Plugin Name: Edit n PlaceVersion: 0.5Plugin URI: http://www.headzoo.comDescription: Allows you to edit your post inline, right on the front page of your blog.Author: Sean HickeyAuthor URI: http://www.headzoo.com*/session_start();define('ENP_PATH', ABSPATH . '/wp-content/plugins/editnplace');define('ENP_URL', get_bloginfo('wpurl') . '/wp-content/plugins/editnplace');add_filter('the_content', 'enp_content', 1);add_filter('wp_head', 'enp_wpHead');add_filter('the_category', 'enp_cats');add_filter('the_title', 'enp_title');$editnplace_linkFunctionCalled = false;/** * Adds template markers to the title * * Adds the markers, which are HTML comments, to the title of * the post. * * @param string $title The post title * @return string */function enp_title($title) { global $post, $user_ID; if (is_feed()) { return $title; } if (!user_can_edit_post($user_ID, $post->ID)) { return $title; } return '<!--enpts-->' . $title . '<!--enpte-->';}/** * Adds template markers to the categories * * Adds the markers, which are HTML comments, to the categories of * the post. * * @param string $cat The post categories * @return string */function enp_cats($cat) { global $post, $user_ID; if (is_feed()) { return $cat; } if (!user_can_edit_post($user_ID, $post->ID)) { return $cat; } return '<!--enp_cat_start-->' . $cat . '<!--enp_cat_end-->';}/** * Adds template markers to the post content * * Adds the markers, which are HTML comments, to the content * of the post, and adds the Edit n Place buttons. * * @param string $content The post content * @return string */function enp_content($content) { global $post, $user_ID, $editnplace_linkFunctionCalled; if (is_feed()) { return $content; } if (!user_can_edit_post($user_ID, $post->ID)) { return $content; } $link = '<!--enp_content_start-->' . $content . '<!--enp_content_end-->'; if (!$editnplace_linkFunctionCalled) { $link .= '<a href="javascript:enp_edit(' . $post->ID . ')">Edit N Place</a>'; } return $link;}/** * Adds JavaScript/CSS to the document head * * Adds all the needed JS and CSS to the document head. * * @return void */function enp_wpHead() { global $userdata; get_currentuserinfo(); if (empty($userdata)) { return; } echo "<script type=\"text/javascript\">\r\n"; echo "var enp_siteURL = '" . get_settings('siteurl') . "';\r\n"; echo "</script>\r\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . ENP_URL . "/style.css\" />\r\n"; echo "<script type=\"text/javascript\" src=\"" . ENP_URL . "/head.js\"></script>"; echo "<script type=\"text/javascript\" src=\"" . ENP_URL . "/js_quicktags.js\"></script>";}/** * Edit N Place edit link function * * You can replace WordPress's built in edit link function with this one, and * put your edit link where ever you want to. Takes one parameter, which is the * text to show for the edit link. The default is 'Edit N Place'. * * @param string $text The text to display for the link * @return void */function enp_edit_link($before = '', $text = 'Edit N Place', $after = '') { global $user_ID, $post, $editnplace_linkFunctionCalled; if (!user_can_edit_post($user_ID, $post->ID)) { return; } $editnplace_linkFunctionCalled = true; $link = $before . '<a href="javascript:enp_edit(' . $post->ID . ')">' . $text . '</a>' . $after; echo $link;}?>