Skip to content

Commit

Permalink
Fix WPCS.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jul 27, 2021
1 parent 08aaf24 commit 71be612
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 42 deletions.
3 changes: 1 addition & 2 deletions src/php/Settings/Abstracts/SettingsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ protected function parent_slug() {
* Is this the main menu page.
*
* @return bool
* @noinspection PhpPureAttributeCanBeAddedInspection
*/
protected function is_main_menu_page() {
// Main menu page should have empty string as parent slug.
Expand Down Expand Up @@ -262,7 +261,7 @@ protected function is_tab() {
* With Multisite active this can also include
* 'network_active' and 'network_only' items.
*
* @return array|mixed Plugin links
* @return array|string[] Plugin links
*/
public function add_settings_link( array $actions ) {
$new_actions = [
Expand Down
11 changes: 1 addition & 10 deletions src/php/Settings/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ protected function section_title() {
return '';
}

/**
* Get parent slug.
*
* @return string
*/
protected function parent_slug() {
return 'options-general.php';
}

/**
* Init class hooks.
*/
Expand Down Expand Up @@ -201,7 +192,7 @@ public function delayed_init_form_fields() {
public function delayed_init_settings() {
$this->delayed_init_form_fields();

parent::init_settings();
$this->init_settings();
}

/**
Expand Down
4 changes: 0 additions & 4 deletions src/php/Settings/PluginSettingsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ protected function plugin_basename() {
* Get plugin url.
*
* @return string
*
* @noinspection PhpPureAttributeCanBeAddedInspection
*/
protected function plugin_url() {
return constant( 'CYR_TO_LAT_URL' );
Expand All @@ -40,8 +38,6 @@ protected function plugin_url() {
* Get plugin version.
*
* @return string
*
* @noinspection PhpPureAttributeCanBeAddedInspection
*/
protected function plugin_version() {
return constant( 'CYR_TO_LAT_VERSION' );
Expand Down
2 changes: 2 additions & 0 deletions src/php/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function __construct() {

/**
* Init class.
*
* @noinspection UnnecessaryCastingInspection
*/
protected function init() {
// Allow to specify MENU_PAGES item as one class, not an array.
Expand Down
10 changes: 0 additions & 10 deletions src/php/Settings/Tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ protected function section_title() {
return '';
}

/**
* Get parent slug.
*
* @return string
*/
protected function parent_slug() {
// Indicate that it is the main menu page.
return 'options-general.php';
}

/**
* Init locales.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/php/background-processes/class-conversion-process.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct( $main ) {
*
* @param mixed $item Queue item to iterate over.
*
* @return mixed
* @return boolean
*/
protected function task( $item ) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct( $main ) {
*
* @param stdClass $post Queue item to iterate over.
*
* @return mixed
* @return boolean
* @noinspection PhpParameterNameChangedDuringInheritanceInspection
*/
protected function task( $post ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct( $main ) {
*
* @param stdClass $term Queue item to iterate over.
*
* @return mixed
* @return boolean
* @noinspection PhpParameterNameChangedDuringInheritanceInspection
*/
protected function task( $term ) {
Expand Down
1 change: 0 additions & 1 deletion src/php/class-conversion-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,6 @@ public static function get( $locale = '' ) {
* On MacOS, files containing characters in the table, are sometimes encoded improperly.
*
* @return array
* @noinspection PhpArrayShapeAttributeCanBeAddedInspection
*/
public static function get_fix_table_for_mac() {
/**
Expand Down
13 changes: 7 additions & 6 deletions src/php/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private function is_gutenberg_editor_active() {
* @param array $data An array of slashed post data.
* @param array $postarr An array of sanitized, but otherwise unmodified post data.
*
* @return mixed
* @return array
* @noinspection PhpUnusedParameterInspection
*/
public function sanitize_post_name( $data, $postarr = [] ) {
Expand Down Expand Up @@ -619,14 +619,15 @@ public function wpml_locale_filter( $locale ) {
public function prepare_in( $items, $format = '%s' ) {
global $wpdb;

$items = (array) $items;
$how_many = count( $items );
$prepared_in = '';
$items = (array) $items;
$how_many = count( $items );

if ( $how_many > 0 ) {
$placeholders = array_fill( 0, $how_many, $format );
$prepared_format = implode( ',', $placeholders );
$prepared_in = $wpdb->prepare( $prepared_format, $items ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
} else {
$prepared_in = '';
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$prepared_in = $wpdb->prepare( $prepared_format, $items );
}

return $prepared_in;
Expand Down
5 changes: 1 addition & 4 deletions src/php/class-requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ private function is_max_input_vars_required() {

/**
* Try to fix max_input_vars.
*
* @noinspection PhpStrFunctionsInspection
*/
protected function try_to_fix_max_input_vars() {
$user_ini_filename = $this->get_user_ini_filename();
Expand Down Expand Up @@ -225,7 +223,6 @@ static function ( $line ) {
* Get .user.ini filename.
*
* @return string
* @noinspection PhpPureAttributeCanBeAddedInspection
*/
private function get_user_ini_filename() {
return ABSPATH . 'wp-admin/' . ini_get( 'user_ini.filename' );
Expand All @@ -238,7 +235,7 @@ private function ask_to_increase_max_input_vars() {
$message = __( 'Please increase max input vars limit up to 1500.', 'cyr2lat' );

$message .= '<br>';
$message .= __( 'See: <a href="http://sevenspark.com/docs/ubermenu-3/faqs/menu-item-limit" target="_blank">Increasing max input vars limit.</a>', 'cyr2lat' );
$message .= __( 'See: <a href="https://sevenspark.com/docs/ubermenu-3/faqs/menu-item-limit" target="_blank">Increasing max input vars limit.</a>', 'cyr2lat' );

$this->admin_notices->add_notice(
$message,
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/class-test-requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function test_vars_requirements_not_met( $within_timeout, $content, $expe
$message = 'Please increase max input vars limit up to 1500.';

$message .= '<br>';
$message .= 'See: <a href="http://sevenspark.com/docs/ubermenu-3/faqs/menu-item-limit" target="_blank">Increasing max input vars limit.</a>';
$message .= 'See: <a href="https://sevenspark.com/docs/ubermenu-3/faqs/menu-item-limit" target="_blank">Increasing max input vars limit.</a>';
}

$admin_notices->shouldReceive( 'add_notice' )->with( $message, 'notice notice-error', $screen_ids );
Expand Down Expand Up @@ -435,7 +435,7 @@ function ( $arg ) use ( $max_input_vars, $user_ini_filename, $ini_ttl ) {
$message = 'Please increase max input vars limit up to 1500.';

$message .= '<br>';
$message .= 'See: <a href="http://sevenspark.com/docs/ubermenu-3/faqs/menu-item-limit" target="_blank">Increasing max input vars limit.</a>';
$message .= 'See: <a href="https://sevenspark.com/docs/ubermenu-3/faqs/menu-item-limit" target="_blank">Increasing max input vars limit.</a>';

$admin_notices->shouldReceive( 'add_notice' )->with( $message, 'notice notice-error', $screen_ids );

Expand Down

0 comments on commit 71be612

Please sign in to comment.