This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## Change Log ## *2009-06-12 / 0.1.2* * Updated plugin license to GPL */ // Include necessary files include_once('php/custom_status.php'); include_once('php/dashboard.php'); include_once('php/post.php'); // Define contants define(EDIT_FLOW_FILE_PATH, dirname(__FILE__).'/'.basename(__FILE__)); define(EDIT_FLOW_URL, plugins_url(plugin_basename(dirname(__FILE__)).'/')); define(EDIT_FLOW_SETTINGS_PAGE, 'options-general.php?page=edit_flow'); define(EDIT_FLOW_CUSTOM_STATUS_PAGE, 'admin.php?page=Edit-Flow-Project/php/custom_status.php'); // Core class class edit_flow { // Unique identified added as a prefix to all options var $options_group = 'edit_flow_'; // Initially stores default option values, but when load_options is run, it is populated with the options stored in the WP db var $options = array( 'custom_statuses_enabled' => 1, 'custom_status_default_status' => 'draft', 'dashboard_widgets_enabled' => 1, 'post_status_widget_enabled' => 1, ); // Used to store the names for any custom tables used by the plugin var $tables = array(); // used to create an instance of the various classes var $custom_status = null; var $dashboard = null; var $post_status = null; /** * Constructor */ function __construct() { global $wpdb; // Define custom tables used here // Sample array entry: 'table_name' => $wpdb->prefix.'table_name' $this->tables = array(); // Load plugin options $this->load_options(); // Create the new custom_status object $this->custom_status = new custom_status(); // Create a new edit_flow_dashboard object if($this->get_plugin_option('dashboard_widgets_enabled')) $this->dashboard = new edit_flow_dashboard(); // Create a new post_status object, if custom statuses enabled if($this->get_plugin_option('custom_statuses_enabled')==1) $this->post_status = new post_status(); } // END __construct() /** * Inititalizes the plugin */ function init() { if(is_admin()) { //Add the necessary pages for the plugin add_action('admin_menu', array(&$this, 'add_menu_items')); } } // END: init() /** * Initialize the plugin for the admin */ function admin_init() { // Register all plugin settings so that we can change them and such foreach($this->options as $option => $value) { register_setting($this->options_group, $this->get_plugin_option_fullname($option)); } } // END: admin_init() /** * This function is called when plugin is activated. */ function activate_plugin ( ) { // Run function to generate db tables $this->build_db_tables(); // Do other fancy stuff! // Like load default values for Custom Status // Create default statuses $default_terms = array( array( 'term' => 'Draft', 'args' => array( 'slug' => 'draft', 'description' => 'Post is simply a draft', ) ), array( 'term' => 'Pending Review', 'args' => array( 'slug' => 'pending', 'description' => 'The post needs to be reviewed by an Editor', ) ), array( 'term' => 'Pitch', 'args' => array( 'slug' => 'pitch', 'description' => 'Post idea proposed', ) ), array( 'term' => 'Assigned', 'args' => array( 'slug' => 'assigned', 'description' => 'The post has been assigned to a writer' ) ), array( 'term' => 'Waiting for Feedback', 'args' => array( 'slug' => 'waiting-for-feedback', 'description' => 'The post has been sent to the editor, and is waiting on feedback' ) ) ); // Okay, now add the default statuses to the db if they don't already exist foreach($default_terms as $term) { if(!is_term($term['term'])) $this->custom_status->add_custom_status( $term['term'], $term['args'] ); } } // END: activate plugin /** * Creates all necessary db tables for plugin, if they don't exist. * @return void */ protected function build_db_tables() { global $wpdb; /* NOTE: Make sure to add table name to the $this->table array (in the __construct() function). We can then access it plugin-wide by: global $edit_flow; $edit_flow->tables['table_name'] WordPress wasn't letting me access the table via $wpdb->table_name, which is why I've set this up. */ } // END: build_db_tables /** * Loads options for the plugin. * If option doesn't exist in database, it is added * * Note: default values are stored in the $this->options array * Note: a prefix unique to the plugin is appended to all options. Prefix is stored in $this->options_group */ protected function load_options ( ) { $new_options = array(); foreach($this->options as $option => $value) { $name = $this->get_plugin_option_fullname($option); $return = get_option($name); if($return === false) { add_option($name, $value); $new_array[$option] = $value; } else { $new_array[$option] = $return; } } $this->options = $new_array; } // END: load_options /** * Returns option for the plugin specified by $name, e.g. custom_stati_enabled * * Note: The plugin option prefix does not need to be included in $name * * @param string name of the option * @return option|null if not found * */ function get_plugin_option ( $name ) { if(is_array($this->options) && $option = $this->options[$name]) return $option; else return null; } // END: get_option // Utility function: appends the option prefix and returns the full name of the option as it is stored in the wp_options db protected function get_plugin_option_fullname ( $name ) { return $this->options_group . $name; } /** * Adds menu items for the plugin */ function add_menu_items ( ) { // Add Top-level Admin Menu add_menu_page('Edit Flow', 'Edit Flow', 8, __FILE__, array(&$this, 'toplevel_page')); // Add sub-menu page for Custom statuses add_submenu_page(__FILE__, 'Custom Status', 'Custom Status', 8, 'Edit-Flow-Project/php/custom_status.php', array(&$this->custom_status,'admin_page')); // Add Options page add_options_page('Edit Flow Options', 'Edit Flow', 8, 'edit_flow', array(&$this, 'options_page')); } // END: add_menu_items() /** * Add Top-level Admin Menu * This should be exported into a separate file (?) */ function toplevel_page() { ?>
The overall goal of this plugin is to improve WordPress' admin for a multi-user newsroom's editorial workflow.
Through discussions with existing newsrooms that use WordPress as their CMS of choice, we have identified the following weak points within the WordPress Administration interface in the context of a multi-user environment:
More about Edit Flow
More about CoPress