Add crosspost user capability
This commit is contained in:
parent
a7051df9f1
commit
d77f3e18aa
@ -711,6 +711,7 @@ function fcntr_admin( $key, $escape = false ) {
|
||||
'fcn_edit_date' => _x( 'Edit Date', 'Capability translation', 'fictioneer' ),
|
||||
'fcn_assign_patreon_tiers' => _x( 'Assign Patreon Tiers', 'Capability translation', 'fictioneer' ),
|
||||
'fcn_expire_passwords' => _x( 'Expire Passwords', 'Capability translation', 'fictioneer' ),
|
||||
'fcn_crosspost' => _x( 'Crosspost', 'Capability translation', 'fictioneer' ),
|
||||
'fcn_reduced_profile' => _x( 'Reduced Profile', 'Capability translation', 'fictioneer' ),
|
||||
'fcn_only_moderate_comments' => _x( 'Only Moderate Comments', 'Capability translation', 'fictioneer' ),
|
||||
'fcn_upload_limit' => _x( 'Upload Limit', 'Capability translation', 'fictioneer' ),
|
||||
|
@ -2833,6 +2833,24 @@ function fictioneer_render_chapter_data_metabox( $post ) {
|
||||
)
|
||||
);
|
||||
|
||||
// Story override
|
||||
if ( current_user_can( 'manage_options' ) || current_user_can( 'fcn_crosspost' ) ) {
|
||||
if ( get_option( 'fictioneer_enable_chapter_appending' ) ) {
|
||||
$override_description = __( 'Accepts a story ID to assign and append the chapter with override permission.', 'fictioneer' );
|
||||
} else {
|
||||
$override_description = __( 'Accepts a story ID to assign the chapter with override permission.', 'fictioneer' );
|
||||
}
|
||||
|
||||
$output['fictioneer_chapter_story_override'] = fictioneer_get_metabox_text(
|
||||
$post,
|
||||
'fictioneer_chapter_story_override',
|
||||
array(
|
||||
'label' => _x( 'Story Override', 'Chapter story override meta field label.', 'fictioneer' ),
|
||||
'description' => $override_description
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Card/List title
|
||||
$output['fictioneer_chapter_list_title'] = fictioneer_get_metabox_text(
|
||||
$post,
|
||||
@ -3025,7 +3043,7 @@ function fictioneer_save_chapter_metaboxes( $post_id ) {
|
||||
}
|
||||
|
||||
// Story
|
||||
if ( isset( $_POST['fictioneer_chapter_story'] ) ) {
|
||||
if ( isset( $_POST['fictioneer_chapter_story'] ) && ! ( $_POST['fictioneer_chapter_story_override'] ?? 0 ) ) {
|
||||
$story_id = fictioneer_validate_id( $_POST['fictioneer_chapter_story'], 'fcn_story' );
|
||||
$current_story_id = absint( fictioneer_get_chapter_story_id( $post_id ) );
|
||||
|
||||
@ -3058,6 +3076,30 @@ function fictioneer_save_chapter_metaboxes( $post_id ) {
|
||||
$fields['fictioneer_chapter_story'] = strval( $story_id ?: 0 );
|
||||
}
|
||||
|
||||
// Story override
|
||||
if ( current_user_can( 'manage_options' ) || current_user_can( 'fcn_crosspost' ) ) {
|
||||
if ( isset( $_POST['fictioneer_chapter_story_override'] ) ) {
|
||||
$story_id = fictioneer_validate_id( $_POST['fictioneer_chapter_story_override'], 'fcn_story' );
|
||||
$current_story_id = absint( fictioneer_get_chapter_story_id( $post_id ) );
|
||||
|
||||
if ( $story_id ) {
|
||||
if ( $current_story_id && $story_id !== $current_story_id ) {
|
||||
$other_story_chapters = fictioneer_get_story_chapter_ids( $current_story_id );
|
||||
$other_story_chapters = array_diff( $other_story_chapters, [ strval( $post_id ) ] );
|
||||
|
||||
update_post_meta( $current_story_id, 'fictioneer_story_chapters', $other_story_chapters );
|
||||
}
|
||||
|
||||
if ( get_option( 'fictioneer_enable_chapter_appending' ) ) {
|
||||
fictioneer_append_chapter_to_story( $post_id, $story_id, true );
|
||||
}
|
||||
|
||||
fictioneer_set_chapter_story_parent( $post_id, $story_id );
|
||||
$fields['fictioneer_chapter_story'] = strval( $story_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Card/List title
|
||||
if ( isset( $_POST['fictioneer_chapter_list_title'] ) ) {
|
||||
$fields['fictioneer_chapter_list_title'] = sanitize_text_field( $_POST['fictioneer_chapter_list_title'] );
|
||||
|
@ -36,7 +36,8 @@ define(
|
||||
'fcn_ignore_fcn_chapter_passwords',
|
||||
'fcn_ignore_fcn_collection_passwords',
|
||||
'fcn_unlock_posts',
|
||||
'fcn_expire_passwords'
|
||||
'fcn_expire_passwords',
|
||||
'fcn_crosspost'
|
||||
)
|
||||
);
|
||||
|
||||
@ -97,11 +98,12 @@ function fictioneer_initialize_roles( $force = false ) {
|
||||
}
|
||||
|
||||
// If this capability is missing, the roles need to be updated
|
||||
if ( $administrator && ! in_array( 'fcn_expire_passwords', array_keys( $administrator->capabilities ) ) ) {
|
||||
if ( $administrator && ! in_array( 'fcn_crosspost', array_keys( $administrator->capabilities ) ) ) {
|
||||
get_role( 'administrator' )->add_cap( 'fcn_custom_page_header' );
|
||||
get_role( 'administrator' )->add_cap( 'fcn_custom_epub_upload' );
|
||||
get_role( 'administrator' )->add_cap( 'fcn_unlock_posts' );
|
||||
get_role( 'administrator' )->add_cap( 'fcn_expire_passwords' );
|
||||
get_role( 'administrator' )->add_cap( 'fcn_crosspost' );
|
||||
|
||||
if ( $editor = get_role( 'editor' ) ) {
|
||||
$editor->add_cap( 'fcn_custom_page_header' );
|
||||
|
@ -1567,6 +1567,8 @@ function fictioneer_append_chapter_to_story( $post_id, $story_id, $force = false
|
||||
return;
|
||||
}
|
||||
|
||||
error_log( $post_id );
|
||||
|
||||
// Setup, continued
|
||||
$chapter_author_id = get_post_field( 'post_author', $post_id );
|
||||
$story_author_id = get_post_field( 'post_author', $story_id );
|
||||
@ -1576,6 +1578,8 @@ function fictioneer_append_chapter_to_story( $post_id, $story_id, $force = false
|
||||
return;
|
||||
}
|
||||
|
||||
error_log( 'force' );
|
||||
|
||||
// Get current story chapters
|
||||
$story_chapters = fictioneer_get_story_chapter_ids( $story_id );
|
||||
|
||||
|
@ -39,7 +39,8 @@ $editor_caps = array(
|
||||
'fcn_story_pages',
|
||||
'fcn_edit_date',
|
||||
'fcn_assign_patreon_tiers',
|
||||
'fcn_expire_passwords'
|
||||
'fcn_expire_passwords',
|
||||
'fcn_crosspost'
|
||||
);
|
||||
|
||||
$restrictions = array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user