Hooks and actions

Actions and Filters are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress; the same concept is used by Wolmart to allow hooking into Wolmart specific functionality so that you can modify it in a child theme or even a plugin.

How To Use a Hook Or A Filter?

So, let’s assume you wanna show product tab accordion in particular single product page. At that time, you can show as accordion using our Wolmart filter.

Step 1: Copy the single product template file and modify the code in that file.

Step 2: Use a filter in a child theme’s single product/tabs.php.

Following is an example code.

add_filter( 'wolmart_single_product_data_tab_type', function() {
     return 'accordion';
});

Actions are similar to the filters. By using an action, you don’t edit or overwrite the core code which is why, your code will rarely need to be changed.

Conversion For Child Themes

If you’d like to learn how to convert Child Themes, you should use actions and filters as much as possible. you can show many actions and filters on following code.

Actions List
1. Wolmart/framework/theme-actions.php
    // Page layout
    add_action( 'wolmart_print_before_page_layout', 'wolmart_print_layout_before' );
    add_action( 'wolmart_print_after_page_layout', 'wolmart_print_layout_after' );

    // Comment
    add_filter( 'wolmart_filter_comment_form_args', 'wolmart_comment_form_args' );
    add_action( 'comment_form_before_fields', 'wolmart_comment_form_before_fields' );
    add_action( 'comment_form_after_fields', 'wolmart_comment_form_after_fields' );
    add_filter( 'pre_get_avatar_data', 'wolmart_set_avatar_size' );

2. Wolmart/framework/addons/skeleton/skeleton.php
    // Sidebar skeleton
    add_action( 'wolmart_sidebar_content_start', array( $this, 'sidebar_content_start' ) );
    add_action( 'wolmart_sidebar_content_end', array( $this, 'sidebar_content_end' ) );
    add_filter( 'wolmart_sidebar_classes', array( $this, 'sidebar_classes' ) );

    // Posts (archive + single) skeleton
    add_filter( 'wolmart_post_loop_wrapper_classes', array( $this, 'post_loop_wrapper_class' ) );
    add_filter( 'wolmart_post_single_class', array( $this, 'post_loop_wrapper_class' ) );
    add_action( 'wolmart_post_loop_before_item', array( $this, 'post_loop_before_item' ) );
    add_action( 'wolmart_post_loop_after_item', array( $this, 'post_loop_after_item' ) );

    // Archive products & categories skeleton
    add_filter( 'wolmart_product_loop_wrapper_classes', array( $this, 'product_loop_wrapper_class' ) );
    add_action( 'wolmart_product_loop_before_item', array( $this, 'product_loop_before_item' ) );
    add_action( 'wolmart_product_loop_after_item', array( $this, 'product_loop_after_item' ) );
    add_action( 'wolmart_product_loop_before_cat', array( $this, 'product_loop_before_cat' ) );
    add_action( 'wolmart_product_loop_after_cat', array( $this, 'product_loop_after_cat' ) );

    // Single product skeleton
    add_filter( 'wolmart_single_product_classes', array( $this, 'single_product_classes' ) );
    add_action( 'wolmart_before_product_gallery', array( $this, 'before_product_gallery' ), 20 );
    add_action( 'wolmart_after_product_gallery', array( $this, 'after_product_gallery' ), 20 );
    if ( ! defined( 'WOLMART_VENDORS' ) ) {
        // We disable skeleton screen for single product page's summary and tabs,
        // because it has too many compatibility issues.
        add_action( 'wolmart_before_product_summary', array( $this, 'before_product_summary' ), 20 );
        add_action( 'wolmart_after_product_summary', array( $this, 'after_product_summary' ), 20 );
        add_action( 'wolmart_wc_product_before_tabs', array( $this, 'before_product_tabs' ), 20 );
        add_action( 'woocommerce_product_after_tabs', array( $this, 'after_product_tabs' ), 20 );
    }

