54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* WordPress Coding Standard.
|
|
*
|
|
* @package WPCS\WordPressCodingStandards
|
|
* @link https://github.com/WordPress/WordPress-Coding-Standards
|
|
* @license https://opensource.org/licenses/MIT MIT
|
|
*/
|
|
|
|
namespace WordPressCS\WordPress\Sniffs\WP;
|
|
|
|
use WordPressCS\WordPress\AbstractFunctionRestrictionsSniff;
|
|
|
|
/**
|
|
* Discourages the use of various WordPress functions and suggests alternatives.
|
|
*
|
|
* @since 0.11.0
|
|
* @since 0.13.0 Class name changed: this class is now namespaced.
|
|
*/
|
|
final class DiscouragedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
|
|
|
|
/**
|
|
* Groups of functions to restrict.
|
|
*
|
|
* Example: groups => array(
|
|
* 'lambda' => array(
|
|
* 'type' => 'error' | 'warning',
|
|
* 'message' => 'Use anonymous functions instead please!',
|
|
* 'functions' => array( 'file_get_contents', 'create_function' ),
|
|
* )
|
|
* )
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getGroups() {
|
|
return array(
|
|
'query_posts' => array(
|
|
'type' => 'warning',
|
|
'message' => '%s() is discouraged. Use WP_Query instead.',
|
|
'functions' => array(
|
|
'query_posts',
|
|
),
|
|
),
|
|
|
|
'wp_reset_query' => array(
|
|
'type' => 'warning',
|
|
'message' => '%s() is discouraged. Use wp_reset_postdata() instead.',
|
|
'functions' => array(
|
|
'wp_reset_query',
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|