PluginProbe
Edit Flow / 0.9.3
Edit Flow v0.9.3
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 / wpcom-helper.php

wpcom-helper.php in Edit Flow 0.9.3, at wpcom-helper.php

55 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 * 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 }