Skip to content

Commit

Permalink
Fix Metabox Loop and Prefix Custom Post Types
Browse files Browse the repository at this point in the history
### Fixed
- Metabox loop now continues to next post type instead of immediately exiting process.
- Custom Post Types are now properly prefixed and checked on save.
  • Loading branch information
smileBeda committed May 29, 2024
1 parent 691d978 commit 5c35a92
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ This is NOT the changelog of the WordPress Plugin you ultimately develop!
### Fixed
- Incorrect author information in several files.
- Require `wp-admin/includes/file.php` if WP_Filesystem is unavailable.
- Save Metabox loop now continues to next post type instead of immediately exiting process.
- Custom Post Types are now properly prefixed and checked on save.

## [v5-alpha] - 2024-05-26

Expand Down
2 changes: 1 addition & 1 deletion src/src/registerables/metaboxes/class-base-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function save_custom_post_meta_box_data( int $post_id = 0 ): void {
|| $post_type !== $_POST['post_type']
|| ! current_user_can( 'edit_post', $post_id )
) {
return;
continue;
}

if ( isset( $_POST[ $this->get_key() ] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/src/registerables/metaboxes/class-example-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Example_Metabox extends Base_Metabox {
*/
protected function initialize_properties(): void {

$this->post_types = array( 'post', 'page', 'item' );
$this->post_types = array( 'post', 'page', Config::get( 'slug' ) . '-item' );
$this->context = array(
'post' => 'side',
'page' => 'normal',
Expand Down

0 comments on commit 5c35a92

Please sign in to comment.