diff --git a/.github/workflows/testing-integration.yml b/.github/workflows/testing-integration.yml
new file mode 100644
index 000000000..fdb125d2d
--- /dev/null
+++ b/.github/workflows/testing-integration.yml
@@ -0,0 +1,66 @@
+name: Testing Integration
+
+on:
+ push:
+ branches:
+ - develop
+ - master
+ pull_request:
+ branches:
+ - develop
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ env:
+ coverage: 0
+ debug: 0
+ strategy:
+ matrix:
+ php: ['7.3', '7.2', '7.1', '7.0']
+ wordpress: ['5.3', '5.0', '4.9']
+ include:
+ - php: '7.0'
+ use_xdebug: 1
+ - php: '7.0'
+ wordpress: '5.0'
+ coverage: 1
+
+ exclude:
+ - php: '7.3'
+ wordpress: '4.9'
+ - php: '7.2'
+ wordpress: '4.9'
+ - php: '7.0'
+ wordpress: '5.3'
+ fail-fast: false
+ name: WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v1
+
+ - name: Build "testing" Docker Image
+ run: |
+ docker-compose build \
+ --build-arg PHP_VERSION=${{ matrix.php }} \
+ --build-arg WP_VERSION=${{ matrix.wordpress }} \
+ --build-arg USE_XDEBUG=${{ matrix.use_xdebug }} \
+ testing
+
+ - name: Run Tests w/ Docker.
+ run: |
+ docker-compose run --rm \
+ -e COVERAGE=${{ matrix.coverage }} \
+ -e DEBUG=${{ matrix.debug }} \
+ testing --scale app=0
+
+ - name: Push Codecoverage to Coveralls.io
+ if: matrix.coverage == 1
+ env:
+ COVERALLS_RUN_LOCALLY: 1
+ COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
+ run: |
+ wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
+ chmod +x php-coveralls.phar
+
+ php php-coveralls.phar -v
\ No newline at end of file
diff --git a/.github/workflows/wordpress-coding-standards.yml b/.github/workflows/wordpress-coding-standards.yml
new file mode 100644
index 000000000..4342619a8
--- /dev/null
+++ b/.github/workflows/wordpress-coding-standards.yml
@@ -0,0 +1,47 @@
+name: WordPress Coding Standards
+
+on:
+ push:
+ branches:
+ - develop
+ - master
+ pull_request:
+ branches:
+ - develop
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v1
+
+ - name: Setup PHP
+ if: matrix.phpcs == 1
+ uses: shivammathur/setup-php@v1
+ with:
+ php-version: 7.3
+ extensions: mbstring, intl
+ tools: composer
+
+ - name: Get Composer Cache Directory
+ id: composer-cache
+ run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+
+ - name: Install dependencies
+ run: |
+ composer require \
+ squizlabs/php_codesniffer \
+ phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs \
+ dealerdirect/phpcodesniffer-composer-installer
+ composer install --no-dev
+
+ - name: Cache dependencies
+ uses: actions/cache@v1
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
+ restore-keys: ${{ runner.os }}-composer
+
+ - name: Run PHP CodeSniffer
+ run: vendor/bin/phpcs
\ No newline at end of file
diff --git a/.phpcs.ruleset.xml b/.phpcs.xml
similarity index 86%
rename from .phpcs.ruleset.xml
rename to .phpcs.xml
index 456ba8869..77a3124a8 100644
--- a/.phpcs.ruleset.xml
+++ b/.phpcs.xml
@@ -3,7 +3,10 @@
Generally-applicable sniffs for WordPress plugins.
- .
+ wp-graphql-woocommerce.php
+ access-functions.php
+ class-inflect.php
+ includes/
/vendor/
/node_modules/
/tests/
@@ -19,21 +22,18 @@
-
+
-
-
-
-
+
-
+
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 2e7c43503..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,115 +0,0 @@
-sudo: false
-dist: trusty
-
-language: php
-
-services:
- - docker
-
-notifications:
- email:
- on_success: never
- on_failure: never
-
-branches:
- only:
- - develop
- - master
-
-cache:
- apt: true
- directories:
- - $HOME/.composer/cache
-
-matrix:
- include:
- - php: 7.3
- env: PHP_VERSION=7.3 WP_VERSION=5.3
- - php: 7.3
- env: PHP_VERSION=7.3 PHPCS=1
- - php: 7.2
- env: PHP_VERSION=7.2 WP_VERSION=5.3
- - php: 7.2
- env: PHP_VERSION=7.2 WP_VERSION=4.9
- - php: 7.1
- env: PHP_VERSION=7.1 WP_VERSION=5.3
- - php: 7.1
- env: PHP_VERSION=7.1 WP_VERSION=4.9
- - php: 7.0
- env: PHP_VERSION=7.0 WP_VERSION=5.0 COVERAGE=1
- - php: 7.0
- env: PHP_VERSION=7.0 WP_VERSION=4.9
- - php: 5.6
- env: PHP_VERSION=5.6 WP_VERSION=5.0
- - php: 5.6
- env: PHP_VERSION=5.6 WP_VERSION=4.9
- allow_failures:
- - env: PHP_VERSION=5.6 WP_VERSION=5.0
- - env: PHP_VERSION=5.6 WP_VERSION=4.9
-
-before_install:
- - sudo rm /usr/local/bin/docker-compose
- - curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > docker-compose
- - chmod +x docker-compose
- - sudo mv docker-compose /usr/local/bin
- - |
- # Remove Xdebug for a huge performance increase:
- if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
- phpenv config-rm xdebug.ini
- else
- echo "xdebug.ini does not exist"
- fi
-
-install:
- - |
- cd $TRAVIS_BUILD_DIR
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- chmod +x wp-cli.phar
- sudo mv wp-cli.phar /usr/local/bin/wp
-
-before_script:
- - |
- if [ ! -z "$WP_VERSION" ]; then
- # Build images.
- docker-compose build \
- --build-arg DESIRED_PHP_VERSION=${PHP_VERSION} \
- --build-arg DESIRED_WP_VERSION=${WP_VERSION} \
- --build-arg USE_XDEBUG=${USE_XDEBUG} \
- testing
- fi
- # Install PHP CodeSniffer and WPCS.
- - |
- if [ "$PHPCS" == "1" ]; then
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer require \
- squizlabs/php_codesniffer \
- phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs \
- dealerdirect/phpcodesniffer-composer-installer
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --no-dev
- fi
-
-script:
- # Execute unit tests with coverage if specified, otherwise without coverage
- - |
- if [ ! -z "$WP_VERSION" ]; then
- docker-compose run --rm \
- -e COVERAGE=${COVERAGE:-0} \
- -e DEBUG=${DEBUG:-0} \
- testing --scale app=0
- fi
- - |
- if [ "$PHPCS" == "1" ]; then
- vendor/bin/phpcs \
- wp-graphql-woocommerce.php \
- access-functions.php \
- class-inflect.php \
- includes/*.php --standard=WordPress
- fi
-after_success:
- # Download and run Coveralls.io client
- - |
- if [ "$COVERAGE" == "1" ]; then
- wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
- chmod +x php-coveralls.phar
-
- travis_retry php php-coveralls.phar -v
- fi
diff --git a/Dockerfile b/Dockerfile
index 332ef179b..f1526adbe 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,10 +3,10 @@
############################################################################
# Using the 'DESIRED_' prefix to avoid confusion with environment variables of the same name.
-ARG DESIRED_WP_VERSION
-ARG DESIRED_PHP_VERSION
+ARG WP_VERSION
+ARG PHP_VERSION
-FROM kidunot89/woographql-app:wp${DESIRED_WP_VERSION}-php${DESIRED_PHP_VERSION}
+FROM kidunot89/woographql-app:wp${WP_VERSION}-php${PHP_VERSION}
LABEL author=kidunot89
@@ -15,11 +15,11 @@ LABEL author_uri=https://github.com/kidunot89
SHELL [ "/bin/bash", "-c" ]
# Redeclare ARGs and set as environmental variables for reuse.
-ARG DESIRED_WP_VERSION
-ARG DESIRED_PHP_VERSION
+ARG WP_VERSION
+ARG PHP_VERSION
ARG USE_XDEBUG
-ENV WP_VERSION=${DESIRED_WP_VERSION}
-ENV PHP_VERSION=${DESIRED_PHP_VERSION}
+ENV WP_VERSION=${WP_VERSION}
+ENV PHP_VERSION=${PHP_VERSION}
ENV USING_XDEBUG=${USE_XDEBUG}
# Install php extensions
@@ -37,7 +37,7 @@ RUN if [ "$PHP_VERSION" != "5.6" ] && [ "$PHP_VERSION" != "7.0" ] && [[ -z "$USI
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini; \
- elif [ "$PHP_VERSION" == "7.0" ]; then \
+ elif [ "$PHP_VERSION" == "7.0" ] || [ ! -z "$USING_XDEBUG" ]; then \
yes | pecl install xdebug-2.6.1 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
diff --git a/README.md b/README.md
index 32ab4a0fc..17e25b150 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
Docs • AxisTaylor • Join Slack
-[![Build Status](https://travis-ci.org/wp-graphql/wp-graphql-woocommerce.svg?branch=develop)](https://travis-ci.org/wp-graphql/wp-graphql-woocommerce) [![Coverage Status](https://coveralls.io/repos/github/wp-graphql/wp-graphql-woocommerce/badge.svg?branch=develop)](https://coveralls.io/github/wp-graphql/wp-graphql-woocommerce?branch=develop)
+[![Actions Status](https://github.com/wp-graphql/wp-graphql-woocommerce/workflows/Testing Integration/badge.svg)](https://github.com/wp-graphql/wp-graphql-woocommerce/actions)[![Coverage Status](https://coveralls.io/repos/github/wp-graphql/wp-graphql-woocommerce/badge.svg?branch=develop)](https://coveralls.io/github/wp-graphql/wp-graphql-woocommerce?branch=develop)
## Quick Install
1. Install & activate [WooCommerce](https://woocommerce.com/)
diff --git a/access-functions.php b/access-functions.php
index f2dd11c48..0686a28c4 100644
--- a/access-functions.php
+++ b/access-functions.php
@@ -94,7 +94,7 @@ function wc_graphql_get_order_statuses() {
*/
function wc_graphql_price( $price, $args = array() ) {
$args = apply_filters(
- 'wc_price_args',
+ 'wc_price_args', // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
wp_parse_args(
$args,
array(
@@ -109,13 +109,32 @@ function wc_graphql_price( $price, $args = array() ) {
$unformatted_price = $price;
$negative = $price < 0;
- $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
- $price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] ), $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] );
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
+
+
+ $price = apply_filters(
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ 'formatted_woocommerce_price',
+ number_format(
+ $price,
+ $args['decimals'],
+ $args['decimal_separator'],
+ $args['thousand_separator']
+ ),
+ $price,
+ $args['decimals'],
+ $args['decimal_separator'],
+ $args['thousand_separator']
+ );
+
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $args['decimals'] > 0 ) {
$price = wc_trim_zeros( $price );
}
+ // phpcs:ignore PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault.NotSet
$symbol = html_entity_decode( get_woocommerce_currency_symbol( $args['currency'] ) );
$return = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], $symbol, $price );
@@ -127,7 +146,7 @@ function wc_graphql_price( $price, $args = array() ) {
* @param array $args Pass on the args.
* @param float $unformatted_price Price as float to allow plugins custom formatting. Since 3.2.0.
*/
- return apply_filters( 'wc_graphql_price', $return, $price, $args, $unformatted_price, $symbol );
+ return apply_filters( 'graphql_woocommerce_price', $return, $price, $args, $unformatted_price, $symbol );
}
/**
@@ -142,9 +161,9 @@ function wc_graphql_price_range( $from, $to ) {
/* translators: 1: price from 2: price to */
_x( '%1$s %2$s %3$s', 'Price range: from-to', 'wp-graphql-woocommerce' ),
is_numeric( $from ) ? wc_graphql_price( $from ) : $from,
- apply_filters( 'graphql_format_price_range_separator', '-', $from, $to ),
+ apply_filters( 'graphql_woocommerce_format_price_range_separator', '-', $from, $to ),
is_numeric( $to ) ? wc_graphql_price( $to ) : $to
);
- return apply_filters( 'graphql_format_price_range', $price, $from, $to );
+ return apply_filters( 'graphql_woocommerce_format_price_range', $price, $from, $to );
}
diff --git a/class-inflect.php b/class-inflect.php
index 2754a903b..d53891e9e 100644
--- a/class-inflect.php
+++ b/class-inflect.php
@@ -15,7 +15,7 @@
/**
* Class Inflect
*/
- class Inflect {
+ class Inflect { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
/**
* Stores plural suffixes.
*
diff --git a/docker-compose.yml b/docker-compose.yml
index c96956927..05c2189d6 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -41,8 +41,8 @@ services:
context: .
dockerfile: Dockerfile
args:
- - DESIRED_PHP_VERSION="${PHP_VERSION:-7.3}"
- - DESIRED_WP_VERSION="${WP_VERSION:-5.2}"
+ - PHP_VERSION="${PHP_VERSION:-7.3}"
+ - WP_VERSION="${WP_VERSION:-5.2}"
- USE_XDEBUG
image: woographql-testing
volumes:
diff --git a/includes/class-woocommerce-filters.php b/includes/class-woocommerce-filters.php
index 3b720a963..fe427aaf8 100644
--- a/includes/class-woocommerce-filters.php
+++ b/includes/class-woocommerce-filters.php
@@ -24,7 +24,7 @@ class WooCommerce_Filters {
* Initializes hooks for WooCommerce-related utilities.
*/
public static function setup() {
- self::$session_header = apply_filters( 'graphql_woo_cart_session_http_header', 'woocommerce-session' );
+ self::$session_header = apply_filters( 'graphql_woocommerce_cart_session_http_header', 'woocommerce-session' );
// Check if request is a GraphQL POST request.
if ( ! defined( 'NO_QL_SESSION_HANDLER' ) ) {
diff --git a/includes/class-wp-graphql-woocommerce.php b/includes/class-wp-graphql-woocommerce.php
index 0665fd928..a75cb743d 100644
--- a/includes/class-wp-graphql-woocommerce.php
+++ b/includes/class-wp-graphql-woocommerce.php
@@ -53,7 +53,7 @@ public static function instance() {
*/
public static function get_post_types() {
return apply_filters(
- 'register_graphql_wc_post_types',
+ 'graphql_woocommerce_post_types',
array(
'product',
'product_variation',
@@ -71,7 +71,7 @@ public static function get_post_types() {
*/
public static function get_enabled_product_types() {
return apply_filters(
- 'graphql_enabled_wc_product_types',
+ 'graphql_woocommerce_product_types',
array(
'simple' => 'SimpleProduct',
'variable' => 'VariableProduct',
@@ -102,7 +102,7 @@ public static function get_product_attribute_taxonomies() {
* @param array $attributes Product attributes being passed.
*/
return apply_filters(
- 'register_graphql_wc_product_attributes_taxonomies',
+ 'graphql_woocommerce_product_attributes_taxonomies',
$attributes
);
}
diff --git a/includes/data/class-factory.php b/includes/data/class-factory.php
index 636aac8db..a3dd41d0f 100644
--- a/includes/data/class-factory.php
+++ b/includes/data/class-factory.php
@@ -184,10 +184,12 @@ public static function resolve_shipping_method( $id ) {
* @return \WC_Cart
*/
public static function resolve_cart() {
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_before_calculate_totals', \WC()->cart );
new \WC_Cart_Totals( \WC()->cart );
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_after_calculate_totals', \WC()->cart );
return \WC()->cart;
diff --git a/includes/data/connection/class-customer-connection-resolver.php b/includes/data/connection/class-customer-connection-resolver.php
index 3f838fd38..e55bea372 100644
--- a/includes/data/connection/class-customer-connection-resolver.php
+++ b/includes/data/connection/class-customer-connection-resolver.php
@@ -132,6 +132,7 @@ public function get_query_args() {
}
$query_args = apply_filters(
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
'graphql_customer_connection_query_args',
$query_args,
$this->source,
diff --git a/includes/data/connection/class-product-connection-resolver.php b/includes/data/connection/class-product-connection-resolver.php
index 1b7b0fb99..bf85d9038 100644
--- a/includes/data/connection/class-product-connection-resolver.php
+++ b/includes/data/connection/class-product-connection-resolver.php
@@ -553,6 +553,7 @@ public function sanitize_input_fields( array $where_args ) {
: PHP_INT_MAX;
$meta_query[] = apply_filters(
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
'woocommerce_get_min_max_price_meta_query',
array(
'key' => '_price',
diff --git a/includes/data/loader/class-wc-post-crud-loader.php b/includes/data/loader/class-wc-post-crud-loader.php
index da1fc71f4..91d98b22a 100644
--- a/includes/data/loader/class-wc-post-crud-loader.php
+++ b/includes/data/loader/class-wc-post-crud-loader.php
@@ -53,7 +53,7 @@ private function resolve_model( $post_type, $id ) {
case 'shop_order_refund':
return new Refund( $id );
default:
- $model = apply_filters( 'wc_post_crud_loader_model', null, $post_type );
+ $model = apply_filters( 'graphql_woocommerce_crud_loader_model', null, $post_type );
if ( ! empty( $model ) ) {
return new $model( $id );
}
diff --git a/includes/data/mutation/class-cart-mutation.php b/includes/data/mutation/class-cart-mutation.php
index 1a94b921a..5ec0ab6c6 100644
--- a/includes/data/mutation/class-cart-mutation.php
+++ b/includes/data/mutation/class-cart-mutation.php
@@ -51,7 +51,7 @@ public static function prepare_cart_item( $input, $context, $info ) {
? json_decode( $input['extraData'], true )
: array();
- return apply_filters( 'woocommerce_new_cart_item_data', $cart_item_args, $input, $context, $info );
+ return apply_filters( 'graphql_woocommerce_new_cart_item_data', $cart_item_args, $input, $context, $info );
}
/**
@@ -82,7 +82,7 @@ public static function retrieve_cart_items( $input, $context, $info, $mutation =
}
}
- return apply_filters( 'retrieve_cart_items', $items, $input, $context, $info, $mutation );
+ return apply_filters( 'graphql_woocommerce_retrieve_cart_items', $items, $input, $context, $info, $mutation );
}
/**
@@ -102,7 +102,7 @@ public static function prepare_cart_fee( $input, $context, $info ) {
! empty( $input['taxClass'] ) ? $input['taxClass'] : '',
);
- return apply_filters( 'woocommerce_new_cart_fee_data', $cart_item_args, $input, $context, $info );
+ return apply_filters( 'graphql_woocommerce_new_cart_fee_data', $cart_item_args, $input, $context, $info );
}
/**
@@ -128,7 +128,7 @@ public static function item_is_valid( array $item ) {
* @throws UserError If GRAPHQL_DEBUG is set to true and errors found.
*/
public static function check_session_token() {
- $token_invalid = apply_filters( 'woo_session_token_errors', null );
+ $token_invalid = apply_filters( 'graphql_woocommerce_session_token_errors', null );
if ( $token_invalid ) {
throw new UserError( $token_invalid );
}
diff --git a/includes/data/mutation/class-checkout-mutation.php b/includes/data/mutation/class-checkout-mutation.php
index e8647160d..00600401b 100644
--- a/includes/data/mutation/class-checkout-mutation.php
+++ b/includes/data/mutation/class-checkout-mutation.php
@@ -36,6 +36,7 @@ class Checkout_Mutation {
* @return boolean
*/
public static function is_registration_required() {
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return apply_filters( 'woocommerce_checkout_registration_required', 'yes' !== get_option( 'woocommerce_enable_guest_checkout' ) );
}
@@ -103,6 +104,7 @@ public static function prepare_checkout_args( $input, $context, $info ) {
}
}
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return apply_filters( 'woocommerce_checkout_posted_data', $data, $input, $context, $info );
}
@@ -210,6 +212,7 @@ protected function update_session( $data ) {
* @throws UserError When not able to create customer.
*/
protected static function process_customer( $data ) {
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$customer_id = apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() );
if ( ! is_user_logged_in() && ( self::is_registration_required() || ! empty( $data['createaccount'] ) ) ) {
@@ -244,6 +247,7 @@ protected static function process_customer( $data ) {
}
// Add customer info from other fields.
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
if ( $customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true, WC()->checkout() ) ) {
$customer = new \WC_Customer( $customer_id );
@@ -271,16 +275,14 @@ protected static function process_customer( $data ) {
}
}
- /**
- * Action hook to adjust customer before save.
- *
- * @since 3.0.0
- */
+ // Action hook to adjust customer before save.
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_checkout_update_customer', $customer, $data );
$customer->save();
}
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_checkout_update_user_meta', $customer_id, $data );
}
@@ -345,6 +347,7 @@ protected static function validate_data( &$data ) {
/* translators: %s: field name */
$postcode_validation_notice = sprintf( __( '%s is not a valid postcode / ZIP.', 'wp-graphql-woocommerce' ), $field_label );
}
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
throw new UserError( apply_filters( 'woocommerce_checkout_postcode_validation_notice', $postcode_validation_notice, $country, $data[ $key ] ) );
}
}
@@ -434,6 +437,7 @@ protected static function validate_checkout( &$data ) {
}
}
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_after_checkout_validation', $data );
}
@@ -475,6 +479,7 @@ protected function process_order_without_payment( $order_id, $transaction_id = '
return array(
'result' => 'success',
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
'redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', $order->get_checkout_order_received_url(), $order ),
);
}
@@ -494,13 +499,13 @@ public static function process_checkout( $data, $input, $context, $info, &$resul
wc_maybe_define_constant( 'WOOCOMMERCE_CHECKOUT', true );
wc_set_time_limit( 0 );
- do_action( 'woocommerce_before_checkout_process' );
+ do_action( 'woocommerce_before_checkout_process' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
if ( WC()->cart->is_empty() ) {
throw new UserError( __( 'Sorry, your session has expired.', 'wp-graphql-woocommerce' ) );
}
- do_action( 'woocommerce_checkout_process', $data, $context, $info );
+ do_action( 'woocommerce_checkout_process', $data, $context, $info ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
// Update session for customer and totals.
self::update_session( $data );
@@ -520,6 +525,7 @@ public static function process_checkout( $data, $input, $context, $info, &$resul
throw new UserError( __( 'Unable to create order.', 'wp-graphql-woocommerce' ) );
}
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_checkout_order_processed', $order_id, $data, $order );
if ( WC()->cart->needs_payment() && ( empty( $input['isPaid'] ) || false === $input['isPaid'] ) ) {
@@ -576,6 +582,7 @@ public static function process_checkout( $data, $input, $context, $info, &$resul
*/
public static function get_value( $input ) {
// Allow 3rd parties to short circuit the logic and return their own default value.
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
if ( ! is_null( $value ) ) {
return $value;
@@ -607,6 +614,8 @@ public static function get_value( $input ) {
if ( '' === $value ) {
$value = null;
}
+
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return apply_filters( 'default_checkout_' . $input, $value, $input );
}
@@ -637,7 +646,7 @@ public static function add_order_meta( $order_id, $meta_data, $input, $context,
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_checkout_meta_save', $order, $meta_data, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_checkout_meta_save', $order, $meta_data, $input, $context, $info );
$order->save();
}
diff --git a/includes/data/mutation/class-customer-mutation.php b/includes/data/mutation/class-customer-mutation.php
index ca89759e0..d0e3bfd5a 100644
--- a/includes/data/mutation/class-customer-mutation.php
+++ b/includes/data/mutation/class-customer-mutation.php
@@ -44,7 +44,7 @@ public static function prepare_customer_props( $input, $mutation ) {
* @var array $input Input data from the GraphQL mutation
* @var string $mutation What customer mutation is being performed for context
*/
- $customer_args = apply_filters( 'woocommerce_new_customer_data', $customer_args, $input, $mutation );
+ $customer_args = apply_filters( 'woocommerce_new_customer_data', $customer_args, $input, $mutation ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return $customer_args;
}
@@ -66,7 +66,7 @@ public static function address_input_mapping( $type = 'billing', $input ) {
'address2' => 'address_2',
);
- $skip = apply_filters( 'customer_address_input_mapping_skipped', array( 'overwrite' ) );
+ $skip = apply_filters( 'graphql_woocommerce_customer_address_input_mapping_skipped', array( 'overwrite' ) );
$type = 'empty_' . $type;
$address = ! empty( $input['overwrite'] ) && true === $input['overwrite']
diff --git a/includes/data/mutation/class-order-mutation.php b/includes/data/mutation/class-order-mutation.php
index 3fb0257ff..a9c4d00ac 100644
--- a/includes/data/mutation/class-order-mutation.php
+++ b/includes/data/mutation/class-order-mutation.php
@@ -29,7 +29,7 @@ public static function authorized( $mutation = 'create', $order_id = null, $inpu
$post_type_object = get_post_type_object( 'shop_order' );
return apply_filters(
- "authorized_to_{$mutation}_orders",
+ "graphql_woocommerce_authorized_to_{$mutation}_orders",
current_user_can(
'delete' === $mutation
? $post_type_object->cap->delete_posts
@@ -78,7 +78,7 @@ public static function create_order( $input, $context, $info ) {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_order_create', $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_order_create', $input, $context, $info );
$order = \wc_create_order( $args );
if ( is_wp_error( $order ) ) {
@@ -93,7 +93,7 @@ public static function create_order( $input, $context, $info ) {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_after_order_create', $order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_order_create', $order, $input, $context, $info );
return $order->get_id();
}
@@ -126,7 +126,7 @@ public static function add_items( $input, $order_id, $context, $info ) {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( "woocommerce_graphql_before_{$type}s_added_to_order", $items, $order_id, $context, $info );
+ do_action( "graphql_woocommerce_before_{$type}s_added_to_order", $items, $order_id, $context, $info );
foreach ( $items as $item_data ) {
// Create Order item.
@@ -152,7 +152,7 @@ public static function add_items( $input, $order_id, $context, $info ) {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( "woocommerce_graphql_after_{$type}s_added_to_order", $items, $order_id, $context, $info );
+ do_action( "graphql_woocommerce_after_{$type}s_added_to_order", $items, $order_id, $context, $info );
}
}
}
@@ -331,7 +331,7 @@ public static function add_order_meta( $order_id, $input, $context, $info ) {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_order_meta_save', $order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_order_meta_save', $order, $input, $context, $info );
$order->save();
}
@@ -372,7 +372,7 @@ public static function apply_coupons( $order_id, $coupons ) {
foreach ( $coupons as $code ) {
$results = $order->apply_coupon( wc_clean( $code ) );
if ( is_wp_error( $results ) ) {
- do_action( 'woocommerce_graphql_' . $results->get_error_code(), $results, $code, $coupons, $order );
+ do_action( 'graphql_woocommerce_' . $results->get_error_code(), $results, $code, $coupons, $order );
}
}
diff --git a/includes/model/class-coupon.php b/includes/model/class-coupon.php
index 85670887d..b99cd111f 100644
--- a/includes/model/class-coupon.php
+++ b/includes/model/class-coupon.php
@@ -1,12 +1,5 @@
post_type_object->name . '_restricted_cap',
$this->get_restricted_cap()
);
diff --git a/includes/model/class-customer.php b/includes/model/class-customer.php
index 79e32eb9a..a31d6488a 100644
--- a/includes/model/class-customer.php
+++ b/includes/model/class-customer.php
@@ -35,6 +35,7 @@ public function __construct( $id = 'session' ) {
'displayName',
);
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$restricted_cap = apply_filters( 'customer_restricted_cap', 'session' === $id ? '' : 'list_users' );
parent::__construct( $restricted_cap, $allowed_restricted_fields, $id );
diff --git a/includes/model/class-order-item.php b/includes/model/class-order-item.php
index a21735660..45017ade5 100644
--- a/includes/model/class-order-item.php
+++ b/includes/model/class-order-item.php
@@ -50,6 +50,7 @@ public function __construct( $item ) {
'orderItemId',
);
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$restricted_cap = apply_filters( 'order_item_restricted_cap', '' );
parent::__construct( $restricted_cap, $allowed_restricted_fields, $author_id );
diff --git a/includes/model/class-product.php b/includes/model/class-product.php
index b1c0c4fef..a0a146a3e 100644
--- a/includes/model/class-product.php
+++ b/includes/model/class-product.php
@@ -184,17 +184,21 @@ protected function init() {
},
'description' => function() {
return ! empty( $this->data->get_description() )
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
? apply_filters( 'the_content', $this->data->get_description() )
: null;
},
'shortDescription' => function() {
$short_description = ! empty( $this->data->get_short_description() )
? apply_filters(
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
'get_the_excerpt',
$this->data->get_short_description(),
get_post( $this->data->get_id() )
)
: null;
+
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return apply_filters( 'the_excerpt', $short_description );
},
'sku' => function() {
diff --git a/includes/model/class-shipping-method.php b/includes/model/class-shipping-method.php
index 0ba216db8..ca2769639 100644
--- a/includes/model/class-shipping-method.php
+++ b/includes/model/class-shipping-method.php
@@ -32,7 +32,8 @@ public function __construct( $method ) {
'id',
'rateId',
);
-
+
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$restricted_cap = apply_filters( 'shipping_method_restricted_cap', '' );
parent::__construct( $restricted_cap, $allowed_restricted_fields, null );
diff --git a/includes/model/class-tax-rate.php b/includes/model/class-tax-rate.php
index bb2869f66..8f5e43205 100644
--- a/includes/model/class-tax-rate.php
+++ b/includes/model/class-tax-rate.php
@@ -33,6 +33,7 @@ public function __construct( $rate ) {
'rateId',
);
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$restricted_cap = apply_filters( 'tax_rate_restricted_cap', '' );
parent::__construct( $restricted_cap, $allowed_restricted_fields, null );
diff --git a/includes/mutation/class-cart-empty.php b/includes/mutation/class-cart-empty.php
index f6788babb..9bb78a841 100644
--- a/includes/mutation/class-cart-empty.php
+++ b/includes/mutation/class-cart-empty.php
@@ -64,7 +64,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Context passed.
* @param ResolveInfo $info Resolver info passed.
*/
- do_action( 'woocommerce_graphql_before_empty_cart', $cloned_cart, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_empty_cart', $cloned_cart, $input, $context, $info );
// Empty cart.
\WC()->cart->empty_cart();
@@ -77,7 +77,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Context passed.
* @param ResolveInfo $info Resolver info passed.
*/
- do_action( 'woocommerce_graphql_after_empty_cart', $cloned_cart, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_empty_cart', $cloned_cart, $input, $context, $info );
return array( 'cart' => $cloned_cart );
};
diff --git a/includes/mutation/class-cart-update-item-quantities.php b/includes/mutation/class-cart-update-item-quantities.php
index 8c2548584..f306c0a81 100644
--- a/includes/mutation/class-cart-update-item-quantities.php
+++ b/includes/mutation/class-cart-update-item-quantities.php
@@ -107,7 +107,7 @@ public static function mutate_and_get_payload() {
throw new UserError( __( 'Provided "items" invalid', 'wp-graphql-woocommerce' ) );
}
- do_action( 'woocommerce_graphql_before_set_item_quantities', $input['items'], $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_set_item_quantities', $input['items'], $input, $context, $info );
// Update quantities. If quantity set to 0, the items in removed.
$removed = array();
@@ -120,14 +120,14 @@ public static function mutate_and_get_payload() {
if ( 0 === $quantity ) {
$removed_item = \WC()->cart->get_cart_item( $key );
$removed_items[] = $removed_item;
- do_action( 'woocommerce_graphql_before_remove_item', $removed_item, 'update_quantity', $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_remove_item', $removed_item, 'update_quantity', $input, $context, $info );
$removed[ $key ] = \WC()->cart->remove_cart_item( $key );
- do_action( 'woocommerce_graphql_after_remove_item', $removed_item, 'update_quantity', $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_remove_item', $removed_item, 'update_quantity', $input, $context, $info );
continue;
}
- do_action( 'woocommerce_graphql_before_set_item_quantity', \WC()->cart->get_cart_item( $key ), $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_set_item_quantity', \WC()->cart->get_cart_item( $key ), $input, $context, $info );
$updated[ $key ] = \WC()->cart->set_quantity( $key, $quantity, true );
- do_action( 'woocommerce_graphql_after_set_item_quantity', \WC()->cart->get_cart_item( $key ), $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_set_item_quantity', \WC()->cart->get_cart_item( $key ), $input, $context, $info );
}
}
@@ -155,7 +155,7 @@ function( $value ) {
}
do_action(
- 'woocommerce_graphql_before_set_item_quantities',
+ 'graphql_woocommerce_before_set_item_quantities',
array_keys( $updated ),
array_keys( $removed ),
$input,
diff --git a/includes/mutation/class-checkout.php b/includes/mutation/class-checkout.php
index 7fc2e92c6..e7a037736 100644
--- a/includes/mutation/class-checkout.php
+++ b/includes/mutation/class-checkout.php
@@ -138,7 +138,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_checkout', $args, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_checkout', $args, $input, $context, $info );
$order_id = Checkout_Mutation::process_checkout( $args, $input, $context, $info, $results );
@@ -159,7 +159,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_after_checkout', $order_id, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_checkout', $order_id, $input, $context, $info );
return array_merge( array( 'id' => $order_id ), $results );
} catch ( Exception $e ) {
diff --git a/includes/mutation/class-order-create.php b/includes/mutation/class-order-create.php
index 6858eeb81..09027dfd8 100644
--- a/includes/mutation/class-order-create.php
+++ b/includes/mutation/class-order-create.php
@@ -66,15 +66,15 @@ public static function get_input_fields() {
),
'status' => array(
'type' => 'OrderStatusEnum',
- 'description' => __( 'Order status' ),
+ 'description' => __( 'Order status', 'wp-graphql-woocommerce' ),
),
'paymentMethod' => array(
'type' => 'String',
- 'description' => __( 'Payment method ID.', 'woocommerce' ),
+ 'description' => __( 'Payment method ID.', 'wp-graphql-woocommerce' ),
),
'paymentMethodTitle' => array(
'type' => 'String',
- 'description' => __( 'Payment method title.', 'woocommerce' ),
+ 'description' => __( 'Payment method title.', 'wp-graphql-woocommerce' ),
),
'transactionId' => array(
'type' => 'String',
@@ -189,7 +189,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_after_order_create', $order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_order_create', $order, $input, $context, $info );
return array( 'id' => $order->get_id() );
} catch ( Exception $e ) {
diff --git a/includes/mutation/class-order-delete-items.php b/includes/mutation/class-order-delete-items.php
index ad3c861ac..b081496dc 100644
--- a/includes/mutation/class-order-delete-items.php
+++ b/includes/mutation/class-order-delete-items.php
@@ -134,7 +134,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_order_items_delete', $ids, $working_order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_order_items_delete', $ids, $working_order, $input, $context, $info );
// Delete order.
$errors = '';
@@ -151,7 +151,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_after_order_delete', $ids, $working_order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_order_delete', $ids, $working_order, $input, $context, $info );
return array( 'order' => $order );
};
diff --git a/includes/mutation/class-order-delete.php b/includes/mutation/class-order-delete.php
index 4f00206d2..e22ec897b 100644
--- a/includes/mutation/class-order-delete.php
+++ b/includes/mutation/class-order-delete.php
@@ -129,7 +129,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_order_delete', $order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_order_delete', $order, $input, $context, $info );
// Delete order.
$success = Order_Mutation::purge( WC_Order_Factory::get_order( $order->ID ), $force_delete );
@@ -152,7 +152,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_after_order_delete', $order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_order_delete', $order, $input, $context, $info );
return array( 'order' => $order );
};
diff --git a/includes/mutation/class-order-update.php b/includes/mutation/class-order-update.php
index 152c4c9c3..d630ea423 100644
--- a/includes/mutation/class-order-update.php
+++ b/includes/mutation/class-order-update.php
@@ -112,7 +112,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_before_order_update', $order_id, $input, $context, $info );
+ do_action( 'graphql_woocommerce_before_order_update', $order_id, $input, $context, $info );
Order_Mutation::add_order_meta( $order_id, $input, $context, $info );
Order_Mutation::add_items( $input, $order_id, $context, $info );
@@ -158,7 +158,7 @@ public static function mutate_and_get_payload() {
* @param AppContext $context Request AppContext instance.
* @param ResolveInfo $info Request ResolveInfo instance.
*/
- do_action( 'woocommerce_graphql_after_order_update', $order, $input, $context, $info );
+ do_action( 'graphql_woocommerce_after_order_update', $order, $input, $context, $info );
return array( 'id' => $order->get_id() );
};
diff --git a/includes/type/enum/class-post-type-orderby-enum.php b/includes/type/enum/class-post-type-orderby-enum.php
index a0537128a..0100bec07 100644
--- a/includes/type/enum/class-post-type-orderby-enum.php
+++ b/includes/type/enum/class-post-type-orderby-enum.php
@@ -80,6 +80,7 @@ public static function register() {
__( 'Fields to order the %s connection by', 'wp-graphql-woocommerce' ),
$name
),
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound
'values' => apply_filters( "{$name}_orderby_enum_values", static::values() ),
)
);
diff --git a/includes/type/interface/class-product.php b/includes/type/interface/class-product.php
index 32f55051e..e24a56fcb 100644
--- a/includes/type/interface/class-product.php
+++ b/includes/type/interface/class-product.php
@@ -93,10 +93,10 @@ public static function register_interface( &$type_registry ) {
if ( empty( $product_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
} elseif ( get_post( $product_id )->post_type !== 'product' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
}
return Factory::resolve_crud_object( $product_id, $context );
@@ -162,10 +162,10 @@ public static function register_interface( &$type_registry ) {
if ( empty( $product_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s' ), $id_type, $product_id ) );
+ throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) );
} elseif ( get_post( $product_id )->post_type !== 'product' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s' ), $id_type, $product_id ) );
+ throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) );
}
return Factory::resolve_crud_object( $product_id, $context );
diff --git a/includes/type/object/class-cart-type.php b/includes/type/object/class-cart-type.php
index e35ad25a3..46f02ff3a 100644
--- a/includes/type/object/class-cart-type.php
+++ b/includes/type/object/class-cart-type.php
@@ -35,7 +35,7 @@ public static function register() {
'type' => 'Cart',
'description' => __( 'The cart object', 'wp-graphql-woocommerce' ),
'resolve' => function() {
- $token_invalid = apply_filters( 'woo_session_token_errors', null );
+ $token_invalid = apply_filters( 'graphql_woocommerce_session_token_errors', null );
if ( $token_invalid ) {
throw new UserError( $token_invalid );
}
@@ -216,7 +216,7 @@ public static function register_cart() {
'resolve' => function( $source ) {
$source->calculate_totals();
$price = isset( $source->get_totals()['total'] )
- ? apply_filters( 'woocommerce_cart_get_total', $source->get_totals()['total'] )
+ ? apply_filters( 'graphql_woocommerce_cart_get_total', $source->get_totals()['total'] )
: null;
return \wc_graphql_price( $price );
},
diff --git a/includes/type/object/class-coupon-type.php b/includes/type/object/class-coupon-type.php
index 6410e1f3a..a91f55e68 100644
--- a/includes/type/object/class-coupon-type.php
+++ b/includes/type/object/class-coupon-type.php
@@ -147,10 +147,10 @@ public static function register() {
if ( empty( $coupon_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No coupon ID was found corresponding to the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No coupon ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
} elseif ( get_post( $coupon_id )->post_type !== 'shop_coupon' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No coupon exists with the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No coupon exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
}
return Factory::resolve_crud_object( $coupon_id, $context );
@@ -211,10 +211,10 @@ public static function register() {
if ( empty( $coupon_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No coupon ID was found corresponding to the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No coupon ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
} elseif ( get_post( $coupon_id )->post_type !== 'shop_coupon' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No coupon exists with the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No coupon exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
}
return Factory::resolve_crud_object( $coupon_id, $context );
diff --git a/includes/type/object/class-downloadable-item-type.php b/includes/type/object/class-downloadable-item-type.php
index 676580aef..3332703e3 100644
--- a/includes/type/object/class-downloadable-item-type.php
+++ b/includes/type/object/class-downloadable-item-type.php
@@ -97,6 +97,7 @@ public static function register() {
);
$download->set_file(
apply_filters(
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
'woocommerce_file_download_path',
$download_data['file'],
\WC()->product_factory->get_product( $product_id ),
diff --git a/includes/type/object/class-meta-data-type.php b/includes/type/object/class-meta-data-type.php
index d2502de28..9ab8d2a4b 100644
--- a/includes/type/object/class-meta-data-type.php
+++ b/includes/type/object/class-meta-data-type.php
@@ -99,7 +99,7 @@ public static function register() {
);
}
// Create meta ID prefix.
- $id_prefix = apply_filters( 'cart_meta_id_prefix', 'cart_' );
+ $id_prefix = apply_filters( 'graphql_woocommerce_cart_meta_id_prefix', 'cart_' );
// Format meta data for resolution.
$data = array();
diff --git a/includes/type/object/class-order-item-type.php b/includes/type/object/class-order-item-type.php
index 8a3871f09..601581668 100644
--- a/includes/type/object/class-order-item-type.php
+++ b/includes/type/object/class-order-item-type.php
@@ -242,7 +242,7 @@ public static function register() {
register_graphql_object_type(
'OrderItemTax',
array(
- 'description' => __( 'Order item tax statement', 'wp-graphql-woocommercer' ),
+ 'description' => __( 'Order item tax statement', 'wp-graphql-woocommerce' ),
'fields' => array(
'taxLineId' => array(
'type' => array( 'non_null' => 'Int' ),
diff --git a/includes/type/object/class-order-type.php b/includes/type/object/class-order-type.php
index 265119d89..d77d2c999 100644
--- a/includes/type/object/class-order-type.php
+++ b/includes/type/object/class-order-type.php
@@ -385,10 +385,10 @@ public static function register() {
if ( empty( $order_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No order ID was found corresponding to the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No order ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
} elseif ( get_post( $order_id )->post_type !== 'shop_order' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No order exists with the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No order exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
}
// Check if user authorized to view order.
diff --git a/includes/type/object/class-product-types.php b/includes/type/object/class-product-types.php
index 354d6bbc4..500814ca5 100644
--- a/includes/type/object/class-product-types.php
+++ b/includes/type/object/class-product-types.php
@@ -418,13 +418,13 @@ private static function register_product_query( $type ) {
if ( empty( $product_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s' ), $id_type, $product_id ) );
+ throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) );
} elseif ( \WC()->product_factory->get_product_type( $product_id ) !== $type ) {
/* translators: Invalid product type message %1$s: Product ID, %2$s: Product type */
- throw new UserError( sprintf( __( 'This product of ID %1$s is not a %2$s product' ), $product_id, $type ) );
+ throw new UserError( sprintf( __( 'This product of ID %1$s is not a %2$s product', 'wp-graphql-woocommerce' ), $product_id, $type ) );
} elseif ( get_post( $product_id )->post_type !== 'product' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s' ), $id_type, $product_id ) );
+ throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) );
}
$product = Factory::resolve_crud_object( $product_id, $context );
diff --git a/includes/type/object/class-product-variation-type.php b/includes/type/object/class-product-variation-type.php
index 45b453602..fe3373a0a 100644
--- a/includes/type/object/class-product-variation-type.php
+++ b/includes/type/object/class-product-variation-type.php
@@ -298,10 +298,10 @@ public static function register() {
if ( empty( $variation_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product variation ID was found corresponding to the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No product variation ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
} elseif ( get_post( $variation_id )->post_type !== 'product_variation' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No product variation exists with the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No product variation exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
}
return Factory::resolve_crud_object( $variation_id, $context );
diff --git a/includes/type/object/class-refund-type.php b/includes/type/object/class-refund-type.php
index e53ab0c66..246ee3054 100644
--- a/includes/type/object/class-refund-type.php
+++ b/includes/type/object/class-refund-type.php
@@ -99,10 +99,10 @@ public static function register() {
if ( empty( $refund_id ) ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No refund ID was found corresponding to the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No refund ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
} elseif ( get_post( $refund_id )->post_type !== 'shop_order_refund' ) {
/* translators: %1$s: ID type, %2$s: ID value */
- throw new UserError( sprintf( __( 'No refund exists with the %1$s: %2$s' ), $id_type, $id ) );
+ throw new UserError( sprintf( __( 'No refund exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $id ) );
}
// Check if user authorized to view order.
diff --git a/includes/type/object/class-shipping-method-type.php b/includes/type/object/class-shipping-method-type.php
index 2780279dc..fe810fff8 100644
--- a/includes/type/object/class-shipping-method-type.php
+++ b/includes/type/object/class-shipping-method-type.php
@@ -26,7 +26,7 @@ public static function register() {
register_graphql_object_type(
'ShippingMethod',
array(
- 'description' => __( 'A shipping method object', 'wp-graphql-woocommercer' ),
+ 'description' => __( 'A shipping method object', 'wp-graphql-woocommerce' ),
'interfaces' => array( 'Node' ),
'fields' => array(
'id' => array(
diff --git a/includes/type/object/class-shipping-package-type.php b/includes/type/object/class-shipping-package-type.php
index f12f24403..6cb195e62 100644
--- a/includes/type/object/class-shipping-package-type.php
+++ b/includes/type/object/class-shipping-package-type.php
@@ -32,6 +32,8 @@ public static function register() {
foreach ( $source['contents'] as $item_id => $values ) {
$product_names[ $item_id ] = $values['data']->get_name() . ' ×' . $values['quantity'];
}
+
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
$product_names = apply_filters( 'woocommerce_shipping_package_details_array', $product_names, $source );
return implode( ', ', $product_names );
@@ -48,6 +50,7 @@ public static function register() {
'type' => 'Boolean',
'description' => __( 'This shipping package supports the shipping calculator.', 'wp-graphql-woocommerce' ),
'resolve' => function( $source ) {
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return apply_filters( 'woocommerce_shipping_show_shipping_calculator', true, $source['index'], $source );
},
),
diff --git a/includes/utils/class-ql-session-handler.php b/includes/utils/class-ql-session-handler.php
index a641fabb9..7f6749d3b 100644
--- a/includes/utils/class-ql-session-handler.php
+++ b/includes/utils/class-ql-session-handler.php
@@ -49,7 +49,7 @@ class QL_Session_Handler extends WC_Session_Handler {
* Constructor for the session class.
*/
public function __construct() {
- $this->_token = apply_filters( 'graphql_woo_cart_session_http_header', 'woocommerce-session' );
+ $this->_token = apply_filters( 'graphql_woocommerce_cart_session_http_header', 'woocommerce-session' );
$this->_table = $GLOBALS['wpdb']->prefix . 'woocommerce_sessions';
}
@@ -238,7 +238,7 @@ public function init_session_token() {
} else {
if ( is_wp_error( $token ) ) {
add_filter(
- 'woo_session_token_errors',
+ 'graphql_woocommerce_session_token_errors',
function( $errors ) use ( $token ) {
$errors = $token->get_error_message();
return $errors;
@@ -317,7 +317,7 @@ public function get_session_header() {
*
* @param string $session_header The header used to identify a user's cart session token.
*/
- return apply_filters( 'graphql_woo_cart_session_header', $session_header );
+ return apply_filters( 'graphql_woocommerce_cart_session_header', $session_header );
}
/**
@@ -362,7 +362,7 @@ public function set_customer_session_token( $set ) {
* @param array $session_data Session data associated with token.
*/
$token = apply_filters(
- 'graphql_woo_cart_session_before_token_sign',
+ 'graphql_woocommerce_cart_session_before_token_sign',
$token,
$this->_customer_id,
$this->_data
@@ -382,7 +382,7 @@ public function set_customer_session_token( $set ) {
* @param array $session_data Session data associated with token.
*/
$token = apply_filters(
- 'graphql_woo_cart_session_signed_token',
+ 'graphql_woocommerce_cart_session_signed_token',
$token,
$this->_customer_id,
$this->_data
@@ -425,7 +425,7 @@ public function set_session_expiration() {
$this->_session_issued = time();
// 48 Hours.
$this->_session_expiration = apply_filters(
- 'graphql_woo_cart_session_expire',
+ 'graphql_woocommerce_cart_session_expire',
time() + ( 3600 * 48 )
);
// 47 Hours.
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 156abf9cd..17e31e50e 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInitcab7a6a7239ac8af7f5a764eb6b56ee1::getLoader();
+return ComposerAutoloaderInit605a02cd7bfd584c6ac9e4f2b4d51817::getLoader();
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 677e21cc7..0f377840e 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInitcab7a6a7239ac8af7f5a764eb6b56ee1
+class ComposerAutoloaderInit605a02cd7bfd584c6ac9e4f2b4d51817
{
private static $loader;
@@ -19,15 +19,15 @@ public static function getLoader()
return self::$loader;
}
- spl_autoload_register(array('ComposerAutoloaderInitcab7a6a7239ac8af7f5a764eb6b56ee1', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInit605a02cd7bfd584c6ac9e4f2b4d51817', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
- spl_autoload_unregister(array('ComposerAutoloaderInitcab7a6a7239ac8af7f5a764eb6b56ee1', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInit605a02cd7bfd584c6ac9e4f2b4d51817', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
- call_user_func(\Composer\Autoload\ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1::getInitializer($loader));
+ call_user_func(\Composer\Autoload\ComposerStaticInit605a02cd7bfd584c6ac9e4f2b4d51817::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ public static function getLoader()
$loader->register(true);
if ($useStaticLoader) {
- $includeFiles = Composer\Autoload\ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1::$files;
+ $includeFiles = Composer\Autoload\ComposerStaticInit605a02cd7bfd584c6ac9e4f2b4d51817::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
- composerRequirecab7a6a7239ac8af7f5a764eb6b56ee1($fileIdentifier, $file);
+ composerRequire605a02cd7bfd584c6ac9e4f2b4d51817($fileIdentifier, $file);
}
return $loader;
}
}
-function composerRequirecab7a6a7239ac8af7f5a764eb6b56ee1($fileIdentifier, $file)
+function composerRequire605a02cd7bfd584c6ac9e4f2b4d51817($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 96c787a5e..d0583a046 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
namespace Composer\Autoload;
-class ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1
+class ComposerStaticInit605a02cd7bfd584c6ac9e4f2b4d51817
{
public static $files = array (
'914b07b8cf678ed0b81bfdb5d23b4f2b' => __DIR__ . '/../..' . '/includes/connection/common-post-type-args.php',
@@ -171,9 +171,9 @@ class ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
- $loader->prefixLengthsPsr4 = ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1::$prefixLengthsPsr4;
- $loader->prefixDirsPsr4 = ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1::$prefixDirsPsr4;
- $loader->classMap = ComposerStaticInitcab7a6a7239ac8af7f5a764eb6b56ee1::$classMap;
+ $loader->prefixLengthsPsr4 = ComposerStaticInit605a02cd7bfd584c6ac9e4f2b4d51817::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInit605a02cd7bfd584c6ac9e4f2b4d51817::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInit605a02cd7bfd584c6ac9e4f2b4d51817::$classMap;
}, null, ClassLoader::class);
}
diff --git a/wp-graphql-woocommerce.php b/wp-graphql-woocommerce.php
index ba3a45b00..00fd88143 100644
--- a/wp-graphql-woocommerce.php
+++ b/wp-graphql-woocommerce.php
@@ -30,15 +30,19 @@
*/
if ( file_exists( __DIR__ . '/c3.php' ) ) {
// Get tests output directory.
- $test_dir = __DIR__ . '/tests/output';
- define( 'C3_CODECOVERAGE_ERROR_LOG_FILE', $test_dir . '/c3_error.log' );
+ $woographql_test_dir = __DIR__ . '/tests/output';
+
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
+ define( 'C3_CODECOVERAGE_ERROR_LOG_FILE', $woographql_test_dir . '/c3_error.log' );
+
+ // Import c3 file.
require_once __DIR__ . '/c3.php';
}
/**
* Setups WPGraphQL WooCommerce constants
*/
-function wp_graphql_woocommerce_constants() {
+function woographql_constants() {
// Plugin version.
if ( ! defined( 'WPGRAPHQL_WOOCOMMERCE_VERSION' ) ) {
define( 'WPGRAPHQL_WOOCOMMERCE_VERSION', '0.4.3' );
@@ -64,7 +68,7 @@ function wp_graphql_woocommerce_constants() {
/**
* Checks if WPGraphQL WooCommerce required plugins are installed and activated
*/
-function wp_graphql_woocommerce_dependencies_not_ready() {
+function woographql_dependencies_not_ready() {
$deps = array();
if ( ! class_exists( '\WPGraphQL' ) ) {
$deps[] = 'WPGraphQL';
@@ -79,10 +83,10 @@ function wp_graphql_woocommerce_dependencies_not_ready() {
/**
* Initializes WPGraphQL WooCommerce
*/
-function wp_graphql_woocommerce_init() {
- wp_graphql_woocommerce_constants();
+function woographql_init() {
+ woographql_constants();
- $not_ready = wp_graphql_woocommerce_dependencies_not_ready();
+ $not_ready = woographql_dependencies_not_ready();
if ( empty( $not_ready ) ) {
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'includes/class-wp-graphql-woocommerce.php';
return WP_GraphQL_WooCommerce::instance();
@@ -111,4 +115,4 @@ function() use ( $dep ) {
return false;
}
-add_action( 'graphql_init', 'wp_graphql_woocommerce_init' );
+add_action( 'graphql_init', 'woographql_init' );