PluginProbe
Edit Flow / 0.1.5
Edit Flow v0.1.5
0.11.1 0.11.0 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.8 0.8.1 0.8.2 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 trunk 0.1.5 0.10.0 0.10.1 0.10.2 All 44 releases
edit-flow / php / post.php

post.php in Edit Flow 0.1.5, at php/post.php

63 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Functions that hook into or modify post.php
4
5 class post_status
6 {
7
8 function __construct() {
9
10 // @TODO: REPLACE THIS WITH ADMIN_ENQUEUE_SCRIPTS FOR 2.8+
11 add_action('admin_enqueue_scripts', array(&$this, 'post_admin_header'));
12 //add_action('admin_print_scripts-edit.php', array(&$this, 'post_admin_header'));
13 //add_action('admin_print_scripts-post-new.php', array(&$this, 'post_admin_header'));
14
15 } // END: __construct()
16
17 /**
18 * Adds all necessary javascripts to make custom statuses work
19 */
20 function post_admin_header() {
21 global $post, $post_ID, $edit_flow, $pagenow;
22
23 if($pagenow == 'post.php' || $pagenow == 'edit.php' || $pagenow == 'post-new.php') {
24
25 $custom_statuses = $edit_flow->custom_status->get_custom_statuses();
26
27 // Get the status of the current post
28 if($post_ID==0) {
29 $selected = $edit_flow->get_plugin_option('custom_status_default_status');
30 } else {
31 $selected = $post->post_status;
32 }
33
34 // Alright, we want to set up the JS var which contains all custom statuses
35 $count = 1;
36 $status_array = '';
37 // Add the "Publish" status if the post is published
38 if($selected == "publish") $status_array .= "{ name: 'Published', slug: 'publish' }, ";
39
40 foreach($custom_statuses as $status) {
41 $status_array .= "{ name: '". addslashes($status->name) ."', slug: '". $status->slug ."'}";
42 $status_array .= ($count == count($custom_statuses)) ? '' : ',';
43 $count++;
44 }
45
46 // Now, let's print the JS vars
47 ?>
48 <script type="text/javascript">
49 var custom_statuses = new Array(<?php echo $status_array ?>);
50 var current_status = '<?php echo $selected ?>';
51 </script>
52
53 <?php
54 // Enqueue custom_status.js
55 wp_enqueue_script('edit_flow-custom_status', EDIT_FLOW_URL.'js/custom_status.js', array('jquery','post'), '', true);
56 }
57 } // END: post_admin_header()
58
59
60 }
61
62
63 ?>