Applied PHPCS To Beta Tester (#39476)

This commit is contained in:
Christopher Allford 2023-08-08 17:20:34 -07:00 committed by GitHub
parent 8f147eafb2
commit 4549bc82c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 552 additions and 169 deletions

View File

@ -9,8 +9,6 @@ defaults:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
env:
PHPCS: ./plugins/woocommerce/vendor/bin/phpcs # Run WooCommerce phpcs setup in phpcs-changed instead of default
permissions: {} permissions: {}
@ -30,6 +28,7 @@ jobs:
id: changed-files id: changed-files
uses: tj-actions/changed-files@v32 uses: tj-actions/changed-files@v32
with: with:
path: plugins/woocommerce
files: | files: |
**/*.php **/*.php
@ -41,6 +40,7 @@ jobs:
- name: Tool versions - name: Tool versions
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
working-directory: plugins/woocommerce
run: | run: |
php --version php --version
composer --version composer --version
@ -48,6 +48,7 @@ jobs:
- name: Run PHPCS - name: Run PHPCS
if: steps.changed-files.outputs.any_changed == 'true' if: steps.changed-files.outputs.any_changed == 'true'
working-directory: plugins/woocommerce
run: | run: |
HEAD_REF=$(git rev-parse HEAD) HEAD_REF=$(git rev-parse HEAD)
git checkout $HEAD_REF git checkout $HEAD_REF

View File

@ -20,6 +20,10 @@ jobs:
- name: Setup WooCommerce Monorepo - name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo uses: ./.github/actions/setup-woocommerce-monorepo
- name: Lint
working-directory: plugins/woocommerce-beta-tester
run: composer run phpcs
- name: Build WooCommerce Beta Tester Zip - name: Build WooCommerce Beta Tester Zip
working-directory: plugins/woocommerce-beta-tester working-directory: plugins/woocommerce-beta-tester
run: pnpm build:zip run: pnpm build:zip

View File

@ -0,0 +1,7 @@
{
"phpVersion": "7.4",
"plugins": [
".",
"https://downloads.wordpress.org/plugin/woocommerce.zip"
]
}

View File

@ -1,4 +1,7 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
use Automattic\WooCommerce\Admin\Notes\Note; use Automattic\WooCommerce\Admin\Notes\Note;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
@ -6,7 +9,11 @@ register_woocommerce_admin_test_helper_rest_route(
'admin_notes_add_note' 'admin_notes_add_note'
); );
/**
* Adds an admin note.
*
* @param WP_REST_Request $request Full data about the request.
*/
function admin_notes_add_note( $request ) { function admin_notes_add_note( $request ) {
$note = new Note(); $note = new Note();
$mock_note_data = get_mock_note_data(); $mock_note_data = get_mock_note_data();
@ -30,6 +37,11 @@ function admin_notes_add_note( $request ) {
return true; return true;
} }
/**
* Adds an email note parameter.
*
* @param Note $note The note to add parameters to.
*/
function add_email_note_params( $note ) { function add_email_note_params( $note ) {
$additional_data = array( $additional_data = array(
'role' => 'administrator', 'role' => 'administrator',
@ -37,6 +49,11 @@ function add_email_note_params( $note ) {
$note->set_content_data( (object) $additional_data ); $note->set_content_data( (object) $additional_data );
} }
/**
* Possibly adds an action to a note.
*
* @param Note $note The note to check and add an action to.
*/
function possibly_add_action( $note ) { function possibly_add_action( $note ) {
if ( $note->get_type() === 'info' ) { if ( $note->get_type() === 'info' ) {
return; return;
@ -48,6 +65,9 @@ function possibly_add_action( $note ) {
$note->add_action( $action_name, 'Test action', wc_admin_url() ); $note->add_action( $action_name, 'Test action', wc_admin_url() );
} }
/**
* Gets mock note data.
*/
function get_mock_note_data() { function get_mock_note_data() {
$plugin_url = site_url() . '/wp-content/plugins/woocommerce-admin-test-helper/'; $plugin_url = site_url() . '/wp-content/plugins/woocommerce-admin-test-helper/';
return array( return array(
@ -55,13 +75,13 @@ function get_mock_note_data() {
'info' => array( 'info' => array(
'banner' => $plugin_url . 'images/admin-notes/banner.jpg', 'banner' => $plugin_url . 'images/admin-notes/banner.jpg',
'thumbnail' => $plugin_url . 'images/admin-notes/thumbnail.jpg', 'thumbnail' => $plugin_url . 'images/admin-notes/thumbnail.jpg',
'plain' => '' 'plain' => '',
), ),
'email' => array( 'email' => array(
'plain' => $plugin_url . 'images/admin-notes/woocommerce-logo-vector.png' 'plain' => $plugin_url . 'images/admin-notes/woocommerce-logo-vector.png',
), ),
'update' => array( 'update' => array(
'plain' => '' 'plain' => '',
) ),
); );
} }

View File

@ -1,9 +1,15 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/admin-notes/delete-all-notes/v1', '/admin-notes/delete-all-notes/v1',
'admin_notes_delete_all_notes' 'admin_notes_delete_all_notes'
); );
/**
* Deletes all admin notes.
*/
function admin_notes_delete_all_notes() { function admin_notes_delete_all_notes() {
global $wpdb; global $wpdb;

View File

@ -5,6 +5,8 @@
* @package WC_Beta_Tester * @package WC_Beta_Tester
*/ */
defined( 'ABSPATH' ) || exit;
/** /**
* Register the test helper route. * Register the test helper route.
* *
@ -23,7 +25,7 @@ function register_woocommerce_admin_test_helper_rest_route( $route, $callback, $
if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) { if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
return new \WP_Error( return new \WP_Error(
'woocommerce_rest_cannot_edit', 'woocommerce_rest_cannot_edit',
__( 'Sorry, you cannot perform this action', 'woocommerce' ) __( 'Sorry, you cannot perform this action', 'woocommerce-beta-tester' )
); );
} }
return true; return true;
@ -52,7 +54,7 @@ require 'tools/disable-wc-email.php';
require 'tools/trigger-update-callbacks.php'; require 'tools/trigger-update-callbacks.php';
require 'tracks/class-tracks-debug-log.php'; require 'tracks/class-tracks-debug-log.php';
require 'features/features.php'; require 'features/features.php';
require 'rest-api-filters/rest-api-filters.php'; require 'rest-api-filters/class-wca-test-helper-rest-api-filters.php';
require 'rest-api-filters/hook.php'; require 'rest-api-filters/hook.php';
require 'live-branches/manifest.php'; require 'live-branches/manifest.php';
require 'live-branches/install.php'; require 'live-branches/install.php';

View File

@ -1,5 +1,6 @@
<?php <?php
use Automattic\WooCommerce\Admin\Features\Features;
defined( 'ABSPATH' ) || exit;
const OPTION_NAME_PREFIX = 'wc_admin_helper_feature_values'; const OPTION_NAME_PREFIX = 'wc_admin_helper_feature_values';
@ -27,6 +28,11 @@ register_woocommerce_admin_test_helper_rest_route(
) )
); );
/**
* Toggles a feature.
*
* @param WP_REST_Request $request Full data about the request.
*/
function toggle_feature( $request ) { function toggle_feature( $request ) {
$features = get_features(); $features = get_features();
$custom_feature_values = get_option( OPTION_NAME_PREFIX, array() ); $custom_feature_values = get_option( OPTION_NAME_PREFIX, array() );
@ -46,11 +52,17 @@ function toggle_feature( $request ) {
return new WP_REST_Response( get_features(), 200 ); return new WP_REST_Response( get_features(), 200 );
} }
/**
* Resets all features to their default values.
*/
function reset_features() { function reset_features() {
delete_option( OPTION_NAME_PREFIX ); delete_option( OPTION_NAME_PREFIX );
return new WP_REST_Response( get_features(), 200 ); return new WP_REST_Response( get_features(), 200 );
} }
/**
* Gets all features.
*/
function get_features() { function get_features() {
if ( function_exists( 'wc_admin_get_feature_config' ) ) { if ( function_exists( 'wc_admin_get_feature_config' ) ) {
return apply_filters( 'woocommerce_admin_get_feature_config', wc_admin_get_feature_config() ); return apply_filters( 'woocommerce_admin_get_feature_config', wc_admin_get_feature_config() );

View File

@ -1,10 +1,12 @@
<?php // @codingStandardsIgnoreLine I don't know why it thinks the doc comment is missing. <?php
/** /**
* REST API endpoints for live branches installation. * REST API endpoints for live branches installation.
* *
* @package WC_Beta_Tester * @package WC_Beta_Tester
*/ */
defined( 'ABSPATH' ) || exit;
require_once __DIR__ . '/../../includes/class-wc-beta-tester-live-branches-installer.php'; require_once __DIR__ . '/../../includes/class-wc-beta-tester-live-branches-installer.php';
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
@ -37,7 +39,7 @@ register_woocommerce_admin_test_helper_rest_route(
} else { } else {
return new \WP_Error( return new \WP_Error(
'woocommerce_rest_cannot_edit', 'woocommerce_rest_cannot_edit',
__( 'Sorry, you cannot perform this action', 'woocommerce' ) __( 'Sorry, you cannot perform this action', 'woocommerce-beta-tester' )
); );
} }
}, },

View File

@ -1,10 +1,12 @@
<?php // @codingStandardsIgnoreLine <?php
/** /**
* Register REST endpoint for fetching live branches manifest. * Register REST endpoint for fetching live branches manifest.
* *
* @package WC_Beta_Tester * @package WC_Beta_Tester
*/ */
defined( 'ABSPATH' ) || exit;
require_once __DIR__ . '/../../includes/class-wc-beta-tester-live-branches-installer.php'; require_once __DIR__ . '/../../includes/class-wc-beta-tester-live-branches-installer.php';
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(

View File

@ -1,5 +1,9 @@
<?php <?php
use function WP_CLI\Utils\esc_like;
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/options', '/options',
'wca_test_helper_get_options', 'wca_test_helper_get_options',
@ -40,20 +44,31 @@ register_woocommerce_admin_test_helper_rest_route(
) )
); );
/**
* A helper to delete options.
*
* @param WP_REST_Request $request The full request data.
*/
function wca_test_helper_delete_option( $request ) { function wca_test_helper_delete_option( $request ) {
global $wpdb; global $wpdb;
$option_names = explode( ',', $request->get_param( 'option_names' ) ); $option_names = explode( ',', $request->get_param( 'option_names' ) );
$option_names = array_map( function( $option_name ) { $option_tokens = implode( ',', array_fill( 0, count( $option_names ), '%s' ) );
return "'" . $option_name . "'";
}, $option_names );
$option_names = implode( ',', $option_names ); $wpdb->query(
$query = "delete from {$wpdb->prefix}options where option_name in ({$option_names})"; $wpdb->prepare(
$wpdb->query( $query ); "DELETE FROM {$wpdb->prefix}options WHERE option_name IN ({$option_tokens})", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
...$option_names,
)
);
return new WP_REST_RESPONSE( null, 204 ); return new WP_REST_RESPONSE( null, 204 );
} }
/**
* A helper to get options.
*
* @param WP_REST_Request $request The full request data.
*/
function wca_test_helper_get_options( $request ) { function wca_test_helper_get_options( $request ) {
global $wpdb; global $wpdb;
@ -61,18 +76,23 @@ function wca_test_helper_get_options( $request ) {
$page = $request->get_param( 'page' ); $page = $request->get_param( 'page' );
$search = $request->get_param( 'search' ); $search = $request->get_param( 'search' );
$query = " $query = "SELECT option_id, option_name, option_value, autoload FROM {$wpdb->prefix}options";
select option_id, option_name, option_value, autoload
from {$wpdb->prefix}options
";
if ( $search ) { if ( $search ) {
$query .= "where option_name like '%{$search}%'"; $search = $wpdb->esc_like( $search );
$query .= ' WHERE option_name LIKE %s';
} }
$query .= ' order by option_id desc limit 30'; $query .= ' ORDER BY option_id DESC LIMIT %d OFFSET %d';
$offset = ( $page - 1 ) * $per_page;
$options = $wpdb->get_results( $query ); if ( $search ) {
$query = $wpdb->prepare( $query, $search, $per_page, $offset ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
} else {
$query = $wpdb->prepare( $query, $per_page, $offset ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
}
$options = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
return new WP_REST_Response( $options, 200 ); return new WP_REST_Response( $options, 200 );
} }

View File

@ -1,5 +1,7 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/rest-api-filters', '/rest-api-filters',
array( WCA_Test_Helper_Rest_Api_Filters::class, 'create' ), array( WCA_Test_Helper_Rest_Api_Filters::class, 'create' ),
@ -52,7 +54,9 @@ register_woocommerce_admin_test_helper_rest_route(
) )
); );
/**
* Class WCA_Test_Helper_Rest_Api_Filters.
*/
class WCA_Test_Helper_Rest_Api_Filters { class WCA_Test_Helper_Rest_Api_Filters {
const WC_ADMIN_TEST_HELPER_REST_API_FILTER_OPTION = 'wc-admin-test-helper-rest-api-filters'; const WC_ADMIN_TEST_HELPER_REST_API_FILTER_OPTION = 'wc-admin-test-helper-rest-api-filters';

View File

@ -1,20 +1,33 @@
<?php <?php
$filters = get_option(WCA_Test_Helper_Rest_Api_Filters::WC_ADMIN_TEST_HELPER_REST_API_FILTER_OPTION, [] ); defined( 'ABSPATH' ) || exit;
$filters = get_option( WCA_Test_Helper_Rest_Api_Filters::WC_ADMIN_TEST_HELPER_REST_API_FILTER_OPTION, array() );
/**
* Sets an array value using dot notation.
*
* @param array $array The array to set the value on.
* @param string $key The dot notation key to set.
* @param mixed $value The value to set.
*/
function array_dot_set( &$array, $key, $value ) { function array_dot_set( &$array, $key, $value ) {
if ( is_null( $key ) ) { if ( is_null( $key ) ) {
return $array = $value; $array = $value;
return $array;
} }
$keys = explode( '.', $key ); $keys = explode( '.', $key );
while ( count($keys) > 1 ) { $key_count = count( $keys );
while ( $key_count > 1 ) {
$key = array_shift( $keys ); $key = array_shift( $keys );
if ( ! isset( $array[ $key ] ) || ! is_array( $array[ $key ] ) ) { if ( ! isset( $array[ $key ] ) || ! is_array( $array[ $key ] ) ) {
$array[$key] = []; $array[ $key ] = array();
} }
$array = &$array[ $key ]; $array = &$array[ $key ];
--$key_count;
} }
$array[ array_shift( $keys ) ] = $value; $array[ array_shift( $keys ) ] = $value;
@ -29,8 +42,9 @@ add_filter(
} }
$route = $request->get_route(); $route = $request->get_route();
$filters = array_filter( $filters = array_filter(
$filters, function ( $filter ) use ( $request, $route ) { $filters,
if ($filter['enabled'] && $filter['endpoint'] == $route ) { function ( $filter ) use ( $request, $route ) {
if ( $filter['enabled'] && $filter['endpoint'] === $route ) {
return true; return true;
} }
return false; return false;

View File

@ -1,9 +1,15 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/tools/delete-all-products/v1', '/tools/delete-all-products/v1',
'tools_delete_all_products' 'tools_delete_all_products'
); );
/**
* A tool to delete all products.
*/
function tools_delete_all_products() { function tools_delete_all_products() {
$query = new \WC_Product_Query(); $query = new \WC_Product_Query();
$products = $query->get_products(); $products = $query->get_products();

View File

@ -1,4 +1,7 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/tools/toggle-emails/v1', '/tools/toggle-emails/v1',
'toggle_emails' 'toggle_emails'
@ -12,9 +15,12 @@ register_woocommerce_admin_test_helper_rest_route(
) )
); );
/**
* A tool to toggle all WooCommerce emails.
*/
function toggle_emails() { function toggle_emails() {
$emails_disabled = 'yes'; $emails_disabled = 'yes';
if ( $emails_disabled === get_option( 'wc_admin_test_helper_email_disabled', 'no' ) ) { if ( get_option( 'wc_admin_test_helper_email_disabled', 'no' ) === $emails_disabled ) {
$emails_disabled = 'no'; $emails_disabled = 'no';
remove_filter( 'woocommerce_email_get_option', 'disable_wc_emails' ); remove_filter( 'woocommerce_email_get_option', 'disable_wc_emails' );
} }
@ -22,6 +28,9 @@ function toggle_emails() {
return new WP_REST_Response( $emails_disabled, 200 ); return new WP_REST_Response( $emails_disabled, 200 );
} }
/**
* A tool to get the status of the WooCommerce emails option.
*/
function get_email_status() { function get_email_status() {
$emails_disabled = get_option( 'wc_admin_test_helper_email_disabled', 'no' ); $emails_disabled = get_option( 'wc_admin_test_helper_email_disabled', 'no' );
return new WP_REST_Response( $emails_disabled, 200 ); return new WP_REST_Response( $emails_disabled, 200 );
@ -32,12 +41,22 @@ if ( 'yes' === get_option( 'wc_admin_test_helper_email_disabled', 'no' ) ) {
add_action( 'woocommerce_email', 'unhook_other_wc_emails' ); add_action( 'woocommerce_email', 'unhook_other_wc_emails' );
} }
/**
* A hook for filtering the disabling of WooCommerce emails.
*
* @param string $key The email option key.
*/
function disable_wc_emails( $key ) { function disable_wc_emails( $key ) {
if ( $key === 'enabled' ) { if ( 'enabled' === $key ) {
return false; return false;
} }
} }
/**
* Unhooks WooCommerce emails.
*
* @param Object $email The email object.
*/
function unhook_other_wc_emails( $email ) { function unhook_other_wc_emails( $email ) {
remove_action( 'woocommerce_low_stock_notification', array( $email, 'low_stock' ) ); remove_action( 'woocommerce_low_stock_notification', array( $email, 'low_stock' ) );
remove_action( 'woocommerce_no_stock_notification', array( $email, 'no_stock' ) ); remove_action( 'woocommerce_no_stock_notification', array( $email, 'no_stock' ) );

View File

@ -1,9 +1,15 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/tools/run-wc-admin-daily/v1', '/tools/run-wc-admin-daily/v1',
'tools_run_wc_admin_daily' 'tools_run_wc_admin_daily'
); );
/**
* A tool to run the daily wc-admin cron.
*/
function tools_run_wc_admin_daily() { function tools_run_wc_admin_daily() {
do_action( 'wc_admin_daily' ); do_action( 'wc_admin_daily' );

View File

@ -1,4 +1,7 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/tools/get-cron-list/v1', '/tools/get-cron-list/v1',
'tools_get_cron_list', 'tools_get_cron_list',
@ -26,6 +29,9 @@ register_woocommerce_admin_test_helper_rest_route(
) )
); );
/**
* A tool to list the crons for WooCommerce Admin.
*/
function tools_get_cron_list() { function tools_get_cron_list() {
$crons = _get_cron_array(); $crons = _get_cron_array();
$events = array(); $events = array();
@ -47,6 +53,11 @@ function tools_get_cron_list() {
return new WP_REST_Response( $events, 200 ); return new WP_REST_Response( $events, 200 );
} }
/**
* A tool to trigger a selected cron.
*
* @param WP_REST_Request $request The full request data.
*/
function trigger_selected_cron( $request ) { function trigger_selected_cron( $request ) {
$hook = $request->get_param( 'hook' ); $hook = $request->get_param( 'hook' );
$signature = $request->get_param( 'signature' ); $signature = $request->get_param( 'signature' );
@ -66,10 +77,13 @@ function trigger_selected_cron( $request ) {
return $scheduled; return $scheduled;
} }
add_filter( 'cron_request', function( array $cron_request ) { add_filter(
'cron_request',
function( array $cron_request ) {
$cron_request['url'] = add_query_arg( 'run-cron', 1, $cron_request['url'] ); $cron_request['url'] = add_query_arg( 'run-cron', 1, $cron_request['url'] );
return $cron_request; return $cron_request;
} ); }
);
spawn_cron(); spawn_cron();
sleep( 1 ); sleep( 1 );
@ -79,6 +93,12 @@ function trigger_selected_cron( $request ) {
return false; return false;
} }
/**
* Schedules a cron event.
*
* @param string $hook The hook to schedule.
* @param array $args The arguments to use for the event.
*/
function schedule_event( $hook, $args = array() ) { function schedule_event( $hook, $args = array() ) {
$event = (object) array( $event = (object) array(
'hook' => $hook, 'hook' => $hook,
@ -87,6 +107,7 @@ function schedule_event( $hook, $args = array() ) {
'args' => $args, 'args' => $args,
); );
$crons = (array) _get_cron_array(); $crons = (array) _get_cron_array();
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
$key = md5( serialize( $event->args ) ); $key = md5( serialize( $event->args ) );
$crons[ $event->timestamp ][ $event->hook ][ $key ] = array( $crons[ $event->timestamp ][ $event->hook ][ $key ] = array(

View File

@ -1,6 +1,6 @@
<?php <?php
use Automattic\WooCommerce\Admin\API\Reports\Cache; defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/tools/get-update-versions/v1', '/tools/get-update-versions/v1',
@ -19,17 +19,25 @@ register_woocommerce_admin_test_helper_rest_route(
'description' => 'Name of the update version', 'description' => 'Name of the update version',
'type' => 'string', 'type' => 'string',
'sanitize_callback' => 'sanitize_text_field', 'sanitize_callback' => 'sanitize_text_field',
) ),
), ),
) )
); );
/**
* A tool to get the list of WooCommerce Admin update versions.
*/
function tools_get_wc_admin_versions() { function tools_get_wc_admin_versions() {
$db_updates = \WC_Install::get_db_update_callbacks(); $db_updates = \WC_Install::get_db_update_callbacks();
return new WP_REST_Response( array_keys( $db_updates ), 200 ); return new WP_REST_Response( array_keys( $db_updates ), 200 );
} }
/**
* Triggers the selected version update callback.
*
* @param WP_REST_Request $request The full request data.
*/
function trigger_selected_update_callbacks( $request ) { function trigger_selected_update_callbacks( $request ) {
$version = $request->get_param( 'version' ); $version = $request->get_param( 'version' );
if ( ! isset( $version ) ) { if ( ! isset( $version ) ) {

View File

@ -1,9 +1,15 @@
<?php <?php
defined( 'ABSPATH' ) || exit;
register_woocommerce_admin_test_helper_rest_route( register_woocommerce_admin_test_helper_rest_route(
'/tools/trigger-wca-install/v1', '/tools/trigger-wca-install/v1',
'tools_trigger_wca_install' 'tools_trigger_wca_install'
); );
/**
* A tool to trigger the WooCommerce install.
*/
function tools_trigger_wca_install() { function tools_trigger_wca_install() {
\WC_Install::install(); \WC_Install::install();

View File

@ -5,6 +5,8 @@
* @package WC_Beta_Tester * @package WC_Beta_Tester
*/ */
defined( 'ABSPATH' ) || exit;
/** /**
* Class Tracks_Debug_Log. * Class Tracks_Debug_Log.
*/ */

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Added PHPCS and fixed linting errors.

View File

@ -30,11 +30,11 @@ class WC_Beta_Tester_Admin_Assets {
$version = WC_VERSION; $version = WC_VERSION;
// Need admin styles for the modal. // Need admin styles for the modal.
wp_register_style( 'wc-beta-tester-admin', WC_Beta_Tester::instance()->plugin_url() . '/assets/css/admin.css', array( 'woocommerce_admin_styles' ) ); wp_register_style( 'wc-beta-tester-admin', WC_Beta_Tester::instance()->plugin_url() . '/assets/css/admin.css', array( 'woocommerce_admin_styles' ), WC_BETA_TESTER_VERSION );
// Register scripts. // Register scripts.
wp_register_script( 'wc-beta-tester-version-info', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-information' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION ); wp_register_script( 'wc-beta-tester-version-info', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-information' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION, false );
wp_register_script( 'wc-beta-tester-version-picker', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-picker' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION ); wp_register_script( 'wc-beta-tester-version-picker', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-picker' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION, false );
wp_localize_script( wp_localize_script(
'wc-beta-tester-version-info', 'wc-beta-tester-version-info',
@ -54,7 +54,7 @@ class WC_Beta_Tester_Admin_Assets {
) )
); );
if ( in_array( $screen_id, array( 'plugins_page_wc-beta-tester', 'plugins_page_wc-beta-tester-version-picker' ) ) ) { if ( in_array( $screen_id, array( 'plugins_page_wc-beta-tester', 'plugins_page_wc-beta-tester-version-picker' ), true ) ) {
wp_enqueue_style( 'wc-beta-tester-admin' ); wp_enqueue_style( 'wc-beta-tester-admin' );
wp_enqueue_script( 'wc-beta-tester-version-info' ); wp_enqueue_script( 'wc-beta-tester-version-info' );
wp_enqueue_script( 'wc-beta-tester-version-picker' ); wp_enqueue_script( 'wc-beta-tester-version-picker' );

View File

@ -10,7 +10,7 @@ defined( 'ABSPATH' ) || exit;
/** /**
* Settings Class. * Settings Class.
*/ */
class WC_Beta_Tester_Settings { class WC_Beta_Tester_Channel {
/** /**
* Constructor * Constructor
@ -134,7 +134,9 @@ class WC_Beta_Tester_Settings {
return; return;
} }
if ( isset( $_GET['settings-updated'] ) ) { // WPCS: input var. // This is just for giving a message, the option form itself will have validated the nonce.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['settings-updated'] ) ) {
add_settings_error( 'wc-beta-tester-messages', 'wc-beta-tester-message', __( 'Settings Saved', 'woocommerce-beta-tester' ), 'updated' ); add_settings_error( 'wc-beta-tester-messages', 'wc-beta-tester-message', __( 'Settings Saved', 'woocommerce-beta-tester' ), 'updated' );
} }
@ -158,4 +160,4 @@ class WC_Beta_Tester_Settings {
} }
} }
new WC_Beta_Tester_Settings(); new WC_Beta_Tester_Channel();

View File

@ -5,6 +5,8 @@
* @package WC_Beta_Tester * @package WC_Beta_Tester
*/ */
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WP_CLI_Command' ) ) { if ( ! class_exists( 'WP_CLI_Command' ) ) {
return; return;
} }

View File

@ -8,36 +8,38 @@
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
* WC_Beta_Tester_Settings_Export Main Class. * WC_Beta_Tester_Import_Export Main Class.
*/ */
class WC_Beta_Tester_Import_Export { class WC_Beta_Tester_Import_Export {
/** /**
* @var string WordPress ajax hook * The AJAX hook for the class.
*/ */
protected const AJAX_HOOK = 'wc_beta_tester_export_settings'; protected const AJAX_HOOK = 'wc_beta_tester_export_settings';
/** /**
* @var string WordPress nonce action * The security nonce for the class.
*/ */
protected const NONCE_ACTION = 'wc-beta-tester-import-settings'; protected const NONCE_ACTION = 'wc-beta-tester-import-settings';
/** /**
* @var string WordPress import action * The import AJAX action.
*/ */
protected const IMPORT_ACTION = 'wc-beta-tester-import'; protected const IMPORT_ACTION = 'wc-beta-tester-import';
/** /**
* @var string WordPress import capability * The capability required to import settings.
*/ */
protected const IMPORT_CAP = 'install_plugins'; protected const IMPORT_CAP = 'install_plugins';
/** /**
* @var string WordPress import file name * The filename of the file containing exported settings.
*/ */
protected const IMPORT_FILENAME = 'woocommerce-settings-json'; protected const IMPORT_FILENAME = 'woocommerce-settings-json';
/** /**
* @var array Import status message * The status message of the import.
*
* @var string
*/ */
protected $message; protected $message;
@ -76,29 +78,35 @@ class WC_Beta_Tester_Import_Export {
// show error/update messages. // show error/update messages.
if ( ! empty( $this->message ) ) { if ( ! empty( $this->message ) ) {
?> ?>
<div class="notice <?php <div class="notice
<?php
echo ! empty( $this->message['type'] ) ? esc_attr( $this->message['type'] ) : ''; echo ! empty( $this->message['type'] ) ? esc_attr( $this->message['type'] ) : '';
?>"><?php echo esc_html( $this->message['message'] ); ?></div> ?>
"><?php echo esc_html( $this->message['message'] ); ?></div>
<?php <?php
} }
?> ?>
<div class="wrap"> <div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<p><?php esc_html_e( 'Export your WooCommerce Settings. The export file should not contain any fields that identify your site or reveal secrets (eg. API keys).', 'woocommerce-beta-tester' ); ?></p> <p><?php esc_html_e( 'Export your WooCommerce Settings. The export file should not contain any fields that identify your site or reveal secrets (eg. API keys).', 'woocommerce-beta-tester' ); ?></p>
<a href="<?php echo esc_url( $export_url ) ?>" class="button-primary"><?php <a href="<?php echo esc_url( $export_url ); ?>" class="button-primary">
<?php
/* translators Export WooCommerce settings button text. */ /* translators Export WooCommerce settings button text. */
esc_html_e( 'Export WooCommerce Settings', 'woocommerce-beta-tester' ); esc_html_e( 'Export WooCommerce Settings', 'woocommerce-beta-tester' );
?></a> ?>
</a>
<hr /> <hr />
<form method="POST" enctype="multipart/form-data"> <form method="POST" enctype="multipart/form-data">
<?php wp_nonce_field( static::NONCE_ACTION ); ?> <?php wp_nonce_field( static::NONCE_ACTION ); ?>
<input type="hidden" name="action" value="<?php echo static::IMPORT_ACTION; ?>" /> <input type="hidden" name="action" value="<?php echo esc_attr( static::IMPORT_ACTION ); ?>" />
<p><?php esc_html_e( 'Import WooCommerce Settings exported with this tool. Some settings like store address, payment gateways, etc. will need to be configured manually.', 'woocommerce-beta-tester' ); ?></p> <p><?php esc_html_e( 'Import WooCommerce Settings exported with this tool. Some settings like store address, payment gateways, etc. will need to be configured manually.', 'woocommerce-beta-tester' ); ?></p>
<button type="submit" class="button-primary"><?php <button type="submit" class="button-primary">
<?php
/* translators Import WooCommerce settings button text. */ /* translators Import WooCommerce settings button text. */
esc_html_e( 'Import WooCommerce Settings', 'woocommerce-beta-tester' ); esc_html_e( 'Import WooCommerce Settings', 'woocommerce-beta-tester' );
?></button> ?>
<input type="file" name="<?php echo static::IMPORT_FILENAME; ?>" /> </button>
<input type="file" name="<?php echo esc_attr( static::IMPORT_FILENAME ); ?>" />
</form> </form>
</div> </div>
<?php <?php
@ -108,7 +116,8 @@ class WC_Beta_Tester_Import_Export {
* Export settings in json format. * Export settings in json format.
*/ */
public function export_settings() { public function export_settings() {
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], static::NONCE_ACTION ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), static::NONCE_ACTION ) ) {
header( 'HTTP/1.1 403 Forbidden' ); header( 'HTTP/1.1 403 Forbidden' );
exit; exit;
} }
@ -128,11 +137,12 @@ class WC_Beta_Tester_Import_Export {
* Import settings in json format if submitted. * Import settings in json format if submitted.
*/ */
public function maybe_import_settings() { public function maybe_import_settings() {
if ( empty( $_POST ) || empty( $_POST['action'] ) || $_POST['action'] !== static::IMPORT_ACTION ) { if ( empty( $_POST ) || empty( $_POST['action'] ) || static::IMPORT_ACTION !== $_POST['action'] ) {
return; return;
} }
if ( ! wp_verify_nonce( $_POST['_wpnonce'], static::NONCE_ACTION ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['_wpnonce'] ), static::NONCE_ACTION ) ) {
$this->add_message( __( 'Invalid submission', 'woocommerce-beta-tester' ) ); $this->add_message( __( 'Invalid submission', 'woocommerce-beta-tester' ) );
return; return;
} }
@ -142,7 +152,8 @@ class WC_Beta_Tester_Import_Export {
return; return;
} }
$tmp_file = $_FILES[ static::IMPORT_FILENAME ]['tmp_name']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$tmp_file = wp_unslash( $_FILES[ static::IMPORT_FILENAME ]['tmp_name'] );
if ( empty( $tmp_file ) ) { if ( empty( $tmp_file ) ) {
$this->add_message( __( 'No file uploaded.', 'woocommerce-beta-tester' ) ); $this->add_message( __( 'No file uploaded.', 'woocommerce-beta-tester' ) );
return; return;
@ -153,9 +164,10 @@ class WC_Beta_Tester_Import_Export {
return; return;
} }
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$maybe_json = file_get_contents( $tmp_file ); $maybe_json = file_get_contents( $tmp_file );
$settings = json_decode( $maybe_json, true ); $settings = json_decode( $maybe_json, true );
if ( $settings !== null ) { if ( null !== $settings ) {
foreach ( $this->get_setting_list() as $option_name ) { foreach ( $this->get_setting_list() as $option_name ) {
if ( ! isset( $settings[ $option_name ] ) ) { if ( ! isset( $settings[ $option_name ] ) ) {
continue; continue;
@ -184,6 +196,7 @@ class WC_Beta_Tester_Import_Export {
if ( false === $setting ) { if ( false === $setting ) {
$setting = null; $setting = null;
} }
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
$settings[ $option_name ] = is_string( $setting ) ? $setting : serialize( $setting ); $settings[ $option_name ] = is_string( $setting ) ? $setting : serialize( $setting );
} }
} }
@ -199,7 +212,7 @@ class WC_Beta_Tester_Import_Export {
protected function add_message( $message, $type = 'error' ) { protected function add_message( $message, $type = 'error' ) {
$this->message = array( $this->message = array(
'message' => $message, 'message' => $message,
'type' => $type 'type' => $type,
); );
} }
@ -207,7 +220,7 @@ class WC_Beta_Tester_Import_Export {
* Get the WooCommerce settings list keys. * Get the WooCommerce settings list keys.
*/ */
private function get_setting_list() { private function get_setting_list() {
require_once( dirname(__FILE__ ) . '/wc-beta-tester-settings-list.php'); require_once dirname( __FILE__ ) . '/wc-beta-tester-settings-list.php';
return wc_beta_tester_setting_list(); return wc_beta_tester_setting_list();
} }
} }

View File

@ -72,7 +72,6 @@ class WC_Beta_Tester_Live_Branches {
wc_admin_register_page( wc_admin_register_page(
array( array(
'id' => 'woocommerce-beta-tester-live-branches', 'id' => 'woocommerce-beta-tester-live-branches',
// phpcs:disable
'title' => __( 'Live Branches', 'woocommerce-beta-tester' ), 'title' => __( 'Live Branches', 'woocommerce-beta-tester' ),
'path' => '/live-branches', 'path' => '/live-branches',
'parent' => 'woocommerce', 'parent' => 'woocommerce',

View File

@ -33,15 +33,16 @@ class WC_Beta_Tester_Version_Picker {
* @throws Exception On update error. * @throws Exception On update error.
*/ */
public function handle_version_switch() { public function handle_version_switch() {
if ( ! isset( $_GET['wcbt_switch_to_version'], $_GET['_wpnonce'] ) ) { // WPCS: Input var ok. if ( ! isset( $_GET['wcbt_switch_to_version'], $_GET['_wpnonce'] ) ) {
return; return;
} }
if ( ! wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'wcbt_switch_version_nonce' ) ) { // WPCS: Input var ok, sanitization ok. // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( ! wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'wcbt_switch_version_nonce' ) ) {
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce-beta-tester' ) ); wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce-beta-tester' ) );
} }
$version = isset( $_GET['wcbt_switch_to_version'] ) ? sanitize_text_field( wp_unslash( $_GET['wcbt_switch_to_version'] ) ) : ''; // WPCS: Input var ok, sanitization ok. $version = isset( $_GET['wcbt_switch_to_version'] ) ? sanitize_text_field( wp_unslash( $_GET['wcbt_switch_to_version'] ) ) : '';
if ( empty( $version ) ) { if ( empty( $version ) ) {
return; return;
@ -58,7 +59,7 @@ class WC_Beta_Tester_Version_Picker {
'title' => 'Version switch result', 'title' => 'Version switch result',
'plugin' => $plugin_name, 'plugin' => $plugin_name,
'version' => $version, 'version' => $version,
'nonce' => wp_unslash( $_GET['_wpnonce'] ), // WPCS: Input var ok, sanitization ok. 'nonce' => wp_unslash( $_GET['_wpnonce'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
); );
$skin = new Automatic_Upgrader_Skin( $skin_args ); $skin = new Automatic_Upgrader_Skin( $skin_args );
@ -128,9 +129,11 @@ class WC_Beta_Tester_Version_Picker {
$tags = array_reverse( $tags ); $tags = array_reverse( $tags );
$versions_html = ''; $versions_html = '';
if ( ! empty( $_GET['switched'] ) ) { // WPCS: input var ok, CSRF ok. // The nonce is validated upstream.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! empty( $_GET['switched'] ) ) {
/* translators: %s: WooCoomerce version */ /* translators: %s: WooCoomerce version */
$versions_html .= '<div class="notice notice-success"><p>' . sprintf( esc_html__( 'Successfully switched version to %s.', 'woocommerce-beta-tester' ), esc_html( sanitize_text_field( wp_unslash( $_GET['switched'] ) ) ) ) . '</p></div>'; // WPCS: input var ok, CSRF ok. $versions_html .= '<div class="notice notice-success"><p>' . sprintf( esc_html__( 'Successfully switched version to %s.', 'woocommerce-beta-tester' ), esc_html( sanitize_text_field( wp_unslash( $_GET['switched'] ) ) ) ) . '</p></div>'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
} }
$versions_html .= '<ul class="wcbt-version-list">'; $versions_html .= '<ul class="wcbt-version-list">';
@ -174,7 +177,7 @@ class WC_Beta_Tester_Version_Picker {
<h1><?php esc_html_e( 'Available WooCommerce Releases', 'woocommerce-beta-tester' ); ?></h1> <h1><?php esc_html_e( 'Available WooCommerce Releases', 'woocommerce-beta-tester' ); ?></h1>
<form name="wcbt-select-version" class="wcbt-select-version-form" action="<?php echo esc_attr( admin_url( '/tools.php' ) ); ?>"> <form name="wcbt-select-version" class="wcbt-select-version-form" action="<?php echo esc_attr( admin_url( '/tools.php' ) ); ?>">
<div class="wcbt-versions-wrap"> <div class="wcbt-versions-wrap">
<?php echo $this->get_versions_html( $channel ); // WPCS: XSS ok. ?> <?php echo $this->get_versions_html( $channel ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div> </div>
<div class="wcbt-submit-wrap"> <div class="wcbt-submit-wrap">
<a href="#wcbt-modal-version-switch-confirm" class="button-primary" id="wcbt-modal-version-switch-confirm"><?php esc_html_e( 'Switch version', 'woocommerce-beta-tester' ); ?></a> <a href="#wcbt-modal-version-switch-confirm" class="button-primary" id="wcbt-modal-version-switch-confirm"><?php esc_html_e( 'Switch version', 'woocommerce-beta-tester' ); ?></a>

View File

@ -24,15 +24,15 @@ class WC_Beta_Tester {
* *
* @var WC_Beta_Tester * @var WC_Beta_Tester
*/ */
protected static $_instance = null; protected static $instance = null;
/** /**
* Main Instance. * Main Instance.
*/ */
public static function instance() { public static function instance() {
self::$_instance = is_null( self::$_instance ) ? new self() : self::$_instance; self::$instance = is_null( self::$instance ) ? new self() : self::$instance;
return self::$_instance; return self::$instance;
} }
/** /**

View File

@ -1,8 +1,17 @@
<?php <?php
/** /**
* List of settings to be exported. * WooCommerce Beta Tester settings list functions.
*
* @package WC_Beta_Tester
*/ */
defined( 'ABSPATH' ) || exit;
/**
* Gets the list of settings that can be edited.
*
* @return string[]
*/
function wc_beta_tester_setting_list() { function wc_beta_tester_setting_list() {
$settings_list = array( $settings_list = array(
'date_format', 'date_format',
@ -122,7 +131,7 @@ function wc_beta_tester_setting_list() {
'woocommerce_trash_pending_orders', 'woocommerce_trash_pending_orders',
'woocommerce_unforce_ssl_checkout', 'woocommerce_unforce_ssl_checkout',
'woocommerce_version', 'woocommerce_version',
'woocommerce_weight_unit' 'woocommerce_weight_unit',
); );
return apply_filters( 'wc_beta_tester_setting_list', $settings_list ); return apply_filters( 'wc_beta_tester_setting_list', $settings_list );
} }

View File

@ -64,6 +64,8 @@
"format:js": "wp-scripts format-js", "format:js": "wp-scripts format-js",
"lint:css": "wp-scripts lint-style", "lint:css": "wp-scripts lint-style",
"lint:css:fix": "wp-scripts lint-style --fix", "lint:css:fix": "wp-scripts lint-style --fix",
"lint:php": "composer run-script phpcs",
"lint:php:fix": "composer run-script phpcbf",
"lint:js": "wp-scripts lint-js", "lint:js": "wp-scripts lint-js",
"lint:js:fix": "wp-scripts lint-js --fix", "lint:js:fix": "wp-scripts lint-js --fix",
"lint:md:docs": "wp-scripts lint-md-docs", "lint:md:docs": "wp-scripts lint-md-docs",

View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<ruleset name="WooCommerce Beta Tester Coding Standards">
<description>WooCommerce Beta Tester PHP_CodeSniffer ruleset.</description>
<file>./woocommerce-beta-tester.php</file>
<file>./includes/</file>
<file>./api/</file>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps" />
<!-- Strip the filepaths in reports down to the relevant bit. -->
<arg name="basepath" value="./" />
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8" />
<!-- Configs -->
<config name="minimum_supported_wp_version" value="5.2" />
<config name="testVersion" value="7.3-" />
<!-- Rules -->
<rule ref="WooCommerce-Core" />
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="woocommerce-beta-tester" />
</properties>
</rule>
<rule ref="WooCommerce.Commenting.CommentHooks.MissingHookComment">
<exclude-pattern>includes/</exclude-pattern>
<exclude-pattern>api/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FileComment.Missing">
<exclude-pattern>includes/</exclude-pattern>
<exclude-pattern>api/</exclude-pattern>
</rule>
</ruleset>

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Added PHPCS and fixed linting errors.

View File

@ -0,0 +1,141 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>WooCommerce dev PHP_CodeSniffer ruleset.</description>
<file>.</file>
<!-- Exclude paths -->
<exclude-pattern>tests/cli/</exclude-pattern>
<exclude-pattern>includes/libraries/</exclude-pattern>
<exclude-pattern>includes/legacy/</exclude-pattern>
<exclude-pattern>includes/api/legacy/</exclude-pattern>
<exclude-pattern>includes/api/v1/</exclude-pattern>
<exclude-pattern>includes/class-wc-geo-ip.php</exclude-pattern>
<exclude-pattern>includes/wc-deprecated-functions.php</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>lib/</exclude-pattern>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps" />
<!-- Strip the filepaths in reports down to the relevant bit. -->
<arg name="basepath" value="./" />
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8" />
<!-- Configs -->
<config name="minimum_supported_wp_version" value="5.2" />
<config name="testVersion" value="7.3-" />
<!-- Rules -->
<rule ref="WooCommerce-Core" />
<rule ref="WooCommerce.Functions.InternalInjectionMethod">
<include-pattern>src/</include-pattern>
<include-pattern>tests/php/src/</include-pattern>
<properties>
<property name="injectionMethod" value="init"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="woocommerce" />
</properties>
</rule>
<rule ref="PHPCompatibility">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents">
<exclude-pattern>tests/src</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>includes/**/abstract-*.php</exclude-pattern>
<exclude-pattern>tests/</exclude-pattern>
<exclude-pattern>src/</exclude-pattern>
<exclude-pattern>tests/php/src/</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ClassFileName">
<include-pattern>src/</include-pattern>
<include-pattern>tests/php/src/</include-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName">
<include-pattern>src/</include-pattern>
<include-pattern>tests/php/src/</include-pattern>
</rule>
<rule ref="Generic.Commenting">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
<exclude-pattern>tests/e2e-tests/</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>i18n/</exclude-pattern>
<exclude-pattern>src/</exclude-pattern>
<exclude-pattern>tests/php</exclude-pattern>
<exclude-pattern>tests/Tools/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FileComment.MissingPackageTag">
<exclude-pattern>src/</exclude-pattern>
<exclude-pattern>tests/php/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FileComment.Missing">
<exclude-pattern>src/</exclude-pattern>
<exclude-pattern>tests/php/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FunctionCommentThrowTag.Missing">
<exclude-pattern>tests/php/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.FileComment.Missing">
<exclude-pattern>tests/php/</exclude-pattern>
</rule>
<!-- Temporary -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
<exclude-pattern>src/Internal/Admin/</exclude-pattern>
<exclude-pattern>src/Admin/</exclude-pattern>
</rule>
<!-- Temporary -->
<rule ref="WooCommerce.Functions.InternalInjectionMethod.MissingFinal">
<exclude-pattern>src/Internal/Admin/</exclude-pattern>
<exclude-pattern>src/Admin/</exclude-pattern>
</rule>
<!-- Temporary -->
<rule ref="WooCommerce.Functions.InternalInjectionMethod.MissingInternalTag">
<exclude-pattern>src/Internal/Admin/</exclude-pattern>
<exclude-pattern>src/Admin/</exclude-pattern>
</rule>
<!-- Temporary -->
<rule ref="WordPress.Security.NonceVerification.Recommended">
<exclude-pattern>src/Internal/Admin/</exclude-pattern>
<exclude-pattern>src/Admin/</exclude-pattern>
</rule>
<!-- Temporary -->
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
<exclude-pattern>src/Internal/Admin/</exclude-pattern>
<exclude-pattern>src/Admin/</exclude-pattern>
</rule>
<!-- Temporary -->
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>src/Internal/Admin/</exclude-pattern>
<exclude-pattern>src/Admin/</exclude-pattern>
</rule>
</ruleset>