Merge pull request #7834 from SiR-DanieL/scrutinizer-issues

Small tweaks and style fixes
This commit is contained in:
Mike Jolley 2015-03-30 10:33:27 +01:00
commit c6dae2b286
23 changed files with 751 additions and 678 deletions

View File

@ -135,7 +135,7 @@ abstract class WC_Abstract_Order {
public function remove_order_items( $type = null ) {
global $wpdb;
if ( $type ) {
if ( ! empty( $type ) ) {
$wpdb->query( $wpdb->prepare( "DELETE FROM itemmeta USING {$wpdb->prefix}woocommerce_order_itemmeta itemmeta INNER JOIN {$wpdb->prefix}woocommerce_order_items items WHERE itemmeta.order_item_id = items.order_item_id AND items.order_id = %d AND items.order_item_type = %s", $this->id, $type ) );
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d AND order_item_type = %s", $this->id, $type ) );
} else {
@ -645,7 +645,7 @@ abstract class WC_Abstract_Order {
'tax_class' => ''
) );
if ( $tax_rates ) {
if ( ! empty( $tax_rates ) ) {
foreach ( $tax_rates as $key => $rate ) {
if ( isset( $rate['shipping'] ) && 'yes' === $rate['shipping'] ) {
$matched_tax_rates[ $key ] = $rate;
@ -1184,7 +1184,7 @@ abstract class WC_Abstract_Order {
$shipping_methods = $this->get_shipping_methods();
$has_method = false;
if ( ! $shipping_methods ) {
if ( empty( $shipping_methods ) ) {
return false;
}

View File

@ -337,7 +337,7 @@ class WC_Product {
$downloadable_files = array_filter( isset( $this->downloadable_files ) ? (array) maybe_unserialize( $this->downloadable_files ) : array() );
if ( $downloadable_files ) {
if ( ! empty( $downloadable_files ) ) {
foreach ( $downloadable_files as $key => $file ) {
@ -1223,23 +1223,9 @@ class WC_Product {
public function get_related( $limit = 5 ) {
global $wpdb;
$limit = absint( $limit );
// Related products are found from category and tag
$tags_array = array(0);
$cats_array = array(0);
// Get tags
$terms = apply_filters( 'woocommerce_get_related_product_tag_terms', wp_get_post_terms( $this->id, 'product_tag' ), $this->id );
foreach ( $terms as $term ) {
$tags_array[] = $term->term_id;
}
// Get categories
$terms = apply_filters( 'woocommerce_get_related_product_cat_terms', wp_get_post_terms( $this->id, 'product_cat' ), $this->id );
foreach ( $terms as $term ) {
$cats_array[] = $term->term_id;
}
$tags_array = $this->get_related_terms( 'product_tag' );
$cats_array = $this->get_related_terms( 'product_cat' );
// Don't bother if none are set
if ( sizeof( $cats_array ) == 1 && sizeof( $tags_array ) == 1 ) {
@ -1247,60 +1233,10 @@ class WC_Product {
}
// Sanitize
$cats_array = array_map( 'absint', $cats_array );
$tags_array = array_map( 'absint', $tags_array );
$exclude_ids = array_map( 'absint', array_merge( array( 0, $this->id ), $this->get_upsells() ) );
// Generate query
$query = array();
$query['fields'] = "SELECT DISTINCT ID FROM {$wpdb->posts} p";
$query['join'] = " INNER JOIN {$wpdb->postmeta} pm ON ( pm.post_id = p.ID AND pm.meta_key='_visibility' )";
$query['join'] .= " INNER JOIN {$wpdb->term_relationships} tr ON (p.ID = tr.object_id)";
$query['join'] .= " INNER JOIN {$wpdb->term_taxonomy} tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)";
$query['join'] .= " INNER JOIN {$wpdb->terms} t ON (t.term_id = tt.term_id)";
if ( get_option( 'woocommerce_hide_out_of_stock_items' ) === 'yes' ) {
$query['join'] .= " INNER JOIN {$wpdb->postmeta} pm2 ON ( pm2.post_id = p.ID AND pm2.meta_key='_stock_status' )";
}
$query['where'] = " WHERE 1=1";
$query['where'] .= " AND p.post_status = 'publish'";
$query['where'] .= " AND p.post_type = 'product'";
$query['where'] .= " AND p.ID NOT IN ( " . implode( ',', $exclude_ids ) . " )";
$query['where'] .= " AND pm.meta_value IN ( 'visible', 'catalog' )";
if ( get_option( 'woocommerce_hide_out_of_stock_items' ) === 'yes' ) {
$query['where'] .= " AND pm2.meta_value = 'instock'";
}
if ( apply_filters( 'woocommerce_product_related_posts_relate_by_category', true, $this->id ) ) {
$query['where'] .= " AND ( tt.taxonomy = 'product_cat' AND t.term_id IN ( " . implode( ',', $cats_array ) . " ) )";
$andor = 'OR';
} else {
$andor = 'AND';
}
// when query is OR - need to check against excluded ids again
if ( apply_filters( 'woocommerce_product_related_posts_relate_by_tag', true, $this->id ) ) {
$query['where'] .= " {$andor} ( ( tt.taxonomy = 'product_tag' AND t.term_id IN ( " . implode( ',', $tags_array ) . " ) )";
$query['where'] .= " AND p.ID NOT IN ( " . implode( ',', $exclude_ids ) . " ) )";
}
$query = apply_filters( 'woocommerce_product_related_posts_query', $query, $this->id );
// How many rows total?
$max_related_posts_transient_name = 'wc_max_related_' . $this->id . WC_Cache_Helper::get_transient_version( 'product' );
if ( false === ( $max_related_posts = get_transient( $max_related_posts_transient_name ) ) ) {
$max_related_posts_query = $query;
$max_related_posts_query['fields'] = "SELECT COUNT(DISTINCT ID) FROM {$wpdb->posts} p";
$max_related_posts = absint( $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_product_max_related_posts_query', $max_related_posts_query, $this->id ) ) ) );
set_transient( $max_related_posts_transient_name, $max_related_posts, DAY_IN_SECONDS * 30 );
}
// Generate limit
$offset = $max_related_posts < $limit ? 0 : absint( rand( 0, $max_related_posts - $limit ) );
$query['limits'] = " LIMIT {$offset}, {$limit} ";
$query = $this->build_related_query( $cats_array, $tags_array, $exclude_ids, $limit );
// Get the posts
$related_posts = $wpdb->get_col( implode( ' ', $query ) );
@ -1505,4 +1441,88 @@ class WC_Product {
return sprintf( __( '%s &ndash; %s', 'woocommerce' ), $identifier, $this->get_title() );
}
/**
* Retrieves related product terms
*
* @param string $term
* @return array
*/
protected function get_related_terms( $term ) {
$terms_array = array(0);
$terms = apply_filters( 'woocommerce_get_related_' . $term . '_terms', wp_get_post_terms( $this->id, $term ), $this->id );
foreach ( $terms as $term ) {
$terms_array[] = $term->term_id;
}
return array_map( 'absint', $terms_array );
}
/**
* Builds the related posts query
*
* @param array $cats_array
* @param array $tags_array
* @param array $exclude_ids
* @param int $limit
* @return string
*/
protected function build_related_query( $cats_array, $tags_array, $exclude_ids, $limit ) {
global $wpdb;
$limit = absint( $limit );
$query = array();
$query['fields'] = "SELECT DISTINCT ID FROM {$wpdb->posts} p";
$query['join'] = " INNER JOIN {$wpdb->postmeta} pm ON ( pm.post_id = p.ID AND pm.meta_key='_visibility' )";
$query['join'] .= " INNER JOIN {$wpdb->term_relationships} tr ON (p.ID = tr.object_id)";
$query['join'] .= " INNER JOIN {$wpdb->term_taxonomy} tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)";
$query['join'] .= " INNER JOIN {$wpdb->terms} t ON (t.term_id = tt.term_id)";
if ( get_option( 'woocommerce_hide_out_of_stock_items' ) === 'yes' ) {
$query['join'] .= " INNER JOIN {$wpdb->postmeta} pm2 ON ( pm2.post_id = p.ID AND pm2.meta_key='_stock_status' )";
}
$query['where'] = " WHERE 1=1";
$query['where'] .= " AND p.post_status = 'publish'";
$query['where'] .= " AND p.post_type = 'product'";
$query['where'] .= " AND p.ID NOT IN ( " . implode( ',', $exclude_ids ) . " )";
$query['where'] .= " AND pm.meta_value IN ( 'visible', 'catalog' )";
if ( get_option( 'woocommerce_hide_out_of_stock_items' ) === 'yes' ) {
$query['where'] .= " AND pm2.meta_value = 'instock'";
}
if ( apply_filters( 'woocommerce_product_related_posts_relate_by_category', true, $this->id ) ) {
$query['where'] .= " AND ( tt.taxonomy = 'product_cat' AND t.term_id IN ( " . implode( ',', $cats_array ) . " ) )";
$andor = 'OR';
} else {
$andor = 'AND';
}
// when query is OR - need to check against excluded ids again
if ( apply_filters( 'woocommerce_product_related_posts_relate_by_tag', true, $this->id ) ) {
$query['where'] .= " {$andor} ( ( tt.taxonomy = 'product_tag' AND t.term_id IN ( " . implode( ',', $tags_array ) . " ) )";
$query['where'] .= " AND p.ID NOT IN ( " . implode( ',', $exclude_ids ) . " ) )";
}
$query = apply_filters( 'woocommerce_product_related_posts_query', $query, $this->id );
// How many rows total?
$max_related_posts_transient_name = 'wc_max_related_' . $this->id . WC_Cache_Helper::get_transient_version( 'product' );
if ( false === ( $max_related_posts = get_transient( $max_related_posts_transient_name ) ) ) {
$max_related_posts_query = $query;
$max_related_posts_query['fields'] = "SELECT COUNT(DISTINCT ID) FROM {$wpdb->posts} p";
$max_related_posts = absint( $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_product_max_related_posts_query', $max_related_posts_query, $this->id ) ) ) );
set_transient( $max_related_posts_transient_name, $max_related_posts, DAY_IN_SECONDS * 30 );
}
// Generate limit
$offset = $max_related_posts < $limit ? 0 : absint( rand( 0, $max_related_posts - $limit ) );
$query['limits'] = " LIMIT {$offset}, {$limit} ";
return $query;
}
}

View File

@ -159,7 +159,7 @@ abstract class WC_Settings_API {
}
}
if ( $this->settings && is_array( $this->settings ) ) {
if ( ! empty( $this->settings ) && is_array( $this->settings ) ) {
$this->settings = array_map( array( $this, 'format_settings' ), $this->settings );
$this->enabled = isset( $this->settings['enabled'] ) && $this->settings['enabled'] == 'yes' ? 'yes' : 'no';
}
@ -215,7 +215,7 @@ abstract class WC_Settings_API {
*/
public function generate_settings_html( $form_fields = array() ) {
if ( ! $form_fields ) {
if ( empty( $form_fields ) ) {
$form_fields = $this->get_form_fields();
}
@ -726,7 +726,7 @@ abstract class WC_Settings_API {
*/
public function validate_settings_fields( $form_fields = array() ) {
if ( ! $form_fields ) {
if ( empty( $form_fields ) ) {
$form_fields = $this->get_form_fields();
}

View File

@ -139,7 +139,7 @@ abstract class WC_Widget extends WP_Widget {
$instance = $old_instance;
if ( ! $this->settings ) {
if ( empty( $this->settings ) ) {
return $instance;
}
@ -165,7 +165,7 @@ abstract class WC_Widget extends WP_Widget {
*/
public function form( $instance ) {
if ( ! $this->settings ) {
if ( empty( $this->settings ) ) {
return;
}

View File

@ -50,42 +50,7 @@ class WC_Customer {
if ( empty( $this->_data ) ) {
// Defaults
$this->_data = array(
'postcode' => '',
'city' => '',
'address' => '',
'address_2' => '',
'state' => '',
'country' => '',
'shipping_postcode' => '',
'shipping_city' => '',
'shipping_address' => '',
'shipping_address_2' => '',
'shipping_state' => '',
'shipping_country' => '',
'is_vat_exempt' => false,
'calculated_shipping' => false
);
if ( is_user_logged_in() ) {
foreach ( $this->_data as $key => $value ) {
$meta_value = get_user_meta( get_current_user_id(), ( false === strstr( $key, 'shipping_' ) ? 'billing_' : '' ) . $key, true );
$this->_data[ $key ] = $meta_value ? $meta_value : $this->_data[ $key ];
}
}
if ( empty( $this->_data['country'] ) ) {
$this->_data['country'] = $this->get_default_country();
}
if ( empty( $this->_data['shipping_country'] ) ) {
$this->_data['shipping_country'] = $this->get_default_country();
}
if ( empty( $this->_data['state'] ) ) {
$this->_data['state'] = $this->get_default_state();
}
if ( empty( $this->_data['shipping_state'] ) ) {
$this->_data['shipping_state'] = $this->get_default_state();
}
$this->set_default_data();
}
// When leaving or ending page load, store data
@ -134,6 +99,7 @@ class WC_Customer {
/**
* Get default country for a customer
*
* @return string
*/
public function get_default_country() {
@ -143,6 +109,7 @@ class WC_Customer {
/**
* Get default state for a customer
*
* @return string
*/
public function get_default_state() {
@ -373,6 +340,51 @@ class WC_Customer {
return apply_filters( 'woocommerce_customer_taxable_address', array( $country, $state, $postcode, $city ) );
}
/**
* Set default data for a customer
*/
public function set_default_data() {
$this->_data = array(
'postcode' => '',
'city' => '',
'address' => '',
'address_2' => '',
'state' => '',
'country' => '',
'shipping_postcode' => '',
'shipping_city' => '',
'shipping_address' => '',
'shipping_address_2' => '',
'shipping_state' => '',
'shipping_country' => '',
'is_vat_exempt' => false,
'calculated_shipping' => false
);
if ( is_user_logged_in() ) {
foreach ( $this->_data as $key => $value ) {
$meta_value = get_user_meta( get_current_user_id(), ( false === strstr( $key, 'shipping_' ) ? 'billing_' : '' ) . $key, true );
$this->_data[ $key ] = $meta_value ? $meta_value : $this->_data[ $key ];
}
}
if ( empty( $this->_data['country'] ) ) {
$this->_data['country'] = $this->get_default_country();
}
if ( empty( $this->_data['shipping_country'] ) ) {
$this->_data['shipping_country'] = $this->get_default_country();
}
if ( empty( $this->_data['state'] ) ) {
$this->_data['state'] = $this->get_default_state();
}
if ( empty( $this->_data['shipping_state'] ) ) {
$this->_data['shipping_state'] = $this->get_default_state();
}
}
/**
* Sets session data for the location.

View File

@ -650,7 +650,7 @@ class WC_Form_Handler {
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity, $variation_id, $variations );
if ( $passed_validation ) {
if ( WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ) ) {
if ( WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ) !== false ) {
wc_add_to_cart_message( $product_id );
$was_added_to_cart = true;
$added_to_cart[] = $product_id;
@ -676,7 +676,7 @@ class WC_Form_Handler {
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $item, $quantity );
if ( $passed_validation ) {
if ( WC()->cart->add_to_cart( $item, $quantity ) ) {
if ( WC()->cart->add_to_cart( $item, $quantity ) !== false ) {
$was_added_to_cart = true;
$added_to_cart[] = $item;
}
@ -716,7 +716,7 @@ class WC_Form_Handler {
if ( $passed_validation ) {
// Add the product to the cart
if ( WC()->cart->add_to_cart( $product_id, $quantity ) ) {
if ( WC()->cart->add_to_cart( $product_id, $quantity ) !== false ) {
wc_add_to_cart_message( $product_id );
$was_added_to_cart = true;
$added_to_cart[] = $product_id;

View File

@ -1122,131 +1122,148 @@ class WC_Geo_IP {
private function _setup_segments() {
$this->databaseType = self::GEOIP_COUNTRY_EDITION;
$this->record_length = self::STANDARD_RECORD_LENGTH;
if ($this->flags & self::GEOIP_SHARED_MEMORY) {
$offset = @shmop_size($this->shmid) - 3;
for ($i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++) {
$delim = @shmop_read($this->shmid, $offset, 3);
if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
$offset = @shmop_size( $this->shmid ) - 3;
for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) {
$delim = @shmop_read( $this->shmid, $offset, 3 );
$offset += 3;
if ($delim == (chr(255) . chr(255) . chr(255))) {
$this->databaseType = ord(@shmop_read($this->shmid, $offset, 1));
if ($this->databaseType >= 106) {
if ( $delim == ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) ) {
$this->databaseType = ord( @shmop_read( $this->shmid, $offset, 1 ) );
if ( $this->databaseType >= 106 ) {
$this->databaseType -= 105;
}
$offset++;
if ($this->databaseType == self::GEOIP_REGION_EDITION_REV0) {
if ( $this->databaseType == self::GEOIP_REGION_EDITION_REV0 ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
} elseif ($this->databaseType == self::GEOIP_REGION_EDITION_REV1) {
} elseif ( $this->databaseType == self::GEOIP_REGION_EDITION_REV1 ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
} elseif (($this->databaseType == self::GEOIP_CITY_EDITION_REV0)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV1)
|| ($this->databaseType == self::GEOIP_ORG_EDITION)
|| ($this->databaseType == self::GEOIP_ORG_EDITION_V6)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION_V6)
|| ($this->databaseType == self::GEOIP_ISP_EDITION)
|| ($this->databaseType == self::GEOIP_ISP_EDITION_V6)
|| ($this->databaseType == self::GEOIP_USERTYPE_EDITION)
|| ($this->databaseType == self::GEOIP_USERTYPE_EDITION_V6)
|| ($this->databaseType == self::GEOIP_LOCATIONA_EDITION)
|| ($this->databaseType == self::GEOIP_ACCURACYRADIUS_EDITION)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6)
|| ($this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1)
|| ($this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1_V6)
|| ($this->databaseType == self::GEOIP_ASNUM_EDITION)
|| ($this->databaseType == self::GEOIP_ASNUM_EDITION_V6)
} elseif ( ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_LOCATIONA_EDITION )
|| ( $this->databaseType == self::GEOIP_ACCURACYRADIUS_EDITION )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION_V6 )
) {
$this->databaseSegments = 0;
$buf = @shmop_read($this->shmid, $offset, self::SEGMENT_RECORD_LENGTH);
for ($j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++) {
$this->databaseSegments += (ord($buf[$j]) << ($j * 8));
$buf = @shmop_read( $this->shmid, $offset, self::SEGMENT_RECORD_LENGTH );
for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) {
$this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) );
}
if (($this->databaseType == self::GEOIP_ORG_EDITION)
|| ($this->databaseType == self::GEOIP_ORG_EDITION_V6)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION_V6)
|| ($this->databaseType == self::GEOIP_ISP_EDITION)
|| ($this->databaseType == self::GEOIP_ISP_EDITION_V6)
if ( ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
) {
$this->record_length = self::ORG_RECORD_LENGTH;
}
}
break;
} else {
$offset -= 4;
}
}
if (($this->databaseType == self::GEOIP_COUNTRY_EDITION) ||
($this->databaseType == self::GEOIP_COUNTRY_EDITION_V6) ||
($this->databaseType == self::GEOIP_PROXY_EDITION) ||
($this->databaseType == self::GEOIP_NETSPEED_EDITION)
if ( ( $this->databaseType == self::GEOIP_COUNTRY_EDITION )
|| ( $this->databaseType == self::GEOIP_COUNTRY_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_PROXY_EDITION )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION )
) {
$this->databaseSegments = self::GEOIP_COUNTRY_BEGIN;
}
} else {
$filepos = ftell($this->filehandle);
fseek($this->filehandle, -3, SEEK_END);
for ($i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++) {
$delim = fread($this->filehandle, 3);
if ($delim == (chr(255) . chr(255) . chr(255))) {
$this->databaseType = ord(fread($this->filehandle, 1));
if ($this->databaseType >= 106) {
$filepos = ftell( $this->filehandle );
fseek( $this->filehandle, -3, SEEK_END );
for ( $i = 0; $i < self::STRUCTURE_INFO_MAX_SIZE; $i++ ) {
$delim = fread( $this->filehandle, 3 );
if ( $delim == ( chr( 255 ) . chr( 255 ) . chr( 255 ) ) ) {
$this->databaseType = ord( fread( $this->filehandle, 1 ) );
if ( $this->databaseType >= 106 ) {
$this->databaseType -= 105;
}
if ($this->databaseType == self::GEOIP_REGION_EDITION_REV0) {
if ( $this->databaseType == self::GEOIP_REGION_EDITION_REV0 ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
} elseif ($this->databaseType == self::GEOIP_REGION_EDITION_REV1) {
} elseif ( $this->databaseType == self::GEOIP_REGION_EDITION_REV1 ) {
$this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
} elseif (($this->databaseType == self::GEOIP_CITY_EDITION_REV0)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV1)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6)
|| ($this->databaseType == self::GEOIP_ORG_EDITION)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION)
|| ($this->databaseType == self::GEOIP_ISP_EDITION)
|| ($this->databaseType == self::GEOIP_ORG_EDITION_V6)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION_V6)
|| ($this->databaseType == self::GEOIP_ISP_EDITION_V6)
|| ($this->databaseType == self::GEOIP_LOCATIONA_EDITION)
|| ($this->databaseType == self::GEOIP_ACCURACYRADIUS_EDITION)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6)
|| ($this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6)
|| ($this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1)
|| ($this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1_V6)
|| ($this->databaseType == self::GEOIP_USERTYPE_EDITION)
|| ($this->databaseType == self::GEOIP_USERTYPE_EDITION_V6)
|| ($this->databaseType == self::GEOIP_ASNUM_EDITION)
|| ($this->databaseType == self::GEOIP_ASNUM_EDITION_V6)
} elseif ( ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_LOCATIONA_EDITION )
|| ( $this->databaseType == self::GEOIP_ACCURACYRADIUS_EDITION )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV0_V6 )
|| ( $this->databaseType == self::GEOIP_CITY_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1 )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION_REV1_V6 )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION )
|| ( $this->databaseType == self::GEOIP_USERTYPE_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION )
|| ( $this->databaseType == self::GEOIP_ASNUM_EDITION_V6 )
) {
$this->databaseSegments = 0;
$buf = fread($this->filehandle, self::SEGMENT_RECORD_LENGTH);
for ($j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++) {
$this->databaseSegments += (ord($buf[$j]) << ($j * 8));
$buf = fread( $this->filehandle, self::SEGMENT_RECORD_LENGTH );
for ( $j = 0; $j < self::SEGMENT_RECORD_LENGTH; $j++ ) {
$this->databaseSegments += ( ord( $buf[ $j ] ) << ( $j * 8 ) );
}
if (($this->databaseType == self::GEOIP_ORG_EDITION)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION)
|| ($this->databaseType == self::GEOIP_ISP_EDITION)
|| ($this->databaseType == self::GEOIP_ORG_EDITION_V6)
|| ($this->databaseType == self::GEOIP_DOMAIN_EDITION_V6)
|| ($this->databaseType == self::GEOIP_ISP_EDITION_V6)
if ( ( $this->databaseType == self::GEOIP_ORG_EDITION )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION )
|| ( $this->databaseType == self::GEOIP_ORG_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_DOMAIN_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_ISP_EDITION_V6 )
) {
$this->record_length = self::ORG_RECORD_LENGTH;
}
}
break;
} else {
fseek($this->filehandle, -4, SEEK_CUR);
fseek( $this->filehandle, -4, SEEK_CUR );
}
}
if (($this->databaseType == self::GEOIP_COUNTRY_EDITION) ||
($this->databaseType == self::GEOIP_COUNTRY_EDITION_V6) ||
($this->databaseType == self::GEOIP_PROXY_EDITION) ||
($this->databaseType == self::GEOIP_NETSPEED_EDITION)
if ( ( $this->databaseType == self::GEOIP_COUNTRY_EDITION )
|| ( $this->databaseType == self::GEOIP_COUNTRY_EDITION_V6 )
|| ( $this->databaseType == self::GEOIP_PROXY_EDITION )
|| ( $this->databaseType == self::GEOIP_NETSPEED_EDITION )
) {
$this->databaseSegments = self::GEOIP_COUNTRY_BEGIN;
}
fseek($this->filehandle, $filepos, SEEK_SET);
fseek( $this->filehandle, $filepos, SEEK_SET );
}
return $this;
@ -1263,92 +1280,109 @@ class WC_Geo_IP {
private function _common_get_record( $seek_country ) {
// workaround php's broken substr, strpos, etc handling with
// mbstring.func_overload and mbstring.internal_encoding
$mbExists = extension_loaded('mbstring');
if ($mbExists) {
$mbExists = extension_loaded( 'mbstring' );
if ( $mbExists ) {
$enc = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
mb_internal_encoding( 'ISO-8859-1' );
}
$record_pointer = $seek_country + (2 * $this->record_length - 1) * $this->databaseSegments;
$record_pointer = $seek_country + ( 2 * $this->record_length - 1 ) * $this->databaseSegments;
if ($this->flags & self::GEOIP_MEMORY_CACHE) {
$record_buf = substr($this->memory_buffer, $record_pointer, FULL_RECORD_LENGTH);
} elseif ($this->flags & self::GEOIP_SHARED_MEMORY) {
$record_buf = @shmop_read($this->shmid, $record_pointer, FULL_RECORD_LENGTH);
if ( $this->flags & self::GEOIP_MEMORY_CACHE ) {
$record_buf = substr( $this->memory_buffer, $record_pointer, FULL_RECORD_LENGTH );
} elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
$record_buf = @shmop_read( $this->shmid, $record_pointer, FULL_RECORD_LENGTH );
} else {
fseek($this->filehandle, $record_pointer, SEEK_SET);
$record_buf = fread($this->filehandle, FULL_RECORD_LENGTH);
fseek( $this->filehandle, $record_pointer, SEEK_SET );
$record_buf = fread( $this->filehandle, FULL_RECORD_LENGTH );
}
$record = new WC_Geo_IP_Record();
$record_buf_pos = 0;
$char = ord(substr($record_buf, $record_buf_pos, 1));
$record->country_code = $this->GEOIP_COUNTRY_CODES[$char];
$record->country_code3 = $this->GEOIP_COUNTRY_CODES3[$char];
$record->country_name = $this->GEOIP_COUNTRY_NAMES[$char];
$record->continent_code = $this->GEOIP_CONTINENT_CODES[$char];
$record_buf_pos++;
$char = ord( substr( $record_buf, $record_buf_pos, 1 ) );
$record->country_code = $this->GEOIP_COUNTRY_CODES[ $char ];
$record->country_code3 = $this->GEOIP_COUNTRY_CODES3[ $char ];
$record->country_name = $this->GEOIP_COUNTRY_NAMES[ $char ];
$record->continent_code = $this->GEOIP_CONTINENT_CODES[ $char ];
$str_length = 0;
$record_buf_pos++;
// Get region
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
while ($char != 0) {
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
while ( $char != 0 ) {
$str_length++;
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
}
if ($str_length > 0) {
$record->region = substr($record_buf, $record_buf_pos, $str_length);
if ( $str_length > 0 ) {
$record->region = substr( $record_buf, $record_buf_pos, $str_length );
}
$record_buf_pos += $str_length + 1;
$str_length = 0;
// Get city
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
while ($char != 0) {
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
while ( $char != 0 ) {
$str_length++;
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
}
if ($str_length > 0) {
$record->city = substr($record_buf, $record_buf_pos, $str_length);
if ( $str_length > 0 ) {
$record->city = substr( $record_buf, $record_buf_pos, $str_length );
}
$record_buf_pos += $str_length + 1;
$str_length = 0;
// Get postal code
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
while ($char != 0) {
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
while ( $char != 0 ) {
$str_length++;
$char = ord(substr($record_buf, $record_buf_pos + $str_length, 1));
$char = ord( substr( $record_buf, $record_buf_pos + $str_length, 1 ) );
}
if ($str_length > 0) {
$record->postal_code = substr($record_buf, $record_buf_pos, $str_length);
if ( $str_length > 0 ) {
$record->postal_code = substr( $record_buf, $record_buf_pos, $str_length );
}
$record_buf_pos += $str_length + 1;
$str_length = 0;
// Get latitude and longitude
$latitude = 0;
$longitude = 0;
for ($j = 0; $j < 3; ++$j) {
$char = ord(substr($record_buf, $record_buf_pos++, 1));
$latitude += ($char << ($j * 8));
for ( $j = 0; $j < 3; ++$j ) {
$char = ord( substr( $record_buf, $record_buf_pos++, 1 ) );
$latitude += ( $char << ( $j * 8 ) );
}
$record->latitude = ($latitude / 10000) - 180;
for ($j = 0; $j < 3; ++$j) {
$char = ord(substr($record_buf, $record_buf_pos++, 1));
$longitude += ($char << ($j * 8));
$record->latitude = ( $latitude / 10000 ) - 180;
for ( $j = 0; $j < 3; ++$j ) {
$char = ord( substr( $record_buf, $record_buf_pos++, 1 ) );
$longitude += ( $char << ( $j * 8 ) );
}
$record->longitude = ($longitude / 10000) - 180;
if (self::GEOIP_CITY_EDITION_REV1 == $this->databaseType) {
$record->longitude = ( $longitude / 10000 ) - 180;
if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) {
$metroarea_combo = 0;
if ($record->country_code == "US") {
for ($j = 0; $j < 3; ++$j) {
$char = ord(substr($record_buf, $record_buf_pos++, 1));
$metroarea_combo += ($char << ($j * 8));
if ( $record->country_code == "US" ) {
for ( $j = 0; $j < 3; ++$j ) {
$char = ord( substr( $record_buf, $record_buf_pos++, 1 ) );
$metroarea_combo += ( $char << ( $j * 8 ) );
}
$record->metro_code = $record->dma_code = floor($metroarea_combo / 1000);
$record->metro_code = $record->dma_code = floor( $metroarea_combo / 1000 );
$record->area_code = $metroarea_combo % 1000;
}
}
if ($mbExists) {
mb_internal_encoding($enc);
if ( $mbExists ) {
mb_internal_encoding( $enc );
}
return $record;
}
@ -1357,48 +1391,55 @@ class WC_Geo_IP {
if ( $seek_country == $this->databaseSegments ) {
return null;
}
return $this->_common_get_record( $seek_country );
}
private function _geoip_seek_country( $ipnum ) {
$offset = 0;
for ($depth = 31; $depth >= 0; --$depth) {
if ($this->flags & self::GEOIP_MEMORY_CACHE) {
for ( $depth = 31; $depth >= 0; --$depth ) {
if ( $this->flags & self::GEOIP_MEMORY_CACHE ) {
$buf = $this->_safe_substr(
$this->memory_buffer,
2 * $this->record_length * $offset,
2 * $this->record_length
);
} elseif ($this->flags & self::GEOIP_SHARED_MEMORY) {
} elseif ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
$buf = @shmop_read(
$this->shmid,
2 * $this->record_length * $offset,
2 * $this->record_length
);
} else {
fseek($this->filehandle, 2 * $this->record_length * $offset, SEEK_SET) == 0
or trigger_error("GeoIP API: fseek failed", E_USER_ERROR);
$buf = fread($this->filehandle, 2 * $this->record_length);
fseek( $this->filehandle, 2 * $this->record_length * $offset, SEEK_SET ) == 0
or trigger_error( "GeoIP API: fseek failed", E_USER_ERROR );
$buf = fread( $this->filehandle, 2 * $this->record_length );
}
$x = array(0, 0);
for ($i = 0; $i < 2; ++$i) {
for ($j = 0; $j < $this->record_length; ++$j) {
$x[$i] += ord($buf[$this->record_length * $i + $j]) << ($j * 8);
$x = array( 0, 0 );
for ( $i = 0; $i < 2; ++$i ) {
for ( $j = 0; $j < $this->record_length; ++$j ) {
$x[ $i ] += ord( $buf[ $this->record_length * $i + $j ] ) << ( $j * 8 );
}
}
if ($ipnum & (1 << $depth)) {
if ($x[1] >= $this->databaseSegments) {
if ( $ipnum & ( 1 << $depth ) ) {
if ( $x[1] >= $this->databaseSegments ) {
return $x[1];
}
$offset = $x[1];
} else {
if ($x[0] >= $this->databaseSegments) {
if ( $x[0] >= $this->databaseSegments ) {
return $x[0];
}
$offset = $x[0];
}
}
trigger_error("GeoIP API: Error traversing database - perhaps it is corrupt?", E_USER_ERROR);
trigger_error( "GeoIP API: Error traversing database - perhaps it is corrupt?", E_USER_ERROR );
return false;
}
@ -1406,6 +1447,7 @@ class WC_Geo_IP {
if ( $addr == null ) {
return 0;
}
$ipnum = ip2long( $addr );
return $this->_get_record( $ipnum );
}
@ -1427,6 +1469,7 @@ class WC_Geo_IP {
return $this->GEOIP_COUNTRY_CODES[ $country_id ];
}
}
return false;
}

View File

@ -75,7 +75,7 @@ class WC_Product_Factory {
/**
* Get the product object
* @param mixed $the_product
* @uses WP_POST
* @uses WP_Post
* @return WP_Post|bool false on failure
*/
private function get_product_object( $the_product ) {

View File

@ -35,7 +35,7 @@ class WC_Query {
/** @public array Product IDs that match the layered nav + price filter */
public $post__in = array();
/** @public array The meta query for the page */
/** @public array|string The meta query for the page */
public $meta_query = '';
/** @public array Post IDs matching layered nav only */

View File

@ -269,6 +269,7 @@ class WC_Tracker {
foreach ( $product_statuses as $product_status ) {
$product_count[ $product_status->name ] = $product_status->count;
}
return $product_count;
}
@ -283,6 +284,7 @@ class WC_Tracker {
foreach ( wc_get_order_statuses() as $status_slug => $status_name ) {
$order_count[ $status_slug ] = $order_count_data->{ $status_slug };
}
return $order_count;
}
@ -298,6 +300,7 @@ class WC_Tracker {
$active_gateways[ $id ] = array( 'title' => $gateway->title, 'supports' => $gateway->supports );
}
}
return $active_gateways;
}
@ -313,6 +316,7 @@ class WC_Tracker {
$active_methods[ $id ] = array( 'title' => $shipping_method->title, 'tax_status' => $shipping_method->tax_status );
}
}
return $active_methods;
}
@ -370,7 +374,8 @@ class WC_Tracker {
} else {
$theme_file = false;
}
if ( $theme_file ) {
if ( $theme_file !== false ) {
$override_data[] = basename( $theme_file );
}
}

View File

@ -78,11 +78,12 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
* @return string
*/
function get_subject() {
if ( ! empty( $this->object ) && $this->object->has_downloadable_item() )
if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) {
return apply_filters( 'woocommerce_email_subject_customer_completed_order', $this->format_string( $this->subject_downloadable ), $this->object );
else
} else {
return apply_filters( 'woocommerce_email_subject_customer_completed_order', $this->format_string( $this->subject ), $this->object );
}
}
/**
* get_heading function.
@ -91,11 +92,12 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
* @return string
*/
function get_heading() {
if ( ! empty( $this->object ) && $this->object->has_downloadable_item() )
if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) {
return apply_filters( 'woocommerce_email_heading_customer_completed_order', $this->format_string( $this->heading_downloadable ), $this->object );
else
} else {
return apply_filters( 'woocommerce_email_heading_customer_completed_order', $this->format_string( $this->heading ), $this->object );
}
}
/**
* get_content_html function.

View File

@ -63,8 +63,9 @@ class WC_Email_Customer_New_Account extends WC_Email {
$this->password_generated = $password_generated;
}
if ( ! $this->is_enabled() || ! $this->get_recipient() )
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
return;
}
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}

View File

@ -402,7 +402,6 @@ class WC_Email extends WC_Settings_API {
} catch ( Exception $e ) {
$logger = new WC_Logger();
$logger->add( 'emogrifier', $e->getMessage() );
}
}
@ -535,53 +534,8 @@ class WC_Email extends WC_Settings_API {
parent::process_admin_options();
// Save templates
if ( ! empty( $_POST['template_html_code'] ) && ! empty( $this->template_html ) ) {
$saved = false;
$file = get_stylesheet_directory() . '/woocommerce/' . $this->template_html;
$code = stripslashes( $_POST['template_html_code'] );
if ( is_writeable( $file ) ) {
$f = fopen( $file, 'w+' );
if ( $f !== false ) {
fwrite( $f, $code );
fclose( $f );
$saved = true;
}
}
if ( ! $saved ) {
$redirect = add_query_arg( 'wc_error', urlencode( __( 'Could not write to template file.', 'woocommerce' ) ) );
wp_redirect( $redirect );
exit;
}
}
if ( ! empty( $_POST['template_plain_code'] ) && ! empty( $this->template_plain ) ) {
$saved = false;
$file = get_stylesheet_directory() . '/woocommerce/' . $this->template_plain;
$code = stripslashes( $_POST['template_plain_code'] );
if ( is_writeable( $file ) ) {
$f = fopen( $file, 'w+' );
if ( $f !== false ) {
fwrite( $f, $code );
fclose( $f );
$saved = true;
}
}
if ( ! $saved ) {
$redirect = add_query_arg( 'wc_error', __( 'Could not write to template file.', 'woocommerce' ) );
wp_redirect( $redirect );
exit;
}
}
$this->save_template( $_POST['template_html_code'], $this->template_html );
$this->save_template( $_POST['template_plain_code'], $this->template_plain );
}
/**
@ -603,6 +557,38 @@ class WC_Email extends WC_Settings_API {
return '';
}
/**
* Save the email templates
*
* @param string $template_code
* @param string $template_path
* @return void
*/
protected function save_template( $template_code, $template_path ) {
if ( ! empty( $template_code ) && ! empty( $template_path ) ) {
$saved = false;
$file = get_stylesheet_directory() . '/woocommerce/' . $template_path;
$code = stripslashes( $template_code );
if ( is_writeable( $file ) ) {
$f = fopen( $file, 'w+' );
if ( $f !== false ) {
fwrite( $f, $code );
fclose( $f );
$saved = true;
}
}
if ( ! $saved ) {
$redirect = add_query_arg( 'wc_error', urlencode( __( 'Could not write to template file.', 'woocommerce' ) ) );
wp_redirect( $redirect );
exit;
}
}
}
/**
* Get the template file in the current theme.
*
@ -698,13 +684,13 @@ class WC_Email extends WC_Settings_API {
/**
* Admin Options
*
* Setup the gateway settings screen.
* Override this in your gateway.
* Setup the email settings screen.
* Override this in your email.
*
* @since 1.0.0
*/
public function admin_options() {
// Do admin acations.
// Do admin actions.
$this->admin_actions();
?>

View File

@ -41,7 +41,6 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
*
* @param array $args
* @param int $order_id
*
* @return array
*/
public function hosted_payment_args( $args, $order_id ) {
@ -58,7 +57,6 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
* Check if order contains subscriptions.
*
* @param int $order_id
*
* @return bool
*/
protected function order_contains_subscription( $order_id ) {
@ -69,7 +67,6 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
* Check if order contains pre-orders.
*
* @param int $order_id
*
* @return bool
*/
protected function order_contains_pre_order( $order_id ) {
@ -81,7 +78,8 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
*
* @param WC_Order $order
* @param string $cart_token
*
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return array
*/
protected function process_subscription( $order, $cart_token = '' ) {
@ -157,7 +155,8 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
*
* @param WC_Order $order
* @param string $cart_token
*
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return array
*/
protected function process_pre_order( $order, $cart_token = '' ) {
@ -263,9 +262,10 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
*
* @param WC_order $order
* @param integer $amount (default: 0)
* @uses Simplify_BadRequestException
* @return bool|WP_Error
*/
public function process_subscription_payment( $order = '', $amount = 0 ) {
public function process_subscription_payment( $order, $amount = 0 ) {
$order_items = $order->get_items();
$order_item = array_shift( $order_items );
$subscription_name = sprintf( __( '%s - Subscription for "%s"', 'woocommerce' ), esc_html( get_bloginfo( 'name', 'display' ) ), $order_item['name'] ) . ' ' . sprintf( __( '(Order #%s)', 'woocommerce' ), $order->get_order_number() );

View File

@ -307,7 +307,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
*
* @param WC_Order $order
* @param string $cart_token
*
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return array
*/
protected function process_standard_payments( $order, $cart_token = '' ) {
@ -501,6 +502,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
* @param int $order_id
* @param float $amount
* @param string $reason
* @uses Simplify_ApiException
* @uses Simplify_BadRequestException
* @return bool|WP_Error
*/
public function process_refund( $order_id, $amount = null, $reason = '' ) {

View File

@ -126,7 +126,7 @@ if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
$wc_endpoints = WC()->query->get_query_vars();
if ( $endpoint ) {
if ( $endpoint !== false ) {
if ( ! isset( $wc_endpoints[ $endpoint ] ) ) {
return false;
} else {
@ -140,6 +140,7 @@ if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
return true;
}
}
return false;
}
}