Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ORIGINAL CODE
- class Zone_List_Table extends WP_List_Table {
- function __construct(){
- global $status, $page;
- //Set parent defaults
- parent::__construct( array(
- 'singular' => 'zone',
- 'plural' => 'zones',
- 'ajax' => false
- ) );
- $this->shipping_zones = get_option( 'be_woocommerce_shipping_zones' );
- /* ISSUE
- * In some circumstances, at this point $this->shipping_zones is NULL,
- * even if get_option() returns a value. I ran extensive tests, in
- * some cases the following statement
- * var_dump(
- * get_option( 'be_woocommerce_shipping_zones' ),
- * $this->shipping_zones
- * )
- *
- * returns an array, followed by NULL, when the two values should instead
- * match.
- *
- * POSSIBLE CAUSES
- * I could not find the exact cause of the issue, but it seems to have
- * something to do with the WP_List_Table__set() and __get() magic
- * methods. Since property $shipping_zones does not exist, the magic
- * methods are fired and return incorrect values.
- *
- * SOLUTION
- * Declare the $shipping_zones property explicitly (see below).
- */
- }
- // FIXED CODE
- class Zone_List_Table extends WP_List_Table {
- // @var array An array containing the shipping zones
- public $shipping_zones;
- function __construct(){
- global $status, $page;
- //Set parent defaults
- parent::__construct( array(
- 'singular' => 'zone',
- 'plural' => 'zones',
- 'ajax' => false
- ) );
- $this->shipping_zones = get_option( 'be_woocommerce_shipping_zones' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement