Skip to content

Commit

Permalink
Add PHPCS rules inside phpcs.xml.dist
Browse files Browse the repository at this point in the history
  • Loading branch information
puntope committed Mar 22, 2023
1 parent 207f9b7 commit 9e29d0a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion includes/class-wc-abstract-google-analytics-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function gaOptout() {
window[disableStr] = true;
}";

wp_register_script( 'google-analytics-opt-out', '', array(), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, false );
wp_register_script( 'google-analytics-opt-out', '', array(), null, false );
wp_add_inline_script( 'google-analytics-opt-out', $code );
wp_enqueue_script( 'google-analytics-opt-out' );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-google-analytics-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public function event_tracking_code( $parameters, $selector ) {
* @param string $code The code to add attached to the google-analytics handler
*/
protected static function load_analytics_code_in_header( $code ) {
wp_register_script( 'google-analytics', '', array( 'google-analytics-opt-out' ), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, false );
wp_register_script( 'google-analytics', '', array( 'google-analytics-opt-out' ), null, false );
wp_add_inline_script( 'google-analytics', $code );
wp_enqueue_script( 'google-analytics' );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-google-gtag-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function ' . self::tracker_var() . '(){dataLayer.push(arguments);}
$track_404_enabled
";

wp_register_script( 'google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . esc_js( $gtag_id ), array( 'google-analytics-opt-out' ), WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION, false );
wp_register_script( 'google-tag-manager', 'https://www.googletagmanager.com/gtag/js?id=' . esc_js( $gtag_id ), array( 'google-analytics-opt-out' ), null, false );
wp_add_inline_script( 'google-tag-manager', apply_filters( 'woocommerce_gtag_snippet', $gtag_snippet ) );
wp_enqueue_script( 'google-tag-manager' );
}
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

<!-- Multiple throws tags are fine -->
<exclude name="Squiz.Commenting.FunctionCommentThrowTag.WrongNumber"/>

<!-- Disable this warning since we load Google external scripts -->
<exclude name="WordPress.WP.EnqueuedResourceParameters.MissingVersion"/>
</rule>

<!-- Include some other sniffs we want to enforce. -->
Expand All @@ -44,6 +47,8 @@
<rule ref="Squiz.Classes">
<exclude name="Squiz.Classes.ClassDeclaration.OpenBraceNewLine"/>
<exclude name="Squiz.Classes.ClassDeclaration.CloseBraceSameLine"/>
<exclude name="Squiz.Classes.ClassDeclaration.SpaceBeforeKeyword"/>
<exclude name="Squiz.Classes.ClassDeclaration.SpaceBeforeCloseBrace"/>
<exclude name="Squiz.Classes.ClassFileName.NoMatch"/>
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
</rule>
Expand Down
5 changes: 0 additions & 5 deletions woocommerce-google-analytics-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
* Domain Path: languages/
*/

// phpcs:disable Squiz.Classes.ClassDeclaration.SpaceBeforeKeyword
// phpcs:disable Squiz.Classes.ClassDeclaration.SpaceBeforeCloseBrace
// phpcs:disable Squiz.Classes.ClassFileName.NoMatch
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps

use Automattic\WooCommerce\Utilities\FeaturesUtil;

if ( ! defined( 'ABSPATH' ) ) {
Expand Down

0 comments on commit 9e29d0a

Please sign in to comment.