true ) ); $post_types_option = Groups_Options::get_option( Groups_Post_Access_Legacy::POST_TYPES, array() ); foreach ( $post_types as $post_type ) { if ( !isset( $post_types_option[$post_type]['add_meta_box'] ) || $post_types_option[$post_type]['add_meta_box'] ) { if ( ( $post_type == 'attachment' ) ) { // filters to display the media's access restriction capabilities add_filter( 'manage_media_columns', array( __CLASS__, 'columns' ) ); // args: string $column_name, int $media_id add_action( 'manage_media_custom_column', array( __CLASS__, 'custom_column' ), 10, 2 ); } else { // filters to display the posts' access restriction capabilities add_filter( 'manage_' . $post_type . '_posts_columns', array( __CLASS__, 'columns' ) ); // args: string $column_name, int $post_id add_action( 'manage_' . $post_type . '_posts_custom_column', array( __CLASS__, 'custom_column' ), 10, 2 ); } } } } } /** * Adds a new column to the post type's table showing the access * restriction capabilities. * * @param array $column_headers * @return array column headers */ public static function columns( $column_headers ) { $column_headers[self::CAPABILITIES] = sprintf( __( 'Access Restrictions', 'groups' ), esc_attr( __( 'One or more capabilities required to read the entry.', 'groups' ) ) ); return $column_headers; } /** * Renders custom column content. * * @param string $column_name * @param int $post_id * @return string custom column content */ public static function custom_column( $column_name, $post_id ) { $output = ''; switch ( $column_name ) { case self::CAPABILITIES : $read_caps = get_post_meta( $post_id, Groups_Post_Access_Legacy::POSTMETA_PREFIX . Groups_Post_Access_Legacy::READ_POST_CAPABILITY ); $valid_read_caps = Groups_Options::get_option( Groups_Post_Access_Legacy::READ_POST_CAPABILITIES, array( Groups_Post_Access_Legacy::READ_POST_CAPABILITY ) ); if ( count( $valid_read_caps ) > 0 ) { sort( $valid_read_caps ); $output = '