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

Commit

Permalink
Merge pull request #38 from liquidweb/fix/normalize-name
Browse files Browse the repository at this point in the history
Normalize the plugin name throughout the codebase
  • Loading branch information
bswatson authored Jan 23, 2018
2 parents 9a95351 + f72a534 commit 178cf15
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 106 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to WooCommerce Custom Order Tables
# Contributing to WooCommerce Custom Orders Table

Thank you for your interest in WooCommerce Custom Order Tables!
Thank you for your interest in WooCommerce Custom Orders Table!


## Reporting bugs and/or suggesting new features
Expand Down Expand Up @@ -44,9 +44,9 @@ Once master has been updated, the release should be tagged, then `master` should

### Unit testing

WooCommerce Custom Order Tables uses [the WordPress core testing suite](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/) to provide automated tests for its functionality.
WooCommerce Custom Orders Table uses [the WordPress core testing suite](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/) to provide automated tests for its functionality.

When submitting pull requests, please include relevant tests for your new features and bugfixes. This helps prevent regressions in future iterations of the plugin, and helps instill confidence in store owners using this to enhance their WooCommerce stores.
When submitting pull requests, please include relevant tests for your new features and bug-fixes. This helps prevent regressions in future iterations of the plugin, and helps instill confidence in store owners using this to enhance their WooCommerce stores.

#### Test coverage

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WooCommerce Order Tables
# WooCommerce Custom Orders Table

