diff --git a/includes/admin/reports/class-wc-report-sales-by-category.php b/includes/admin/reports/class-wc-report-sales-by-category.php
index e09c0cb6d7632..746f9ac3ea51b 100644
--- a/includes/admin/reports/class-wc-report-sales-by-category.php
+++ b/includes/admin/reports/class-wc-report-sales-by-category.php
@@ -222,7 +222,7 @@ public function category_widget() {
$r['value'] = 'id';
$r['selected'] = $this->show_categories;
- include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-dropdown-walker.php';
+ include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';
echo wc_walk_category_dropdown_tree( $categories, 0, $r ); // @codingStandardsIgnoreLine
?>
diff --git a/includes/walkers/class-product-cat-dropdown-walker.php b/includes/walkers/class-product-cat-dropdown-walker.php
index 7eaa210c8d141..90ff3c7cf60aa 100644
--- a/includes/walkers/class-product-cat-dropdown-walker.php
+++ b/includes/walkers/class-product-cat-dropdown-walker.php
@@ -1,104 +1,11 @@
'parent',
- 'id' => 'term_id',
- 'slug' => 'slug',
- );
-
- /**
- * Starts the list before the elements are added.
- *
- * @see Walker::start_el()
- * @since 2.1.0
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param object $cat
- * @param int $depth Depth of category in reference to parents.
- * @param array $args
- * @param int $current_object_id
- */
- public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
-
- if ( ! empty( $args['hierarchical'] ) ) {
- $pad = str_repeat( ' ', $depth * 3 );
- } else {
- $pad = '';
- }
-
- $cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
- $value = ( isset( $args['value'] ) && 'id' === $args['value'] ) ? $cat->term_id : $cat->slug;
- $output .= "\t\n";
- }
-
- /**
- * Traverse elements to create list from elements.
- *
- * Display one element if the element doesn't have any children otherwise,
- * display the element and its children. Will only traverse up to the max.
- * depth and no ignore elements under that depth. It is possible to set the.
- * max depth to include all depths, see walk() method.
- *
- * This method shouldn't be called directly, use the walk() method instead.
- *
- * @since 2.5.0
- *
- * @param object $element Data object
- * @param array $children_elements List of elements to continue traversing.
- * @param int $max_depth Max depth to traverse.
- * @param int $depth Depth of current element.
- * @param array $args
- * @param string $output Passed by reference. Used to append additional content.
- * @return null Null on failure with no changes to parameters.
- */
- public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
- if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
- return;
- }
- parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
- }
-}
-
-endif;
+require dirname( __FILE__ ) . '/class-wc-product-cat-dropdown-walker.php';
diff --git a/includes/walkers/class-product-cat-list-walker.php b/includes/walkers/class-product-cat-list-walker.php
index f4b0ce84bf663..63a172e93417e 100644
--- a/includes/walkers/class-product-cat-list-walker.php
+++ b/includes/walkers/class-product-cat-list-walker.php
@@ -1,153 +1,11 @@
'parent',
- 'id' => 'term_id',
- 'slug' => 'slug',
- );
-
- /**
- * Starts the list before the elements are added.
- *
- * @see Walker::start_lvl()
- * @since 2.1.0
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param int $depth Depth of category. Used for tab indentation.
- * @param array $args Will only append content if style argument value is 'list'.
- */
- public function start_lvl( &$output, $depth = 0, $args = array() ) {
- if ( 'list' != $args['style'] ) {
- return;
- }
-
- $indent = str_repeat( "\t", $depth );
- $output .= "$indent
\n";
- }
-
- /**
- * Ends the list of after the elements are added.
- *
- * @see Walker::end_lvl()
- * @since 2.1.0
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param int $depth Depth of category. Used for tab indentation.
- * @param array $args Will only append content if style argument value is 'list'.
- */
- public function end_lvl( &$output, $depth = 0, $args = array() ) {
- if ( 'list' != $args['style'] ) {
- return;
- }
-
- $indent = str_repeat( "\t", $depth );
- $output .= "$indent
\n";
- }
-
- /**
- * Start the element output.
- *
- * @see Walker::start_el()
- * @since 2.1.0
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param object $cat
- * @param int $depth Depth of category in reference to parents.
- * @param array $args
- * @param integer $current_object_id
- */
- public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
- $output .= '
' . _x( $cat->name, 'product category name', 'woocommerce' ) . '';
-
- if ( $args['show_count'] ) {
- $output .= ' (' . $cat->count . ')';
- }
- }
-
- /**
- * Ends the element output, if needed.
- *
- * @see Walker::end_el()
- * @since 2.1.0
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param object $cat
- * @param int $depth Depth of category. Not used.
- * @param array $args Only uses 'list' for whether should append to output.
- */
- public function end_el( &$output, $cat, $depth = 0, $args = array() ) {
- $output .= "
\n";
- }
-
- /**
- * Traverse elements to create list from elements.
- *
- * Display one element if the element doesn't have any children otherwise,
- * display the element and its children. Will only traverse up to the max.
- * depth and no ignore elements under that depth. It is possible to set the.
- * max depth to include all depths, see walk() method.
- *
- * This method shouldn't be called directly, use the walk() method instead.
- *
- * @since 2.5.0
- *
- * @param object $element Data object
- * @param array $children_elements List of elements to continue traversing.
- * @param int $max_depth Max depth to traverse.
- * @param int $depth Depth of current element.
- * @param array $args
- * @param string $output Passed by reference. Used to append additional content.
- * @return null Null on failure with no changes to parameters.
- */
- public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
- if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
- return;
- }
- parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
- }
-}
-
-endif;
+require dirname( __FILE__ ) . '/class-wc-product-cat-list-walker.php';
diff --git a/includes/walkers/class-wc-product-cat-dropdown-walker.php b/includes/walkers/class-wc-product-cat-dropdown-walker.php
new file mode 100644
index 0000000000000..34250efcfb162
--- /dev/null
+++ b/includes/walkers/class-wc-product-cat-dropdown-walker.php
@@ -0,0 +1,102 @@
+ 'parent',
+ 'id' => 'term_id',
+ 'slug' => 'slug',
+ );
+
+ /**
+ * Starts the list before the elements are added.
+ *
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $cat Category.
+ * @param int $depth Depth of category in reference to parents.
+ * @param array $args Arguments.
+ * @param int $current_object_id Current object ID.
+ */
+ public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
+
+ if ( ! empty( $args['hierarchical'] ) ) {
+ $pad = str_repeat( ' ', $depth * 3 );
+ } else {
+ $pad = '';
+ }
+
+ $cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
+ $value = ( isset( $args['value'] ) && 'id' === $args['value'] ) ? $cat->term_id : $cat->slug;
+ $output .= "\t\n";
+ }
+
+ /**
+ * Traverse elements to create list from elements.
+ *
+ * Display one element if the element doesn't have any children otherwise,
+ * display the element and its children. Will only traverse up to the max.
+ * depth and no ignore elements under that depth. It is possible to set the.
+ * max depth to include all depths, see walk() method.
+ *
+ * This method shouldn't be called directly, use the walk() method instead.
+ *
+ * @since 2.5.0
+ *
+ * @param object $element Data object.
+ * @param array $children_elements List of elements to continue traversing.
+ * @param int $max_depth Max depth to traverse.
+ * @param int $depth Depth of current element.
+ * @param array $args Arguments.
+ * @param string $output Passed by reference. Used to append additional content.
+ * @return null Null on failure with no changes to parameters.
+ */
+ public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
+ if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
+ return;
+ }
+ parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
+ }
+}
diff --git a/includes/walkers/class-wc-product-cat-list-walker.php b/includes/walkers/class-wc-product-cat-list-walker.php
new file mode 100644
index 0000000000000..28b1785f163eb
--- /dev/null
+++ b/includes/walkers/class-wc-product-cat-list-walker.php
@@ -0,0 +1,153 @@
+ 'parent',
+ 'id' => 'term_id',
+ 'slug' => 'slug',
+ );
+
+ /**
+ * Starts the list before the elements are added.
+ *
+ * @see Walker::start_lvl()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of category. Used for tab indentation.
+ * @param array $args Will only append content if style argument value is 'list'.
+ */
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
+ if ( 'list' !== $args['style'] ) {
+ return;
+ }
+
+ $indent = str_repeat( "\t", $depth );
+ $output .= "$indent
\n";
+ }
+
+ /**
+ * Ends the list of after the elements are added.
+ *
+ * @see Walker::end_lvl()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param int $depth Depth of category. Used for tab indentation.
+ * @param array $args Will only append content if style argument value is 'list'.
+ */
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
+ if ( 'list' !== $args['style'] ) {
+ return;
+ }
+
+ $indent = str_repeat( "\t", $depth );
+ $output .= "$indent
\n";
+ }
+
+ /**
+ * Start the element output.
+ *
+ * @see Walker::start_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $cat Category.
+ * @param int $depth Depth of category in reference to parents.
+ * @param array $args Arguments.
+ * @param integer $current_object_id Current object ID.
+ */
+ public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
+ $cat_id = intval( $cat->term_id );
+
+ $output .= '
' . apply_filters( 'list_product_cats', $cat->name, $cat ) . '';
+
+ if ( $args['show_count'] ) {
+ $output .= ' (' . $cat->count . ')';
+ }
+ }
+
+ /**
+ * Ends the element output, if needed.
+ *
+ * @see Walker::end_el()
+ * @since 2.1.0
+ *
+ * @param string $output Passed by reference. Used to append additional content.
+ * @param object $cat Category.
+ * @param int $depth Depth of category. Not used.
+ * @param array $args Only uses 'list' for whether should append to output.
+ */
+ public function end_el( &$output, $cat, $depth = 0, $args = array() ) {
+ $output .= "
\n";
+ }
+
+ /**
+ * Traverse elements to create list from elements.
+ *
+ * Display one element if the element doesn't have any children otherwise,
+ * display the element and its children. Will only traverse up to the max.
+ * depth and no ignore elements under that depth. It is possible to set the.
+ * max depth to include all depths, see walk() method.
+ *
+ * This method shouldn't be called directly, use the walk() method instead.
+ *
+ * @since 2.5.0
+ *
+ * @param object $element Data object.
+ * @param array $children_elements List of elements to continue traversing.
+ * @param int $max_depth Max depth to traverse.
+ * @param int $depth Depth of current element.
+ * @param array $args Arguments.
+ * @param string $output Passed by reference. Used to append additional content.
+ * @return null Null on failure with no changes to parameters.
+ */
+ public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
+ if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
+ return;
+ }
+ parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
+ }
+}
diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php
index f6f742484aca3..a2bcecc3a1d06 100644
--- a/includes/wc-term-functions.php
+++ b/includes/wc-term-functions.php
@@ -219,7 +219,7 @@ function wc_walk_category_dropdown_tree() {
$args = func_get_args();
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) {
- include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-dropdown-walker.php';
+ include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';
}
// The user's options are the third parameter.
diff --git a/includes/widgets/class-wc-widget-product-categories.php b/includes/widgets/class-wc-widget-product-categories.php
index ed09be88921b9..b90816d2c95e7 100644
--- a/includes/widgets/class-wc-widget-product-categories.php
+++ b/includes/widgets/class-wc-widget-product-categories.php
@@ -250,7 +250,7 @@ public function widget( $args, $instance ) {
"
);
} else {
- include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php';
+ include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-list-walker.php';
$list_args['walker'] = new WC_Product_Cat_List_Walker();
$list_args['title_li'] = '';