Warning: include_once(): Failed opening '/home/merciket/public_html/wp-content/plugins/gravityforms/gravityforms.php' for inclusion (include_path='.:/opt/alt/php74/usr/share/pear') in /home/merciket/public_html/wp-settings.php on line 473
y = wc_string_to_bool( $attributes['showChildrenOnly'] ) && is_product_category(); if ( $children_only ) { $term_id = get_queried_object_id(); $categories = get_terms( 'product_cat', [ 'hide_empty' => ! $attributes['hasEmpty'], 'pad_counts' => true, 'hierarchical' => true, 'child_of' => $term_id, ] ); } else { $categories = get_terms( 'product_cat', [ 'hide_empty' => ! $attributes['hasEmpty'], 'pad_counts' => true, 'hierarchical' => true, ] ); } if ( ! is_array( $categories ) || empty( $categories ) ) { return []; } // This ensures that no categories with a product count of 0 is rendered. if ( ! $attributes['hasEmpty'] ) { $categories = array_filter( $categories, function( $category ) { return 0 !== $category->count; } ); } return $hierarchical ? $this->build_category_tree( $categories, $children_only ) : $categories; } /** * Build hierarchical tree of categories. * * @param array $categories List of terms. * @param bool $children_only Is the block rendering only the children of the current category. * @return array */ protected function build_category_tree( $categories, $children_only ) { $categories_by_parent = []; foreach ( $categories as $category ) { if ( ! isset( $categories_by_parent[ 'cat-' . $category->parent ] ) ) { $categories_by_parent[ 'cat-' . $category->parent ] = []; } $categories_by_parent[ 'cat-' . $category->parent ][] = $category; } $parent_id = $children_only ? get_queried_object_id() : 0; $tree = $categories_by_parent[ 'cat-' . $parent_id ]; // these are top level categories. So all parents. unset( $categories_by_parent[ 'cat-' . $parent_id ] ); foreach ( $tree as $category ) { if ( ! empty( $categories_by_parent[ 'cat-' . $category->term_id ] ) ) { $category->children = $this->fill_category_children( $categories_by_parent[ 'cat-' . $category->term_id ], $categories_by_parent ); } } return $tree; } /** * Build hierarchical tree of categories by appending children in the tree. * * @param array $categories List of terms. * @param array $categories_by_parent List of terms grouped by parent. * @return array */ protected function fill_category_children( $categories, $categories_by_parent ) { foreach ( $categories as $category ) { if ( ! empty( $categories_by_parent[ 'cat-' . $category->term_id ] ) ) { $category->children = $this->fill_category_children( $categories_by_parent[ 'cat-' . $category->term_id ], $categories_by_parent ); } } return $categories; } /** * Render the category list as a dropdown. * * @param array $categories List of terms. * @param array $attributes Block attributes. Default empty array. * @param int $uid Unique ID for the rendered block, used for HTML IDs. * @return string Rendered output. */ protected function renderDropdown( $categories, $attributes, $uid ) { $aria_label = empty( $attributes['hasCount'] ) ? __( 'List of categories', 'woocommerce' ) : __( 'List of categories with their product counts', 'woocommerce' ); $output = '
'; return $output; } /** * Render dropdown options list. * * @param array $categories List of terms. * @param array $attributes Block attributes. Default empty array. * @param int $uid Unique ID for the rendered block, used for HTML IDs. * @param int $depth Current depth. * @return string Rendered output. */ protected function renderDropdownOptions( $categories, $attributes, $uid, $depth = 0 ) { $output = ''; foreach ( $categories as $category ) { $output .= ' ' . ( ! empty( $category->children ) ? $this->renderDropdownOptions( $category->children, $attributes, $uid, $depth + 1 ) : '' ) . ' '; } return $output; } /** * Render the category list as a list. * * @param array $categories List of terms. * @param array $attributes Block attributes. Default empty array. * @param int $uid Unique ID for the rendered block, used for HTML IDs. * @param int $depth Current depth. * @return string Rendered output. */ protected function renderList( $categories, $attributes, $uid, $depth = 0 ) { $classes = [ 'wc-block-product-categories-list', 'wc-block-product-categories-list--depth-' . absint( $depth ), ]; if ( ! empty( $attributes['hasImage'] ) ) { $classes[] = 'wc-block-product-categories-list--has-images'; } $output = ''; return $output; } /** * Render a list of terms. * * @param array $categories List of terms. * @param array $attributes Block attributes. Default empty array. * @param int $uid Unique ID for the rendered block, used for HTML IDs. * @param int $depth Current depth. * @return string Rendered output. */ protected function renderListItems( $categories, $attributes, $uid, $depth = 0 ) { $output = ''; $link_color_class_and_style = StyleAttributesUtils::get_link_color_class_and_style( $attributes ); $link_color_style = isset( $link_color_class_and_style['style'] ) ? $link_color_class_and_style['style'] : ''; foreach ( $categories as $category ) { $output .= '
  • ' . $this->get_image_html( $category, $attributes ) . '' . esc_html( $category->name ) . '' . '' . $this->getCount( $category, $attributes ) . ( ! empty( $category->children ) ? $this->renderList( $category->children, $attributes, $uid, $depth + 1 ) : '' ) . '
  • '; } return preg_replace( '/\r|\n/', '', $output ); } /** * Returns the category image html * * @param \WP_Term $category Term object. * @param array $attributes Block attributes. Default empty array. * @param string $size Image size, defaults to 'woocommerce_thumbnail'. * @return string */ public function get_image_html( $category, $attributes, $size = 'woocommerce_thumbnail' ) { if ( empty( $attributes['hasImage'] ) ) { return ''; } $image_id = get_term_meta( $category->term_id, 'thumbnail_id', true ); if ( ! $image_id ) { return '' . wc_placeholder_img( 'woocommerce_thumbnail' ) . ''; } return '' . wp_get_attachment_image( $image_id, 'woocommerce_thumbnail' ) . ''; } /** * Get the count, if displaying. * * @param object $category Term object. * @param array $attributes Block attributes. Default empty array. * @return string */ protected function getCount( $category, $attributes ) { if ( empty( $attributes['hasCount'] ) ) { return ''; } if ( $attributes['isDropdown'] ) { return '(' . absint( $category->count ) . ')'; } $screen_reader_text = sprintf( /* translators: %s number of products in cart. */ _n( '%d product', '%d products', absint( $category->count ), 'woocommerce' ), absint( $category->count ) ); return '' . '' . '' . esc_html( $screen_reader_text ) . '' . ''; } }
    Fatal error: Uncaught Error: Class 'Automattic\WooCommerce\Blocks\BlockTypes\ProductCategories' not found in /home/merciket/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php:106 Stack trace: #0 /home/merciket/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\BlockTypesController->register_blocks('') #1 /home/merciket/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #2 /home/merciket/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #3 /home/merciket/public_html/wp-settings.php(643): do_action('init') #4 /home/merciket/public_html/wp-config.php(92): require_once('/home/merciket/...') #5 /home/merciket/public_html/wp-load.php(50): require_once('/home/merciket/...') #6 /home/merciket/public_html/wp-blog-header.php(13): require_once('/home/merciket/...') #7 /home/merciket/public_html/index.php(17): require('/home/merciket/...') #8 {main} thrown in /home/merciket/public_html/wp-content/plugins/woocommerce/src/Blocks/BlockTypesController.php on line 106