Search Results for:

v0.7.5: Enhancements and bugfixes

A couple of localizations, some small enhancements, and another laundry bag of fixes:

  • New Japanese localization thanks to naokomc.
  • New French localization thanks to boris-hocde.
  • Allow custom post statuses to be completely disabled for a post type, preventing situations where ‘draft’ posts could disappear when the draft status was deleted.
  • Better implementation of the hack we have to employ for editable slugs in the post edit screen. Thanks cojennin for the assist.
  • Editorial metadata names can now be up to 200 characters (instead of 20 previously). Props cojennin.
  • Bug fix: Load modules on ‘init’ so the strings associated with each class can be properly translated.
  • Bug fix: Pagination functional again when filtering to a post type.
  • Bug fix: Pre-PHP 5.2.9 array_unique() compatibility.
  • Bug fix: Respect the timezone when indicating which day is Today.
  • Bug fix: Calendar should work for all post types, regardless of which are supposed to be added to it.

See Github for all of the closed issues.

Also of note: edit(orial) flow is coming to core for WordPress 3.6! This will mostly be bug fixes around custom statuses, but I’m hoping to release Edit Flow v0.8 around the same time. Let me know if you’d like to help with contributing.

As always, please hit us with questions, feature requests, and bug reports in the WordPress.org forums.

v0.7.4: Enhancements and bugfixes

Some small enhancements, and a laundry bag of fixes:

  • Added ‘Scheduled’ as one of the statuses you see in the ‘Posts At A Glance’ widget. ‘Private’ and other core statuses can be added with a filter.
  •  Sort posts on the Manage Posts view by visible editorial metadata date fields.
  • Modify email notifications with two filters.
  • Bug fix: Proper support for unicode characters in custom status and editorial metadata descriptions.
  • Bug fix: Show the proper last modified value on the story budget when the server’s timezone is not set to GMT. Props danls.
  • Bug fix: Make the jQuery UI theme for Edit Flow more specific so it doesn’t conflict with core modals.
  • Bug fix: Use the proper singlular label for a post type when generating notification text.
  • Bug fix: Post slug now updates when the post has a custom status.
  • Bug fix: When determining whether a user can change a post’s status, check the ‘edit_posts’ cap for the post type.

See Github for all of the closed issues.

As always, please hit us with questions, feature requests, and bug reports in the WordPress.org forums. If you’d like to help out, check out our guide to contributing.

Hide the “Publish” button for certain custom statuses

We’ve all done it before — accidentally published a post before it was ready to go. With Edit Flow, you can minimize these accidents by hiding the “Publish” button for your in-progress custom statuses, and then only showing it when the post has reached the last stage of production.

First, read the introduction to extending Edit Flow. Once you’ve done so, you can modify the code snippet below to work for your needs. It will simply hide the “Publish” button until you’ve saved the post with one of the statuses in the array.

[sourcecode language=”php”]
/**
* Hide the "Publish" button until a post is ready to be published
* In this example, we only show the "Publish button" until the post has the "Pending" status
*
* @see http://editflow.org/extend/hide-the-publish-button-for-certain-custom-statuses/
*/
function efx_hide_publish_button_until() {

if ( ! function_exists( ‘EditFlow’ ) )
return;

if ( ! EditFlow()->custom_status->is_whitelisted_page() )
return;

// Show the publish button if the post has one of these statuses
$show_publish_button_for_status = array(
‘pending’,
// The statuses below are WordPress’ public statuses
‘future’,
‘publish’,
‘schedule’,
‘private’,
);
if ( ! in_array( get_post_status(), $show_publish_button_for_status ) ) {
?>
<style>
/** Classic Editor **/
#publishing-action { display: none; }

/** Gutenberg Editor **/
.edit-post-header__settings .components-button.editor-post-publish-panel__toggle { display: none; }
</style>
<?php
}
}
add_action( ‘admin_head’, ‘efx_hide_publish_button_until’ );
[/sourcecode]

Install

Edit Flow is a free plugin you can easily download and install from the WordPress.org plugin directory or be found on GitHub.

v0.7.2: Custom statuses for contributors

Thanks to an awesome contribution from Daniel Chesterton, we have an oft-requested feature to give you today: custom statuses for contributors. Previously, your contributors and other users without the ‘publish_posts’ capability had two options, “Save as Draft” or “Submit for Review”. With Edit Flow v0.7.2, they can save content to any stage of your workflow.

Here’s what the submit meta box now looks like for your contributors:

You can use a simple filter to restrict your contributors to only changing specific statuses. If you did so, it would look like this:

