Skip to content

Commit 2a86454

Browse files
committed
phpstan fixes
1 parent 9212a4f commit 2a86454

15 files changed

+47
-63
lines changed

includes/admin/admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function wzkb_admin_notices() {
101101
function wzkb_dashboard_glance_items( $items ) {
102102
$num_posts = wp_count_posts( 'wz_knowledgebase' );
103103

104-
if ( $num_posts && $num_posts->publish ) {
104+
if ( ! empty( $num_posts->publish ) ) {
105105
/* translators: 1. Number of articles */
106106
$text = _n( '%s KB article', '%s KB articles', $num_posts->publish, 'knowledgebase' );
107107

includes/admin/modules/cache.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,3 @@ function wzkb_cache_get_meta_keys() {
9898
*/
9999
return apply_filters( 'wzkb_cache_get_meta_keys', $keys );
100100
}
101-

includes/admin/settings/class-knowledgebase-settings.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Knowledgebase_Settings {
2626
/**
2727
* Class instance.
2828
*
29-
* @var class Class instance.
29+
* @var Knowledgebase_Settings Class instance.
3030
*/
3131
public static $instance;
3232

@@ -106,10 +106,10 @@ protected function __construct() {
106106
$this->settings_api = new Knowledgebase_Admin\Settings_API( $this->settings_key, self::$prefix, $args );
107107

108108
add_action( 'admin_head', array( $this, 'admin_head' ), 11 );
109-
add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
109+
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
110110
add_filter( 'plugin_action_links_' . plugin_basename( WZKB_PLUGIN_FILE ), array( $this, 'plugin_actions_links' ) );
111111
add_action( 'wzkb_settings_page_header', array( $this, 'settings_page_header' ), 11 );
112-
add_action( 'wzkb_settings_sanitize', array( $this, 'change_settings_on_save' ), 99 );
112+
add_filter( 'wzkb_settings_sanitize', array( $this, 'change_settings_on_save' ), 99 );
113113
}
114114

115115
/**
@@ -505,7 +505,7 @@ public function get_help_sidebar() {
505505
*
506506
* @since 2.2.0
507507
*
508-
* @param array $help_sidebar Help sidebar content.
508+
* @param string $help_sidebar Help sidebar content.
509509
*/
510510
return apply_filters( self::$prefix . '_settings_help_sidebar', $help_sidebar );
511511
}
@@ -632,7 +632,7 @@ public function get_admin_footer_text() {
632632
* @since 2.2.0
633633
*
634634
* @param array $settings Settings array.
635-
* @return string $settings Sanitized settings array.
635+
* @return array $settings Sanitized settings array.
636636
*/
637637
public function change_settings_on_save( $settings ) {
638638

@@ -641,7 +641,6 @@ public function change_settings_on_save( $settings ) {
641641

642642
return $settings;
643643
}
644-
645644
}
646645

647646
/** Initiate the class */

includes/admin/settings/class-settings-api.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function __construct( $settings_key, $prefix, $args ) {
179179
public function hooks() {
180180
add_action( 'admin_menu', array( $this, 'admin_menu' ), 11 );
181181
add_action( 'admin_init', array( $this, 'admin_init' ) );
182-
add_action( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
182+
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
183183
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
184184
}
185185

@@ -639,7 +639,7 @@ public function get_field_description( $args ) {
639639
* After Settings Output filter
640640
*
641641
* @param string $desc Description of the field.
642-
* @param array Arguments array.
642+
* @param array $args Arguments array.
643643
*/
644644
$desc = apply_filters( $this->prefix . '_setting_field_description', $desc, $args );
645645
return $desc;
@@ -689,7 +689,7 @@ public function callback_header( $args ) {
689689
* After Settings Output filter
690690
*
691691
* @param string $html HTML string.
692-
* @param array Arguments array.
692+
* @param array $args Arguments array.
693693
*/
694694
echo apply_filters( $this->prefix . '_after_setting_output', $html, $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
695695
}
@@ -1027,9 +1027,9 @@ public function callback_number( $args ) {
10271027

10281028
$html = sprintf(
10291029
'<input type="number" step="%1$s" max="%2$s" min="%3$s" class="%4$s" id="%8$s[%5$s]" name="%8$s[%5$s]" value="%6$s" %7$s />',
1030-
esc_attr( $step ),
1031-
esc_attr( $max ),
1032-
esc_attr( $min ),
1030+
esc_attr( (string) $step ),
1031+
esc_attr( (string) $max ),
1032+
esc_attr( (string) $min ),
10331033
sanitize_html_class( $size ) . '-text',
10341034
sanitize_key( $args['id'] ),
10351035
esc_attr( stripslashes( $value ) ),
@@ -1059,7 +1059,7 @@ public function callback_select( $args ) {
10591059
$chosen = '';
10601060
}
10611061

1062-
$html = sprintf( '<select id="%1$s[%2$s]" name="%1$s[%2$s]" %2$s />', $this->settings_key, sanitize_key( $args['id'] ), $chosen );
1062+
$html = sprintf( '<select id="%1$s[%2$s]" name="%1$s[%2$s]" %3$s />', $this->settings_key, sanitize_key( $args['id'] ), $chosen );
10631063

10641064
foreach ( $args['options'] as $option => $name ) {
10651065
$html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', sanitize_key( $option ), selected( $option, $value, false ), $name );
@@ -1325,13 +1325,12 @@ public function settings_sanitize( $input ) {
13251325
if ( ! isset( $input[ $key ] ) ) {
13261326
unset( $output[ $key ] );
13271327
}
1328-
}
13291328

1330-
// Delete any settings that are no longer part of our registered settings.
1331-
if ( array_key_exists( $key, $output ) && ! array_key_exists( $key, $settings_types ) ) {
1332-
unset( $output[ $key ] );
1329+
// Delete any settings that are no longer part of our registered settings.
1330+
if ( array_key_exists( $key, $output ) && ! array_key_exists( $key, $settings_types ) ) {
1331+
unset( $output[ $key ] );
1332+
}
13331333
}
1334-
13351334
add_settings_error( $this->prefix . '-notices', '', $this->translation_strings['success_message'], 'updated' );
13361335

13371336
/**
@@ -1395,7 +1394,7 @@ public function sanitize_text_field( $value ) {
13951394
/**
13961395
* Sanitize number fields
13971396
*
1398-
* @param array $value The field value.
1397+
* @param string $value The field value.
13991398
* @return string $value Sanitized value
14001399
*/
14011400
public function sanitize_number_field( $value ) {
@@ -1579,7 +1578,7 @@ public function show_navigation() {
15791578

15801579
$active = $active_tab === $tab_id ? ' ' : '';
15811580

1582-
$html .= '<li><a href="#' . esc_attr( $tab_id ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab ' . sanitize_html_class( $active ) . '">';
1581+
$html .= '<li style="margin-bottom:0;"><a href="#' . esc_attr( $tab_id ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab ' . sanitize_html_class( $active ) . '">';
15831582
$html .= esc_html( $tab_name );
15841583
$html .= '</a></li>';
15851584

@@ -1691,7 +1690,6 @@ public function settings_help() {
16911690
$screen->add_help_tab( $tab );
16921691
}
16931692
}
1694-
16951693
}
16961694

16971695
endif;

includes/admin/settings/options-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,17 @@ function wzkb_settings_reset() {
250250
function wz_tag_search() {
251251

252252
if ( ! isset( $_REQUEST['tax'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
253-
wp_die( 0 );
253+
wp_die();
254254
}
255255

256256
$taxonomy = sanitize_key( $_REQUEST['tax'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
257257
$tax = get_taxonomy( $taxonomy );
258258
if ( ! $tax ) {
259-
wp_die( 0 );
259+
wp_die();
260260
}
261261

262262
if ( ! current_user_can( $tax->cap->assign_terms ) ) {
263-
wp_die( -1 );
263+
wp_die();
264264
}
265265

266266
$s = isset( $_REQUEST['q'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended

includes/deprecated.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@
2525
*/
2626
global $wzkb_options;
2727
$wzkb_options = wzkb_get_settings();
28-

includes/feed.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ function wzkb_in_feed( $query ) {
3939
return $query;
4040
}
4141
add_filter( 'request', 'wzkb_in_feed', 11 );
42-

includes/main.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ function wzkb_looper( $term_id, $level, $nested = true, $args = array() ) {
148148

149149
// Get Knowledge Base Sections.
150150
$sections = get_terms(
151-
'wzkb_category',
152151
array(
152+
'taxonomy' => 'wzkb_category',
153153
'orderby' => 'slug',
154154
'hide_empty' => $args['show_empty_sections'] ? 0 : 1,
155155
'parent' => $term_id,
@@ -180,9 +180,9 @@ function wzkb_looper( $term_id, $level, $nested = true, $args = array() ) {
180180
*
181181
* @since 1.0.0
182182
*
183-
* @param string $output Formatted HTML output
184-
* @param int $term_id Term ID
185-
* @param int $level Level of the loop
183+
* @param string $output Formatted HTML output
184+
* @param \WP_Term $term Term ID
185+
* @param int $level Level of the loop
186186
*/
187187
return apply_filters( 'wzkb_looper', $output, $term, $level );
188188
}
@@ -321,12 +321,12 @@ function wzkb_article_header( $term, $level, $args = array() ) {
321321
*
322322
* @since 1.1.0
323323
*
324-
* @param string $output Formatted footer output
325-
* @param object $term Current term
326-
* @param int $level Current level in the recursive loop
327-
* @param object $query Query results object
324+
* @param string $output Formatted footer output.
325+
* @param object $term Current term.
326+
* @param int $level Current level in the recursive loop.
327+
* @param array $args Parameters array.
328328
*/
329-
return apply_filters( 'wzkb_article_header', $output, $term, $level );
329+
return apply_filters( 'wzkb_article_header', $output, $term, $level, $args );
330330
}
331331

332332

@@ -423,10 +423,10 @@ function wzkb_article_footer( $term, $level, $query, $args = array() ) {
423423
*
424424
* @since 1.1.0
425425
*
426-
* @param string $output Formatted footer output
427-
* @param string $output Formatted ul loop
428-
* @param object $term Current term
429-
* @param int $level Current level in the recursive loop
426+
* @param string $output Formatted footer output.
427+
* @param object $term Current term.
428+
* @param int $level Current level in the recursive loop.
429+
* @param object $query Query results object.
430430
*/
431431
return apply_filters( 'wzkb_article_footer', $output, $term, $level, $query );
432432
}
@@ -467,8 +467,8 @@ function wzkb_categories_list( $term_id, $level = 0, $args = array() ) {
467467

468468
// Get Knowledge Base Sections.
469469
$sections = get_terms(
470-
'wzkb_category',
471470
array(
471+
'taxonomy' => 'wzkb_category',
472472
'orderby' => 'slug',
473473
'hide_empty' => wzkb_get_option( 'show_empty_sections' ) ? 0 : 1,
474474
'parent' => $term_id,

includes/public/public.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
function wzkb_lang_init() {
2424
load_plugin_textdomain( 'wzkb', false, dirname( plugin_basename( WZKB_PLUGIN_FILE ) ) . '/languages/' );
2525
}
26-
add_action( 'plugins_loaded', 'wzkb_lang_init' );
26+
add_action( 'init', 'wzkb_lang_init' );
2727

2828

2929
/**

includes/search.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @since 1.1.0
2222
*
2323
* @param boolean $echo_output Default to echo and not return the form.
24-
* @return string|null String when retrieving, null when displaying or if searchform.php exists.
24+
* @return void|string|null String when retrieving, null when displaying or if searchform.php exists.
2525
*/
2626
function wzkb_get_search_form( $echo_output = true ) {
2727

@@ -41,7 +41,7 @@ function wzkb_get_search_form( $echo_output = true ) {
4141
*
4242
* @since 1.1.0
4343
*
44-
* @param string $form The search form HTML output.
44+
* @param string|null $form The search form HTML output.
4545
*/
4646
$result = apply_filters( 'wzkb_get_search_form', $form );
4747

@@ -55,5 +55,3 @@ function wzkb_get_search_form( $echo_output = true ) {
5555
return $result;
5656
}
5757
}
58-
59-

0 commit comments

Comments
 (0)