fix PHP Fatal errors on lower PHP versions
Fatal error: Can't use method return value in write context
This commit is contained in:
parent
9668247b95
commit
0cf5fc4904
|
@ -104,6 +104,7 @@ class WC_HookFinder {
|
|||
|
||||
foreach ( $tokens as $index => $token ) {
|
||||
if ( is_array( $token ) ) {
|
||||
$trimmed_token_1 = trim( $token[1] )
|
||||
if ( T_CLASS == $token[0] ) {
|
||||
$token_type = 'class';
|
||||
} elseif ( T_FUNCTION == $token[0] ) {
|
||||
|
@ -112,7 +113,7 @@ class WC_HookFinder {
|
|||
$token_type = 'action';
|
||||
} elseif ( 'apply_filters' === $token[1] ) {
|
||||
$token_type = 'filter';
|
||||
} elseif ( $token_type && ! empty( trim( $token[1] ) ) ) {
|
||||
} elseif ( $token_type && ! empty( $trimmed_token_1 ) ) {
|
||||
switch ( $token_type ) {
|
||||
case 'class' :
|
||||
$current_class = $token[1];
|
||||
|
|
|
@ -242,6 +242,7 @@ class WC_CLI_Coupon extends WC_CLI_Command {
|
|||
}
|
||||
|
||||
$coupon_post = get_post( $coupon->get_id() );
|
||||
$coupon_usage_limit = $coupon->get_usage_limit();
|
||||
$coupon_data = array(
|
||||
'id' => $coupon->get_id(),
|
||||
'code' => $coupon->get_code(),
|
||||
|
@ -252,7 +253,7 @@ class WC_CLI_Coupon extends WC_CLI_Command {
|
|||
'individual_use' => $coupon->get_individual_use(),
|
||||
'product_ids' => implode( ', ', $coupon->get_product_ids() ),
|
||||
'exclude_product_ids' => implode( ', ', $coupon->get_excluded_product_ids() ),
|
||||
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit' => ( ! empty( $coupon_usage_limit ) ) ? $coupon_usage_limit : null,
|
||||
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
|
||||
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
|
||||
'usage_count' => (int) $coupon->get_usage_count(),
|
||||
|
@ -577,6 +578,9 @@ class WC_CLI_Coupon extends WC_CLI_Command {
|
|||
foreach ( $posts as $post ) {
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon->read( $post->ID );
|
||||
$coupon_usage_limit = $coupon->get_usage_limit();
|
||||
$coupon_usage_limit_per_user = $coupon->get_usage_limit_per_user();
|
||||
$coupon_date_expires = $coupon->get_date_expires();
|
||||
$items[] = array(
|
||||
'id' => $post->ID,
|
||||
'code' => $post->post_title,
|
||||
|
@ -587,11 +591,11 @@ class WC_CLI_Coupon extends WC_CLI_Command {
|
|||
'individual_use' => $coupon->get_individual_use(),
|
||||
'product_ids' => implode( ', ', is_array( $coupon->get_product_ids() ) ? $coupon->get_product_ids() : array() ),
|
||||
'exclude_product_ids' => implode( ', ', is_array( $coupon->get_excluded_product_ids() ) ? $coupon->get_excluded_product_ids() : array() ),
|
||||
'usage_limit' => ( ! empty( $coupon->get_usage_limit() ) ) ? $coupon->get_usage_limit() : null,
|
||||
'usage_limit_per_user' => ( ! empty( $coupon->get_usage_limit_per_user() ) ) ? $coupon->get_usage_limit_per_user() : null,
|
||||
'usage_limit' => ( ! empty( $coupon_usage_limit ) ) ? $coupon_usage_limit : null,
|
||||
'usage_limit_per_user' => ( ! empty( $coupon_usage_limit_per_user ) ) ? $coupon_usage_limit_per_user : null,
|
||||
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
|
||||
'usage_count' => (int) $coupon->get_usage_count(),
|
||||
'expiry_date' => ( ! empty( $coupon->get_date_expires() ) ) ? $this->format_datetime( $coupon->get_date_expires() ) : null,
|
||||
'expiry_date' => ( ! empty( $coupon_date_expires ) ) ? $this->format_datetime( $coupon_date_expires ) : null,
|
||||
'free_shipping' => $coupon->get_free_shipping(),
|
||||
'product_category_ids' => implode( ', ', is_array( $coupon->get_product_categories() ) ? $coupon->get_product_categories() : array() ),
|
||||
'exclude_product_category_ids' => implode( ', ', is_array( $coupon->get_excluded_product_categories() ) ? $coupon->get_excluded_product_categories() : array() ),
|
||||
|
|
Loading…
Reference in New Issue