mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed content restriction feature for "attachment" post types;
This commit is contained in:
@@ -105,6 +105,11 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
if ( ! empty( $post_types[ $current_screen->id ] ) ) {
|
||||
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
|
||||
add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
|
||||
|
||||
if ( $current_screen->id == 'attachment' ) {
|
||||
add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
|
||||
add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -180,6 +185,27 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
}
|
||||
|
||||
|
||||
function save_attachment_metabox_restrict_content( $post_id ) {
|
||||
// validate nonce
|
||||
if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) )
|
||||
return $post_id;
|
||||
|
||||
$post = get_post( $post_id );
|
||||
|
||||
// validate user
|
||||
$post_type = get_post_type_object( $post->post_type );
|
||||
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
|
||||
return $post_id;
|
||||
|
||||
if ( ! empty( $_POST['um_content_restriction'] ) )
|
||||
update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] );
|
||||
else
|
||||
delete_post_meta( $post_id, 'um_content_restriction' );
|
||||
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
|
||||
function um_category_access_fields_create() {
|
||||
$data = array();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user