In this release, we’ve also incorporated the following changes:

  • Support for trashing posts from the calendar. Thanks Dan York for the idea and a bit of code.
  • Updated codebase to use PHP5-style OOP references.
  • Fixed some script and stylesheet references that had a double ‘//’ in the URI path
  • New edit_flow_supported_module_post_types_args filter allows you to enable custom statuses and other modules for private post types

See Github for all of the closed issues.

As always, please hit us with questions, feature requests, and bug reports in the WordPress.org forums. If you’d like to help out, check out our guide to contributing.

Limit custom statuses based on user role

In v0.7.2, we added the ability for users without the ‘publish_posts’ capability to use any of your custom statuses — not just “Draft” and “Pending Review.” If you’d like to enforce a more structured workflow, it’s now an easy thing to restrict access to specific post statuses based on user role, capabilities or user group relationship. If a user doesn’t have access to a given status, they’ll still be able to edit the post when it’s saved with that status.

If you haven’t already, please read the introduction to extending Edit Flow. Once you’ve done so, you can modify the example below to your needs. This particular example limits the post statuses available to a user with the “Contributor” role.

[sourcecode language=”php”]
/**
* Limit custom statuses based on user role
* In this example, we limit the statuses available to the
* ‘contributor’ user role
*
* @see http://editflow.org/extend/limit-custom-statuses-based-on-user-role/
*
* @param array $custom_statuses The existing custom status objects
* @return array $custom_statuses Our possibly modified set of custom statuses
*/
function efx_limit_custom_statuses_by_role( $custom_statuses ) {

$current_user = wp_get_current_user();
switch( $current_user->roles[0] ) {
// Only allow a contributor to access specific statuses from the dropdown
case ‘contributor’:
$permitted_statuses = array(
‘pitch’,
‘draft’,
‘in-progress’,
);
// Remove the custom status if it’s not whitelisted
foreach( $custom_statuses as $key => $custom_status ) {
if ( !in_array( $custom_status->slug, $permitted_statuses ) )
unset( $custom_statuses[$key] );
}
break;
}
return $custom_statuses;
}
add_filter( ‘ef_custom_status_list’, ‘efx_limit_custom_statuses_by_role’ );
[/sourcecode]

Modify CSS classes applied to posts on the calendar

There are a few CSS classes wrapped around each post on the calendar by default. Customizing these further is just a matter of modifying the classes with the ef_calendar_table_td_li_classes filter.

If you haven’t already, please read the introduction to extending Edit Flow. Once you’ve done so, you can modify the example below to your needs. This particular example will add the post categories as additional CSS selectors.

[sourcecode language=”php”]
/**
* Modify CSS classes applied to posts on the calendar
*
* @see http://editflow.org/extend/modify-css-classes-applied-to-posts-on-the-calendar/
*
* @param array $post_classes Existing post classes
* @param string $week_single_date The date this post appears on
* @param int $post_id Unique identifier for the post we’re modifying
* @return array $post_classes Post classes after we’ve made any requisite modifications
*/
function efx_modify_calendar_post_css_classes( $post_classes, $week_single_date, $post_id ) {

$categories = wp_get_post_categories( $post_id, array( ‘fields’ => ‘slugs’ ) );
foreach( (array)$categories as $category ) {
$post_classes[] = ‘category-‘ . $category;
}
return $post_classes;
}
add_filter( ‘ef_calendar_table_td_li_classes’, ‘efx_modify_calendar_post_css_classes’, 10, 3 );
[/sourcecode]

Change sort order of posts on the calendar

In v0.7, we changed the behavior of the calendar to display posts based on the sort order of your custom statuses. The idea here is that the earliest posts in your workflow are most likely the ones needing the most attention.

If this isn’t the case for you, you can hook into the 'ef_calendar_posts_for_week' filter to sort the posts however you’d like. If you haven’t already, please read the introduction to extending Edit Flow. The code snippet below sorts posts into chronological order; you may need a bit of PHP knowledge to modify it to a different approach.

[sourcecode language=”php”]
<?php
/**
* Change sort order of posts on the calendar
* Take the already sorted posts and sort them again
* based on our own criteria
*
* @see http://editflow.org/extend/change-sort-order-of-posts-on-the-calendar/
*
* @param array $day_posts An array of post objects for the day
* @return array $day_posts Our re-sorted array of post objects
*/
function efx_change_calendar_posts_sort_order( $day_posts ) {

// Load the posts into a temporary array by post_date timestamp for sorting
$tmp_posts = array();
foreach( $day_posts as $post_obj ) {
$post_date_timestamp = strtotime( $post_obj->post_date );
$tmp_posts[$post_date_timestamp] = $post_obj;
}
ksort( $tmp_posts, SORT_NUMERIC );
// Re-load the post objects onto our array of posts
$day_posts = array();
foreach( $tmp_posts as $post_obj ) {
$day_posts[] = $post_obj;
}
return $day_posts;
}
add_filter( ‘ef_calendar_posts_for_week’, ‘efx_change_calendar_posts_sort_order’ );[/sourcecode]

