How do I modify this wordpress plugin script slightly?

Hi,

I am using a very useful wordpress plugin called "LIGHTBULB SAVE AND CLOSE". It adds an extra button on the pages/posts sections of the wordpress CMS so I get an extra button "PUBLISH AND CLOSE" when I finish editing ("UPDATE AND CLOSE" if I have made changes).
The code is below.

<?php

/**
 * Plugin Name: Lightbulb Save and Close
 * Plugin URI:  http://lightbulbdigital.com.au/wordpress-plugins
 * Description: Adds a button to the Edit Post page which saves the post and redirects back to the post listing page.
 * Version:     1.2.1
 * Author:      Lightbulb Digital
 * Author URI:  http://lightbulbdigital.com.au
 * License:     GPL2
 */

// Set up the plugin if the user has access to the admin area
add_action('admin_init', array('lb_save_close', 'init'));

class lb_save_close {

	/**
	 * Hook into various WordPress events
	 */
	public static function init() {
		add_action('post_submitbox_misc_actions', array('lb_save_close', 'add_button')); // add button
		add_filter('redirect_post_location', array('lb_save_close', 'redirect'), '99'); // change redirect URL
		add_action('admin_notices', array('lb_save_close', 'saved_notice'));
	}

	/**
	 * Adds the custom button into the post edit page
	 */
	public static function add_button() {
		// work out if post is published or not
		$status = get_post_status($_GET['post']);
		// if the post is already published, label the button as "update"
		$button_label = ($status == 'publish' || $status == 'private') ? 'Update and Close' : 'Publish and Close';

		// TODO: fix duplicated IDs
		?>

		<div id="major-publishing-actions" style="overflow:hidden">
			<div id="publishing-action">
				<input type="hidden" name="saveclose_referer" value="<?php echo $_SERVER['HTTP_REFERER'] ?>">
				<input type="submit" tabindex="5" value="<?php echo $button_label ?>" class="button-primary" id="custom" name="save-close">
			</div>
		</div>

		<?php
	}

	/**
	 * Generates the URL to redirect to
	 * @param $location The redirect location (we're overwriting this)
	 * @return string The new URL to redirect to, which should be the post listing page of the relevant post type
	 */
	public static function redirect($location) {
		if (!isset($_POST['save-close'])) return $location;

		// determine the post status (private if selected, else published)
		//$post_status = ($_POST['post_status'] == 'private') ? 'private' : 'publish';

		// we want to publish new posts
		$post_status = 'publish';

		// if the post was published, allow the status to be changed to something else (eg. draft)
		if ($_POST['original_post_status'] == 'publish' || $_POST['original_post_status'] == 'private') {
			$post_status = $_POST['post_status'];
		}
		// handle private post visibility
		if ($_POST['post_status'] == 'private') {
			$post_status = 'private';
		}

		wp_update_post(array('ID' => $_POST['post_ID'], 'post_status' => $post_status));

		// if we have an HTTP referer saved, and it's a post listing page, redirect back to that (maintains pagination, filters, etc.)
		if (isset($_POST['saveclose_referer']) && strstr($_POST['saveclose_referer'], 'edit.php') !== false) {
			if (strstr($_POST['saveclose_referer'], 'lbsmessage') === false) {
				if (strstr($_POST['saveclose_referer'], '?') === false) {
					return $_POST['saveclose_referer'] . '?lbsmessage=1';
				}
				return $_POST['saveclose_referer'] . '&lbsmessage=1';
			}
			return $_POST['saveclose_referer'];
		}
		// no referer saved, just redirect back to the main post listing page for the post type
		else {
			return get_admin_url() . 'edit.php?lbsmessage=1&post_type=' . $_POST['post_type'];
		}
	}

	/**
	 * Display a notice on the post listing page to inform the user that a post was saved
	 */
	public static function saved_notice() {
		if (isset($_GET['lbsmessage'])) {
			?>
			<div class="updated">
				<p>Post saved</p>
			</div>
			<?php
		}
	}

}

Open in new window



What I would like is to be able to modify this script and add another button called "PUBLISH AND NEW" (or "UPDATE AND NEW" if the item has been modified). I am adding several hundred pages to a wordpress site and it is getting very tedious without such simple but useful functionality. I remember that Joomala has it out of the box.

Just a thought, if you are not happy to modify this code, maybe I could save it as a new plugin with the adjusted code? That way if the original is updated during wordpress updates these changes don't get wiped out

Any help will be appreciated.

thanks
badwolfffAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

eemitCommented:
Modified plugin Version attached.

Upload the entire 'lightbulb-save-and-close-or-new' folder to the '/wp-content/plugins/' directory.

Deactivate original plugin and activate this plugin through the 'Plugins' menu in WordPress.
lightbulb-save-and-close-or-new.zip
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
badwolfffAuthor Commented:
Yahoo! I am so happy! Thanks so much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.