[![Build Status](https://travis-ci.org/liquidweb/woocommerce-order-tables.svg?branch=fix%2Ftravis-config)](https://travis-ci.org/liquidweb/woocommerce-order-tables)

Expand All @@ -10,7 +10,7 @@ WooCommerce even with CRUD classes in core, still uses a custom post type for or
### Here's how
WooCommerce saves more than 40 custom fields per order— including those from plugins— inside the wp_postmeta table. If your store gets ~40 per day, that's 1600 rows (40 * 40) added to the postmeta table in a day.

In one month that number can be 48,000 new rows (1600 * 30) added to your postmeta table. The more rows in a table the longer it will take for a query to execute. WooCommerce Order Tables creates a new table for WooCommerce orders which would cut that number tremendously by making each custom field into a column so that 1 order = 1 row.
In one month that number can be 48,000 new rows (1600 * 30) added to your postmeta table. The more rows in a table the longer it will take for a query to execute. WooCommerce Custom Orders Table creates a new table for WooCommerce orders which would cut that number tremendously by making each custom field into a column so that 1 order = 1 row.

## Installation
This plugin uses a Composer autoloader. If you are working with code from the `master` branch in a development environment, the autoloader needs to be generated in order for the plugin to work. After cloning this repository, run `composer install` in the root directory of the plugin.
Expand All @@ -25,7 +25,7 @@ The easiest way to accomplish this is via [WP-CLI](http://wp-cli.org/), and the

### Counting the orders to be migrated

If you'd like to see the number of orders that have yet to be moved into the order table, you can quickly retrieve this value with the `count` command:
If you'd like to see the number of orders that have yet to be moved into the orders table, you can quickly retrieve this value with the `count` command:

```
$ wp wc-order-table count
Expand All @@ -51,7 +51,7 @@ Orders are queried in batches (determined via the `--batch-size` option) in orde

### Copying data from the orders table into post meta

If you require the post meta fields to be present (or are removing the custom order table plugin), you may rollback the migration at any time with the `backfill` command.
If you require the post meta fields to be present (or are removing the custom orders table plugin), you may rollback the migration at any time with the `backfill` command.

```
$ wp wc-order-table backfill
Expand Down
14 changes: 3 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"name": "liquidweb/wc-custom-order-table",
"description": "Store WooCommerce order data in a custom table.",
"name": "liquidweb/woocommerce-custom-orders-table",
"description": "Store WooCommerce order data in a custom table for improved performance",
"type": "wordpress-plugin",
"license": "GPL-2.0",
"license": "GPL-2.0-only",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/liquidweb/woocommerce"
}
],
"require": {
"php": ">=5.2"
},
"require-dev": {
"php": "^7.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
Expand All @@ -20,11 +17,6 @@
"woocommerce/woocommerce-sniffs": "^0.0.1",
"wp-coding-standards/wpcs": "^0.14"
},
"autoload": {
"classmap": [
"includes"
]
},
"autoload-dev": {
"classmap": [
"tests/test-tools",
Expand Down
4 changes: 2 additions & 2 deletions includes/class-wc-customer-data-store-custom-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/**
* WooCommerce customer data store.
*
* @package WooCommerce_Custom_Order_Tables
* @package WooCommerce_Custom_Orders_Table
* @author Liquid Web
*/

/**
* Extend the WC_Order_Data_Store_CPT class in order to overload methods that directly query the
* postmeta tables.
* postmeta table.
*/
class WC_Customer_Data_Store_Custom_Table extends WC_Customer_Data_Store {

Expand Down
21 changes: 11 additions & 10 deletions includes/class-wc-order-data-store-custom-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* WooCommerce order data store.
*
* @package WooCommerce_Custom_Order_Tables
* @package WooCommerce_Custom_Orders_Table
* @author Liquid Web
*/

Expand Down Expand Up @@ -123,10 +123,9 @@ public function delete( &$order, $args = array() ) {

// Delete the database row if force_delete is true.
if ( isset( $args['force_delete'] ) && $args['force_delete'] ) {
$wpdb->delete(
"{$wpdb->prefix}woocommerce_orders",
array( 'order_id' => $order_id )
); // WPCS: DB call OK.
$wpdb->delete( wc_custom_order_table()->get_table_name(), array(
'order_id' => $order_id,
) ); // WPCS: DB call OK.
}
}

Expand Down Expand Up @@ -318,8 +317,10 @@ protected function update_post_meta( &$order ) {
public function get_order_id_by_order_key( $order_key ) {
global $wpdb;

$table = wc_custom_order_table()->get_table_name();

return $wpdb->get_var( $wpdb->prepare(
"SELECT order_id FROM {$wpdb->prefix}woocommerce_orders WHERE order_key = %s",
'SELECT order_id FROM ' . esc_sql( $table ) . ' WHERE order_key = %s',
$order_key
) ); // WPCS: DB call OK.
}
Expand Down Expand Up @@ -565,7 +566,7 @@ public static function posts_join( $join, $wp_query ) {
$join = preg_replace( $regex, '', $join );
}

$table = wc_custom_order_table()->get_table_name();
$table = esc_sql( wc_custom_order_table()->get_table_name() );
$join .= " LEFT JOIN {$table} ON ( {$wpdb->posts}.ID = {$table}.order_id ) ";

// Don't necessarily apply this to subsequent posts_join filter callbacks.
Expand All @@ -589,7 +590,7 @@ public static function meta_query_where( $where, $wp_query ) {
global $wpdb;

$meta_query = $wp_query->get( 'wc_order_meta_query' );
$table = wc_custom_order_table()->get_table_name();
$table = esc_sql( wc_custom_order_table()->get_table_name() );

if ( empty( $meta_query ) ) {
return $where;
Expand Down Expand Up @@ -649,7 +650,7 @@ public static function filter_order_report_query( $query ) {
'post_id' => false,
'post_parent' => false,
);
$table = wc_custom_order_table()->get_table_name();
$table = esc_sql( wc_custom_order_table()->get_table_name() );
$replacements = array();

foreach ( $matches[0] as $key => $value ) {
Expand Down Expand Up @@ -694,7 +695,7 @@ public static function filter_order_report_query( $query ) {

/**
* When the add_order_indexes system status tool is run, populate missing address indexes in
* the order table.
* the orders table.
*
* @global $wpdb
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
/**
* CLI Tool for migrating order data to/from custom table.
*
* @package WooCommerce_Custom_Order_Tables
* @package WooCommerce_Custom_Orders_Table
* @author Liquid Web
*/

/**
* Manages the contents of the WooCommerce order table.
* Manages the contents of the WooCommerce orders table.
*/
class WC_Custom_Order_Table_CLI extends WP_CLI_Command {
class WooCommerce_Custom_Orders_Table_CLI extends WP_CLI_Command {

/**
* Count how many orders have yet to be migrated into the custom order table.
* Count how many orders have yet to be migrated into the custom orders table.
*
* ## EXAMPLES
*
Expand All @@ -36,15 +36,15 @@ public function count() {

WP_CLI::log( sprintf(
/* Translators: %1$d is the number of orders to be migrated. */
_n( 'There is %1$d order to be migrated.', 'There are %1$d orders to be migrated.', $order_count, 'wc-custom-order-table' ),
_n( 'There is %1$d order to be migrated.', 'There are %1$d orders to be migrated.', $order_count, 'woocommerce-custom-orders-table' ),
$order_count
) );

return $order_count;
}

/**
* Migrate order data to the custom order table.
* Migrate order data to the custom orders table.
*
* ## OPTIONS
*
Expand All @@ -70,7 +70,7 @@ public function migrate( $args = array(), $assoc_args = array() ) {
$order_count = $this->count();

if ( ! $order_count ) {
return WP_CLI::warning( __( 'There are no orders to migrate, aborting.', 'wc-custom-order-table' ) );
return WP_CLI::warning( __( 'There are no orders to migrate, aborting.', 'woocommerce-custom-orders-table' ) );
}

$assoc_args = wp_parse_args( $assoc_args, array(
Expand Down Expand Up @@ -116,12 +116,12 @@ public function migrate( $args = array(), $assoc_args = array() ) {

// Issue a warning if no orders were migrated.
if ( ! $processed ) {
return WP_CLI::warning( __( 'No orders were migrated.', 'wc-custom-order-table' ) );
return WP_CLI::warning( __( 'No orders were migrated.', 'woocommerce-custom-orders-table' ) );
}

WP_CLI::success( sprintf(
/* Translators: %1$d is the number of migrated orders. */
_n( '%1$d order was migrated.', '%1$d orders were migrated.', $processed, 'wc-custom-order-table' ),
_n( '%1$d order was migrated.', '%1$d orders were migrated.', $processed, 'woocommerce-custom-orders-table' ),
$processed
) );
}
Expand All @@ -130,7 +130,7 @@ public function migrate( $args = array(), $assoc_args = array() ) {
* Copy order data into the postmeta table.
*
* Note that this could dramatically increase the size of your postmeta table, but is recommended
* if you wish to stop using the custom order table plugin.
* if you wish to stop using the custom orders table plugin.
*
* ## OPTIONS
*
Expand Down Expand Up @@ -162,7 +162,7 @@ public function backfill( $args = array(), $assoc_args = array() ) {
$order_count = $wpdb->get_var( 'SELECT COUNT(order_id) FROM ' . esc_sql( $order_table ) ); // WPCS: DB call ok.

if ( ! $order_count ) {
return WP_CLI::warning( __( 'There are no orders to migrate, aborting.', 'wc-custom-order-table' ) );
return WP_CLI::warning( __( 'There are no orders to migrate, aborting.', 'woocommerce-custom-orders-table' ) );
}

$assoc_args = wp_parse_args( $assoc_args, array(
Expand Down Expand Up @@ -195,12 +195,12 @@ public function backfill( $args = array(), $assoc_args = array() ) {

// Issue a warning if no orders were migrated.
if ( ! $processed ) {
return WP_CLI::warning( __( 'No orders were migrated.', 'wc-custom-order-table' ) );
return WP_CLI::warning( __( 'No orders were migrated.', 'woocommerce-custom-orders-table' ) );
}

WP_CLI::success( sprintf(
/* Translators: %1$d is the number of migrated orders. */
_n( '%1$d order was migrated.', '%1$d orders were migrated.', $processed, 'wc-custom-order-table' ),
_n( '%1$d order was migrated.', '%1$d orders were migrated.', $processed, 'woocommerce-custom-orders-table' ),
$processed
) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
/**
* Table installation procedure.
*
* @package WooCommerce_Custom_Order_Tables
* @package WooCommerce_Custom_Orders_Table
* @author Liquid Web
*/

/**
* Installer for WooCommerce Custom Order Tables.
* Installer for WooCommerce Custom Orders Table.
*
* Usage:
*
* WC_Custom_Order_Table_Install::activate();
* WooCommerce_Custom_Orders_Table_Install::activate();
*/
class WC_Custom_Order_Table_Install {
class WooCommerce_Custom_Orders_Table_Install {

/**
* The option key that contains the current schema version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
/**
* Core plugin functionality.
*
* @package WooCommerce_Custom_Order_Tables
* @package WooCommerce_Custom_Orders_Table
* @author Liquid Web
*/

/**
* Core functionality for WooCommerce Custom Order Tables.
* Core functionality for WooCommerce Custom Orders Table.
*/
class WC_Custom_Order_Table {
class WooCommerce_Custom_Orders_Table {

/**
* The database table name.
Expand All @@ -34,18 +34,18 @@ public function setup() {

// If we're in a WP-CLI context, load the WP-CLI command.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'wc-order-table', 'WC_Custom_Order_Table_CLI' );
WP_CLI::add_command( 'wc-order-table', 'WooCommerce_Custom_Orders_Table_CLI' );
}
}

/**
* Retrieve the WooCommerce order table name.
* Retrieve the WooCommerce orders table name.
*
* @return string The database table name.
*/
public function get_table_name() {
/**
* Filter the WooCommerce order table name.
* Filter the WooCommerce orders table name.
*
* @param string $table The WooCommerce orders table name.
*/
Expand Down
4 changes: 2 additions & 2 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<rule ref="WordPress.WP.I18n">
<!-- Set the expected text domain. -->
<properties>
<property name="text_domain" type="array" value="wc-custom-order-table" />
<property name="text_domain" type="array" value="woocommerce-custom-orders-table" />
</properties>
</rule>

<rule ref="PHPCompatibility">
<exclude name="PHPCompatibility.PHP.NewKeywords.t_namespaceFound" />
<exclude-pattern>includes/class-wc-custom-order-table-cli.php</exclude-pattern>
<exclude-pattern>includes/class-woocommerce-custom-orders-table-cli.php</exclude-pattern>
</rule>

<!-- Check all PHP files in directory tree by default. -->
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<filter>
<whitelist>
<directory suffix=".php">includes</directory>
<file>wc-custom-order-table.php</file>
<file>woocommerce-custom-orders-table.php</file>
</whitelist>
</filter>
</phpunit>
11 changes: 6 additions & 5 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
/**
* Bootstrap the PHPUnit test suite(s).
*
* Since WooCommerce Custom Order Tables is meant to integrate seamlessly with WooCommerce itself,
* Since WooCommerce Custom Orders Table is meant to integrate seamlessly with WooCommerce itself,
* the bootstrap relies heavily on the WooCommerce core test suite.
*
* @package Woocommerce_Order_Tables
* @package WooCommerce_Custom_Orders_Table
* @author Liquid Web
*/

$_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
Expand All @@ -26,15 +27,15 @@

// Manually load the plugin on muplugins_loaded.
function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/wc-custom-order-table.php';
require dirname( dirname( __FILE__ ) ) . '/woocommerce-custom-orders-table.php';

echo esc_html( sprintf(
/* Translators: %1$s is the WooCommerce release being loaded. */
__( 'Using WooCommerce %1$s.', 'wc-custom-order-table' ),
__( 'Using WooCommerce %1$s.', 'woocommerce-custom-orders-table' ),
WC_VERSION
) ) . PHP_EOL;

WC_Custom_Order_Table_Install::activate();
WooCommerce_Custom_Orders_Table_Install::activate();

add_filter( 'woocommerce_email_actions', '__return_empty_array' );
}
Expand Down
Loading

0 comments on commit 178cf15

Please sign in to comment.