Skip to content

Commit

Permalink
FEE: Fix issues with subscribers not being able to create new papers.
Browse files Browse the repository at this point in the history
- Add a hardcoded block in FEE to load its scripts for subscribers
- Comment out 'map_meta_cap' call in register_post_type().  This was
  breaking a few things...

See #10.
  • Loading branch information
r-a-y committed Sep 28, 2015
1 parent a0a832b commit 306126c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions includes/class-cacsp-fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ function wp_enqueue_scripts() {
if ( $this->has_fee() ) {
wp_enqueue_media( array( 'post' => $post->ID ) );
}

// subscribers need this to check against the 'edit_papers' cap and not 'edit_posts'
if ( current_user_can( 'edit_papers' ) && ! current_user_can( 'edit_posts' ) ) {
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) || file_exists( dirname( __FILE__ ) . '/.gitignore' ) ? '' : '.min';

if ( is_singular() ) {
require_once( ABSPATH . '/wp-admin/includes/post.php' );

$user_id = wp_check_post_lock( $post->ID );
$user = get_userdata( $user_id );
}

wp_enqueue_style( 'fee-adminbar', $this->url( '/css/fee-adminbar.css' ), false, $this->package['version'], 'screen' );
wp_enqueue_script( 'fee-adminbar', $this->url( '/js/fee-adminbar' . $suffix . '.js' ), array( 'wp-util' ), $this->package['version'], true );
wp_localize_script( 'fee-adminbar', 'fee', array(
'lock' => ( is_singular() && $user_id ) ? $user->display_name : false,
'supportedPostTypes' => $this->get_supported_post_types(),
'postNew' => admin_url( 'post-new.php' ),
'nonce' => wp_create_nonce( 'fee-new' )
) );
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function cacsp_register_post_types() {
'labels' => $labels,
'public' => true,
'capability_type' => 'paper',
'map_meta_cap' => true,
//'map_meta_cap' => true,
'rewrite' => array(
'slug' => 'papers',
'with_front' => false,
Expand Down

0 comments on commit 306126c

Please sign in to comment.