Skip to content
23 changes: 23 additions & 0 deletions plugins/otter-pro/inc/plugins/class-woocommerce-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@
add_filter( 'wc_get_template_part', array( $this, 'wc_get_template_part' ), 1000, 3 );
add_action( 'otter_blocks_woocommerce_content', 'the_content' );
add_filter( 'body_class', array( $this, 'add_body_class' ), 1000, 1 );
add_action( 'enqueue_block_editor_assets', array( $this, 'show_meta_boxes_pane' ) );
}

/**
* Keep the Meta Boxes pane open by default in the block editor.
*
* Since WP 6.7 the iframed post editor renders meta boxes inside a bottom
* drawer that is collapsed unless the user opened it before. On builder
* products that hides the WooCommerce Product data panel (price, inventory
* etc.), so default the drawer to open. An explicit user preference is not
* overridden, as setDefaults only applies to unset preferences.
*
* @access public
*/
public function show_meta_boxes_pane() {

Check failure on line 47 in plugins/otter-pro/inc/plugins/class-woocommerce-builder.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method ThemeIsle\OtterPro\Plugins\WooCommerce_Builder::show_meta_boxes_pane() has no return type specified.
if ( 'product' !== get_post_type() || ! boolval( get_post_meta( get_the_ID(), '_themeisle_gutenberg_woo_builder', true ) ) ) {
Comment on lines +83 to +84

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 3bc2a95tests/test-woocommerce-builder.php creates the post contexts and inspects the wp-edit-post inline data: the default is present for a builder-enabled product and absent for both a product without the builder and a regular post.

return;
}

wp_add_inline_script(
'wp-edit-post',
'window.wp && wp.data && wp.data.dispatch( "core/preferences" ).setDefaults( "core/edit-post", { metaBoxesMainIsOpen: true } );'
);
}

/**
Expand Down
Loading