Skip to content

Commit

Permalink
Improve use of get_current_screen since it returns NULL in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Isabel Castillo committed Dec 23, 2016
1 parent 56fb2c6 commit f9c58d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=me%40
Tags: custom product attributes, woocommerce product attributes, product attributes, custom attributes, woocommerce custom product attributes
Requires at least: 3.8
Tested up to: 4.7
Stable tag: 1.5.1
Stable tag: 1.5.2
License: GNU Version 2 or Any Later Version
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -117,6 +117,9 @@ Add this CSS:

== Changelog ==

= 1.5.2 =
* Fix - Improve use of get_current_screen since it returns NULL in some cases.

= 1.5.1 =
* Fix - Removed attributes from the admin main Orders page because it was ruining the HTML for the item names.

Expand Down Expand Up @@ -182,6 +185,9 @@ Add this CSS:
= 1.0 =
* Initial release.
== Upgrade Notice ==
= 1.5.2 =
Fix - Improve use of get_current_screen since it returns NULL in some cases.

= 1.5.1 =
Fix - Removed attributes from the admin main Orders page because it was ruining the HTML for the item names.

Expand Down
9 changes: 6 additions & 3 deletions woocommerce-show-attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: WooCommerce Show Attributes
Plugin URI: https://isabelcastillo.com/docs/category/woocommerce-show-attributes
Description: Show WooCommerce custom product attributes on the Product, Shop and Cart pages, admin Order Details page and emails.
Version: 1.5.1
Version: 1.5.2
Author: Isabel Castillo
Author URI: https://isabelcastillo.com
License: GPL2
Expand Down Expand Up @@ -276,8 +276,11 @@ public function show_atts_on_product_page() {
*/
public function show_atts_on_customer_order( $item_name, $item ) {
// Do not show this on the admin main Orders page
if ( function_exists( 'get_current_screen' ) && 'edit-shop_order' == get_current_screen()->id ) {
return $item_name;
if ( function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! empty( $screen ) && isset( $screen->id ) && 'edit-shop_order' == $screen->id ) {
return $item_name;
}
}

$show_weight = null;
Expand Down

0 comments on commit f9c58d7

Please sign in to comment.