# edit-flow/0.1.5/php/post.php

Edit Flow, version 0.1.5. 63 lines.

- Page: https://pluginprobe.com/plugins/edit-flow/0.1.5/code/php/post.php
- Raw: https://pluginprobe.com/plugins/edit-flow/0.1.5/raw/php/post.php
- Modified: 2009-06-13T15:30:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/edit-flow/0.1.5/code/php/post.php#L10-L20`.

```php
<?php

// Functions that hook into or modify post.php

class post_status
{
	
	function __construct() {
		
		// @TODO: REPLACE THIS WITH ADMIN_ENQUEUE_SCRIPTS FOR 2.8+
		add_action('admin_enqueue_scripts', array(&$this, 'post_admin_header'));
		//add_action('admin_print_scripts-edit.php', array(&$this, 'post_admin_header'));
		//add_action('admin_print_scripts-post-new.php', array(&$this, 'post_admin_header'));
		
	} // END: __construct()
	
	/**
	 * Adds all necessary javascripts to make custom statuses work
	 */
	function post_admin_header() {
		global $post, $post_ID, $edit_flow, $pagenow;
		
		if($pagenow == 'post.php' || $pagenow == 'edit.php' || $pagenow == 'post-new.php') {
			
			$custom_statuses = $edit_flow->custom_status->get_custom_statuses();
	
			// Get the status of the current post		
			if($post_ID==0) {
				$selected = $edit_flow->get_plugin_option('custom_status_default_status');
			} else {
				$selected = $post->post_status;
			}
	
			// Alright, we want to set up the JS var which contains all custom statuses
			$count = 1;
			$status_array = '';
			// Add the "Publish" status if the post is published
			if($selected == "publish") $status_array .= "{ name: 'Published', slug: 'publish' }, ";
			
			foreach($custom_statuses as $status) {
				$status_array .= "{ name: '". addslashes($status->name) ."', slug: '". $status->slug ."'}";
				$status_array .= ($count == count($custom_statuses)) ? '' : ',';
				$count++;
			}
			
			// Now, let's print the JS vars
			?>
			<script type="text/javascript">
				var custom_statuses = new Array(<?php echo $status_array ?>);
				var current_status = '<?php echo $selected ?>';
			</script>
			
			<?php
			// Enqueue custom_status.js
			wp_enqueue_script('edit_flow-custom_status', EDIT_FLOW_URL.'js/custom_status.js', array('jquery','post'), '', true);
		}
	} // END: post_admin_header()
	
	
}


?>
```
