Skip to content

Commit 64c0819

Browse files
committed
PHPCS fixes
1 parent 126532e commit 64c0819

File tree

4 files changed

+77
-78
lines changed

4 files changed

+77
-78
lines changed

includes/main.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,77 @@ function wzkb_cache_get_key( $attr ) {
445445

446446
return $meta_key;
447447
}
448+
449+
/**
450+
* Get a hierarchical list of WZ Knowledge Base sections.
451+
*
452+
* @param int $term_id Term ID.
453+
* @param int $level Level of the loop.
454+
* @param array $args Array or arguments.
455+
* @return string HTML output with the categories.
456+
*/
457+
function wzkb_categories_list( $term_id, $level = 0, $args = array() ) {
458+
459+
$defaults = array(
460+
'depth' => 0, // Depth of nesting.
461+
'before_li_item' => '', // Before list item - just after <li>.
462+
'after_li_item' => '', // Before list item - just before </li>.
463+
);
464+
465+
// Parse incomming $args into an array and merge it with $defaults.
466+
$args = wp_parse_args( $args, $defaults );
467+
468+
// Get Knowledge Base Sections.
469+
$sections = get_terms(
470+
'wzkb_category',
471+
array(
472+
'orderby' => 'slug',
473+
'hide_empty' => wzkb_get_option( 'show_empty_sections' ) ? 0 : 1,
474+
'parent' => $term_id,
475+
)
476+
);
477+
478+
$output = '';
479+
480+
if ( ! empty( $sections ) && ! is_wp_error( $sections ) ) {
481+
482+
$output .= '<ul class="wzkb_terms_widget wzkb_term_' . $term_id . ' wzkb_ul_level_' . $level . '">';
483+
484+
++$level;
485+
486+
foreach ( $sections as $term ) {
487+
488+
$term_link = get_term_link( $term );
489+
490+
// If there was an error, continue to the next term.
491+
if ( is_wp_error( $term_link ) ) {
492+
continue;
493+
}
494+
495+
$output .= '<li class="wzkb_cat_' . $term->term_id . '">' . $args['before_li_item'];
496+
$output .= '<a href="' . esc_url( $term_link ) . '" title="' . esc_attr( $term->name ) . '" >' . $term->name . '</a>';
497+
$output .= wzkb_categories_list( $term->term_id, $level, $args );
498+
$output .= $args['after_li_item'] . '</li>';
499+
500+
// Exit the loop if we are at the depth.
501+
if ( 0 < $args['depth'] && $level >= $args['depth'] ) {
502+
break;
503+
}
504+
}
505+
$output .= '</ul>';
506+
}
507+
508+
return $output;
509+
}
510+
511+
/**
512+
* Initialise the widget.
513+
*
514+
* @since 1.9.0
515+
*/
516+
function register_wzkb_widgets() {
517+
register_widget( 'WZKB_Breadcrumb_Widget' );
518+
register_widget( 'WZKB_Sections_Widget' );
519+
register_widget( 'WZKB_Articles_Widget' );
520+
}
521+
add_action( 'widgets_init', 'register_wzkb_widgets' );

includes/search.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
*
2121
* @since 1.1.0
2222
*
23-
* @param boolean $echo Default to echo and not return the form.
23+
* @param boolean $echo_output Default to echo and not return the form.
2424
* @return string|null String when retrieving, null when displaying or if searchform.php exists.
2525
*/
26-
function wzkb_get_search_form( $echo = true ) {
26+
function wzkb_get_search_form( $echo_output = true ) {
2727

2828
$form = '
2929
<form role="search" method="get" class="wzkb-search-form" action="' . esc_url( home_url( '/' ) ) . '">
@@ -49,7 +49,7 @@ function wzkb_get_search_form( $echo = true ) {
4949
$result = $form;
5050
}
5151

52-
if ( $echo ) {
52+
if ( $echo_output ) {
5353
echo $result; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
5454
} else {
5555
return $result;

includes/widgets/class-wzkb-breadcrumb-widget.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,3 @@ public function widget( $args, $instance ) {
161161
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
162162
} // Ending function widget.
163163
}
164-
165-
166-
/**
167-
* Initialise the widget.
168-
*
169-
* @since 1.9.0
170-
*/
171-
function register_wzkb_widgets() {
172-
register_widget( 'WZKB_Breadcrumb_Widget' );
173-
register_widget( 'WZKB_Sections_Widget' );
174-
register_widget( 'WZKB_Articles_Widget' );
175-
}
176-
add_action( 'widgets_init', 'register_wzkb_widgets' );

includes/widgets/class-wzkb-sections-widget.php

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -184,65 +184,3 @@ public function widget( $args, $instance ) {
184184
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
185185
} // Ending function widget.
186186
}
187-
188-
/**
189-
* Get a hierarchical list of WZ Knowledge Base sections.
190-
*
191-
* @param int $term_id Term ID.
192-
* @param int $level Level of the loop.
193-
* @param array $args Array or arguments.
194-
* @return string HTML output with the categories.
195-
*/
196-
function wzkb_categories_list( $term_id, $level = 0, $args = array() ) {
197-
198-
$defaults = array(
199-
'depth' => 0, // Depth of nesting.
200-
'before_li_item' => '', // Before list item - just after <li>.
201-
'after_li_item' => '', // Before list item - just before </li>.
202-
);
203-
204-
// Parse incomming $args into an array and merge it with $defaults.
205-
$args = wp_parse_args( $args, $defaults );
206-
207-
// Get Knowledge Base Sections.
208-
$sections = get_terms(
209-
'wzkb_category',
210-
array(
211-
'orderby' => 'slug',
212-
'hide_empty' => wzkb_get_option( 'show_empty_sections' ) ? 0 : 1,
213-
'parent' => $term_id,
214-
)
215-
);
216-
217-
$output = '';
218-
219-
if ( ! empty( $sections ) && ! is_wp_error( $sections ) ) {
220-
221-
$output .= '<ul class="wzkb_terms_widget wzkb_term_' . $term_id . ' wzkb_ul_level_' . $level . '">';
222-
223-
++$level;
224-
225-
foreach ( $sections as $term ) {
226-
227-
$term_link = get_term_link( $term );
228-
229-
// If there was an error, continue to the next term.
230-
if ( is_wp_error( $term_link ) ) {
231-
continue;
232-
}
233-
234-
$output .= '<li class="wzkb_cat_' . $term->term_id . '">' . $args['before_li_item'];
235-
$output .= '<a href="' . esc_url( $term_link ) . '" title="' . esc_attr( $term->name ) . '" >' . $term->name . '</a>';
236-
$output .= wzkb_categories_list( $term->term_id, $level, $args );
237-
$output .= $args['after_li_item'] . '</li>';
238-
239-
// Exit the loop if we are at the depth.
240-
if ( 0 < $args['depth'] && $level >= $args['depth'] ) {
241-
break;
242-
}
243-
}
244-
$output .= '</ul>';
245-
}
246-
247-
return $output;
248-
}

0 commit comments

Comments
 (0)