Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: cf
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 68 lines (55 sloc) 2.76 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
<?php
if ( did_action( 'plugins_loaded' ) )
Rvy_Helper::init_rvy_interface();
else
add_action( 'plugins_loaded', array( 'Rvy_Helper', 'init_rvy_interface' ) );


Class Rvy_Helper {
function init_rvy_interface() {
if ( ! empty($GLOBALS['revisionary']) && method_exists( $GLOBALS['revisionary'], 'set_content_roles' ) ) {

if ( class_exists('RevisionaryContentRoles') ) {
require_once( dirname(__FILE__).'/revisionary-content-roles_rs.php' );
$GLOBALS['revisionary']->set_content_roles( new Scoper_RvyContentRoles() );
}
}
}

// Allow contributors and revisors to edit published post/page, with change stored as a revision pending review
function convert_post_edit_caps( $rs_reqd_caps, $post_type ) {
global $revisionary, $scoper;

if ( ! empty( $revisionary->skip_revision_allowance ) || ! rvy_get_option('pending_revisions') )
return $rs_reqd_caps;

$post_id = $scoper->data_sources->detect('id', 'post');

// don't need to fudge the capreq for post.php unless existing post has public/private status
$status = get_post_field( 'post_status', $post_id, 'post' );
$status_obj = get_post_status_object( $status );

if ( empty( $status_obj->public ) && empty( $status_obj->private ) && ( 'future' != $status ) )
return $rs_reqd_caps;

if ( $type_obj = get_post_type_object( $post_type ) ) {
$replace_caps = array( 'edit_published_posts', 'edit_private_posts', 'publish_posts', $type_obj->cap->edit_published_posts, $type_obj->cap->edit_private_posts, $type_obj->cap->publish_posts );
$use_cap_req = $type_obj->cap->edit_posts;
} else
$replace_caps = array();

if ( array_intersect( $rs_reqd_caps, $replace_caps) ) {
foreach ( $rs_reqd_caps as $key => $cap_name )
if ( in_array($cap_name, $replace_caps) )
$rs_reqd_caps[$key] = $use_cap_req;
}

return $rs_reqd_caps;
}

// ensure proper cap requirements when a non-Administrator Quick-Edits or Bulk-Edits Posts/Pages (which may be included in the edit listing only for revision submission)
function fix_table_edit_reqd_caps( $rs_reqd_caps, $orig_meta_cap, $_post, $object_type_obj ) {
foreach( array( 'edit', 'delete' ) as $op ) {
if ( in_array( $orig_meta_cap, array( "{$op}_post", "{$op}_page" ) ) ) {
$status_obj = get_post_status_object( $_post->post_status );
foreach( array( 'public' => 'published', 'private' => 'private' ) as $status_prop => $cap_suffix ) {
if ( ! empty($status_obj->$status_prop) ) {
$cap_prop = "{$op}_{$cap_suffix}_posts";
$rs_reqd_caps[]= $object_type_obj->cap->$cap_prop;
$GLOBALS['revisionary']->skip_revision_allowance = true;
}
}
}
}
return $rs_reqd_caps;
}
}

?>
Something went wrong with that request. Please try again.