Skip to content

Commit

Permalink
Merge bd4f35e into 0603f83
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 authored Feb 20, 2020
2 parents 0603f83 + bd4f35e commit 39355a9
Show file tree
Hide file tree
Showing 51 changed files with 284 additions and 243 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/testing-integration.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions .github/workflows/wordpress-coding-standards.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions .phpcs.ruleset.xml → .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<description>Generally-applicable sniffs for WordPress plugins.</description>

<!-- What to scan -->
<file>.</file>
<file>wp-graphql-woocommerce.php</file>
<file>access-functions.php</file>
<file>class-inflect.php</file>
<file>includes/</file>
<exclude-pattern>/vendor/</exclude-pattern>
<exclude-pattern>/node_modules/</exclude-pattern>
<exclude-pattern>/tests/</exclude-pattern>
Expand All @@ -19,21 +22,18 @@

<!-- Rules: Check PHP version compatibility -->
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.3-"/>
<config name="testVersion" value="5.6-"/>
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>

<!-- Rules: WordPress Coding Standards -->
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
<config name="minimum_supported_wp_version" value="4.6"/>
<rule ref="WordPress">
<exclude name="WordPress.VIP"/>
</rule>
<config name="minimum_supported_wp_version" value="4.9"/>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
<property name="prefixes" type="array" value="WPGraphQL\WooCommerce"/>
<property name="prefixes" type="array" value="WPGraphQL\WooCommerce,woographql,WPGRAPHQL_WOOCOMMERCE,WP_GraphQL_WooCommerce,graphql_,wc_graphql_"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
Expand Down
115 changes: 0 additions & 115 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<a href="https://woographql.axistaylor.com/" target="_blank">Docs</a> • <a href="https://www.axistaylor.com" target="_blank">AxisTaylor</a> • <a href="https://wpgql-slack.herokuapp.com/" target="_blank">Join Slack</a>

[![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/)
Expand Down
31 changes: 25 additions & 6 deletions access-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 );

Expand All @@ -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 );
}

/**
Expand All @@ -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 );
}
2 changes: 1 addition & 1 deletion class-inflect.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Class Inflect
*/
class Inflect {
class Inflect { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
/**
* Stores plural suffixes.
*
Expand Down
Loading

0 comments on commit 39355a9

Please sign in to comment.