Fix PHPCS errors and warnings
This commit is contained in:
parent
5c82baef5b
commit
eabda2b61e
|
@ -102,4 +102,16 @@
|
||||||
<rule ref="Squiz.Commenting.FileComment.Missing">
|
<rule ref="Squiz.Commenting.FileComment.Missing">
|
||||||
<exclude-pattern>tests/php/</exclude-pattern>
|
<exclude-pattern>tests/php/</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="WordPress.NamingConventions.ValidVariableName">
|
||||||
|
<exclude-pattern>tests/php/src</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="Squiz.Commenting">
|
||||||
|
<exclude-pattern>tests/php/src</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule ref="WordPress.WP.GlobalVariablesOverride">
|
||||||
|
<exclude-pattern>tests/php/src</exclude-pattern>
|
||||||
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -37,7 +37,7 @@ class WPConsentAPI {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function on_plugins_loaded() {
|
protected function on_plugins_loaded() {
|
||||||
// Include integration to WP Consent Level API if available
|
// Include integration to WP Consent Level API if available.
|
||||||
if ( ! $this->is_wp_consent_api_active() ) {
|
if ( ! $this->is_wp_consent_api_active() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ use WP_User;
|
||||||
* Class SourceAttributionController
|
* Class SourceAttributionController
|
||||||
*
|
*
|
||||||
* @since x.x.x
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* phpcs:disable WordPress.PHP.DisallowShortTernary
|
||||||
|
* phpcs:disable Generic.Commenting.DocComment.MissingShort
|
||||||
*/
|
*/
|
||||||
class SourceAttributionController implements RegisterHooksInterface {
|
class SourceAttributionController implements RegisterHooksInterface {
|
||||||
|
|
||||||
|
@ -57,7 +60,8 @@ class SourceAttributionController implements RegisterHooksInterface {
|
||||||
* @internal
|
* @internal
|
||||||
*
|
*
|
||||||
* @param LegacyProxy $proxy The legacy proxy.
|
* @param LegacyProxy $proxy The legacy proxy.
|
||||||
* @param WC_Logger_Interface|null $logger The logger object. If not provided, it will be obtained from the proxy.
|
* @param FeaturesController $controller The feature controller.
|
||||||
|
* @param WC_Logger_Interface $logger The logger object. If not provided, it will be obtained from the proxy.
|
||||||
*/
|
*/
|
||||||
final public function init( LegacyProxy $proxy, FeaturesController $controller, ?WC_Logger_Interface $logger = null ) {
|
final public function init( LegacyProxy $proxy, FeaturesController $controller, ?WC_Logger_Interface $logger = null ) {
|
||||||
$this->proxy = $proxy;
|
$this->proxy = $proxy;
|
||||||
|
@ -183,13 +187,40 @@ class SourceAttributionController implements RegisterHooksInterface {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the lifetime of the cookie used for source tracking.
|
||||||
|
*
|
||||||
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* @param int $lifetime The lifetime of the cookie in months.
|
||||||
|
*/
|
||||||
|
$lifetime = (int) apply_filters( 'wc_order_source_attribution_cookie_lifetime_months', 6 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the session length for source tracking.
|
||||||
|
*
|
||||||
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* @param int $session_length The session length in minutes.
|
||||||
|
*/
|
||||||
|
$session_length = (int) apply_filters( 'wc_order_source_attribution_session_length_minutes', 30 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter to allow tracking.
|
||||||
|
*
|
||||||
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* @param bool $allow_tracking True to allow tracking, false to disable.
|
||||||
|
*/
|
||||||
|
$allow_tracking = wc_bool_to_string( apply_filters( 'wc_order_source_attribution_allow_tracking', true ) );
|
||||||
|
|
||||||
// Pass parameters to Order Source Attribution JS.
|
// Pass parameters to Order Source Attribution JS.
|
||||||
$params = array(
|
$params = array(
|
||||||
'lifetime' => (int) apply_filters( 'wc_order_source_attribution_cookie_lifetime_months', 6 ),
|
'lifetime' => $lifetime,
|
||||||
'session' => (int) apply_filters( 'wc_order_source_attribution_session_length_minutes', 30 ),
|
'session' => $session_length,
|
||||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||||
'prefix' => $this->field_prefix,
|
'prefix' => $this->field_prefix,
|
||||||
'allowTracking' => wc_bool_to_string( apply_filters( 'wc_order_source_attribution_allow_tracking', true ) ),
|
'allowTracking' => $allow_tracking,
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_localize_script( 'woocommerce-order-source-attribution-js', 'wc_order_attribute_source_params', $params );
|
wp_localize_script( 'woocommerce-order-source-attribution-js', 'wc_order_attribute_source_params', $params );
|
||||||
|
@ -295,6 +326,7 @@ class SourceAttributionController implements RegisterHooksInterface {
|
||||||
/**
|
/**
|
||||||
* Save source data for an Order object.
|
* Save source data for an Order object.
|
||||||
*
|
*
|
||||||
|
* @param array $source_data The source data.
|
||||||
* @param WC_Order $order The order object.
|
* @param WC_Order $order The order object.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Order source attribution meta.
|
|
||||||
*
|
|
||||||
* @since x.x.x
|
|
||||||
*
|
|
||||||
* phpcs:disable Generic.Commenting.DocComment.MissingShort
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare( strict_types=1 );
|
declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Automattic\WooCommerce\Internal\Traits;
|
namespace Automattic\WooCommerce\Internal\Traits;
|
||||||
|
@ -21,6 +13,8 @@ use WP_Post;
|
||||||
* Trait SourceAttributionMeta
|
* Trait SourceAttributionMeta
|
||||||
*
|
*
|
||||||
* @since x.x.x
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* phpcs:disable Generic.Commenting.DocComment.MissingShort
|
||||||
*/
|
*/
|
||||||
trait SourceAttributionMeta {
|
trait SourceAttributionMeta {
|
||||||
|
|
||||||
|
@ -53,11 +47,13 @@ trait SourceAttributionMeta {
|
||||||
private $field_prefix = '';
|
private $field_prefix = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the device type based on the other meta fields.
|
||||||
|
*
|
||||||
* @since x.x.x
|
* @since x.x.x
|
||||||
*
|
*
|
||||||
* @param array $values
|
* @param array $values The meta values.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string The device type.
|
||||||
*/
|
*/
|
||||||
protected function get_device_type( array $values ): string {
|
protected function get_device_type( array $values ): string {
|
||||||
$detector = new MobileDetect( array(), $values['user_agent'] );
|
$detector = new MobileDetect( array(), $values['user_agent'] );
|
||||||
|
@ -267,7 +263,7 @@ trait SourceAttributionMeta {
|
||||||
$values['device_type'] = $this->get_device_type( $values );
|
$values['device_type'] = $this->get_device_type( $values );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the origin label
|
// Set the origin label.
|
||||||
if ( array_key_exists( 'type', $values ) && array_key_exists( 'utm_source', $values ) ) {
|
if ( array_key_exists( 'type', $values ) && array_key_exists( 'utm_source', $values ) ) {
|
||||||
$values['origin'] = $this->get_origin_label( $values['type'], $values['utm_source'] );
|
$values['origin'] = $this->get_origin_label( $values['type'], $values['utm_source'] );
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ use Automattic\WooCommerce\Internal\Traits\ScriptDebug;
|
||||||
* Class TrackingController
|
* Class TrackingController
|
||||||
*
|
*
|
||||||
* @since x.x.x
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* phpcs:disable Generic.Commenting.DocComment.MissingShort
|
||||||
*/
|
*/
|
||||||
class TrackingController implements RegisterHooksInterface {
|
class TrackingController implements RegisterHooksInterface {
|
||||||
|
|
||||||
|
@ -25,6 +27,8 @@ class TrackingController implements RegisterHooksInterface {
|
||||||
/**
|
/**
|
||||||
* WCCOMTracking init.
|
* WCCOMTracking init.
|
||||||
*
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
* @param FeaturesController $features_controller Features controller.
|
* @param FeaturesController $features_controller Features controller.
|
||||||
*/
|
*/
|
||||||
final public function init( FeaturesController $features_controller ) {
|
final public function init( FeaturesController $features_controller ) {
|
||||||
|
|
|
@ -9,6 +9,8 @@ use Automattic\WooCommerce\Proxies\LegacyProxy;
|
||||||
* Class VersionUtil
|
* Class VersionUtil
|
||||||
*
|
*
|
||||||
* @since x.x.x
|
* @since x.x.x
|
||||||
|
*
|
||||||
|
* phpcs:disable Generic.Commenting.DocComment.MissingShort
|
||||||
*/
|
*/
|
||||||
class VersionUtil {
|
class VersionUtil {
|
||||||
|
|
||||||
|
@ -19,8 +21,9 @@ class VersionUtil {
|
||||||
* Init this class instance.
|
* Init this class instance.
|
||||||
*
|
*
|
||||||
* @since x.x.x
|
* @since x.x.x
|
||||||
|
* @internal
|
||||||
*
|
*
|
||||||
* @param LegacyProxy $proxy
|
* @param LegacyProxy $proxy The legacy proxy instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
declare( strict_types=1 );
|
|
||||||
/**
|
/**
|
||||||
* Display the Customer History metabox.
|
* Display the Customer History metabox.
|
||||||
*
|
*
|
||||||
|
@ -7,9 +6,11 @@ declare( strict_types=1 );
|
||||||
*
|
*
|
||||||
* @see Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes\CustomerHistory
|
* @see Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes\CustomerHistory
|
||||||
* @package WooCommerce\Templates
|
* @package WooCommerce\Templates
|
||||||
* @version 8.2.0
|
* @version 8.4.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
declare( strict_types=1 );
|
|
||||||
/**
|
/**
|
||||||
* Display the Source Data metabox.
|
* Display the Source Data metabox.
|
||||||
*
|
*
|
||||||
|
@ -7,9 +6,11 @@ declare( strict_types=1 );
|
||||||
*
|
*
|
||||||
* @see Automattic\WooCommerce\Internal\Orders\SourceAttributionController
|
* @see Automattic\WooCommerce\Internal\Orders\SourceAttributionController
|
||||||
* @package WooCommerce\Templates
|
* @package WooCommerce\Templates
|
||||||
* @version 8.2.0
|
* @version 8.4.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare( strict_types=1 );
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,17 +15,6 @@ class SourceAttributionControllerTest extends WP_UnitTestCase {
|
||||||
|
|
||||||
protected SourceAttributionController $attribution_fields_class;
|
protected SourceAttributionController $attribution_fields_class;
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called before the first test of this test class is run.
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function setUpBeforeClass(): void {
|
|
||||||
parent::setUpBeforeClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the fixture, for example, open a network connection.
|
* Sets up the fixture, for example, open a network connection.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue