Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions inc/class-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public function __construct() {
add_action( 'init', [ $this, 'register_post_type' ], 0 );
add_filter( 'allowed_block_types_all', [ $this, 'allow_post_types' ], PHP_INT_MAX, 2 );
add_action( 'init', [ $this, 'register_meta' ] );
add_filter( 'manage_release-note_posts_columns', [ $this, 'add_columns' ] );
add_action( 'manage_release-note_posts_custom_column', [ $this, 'add_column_data' ], 10, 2 );
}

/**
Expand Down Expand Up @@ -155,4 +157,33 @@ public function allow_post_types( array|bool $allowed_block_types, \WP_Block_Edi
default => $allowed_block_types,
};
}

/**
* Add column
*
* @param string $column - column name
* @param int $post_id - post id
* @return void
*/
public function add_columns( array $columns ): array {
$columns['version'] = __( 'Version', 'release-notes' );

return $columns;
}

/**
* Add column data
*
* @param string $column - column name
* @param int $post_id - post id
* @return void
*/
public function add_column_data( string $column, int $post_id ): void {
switch ( $column ) {
case 'version':
$version = get_post_meta( $post_id, 'version', true );
echo esc_html( $version );
break;
}
}
}
Loading