3. Wolmart/framework/plugins/woocommerce/product-loop.php
   // Product Loop Details
   add_action( 'wolmart_shop_loop_item_categories', 'wolmart_shop_loop_item_categories' );
   // Product Loop Hide Details (for classic type)
   add_action( 'wolmart_product_loop_hide_details', 'wolmart_product_loop_action' );


4. Wolmart/framework/plugins/woocommerce/product-single.php
   // Single Product - the other types except gallery and sticky-both types
   add_action( 'wolmart_after_product_summary_wrap', 'wolmart_single_product_wrap_second_end', 20 );
   // Single Product - sticky-both type
   add_action( 'wolmart_before_product_summary', 'wolmart_wc_show_product_images_sticky_both', 5 );
   // Single Product - sticky-info type
   add_action( 'wolmart_after_product_summary_wrap', 'wolmart_single_product_wrap_sticky_info_end', 15 );
   // Single Product Media
   add_action( 'wolmart_woocommerce_product_images', 'wolmart_single_product_images' );
   // Product Listed Attributes (in archive loop and single)
   add_action( 'wolmart_wc_product_listed_attributes', 'wolmart_wc_product_listed_attributes_html' );


5. Wolmart/framework/plugins/woocommerce/woo-functions.php
   // Woocommerce Breadcrumb
   add_filter( 'woocommerce_breadcrumb_defaults', 'wolmart_wc_breadcrumb_args' );
   // Woocommerce Notice Skin
   add_action( 'wolmart_wc_before_notice', 'wolmart_wc_notice_action', 10, 2 );
   add_action( 'wolmart_wc_after_notice', 'wolmart_wc_notice_close', 10, 2 );
Filters List
1. Wolmart/comments.php
   apply_filters( 'wolmart_filter_comment_args', array() );
   apply_filters( 'wolmart_filter_comment_form_args', array() );


2. Wolmart/framework/core-functions.php

   apply_filters( 'wolmart_get_template_part', $template, $slug, $name );
   apply_filters( 'wolmart_get_col_class', $class );


3. Wolmart/framework/theme-functions.php

   apply_filters( 'wolmart_filter_reponsive_cols', $result, $cols );
   apply_filters( 'wolmart_filter_trim_description', '<p>' . mb_substr( $content, 0, $limit ) . $affix . '</p>' );
   apply_filters( 'wolmart_core_filter_doing_ajax', false );
   apply_filters( 'wolmart_is_shop', true );
   apply_filters( 'wolmart_is_product', false );


4. Wolmart/framework/theme-actions.php
   apply_filters( 'wolmart_main_content_class', 'main-content' );


5. Wolmart/framework/addons/live-search/live-search.php
   apply_filters( 'wolmart_live_search_query', sanitize_text_field( $_REQUEST['query'] ) );
   apply_filters( 'wolmart_live_search_post_type', $post_type );
   apply_filters( 'wolmart_live_search_products_query', sanitize_text_field( $_REQUEST['query'] ) );
   apply_filters( 'wolmart_live_search_products_by_sku_query', sanitize_text_field( $_REQUEST['query'] ) );
   apply_filters( 'wolmart_live_search_products_by_tag_query', sanitize_text_field( $_REQUEST['query'] ) );
   apply_filters( 'wolmart_live_search_function', 'get_posts', $search_query, $args );


6. Wolmart/framework/addons/product-custom-tab/product-custom-tab-admin.php
   apply_filters( 'wolmart_product_custom_tab_content_editor_settings', $settings );


7. Wolmart/framework/plugins/woocommerce/product-loop.php
   apply_filters( 'wolmart_product_hover_image_html', $attachment_image ); 
   apply_filters( 'wolmart_is_single_product_widget', false );
   apply_filters( 'wolmart_check_product_variation_type', true, $attribute_name );


