| 1 |
<?php |
| 2 |
/** |
| 3 |
* Ensure Edit Flow is instantiated |
| 4 |
*/ |
| 5 |
add_action( 'after_setup_theme', 'EditFlow' ); |
| 6 |
|
| 7 |
/** |
| 8 |
* Don't load caps on install for WP.com. Instead, let's add |
| 9 |
* them with the WP.com + core caps approach |
| 10 |
*/ |
| 11 |
add_filter( 'ef_kill_add_caps_to_role', '__return_true' ); |
| 12 |
add_filter( 'ef_view_calendar_cap', function() { return 'edit_posts'; } ); |
| 13 |
add_filter( 'ef_view_story_budget_cap', function() { return 'edit_posts'; } ); |
| 14 |
add_filter( 'ef_edit_post_subscriptions_cap', function() { return 'edit_others_posts'; } ); |
| 15 |
add_filter( 'ef_manage_usergroups_cap', function() { return 'manage_options'; } ); |
| 16 |
|
| 17 |
/** |
| 18 |
* Edit Flow loads modules after plugins_loaded, which has already been fired on WP.com |
| 19 |
* Let's run the method at after_setup_themes |
| 20 |
*/ |
| 21 |
add_filter( 'after_setup_theme', 'edit_flow_wpcom_load_modules' ); |
| 22 |
function edit_flow_wpcom_load_modules() { |
| 23 |
global $edit_flow; |
| 24 |
if ( method_exists( $edit_flow, 'action_ef_loaded_load_modules' ) ) { |
| 25 |
$edit_flow->action_ef_loaded_load_modules(); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Share A Draft on WordPress.com breaks when redirect canonical is enabled |
| 31 |
* get_permalink() doesn't respect custom statuses |
| 32 |
* |
| 33 |
* @see http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/canonical.php#L113 |
| 34 |
*/ |
| 35 |
add_filter( 'redirect_canonical', 'edit_flow_wpcom_redirect_canonical' ); |
| 36 |
function edit_flow_wpcom_redirect_canonical( $redirect ) { |
| 37 |
|
| 38 |
if ( ! empty( $_GET['shareadraft'] ) ) { |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
return $redirect; |
| 43 |
} |
| 44 |
|
| 45 |
// This should fix a caching race condition that can sometimes create a published post with an empty slug |
| 46 |
add_filter( 'ef_fix_post_name_post', 'edit_flow_fix_fix_post_name' ); |
| 47 |
function edit_flow_fix_fix_post_name( $post ) { |
| 48 |
global $wpdb; |
| 49 |
$post_status = $wpdb->get_var( $wpdb->prepare( 'SELECT post_status FROM ' . $wpdb->posts . ' WHERE ID = %d', $post->ID ) ); |
| 50 |
if ( null !== $post_status ) { |
| 51 |
$post->post_status = $post_status; |
| 52 |
} |
| 53 |
|
| 54 |
return $post; |
| 55 |
} |