Skip to content

Commit

Permalink
Fixed "Product type" dropdown on WP 5.5
Browse files Browse the repository at this point in the history
WP 5.5 doesn't introduce a <span> tag inside metaboxes headings
  • Loading branch information
claudiosanches committed Jul 29, 2020
1 parent d5bedd8 commit 97c7937
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
28 changes: 22 additions & 6 deletions assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4347,14 +4347,13 @@ img.help_tip {

span {
display: block;
vertical-align: middle;
line-height: 24px;
}

span {
display: inline;
line-height: inherit;
vertical-align: baseline;
}
.type_box {
display: inline;
line-height: inherit;
vertical-align: baseline;
}

select {
Expand Down Expand Up @@ -6819,6 +6818,23 @@ table.bar_chart {
}
}

.wc-wp-version-gte-55 {

#woocommerce-product-data {

.hndle {
display: block;
line-height: 24px;

.type_box {
display: inline;
line-height: inherit;
vertical-align: baseline;
}
}
}
}

/**
* Select2 colors for built-in admin color themes.
*/
Expand Down
6 changes: 5 additions & 1 deletion assets/js/admin/meta-boxes-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ jQuery( function( $ ) {
});

// Type box.
$( '.type_box' ).appendTo( '#woocommerce-product-data .hndle span' );
if ( $( 'body' ).hasClass( 'wc-wp-version-gte-55' ) ) {
$( '.type_box' ).appendTo( ' #woocommerce-product-data .hndle' );
} else {
$( '.type_box' ).appendTo( ' #woocommerce-product-data .hndle span' );
}

$( function() {
// Prevent inputs in meta box headings opening/closing contents.
Expand Down
5 changes: 5 additions & 0 deletions includes/admin/class-wc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ public function include_admin_body_class( $classes ) {
$classes .= ' wc-wp-version-gte-53';
}

// Add WP 5.5+ compatibility class.
if ( $raw_version && version_compare( $version, '5.5', '>=' ) ) {
$classes .= ' wc-wp-version-gte-55';
}

return $classes;
}
}
Expand Down

0 comments on commit 97c7937

Please sign in to comment.