8. Wolmart/framework/plugins/woocommerce/product-single.php
   apply_filters( 'wolmart_doing_quickview', true );
   apply_filters( 'wolmart_single_product_layout', $layout );
   apply_filters( 'wolmart_wc_thumbnail_image_size', 'woocommerce_thumbnail' );
   apply_filters( 'wolmart_wc_get_gallery_image_html', $image );
   apply_filters( 'wolmart_single_product_navigation', $html );
   apply_filters( 'wolmart_filter_single_prev_next_product', $args );
   apply_filters( 'wolmart_single_product_sticky_cart_enabled', ! empty( $wolmart_layout['single_product_sticky'] ) );
   apply_filters( 'wolmart_single_product_gallery_type_class', ' row cols-1 cols-md-2 cols-lg-3' );
   apply_filters( 'wolmart_single_product_divider', '<hr class="product-divider">' );
   apply_filters( 'wolmart_is_single_product_widget', false );


9. Wolmart/framework/plugins/woocommerce/woo-functions.php
   apply_filters( 'wolmart_breadcrumb_args', $args );


10. Wolmart/framework/addons/walker/walker-nav-menu.php
   apply_filters( 'wolmart_menu_lazyload_content', $content );


11. Wolmart/framework/templates/sidebar.php
   apply_filters( 'wolmart_sidebar_classes', $sidebar_class );


12. Wolmart/framework/templates/posts/archive.php
   apply_filters( 'wolmart_post_loop_wrapper_classes', $wrap_classes );


13. Wolmart/framework/templates/posts/single.php
   apply_filters( 'wolmart_post_single_class', array( 'post-single' ) );


14. Wolmart/framework/templates/posts/elements/post-related.php
   apply_filters( 'wolmart_filter_related_posts_args', $args );


15. Wolmart/framework/templates/woocommerce/content-single-product.php
  apply_filters( 'wolmart_is_single_product_widget', false );
  apply_filters( 'wolmart_single_product_classes', $classes );
  apply_filters( 'wolmart_single_product_summary_class', 'summary entry-summary' );


16. Wolmart/framework/templates/woocommerce/loop/loop-start.php
  apply_filters( 'wolmart_wc_product_count_row', wolmart_get_option( 'product_count_row' ) );
  apply_filters( 'wolmart_wc_loadmore_type', wc_get_loop_prop( 'loadmore_type' ) );
  apply_filters( 'wolmart_product_loop_wrapper_classes', $wrapper_class );


17. Wolmart/framework/templates/woocommerce/loop/rating.php
  apply_filters( 'wolmart_single_product_rating_show_number', false );
  apply_filters( 'wolmart_single_product_show_review', comments_open() && 'widget' != wc_get_loop_prop( 'product_type' ) );


18. Wolmart/framework/templates/woocommerce/loop/sale-flash.php
  apply_filters( 'wolmart_product_label_group_class', '' );


19. Wolmart/framework/templates/woocommerce/notices/error.php
  apply_filters( 'wolmart_wc_notice_class', '', $notice, 'error' );


20. Wolmart/framework/templates/woocommerce/single-product/product-image.php
   apply_filters( 'wolmart_single_product_gallery_main_classes', array( 'woocommerce-product-gallery__wrapper' ) );


21. Wolmart/framework/templates/woocommerce/single-product/title.php
   apply_filters( 'wolmart_single_product_title_tag', wolmart_doing_quickview() ? 'h2' : 'h1' );
   apply_filters( 'wolmart_is_single_product_widget', false );


22. Wolmart/framework/templates/woocommerce/single-product/tabs/custom_tab.php
   apply_filters( 'wolmart_product_tab_title', $tab_title );


23. Wolmart/woocomerce/single-product/tabs/tabs.php
  apply_filters( 'wolmart_single_product_data_tab_type', 'tab' );
  apply_filters( 'wolmart_single_product_data_tab_class', $wrapper_class );

Demos

HomeCategoriesAccountCart
Search