Only allow specific users to drag and drop posts on the calendar

In v0.7, we reintroduced the ability to drag and drop posts on the calendar. It can work in one of two ways: you can drag and drop for scheduling purposes and not affect the publication date, or you can change the publication date.

Users can drag and drop a post if they have permissions to modify the post. This closely how core works: contributors can modify their own unpublished posts, authors can modify their own unpublished and published posts, and editors can modify everyone’s content. You may not want to allow every user to drag and drop posts on the calendar though.

First, read the introduction to extending Edit Flow. Once you’ve done so, you can modify the code snippet below to work for your needs. Basically, what’s happening is we’re removing some code for users who don’t match our criteria.

[sourcecode language=”php”]<?php
/**
* Only allow specific users to drag and drop posts on the calendar
* The easiest way to do this is just removing the class that makes them sortable
*
* @see http://editflow.org/extend/only-allow-specific-users-to-drag-and-drop-posts-on-the-calendar/
*
* @param array $post_classes A list of the classes to be printed for each item
* @return array $post_classes The possibly modified post classes
*/
function efx_restrict_calendar_drag_and_drop( $post_classes ) {

// This takes a whitelist approach; only user logins appearing in
// the $permitted_users array will be permitted to drag and drop
$permitted_users = array(
// ‘daniel’, // Add whichever usernames you’d like as pieces of the array and uncomment
);
// Unset the ‘sortable’ class if the user isn’t in our whitelist
// The ‘sortable’ class is used by jQuery to determine whether a post can be moved
if ( !in_array( wp_get_current_user()->user_login, $permitted_users ) ) {
foreach( $post_classes as $key => $post_class ) {
if ( ‘sortable’ == $post_class )
unset( $post_classes[$key] );
}
}
return $post_classes;
}
add_action( ‘ef_calendar_table_td_li_classes’, ‘efx_restrict_calendar_drag_and_drop’ );[/sourcecode]

With a bit of PHP knowledge, you can easily modify the snippet to blacklist users instead of whitelisting them (e.g. if ( in_array( wp_get_current_user()->user_login, $blacklisted_users ) ), or handle access based on user capabilities (e.g. if ( !current_user_can( 'publish_posts' ) ).

Edit Flow v0.7.1: Enhancements and bugfixes

Coming to you live from a rainy Portland afternoon: Edit Flow v0.7.1. This is mostly a enhancements and bugfixes release with the following points of interest:

  • Shows the year on the calendar and story budget if it’s not the current year.
  • Allows users to save post subscriptions the first time they save the post. This also fixes the bug where a user wouldn’t be subscribed until they saved the post twice.
  • Changed the behavior of notifications for the user changing a status or leaving a comment. Previously, they’d receive an email with the action they just performed; now they do not. This can be changed with a filter.
  • New Italian localization thanks to Luca Patané.
  • Bug fix: Auto-subscribe the post author to their posts by default but make it filterable.
  • Bug fix: Only show “authors”, or contributors and above, in the user dropdown for the calendar and the story budget. This new behavior can be filtered out however.
  • Bug fix: Metaboxes are registered with proper priority. Props benbalter
  • Bug fix: If a user hasn’t ever opened the calendar before, the date should default to today, not the Unix Epoch
  • Bug fix: Prevent editorial metadata filters from stomping on others’ uses by actually returning the original value when we don’t want to manipulate it
  • Bug fix: Specify a max-width on <select> dropdowns in the calendar and story budget so long values don’t break formatting

See Github for all of the closed issues.

On that note, getting involved with the code side of the project is now easier than ever. We’ve moved all of our project management to Github.

One way to get acquainted with the code base is by producing a functional code snippet. We have a list of code snippets requested at one point or another, including:

  • Remove the publish capability for certain statuses so you don’t accidentally publish a pitch or similar pre-production post (#55)
  • Send out reminders to users based on the value in an editorial metadata date field (#48)
  • Include users listed in the “User” editorial metadata field as recipients of notifications (#46)

If your code snippet works well and meets our standards, we’ll add it to our site documentation and thank you profusely.