Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

Commit c0d1be4

Browse files
Merge pull request #21 from liquidweb/fix/phpcs-cleanup
PHP_CodeSniffer cleanup
2 parents 6fe5eb1 + cec0958 commit c0d1be4

8 files changed

+32
-14
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ matrix:
2626
env: WP_VERSION=latest
2727
- php: 5.6
2828
env: WP_VERSION=trunk
29-
- php: 5.6
30-
env: WP_TRAVISCI=phpcs
29+
#- php: 5.6
30+
# env: WP_TRAVISCI=phpcs
3131
- php: 5.3
3232
env: WP_VERSION=latest
3333
dist: precise

includes/class-wc-custom-order-table-cli.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* @author Liquid Web
77
*/
88

9+
/**
10+
* Manages the contents of the WooCommerce order table.
11+
*/
912
class WC_Custom_Order_Table_CLI extends WP_CLI_Command {
1013

1114
/**

includes/class-wc-custom-order-table-install.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
* @author Liquid Web
77
*/
88

9+
/**
10+
* Installer for WooCommerce Custom Order Tables.
11+
*
12+
* Usage:
13+
*
14+
* WC_Custom_Order_Table_Install::activate();
15+
*/
916
class WC_Custom_Order_Table_Install {
1017

1118
/**
@@ -25,7 +32,7 @@ class WC_Custom_Order_Table_Install {
2532
*/
2633
public static function activate() {
2734
// We're already on the latest schema version.
28-
if ( (int) self::$table_version === (int) get_option( self::SCHEMA_VERSION_KEY ) ) {
35+
if ( (int) get_option( self::SCHEMA_VERSION_KEY ) === (int) self::$table_version ) {
2936
return false;
3037
}
3138

includes/class-wc-custom-order-table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* @author Liquid Web
77
*/
88

9+
/**
10+
* Core functionality for WooCommerce Custom Order Tables.
11+
*/
912
class WC_Custom_Order_Table {
1013

1114
/**

includes/class-wc-order-data-store-custom-table.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
/**
33
* WooCommerce order data store.
44
*
5-
* Orders are still treated as posts within WordPress, but the data is stored in a separate table.
6-
*
75
* @package WooCommerce_Custom_Order_Tables
86
* @author Liquid Web
97
*/
108

9+
/**
10+
* Extension of the Abstract_WC_Order_Data_Store_CPT class, designed to map data between
11+
* WooCommerce and the custom database table.
12+
*
13+
* Orders are still treated as posts within WordPress, but the data is stored in a separate table.
14+
*/
1115
class WC_Order_Data_Store_Custom_Table extends Abstract_WC_Order_Data_Store_CPT implements WC_Object_Data_Store_Interface, WC_Order_Data_Store_Interface {
1216

1317
/**
@@ -403,12 +407,12 @@ public function get_orders( $args = array() ) {
403407
$wc_customer_query = array();
404408

405409
if ( ! empty( $args['customer'] ) ) {
406-
$values = is_array( $args['customer'] ) ? $args['customer'] : array( $args['customer'] );
410+
$values = is_array( $args['customer'] ) ? $args['customer'] : array( $args['customer'] );
407411
$wc_customer_query = array_merge( $wc_customer_query, $values );
408412
}
409413

410414
if ( ! empty( $args['email'] ) ) {
411-
$values = is_array( $args['email'] ) ? $args['email'] : array( $args['email'] );
415+
$values = is_array( $args['email'] ) ? $args['email'] : array( $args['email'] );
412416
$wc_customer_query = array_merge( $wc_customer_query, $values );
413417
}
414418

@@ -482,13 +486,13 @@ public function get_orders( $args = array() ) {
482486
*/
483487
private function get_orders_generate_customer_meta_query( $values, $relation = 'or' ) {
484488
$meta_query = array(
485-
'relation' => strtoupper( $relation ),
489+
'relation' => strtoupper( $relation ),
486490
'customer_emails' => array(
487491
'key' => '_billing_email',
488492
'value' => array(),
489493
'compare' => 'IN',
490494
),
491-
'customer_ids' => array(
495+
'customer_ids' => array(
492496
'key' => '_customer_user',
493497
'value' => array(),
494498
'compare' => 'IN',
@@ -713,7 +717,7 @@ public function populate_from_meta( &$order, $save = true, $delete = false ) {
713717

714718
if ( is_null( $table_data ) ) {
715719
$original_creating = $this->creating;
716-
$this->creating = true;
720+
$this->creating = true;
717721
}
718722

719723
foreach ( $this->get_postmeta_mapping() as $column => $meta_key ) {
@@ -777,8 +781,8 @@ public function query( $query_vars ) {
777781

778782
if ( ! empty( $args['errors'] ) ) {
779783
$query = (object) array(
780-
'posts' => array(),
781-
'found_posts' => 0,
784+
'posts' => array(),
785+
'found_posts' => 0,
782786
'max_num_pages' => 0,
783787
);
784788
} else {

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414

1515
<exclude-pattern>*/node_modules/*</exclude-pattern>
1616
<exclude-pattern>*/vendor/*</exclude-pattern>
17+
<exclude-pattern>*/tests/*</exclude-pattern>
1718
</ruleset>

tests/test-installation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function test_can_upgrade_table() {
7676
// Get the current schema version, then increment it.
7777
$property = new ReflectionProperty( 'WC_Custom_Order_Table_Install', 'table_version' );
7878
$property->setAccessible( true );
79-
$version = $property->getValue();
79+
$version = $property->getValue();
8080
$property->setValue( $version + 1 );
8181

8282
// Run the activation script again.

wc-custom-order-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ function wc_custom_order_table() {
5050
return $wc_custom_order_table;
5151
}
5252

53-
add_action('plugins_loaded', 'wc_custom_order_table');
53+
add_action( 'plugins_loaded', 'wc_custom_order_table' );

0 commit comments

Comments
 (0)