<?xml version="1.0"?>
<ruleset name="Civil Publisher Plugin">
	<description>PHP_CodeSniffer standard for Civil Publisher Plugin.</description>

	<!--
	Pass some flags to PHPCS:
	 p flag: Show progress of the run.
	 s flag: Show sniff codes in all reports.
	 n flag: Do not print warnings.
	-->
	<arg value="psn" />

	<!--
	Only check the PHP files.
	Check all files in this directory and the directories below it.
	Exclude a few directories and autogenerated files.
	-->
	<arg name="extensions" value="php" />
	<file>.</file>
	<exclude-pattern>*/node_modules/*</exclude-pattern>
	<exclude-pattern>tests/</exclude-pattern>
	<exclude-pattern>vendor/</exclude-pattern>
	<exclude-pattern>lib/</exclude-pattern>

	<rule ref="WordPress" />
	<!-- The version set here matches the minimum version tested in .travis.yml.  -->
	<config name="minimum_supported_wp_version" value="4.9" />

	<rule ref="Squiz.Commenting.FileComment.SpacingAfterComment">
		<!--
		Downgrade while so many PHP files are empty to start with.
		The empty file makes it difficult to comply with this rule
		and the trailing newline rule at the same time.
		-->
		<type>warning</type>

		<!--
		Once your PHP files have been filled in, you might be able
		to start checking for compliance again with an
		exclude-pattern like these:

		<exclude-pattern>themes(/vip)?/[^/]+/[^/]+\.php$</exclude-pattern>
		<exclude-pattern>themes(/vip)?/[^/]+/template-parts/*</exclude-pattern>
		-->
	</rule>

	<rule ref="Generic.Files.OneObjectStructurePerFile">
		<!--
		Increase severity. If it becomes a problem for this sniff to trigger an
		error, then we might want to provide feedback to the WPCS maintainers.
		See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1111.
		-->
		<type>error</type>
	</rule>

	<rule ref="WordPress.WP.I18n">
		<properties>
			<!--
			Verify that the text_domain is set to the desired text-domain.
			Multiple valid text domains can be provided as a comma-delimited list.
			 -->
			<property name="text_domain" type="array" value="civil-cms" />
		</properties>

		<exclude-pattern>plugins/</exclude-pattern>
	</rule>

	<rule ref="WordPress.Files.FileName">
		<properties>
			<!--
			Allow for theme-specific exceptions to the file name rules based
			on the theme hierarchy.
			 -->
			<property name="is_theme" value="true" />
		</properties>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
		<properties>
			<property name="prefixes" type="array" value="civil_publisher" />
		</properties>

		<!-- In practice, partials should be loaded outside of the global namespace with get_template_part(). -->
		<exclude-pattern>themes(/vip)?/[^/]+/template-parts/</exclude-pattern>
		<exclude-pattern>vendor/</exclude-pattern>
		<exclude-pattern>plugins/</exclude-pattern>

		<exclude-pattern>inc/classes/class-path-dispatch.php</exclude-pattern>
		<exclude-pattern>inc/classes/unique-wp-query/</exclude-pattern>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound">
		<type>warning</type>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound">
		<type>warning</type>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound">
		<type>warning</type>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
		<type>warning</type>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
		<type>warning</type>
	</rule>

	<rule ref="WordPress.WP.EnqueuedResourceParameters.MissingVersion">
		<type>warning</type>
	</rule>

	<!-- Exclude all VIP Classic rules that are ok on Go sites -->
	<rule ref="WordPress-VIP-Go">
		<!-- Users -->
		<exclude name="WordPress.VIP.RestrictedFunctions.user_meta_get_user_meta" />
		<exclude name="WordPress.VIP.RestrictedFunctions.user_meta_update_user_meta" />
		<exclude name="WordPress.VIP.RestrictedFunctions.user_meta_delete_user_meta" />
		<exclude name="WordPress.VIP.RestrictedFunctions.user_meta_add_user_meta" />

		<!-- Blogs -->
		<exclude name="WordPress.VIP.RestrictedFunctions.switch_to_blog_switch_to_blog" />
	</rule>

	<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace">
		<exclude-pattern>inc/fields.php</exclude-pattern>
	</rule>

	<rule ref="WordPress.WP.EnqueuedResourceParameters.MissingVersion">
		<type>warning</type>
	</rule>

	<rule ref="PEAR.Functions.FunctionCallSignature.MultipleArguments">
		<type>warning</type>
	</rule>

	<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
		<type>warning</type>
	</rule>

	<rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
		<type>warning</type>
	</rule>
</ruleset>
