Porto Hooks – Actions and Filters

Category: Build Your Site 0

Porto Hooks – Actions and Filters

Actions and Filters are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress; the same concept is used by Porto to allow hooking into Porto 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 want to show product tab accordion in particular single product page. At that time, you can show as accordion using our Porto 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( 'porto_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.

 

Filters List
1. porto\footer\footer_tooltip.php
// Filters footer tooltip content.
apply_filters( 'porto_footer_tooltip', $tooltip_content );
2. porto\header\header_tooltip.php
// Filters header tooltip content.
apply_filters( 'porto_header_tooltip', $tooltip_content );
3. porto\inc\admin\customizer\header-builder.php
// Filters customizer header builder elements.
apply_filters( 'porto_header_elements', $elements );
4. porto\inc\admin\setup_wizard\speed_optimize_wizard.php
// Filters all shortcode list.
apply_filters( 'porto_all_shortcode_list', $shortcode_list );
// Filters all used shortcode list on site.
apply_filters( 'porto_used_shortcode_list', $used, $return_ids );
5. porto\inc\functions\class-dynamic-style.php
// Filters dynamic style internal css.
apply_filters( 'porto_dynamic_style_internal_output', $this->minify_css( $css ) );
6. porto\inc\functions\content_type.php
// Filters the meta value.
apply_filters( 'porto_get_meta_value_' . $meta_key, $value );
// Filters the page( portfolio, event, faq ) layout default settings. ( especially sidebar setting )
apply_filters( 'porto_meta_use_default', ( 'default' != $value ) ? true : false );
// Filters the page layout. ( includes portfolio, event, faq, 404page and so on )
apply_filters( 'porto_meta_layout', array( $value, $sidebar, $sidebar2 ) );
// Filters the default page layout. ( includes portfolio, event, faq, 404page and so on )
apply_filters( 'porto_meta_default_layout', $value );
// Filters the setting of sticky sidebar.
apply_filters( 'porto_meta_sticky_sidebar', $value );
// Filters the portfolio sub title.
apply_filters( 'porto_portfolio_sub_title', $output );
7. porto\inc\functions\general.php
// Filters template part path.
apply_filters( 'porto_get_template_part', $template, $slug, $name );
// Filters generate column classes for grid.
apply_filters( 'porto_generate_column_classes', $cols_arr, $cols, true );
// Filters mini screen size.
apply_filters( 'porto_mini_screen_size', 320 );
// Fitlers whether current page is product page or not.
apply_filters( 'porto_is_product', $result );
// Filters whether current page is shop page or not.
apply_filters( 'porto_is_shop', $result );
8. porto\inc\functions\layout.php
// Filters the porto header logo shortcode render.
apply_filters( 'porto_logo', ob_get_clean() );
// Filters the porto currency switcher shortcode render.
apply_filters( 'porto_currency_switcher', $result );
// Filters the porto mobile currency switcher shortcode render.
apply_filters( 'porto_mobile_currency_switcher', $result );
// Filters the porto view switcher shortcode render.
apply_filters( 'porto_view_switcher', $result );
// Filters the porto mobile view switcher shortcode render.
apply_filters( 'porto_mobile_view_switcher', $result );
// Filters the porto top navigation shortcode render.
apply_filters( 'porto_top_navigation', $output );
// Filters the porto mobile top navigation shortcode render.
apply_filters( 'porto_mobile_top_navigation', $output );
// Filters the porto main menu shortcode render.
apply_filters( 'porto_main_menu', $output );
// Filters the porto secondary menu shortcode render.
apply_filters( 'porto_secondary_menu', $output );
// Filters the porto main toggle menu shortcode render.
apply_filters( 'porto_main_toggle_menu', $output );
// Filters the porto header side menu shortcode render.
apply_filters( 'porto_header_side_menu', $output );
// Filters the whether site has sidebar menu or not.
apply_filters( 'porto_is_sidebar_menu', $have_sidebar_menu );
// Filters the sidebar menu shortcode render.
apply_filters( 'porto_sidebar_menu', $output );
// Filters the mobile menu shortcode render.
apply_filters( 'porto_mobile_menu', $output );
// Filters the search form shortcode render.
apply_filters( 'porto_search_form', $result );
// Filters the search form content shortcode render.
apply_filters( 'porto_search_form_content', ob_get_clean() );
// Filters the header socials shortcode render.
apply_filters( 'porto_header_socials', ob_get_clean() );
// Filters the minicart shortcode render.
apply_filters( 'porto_minicart', ob_get_clean() );
// Filters the page layout type. There are 3 types: boxed, wide, full.
apply_filters( 'porto_get_wrapper_type', $porto_settings['wrapper'] );
// Filters the header type.
apply_filters( 'porto_get_header_type', porto_header_type_is_preset() ? $porto_settings['header-type'] : '' );
// Filters the header builder layout.
apply_filters( 'porto_header_builder_current_layout', $porto_header_builder_layout );
// Filters the mini cart type. There are 4 types: simple, arrow-alt, inline, text.
apply_filters( 'porto_get_minicart_type', $minicart_type );
// Filters the blog id.
apply_filters( 'porto_get_blog_id', get_current_blog_id() );
// Filters the skin: dark or light
apply_filters( 'porto_is_dark_skin', ( isset( $porto_settings['css-type'] ) && 'dark' == $porto_settings['css-type'] ) );
9. porto\inc\functions\layout\breadcrumbs.php
// Filters the breadcrumb shortcode render.
apply_filters( 'porto_breadcrumbs', $output );
10. porto\inc\functions\layout\page-title.php
// Filters the page title.
apply_filters( 'porto_page_title', $output );
// Filters the page sub title.
apply_filters( 'porto_page_sub_title', $output );
11. porto\inc\functions\woocommerce.php
// Filters lazy load images.
apply_filters( 'porto_lazy_load_images', $thumb_image );
// Filters product short description length.
apply_filters( 'porto_woocommerce_short_description_length', 30 );
// Filters product stock html.
apply_filters( 'porto_woocommerce_stock_html', $availability_html, $availability['availability'], $product );
// Filters cart page type ( Type 1, Type 2 )
apply_filters( 'porto_filter_cart_version', $cart_ver );
// Filters checkout page type ( Type 1, Type 2 )
apply_filters( 'porto_filter_checkout_version', $checkout_ver );
12. porto\inc\lib\infinite-scroll\infinite-scroll.php
// Filters infinite scroll parameters.
apply_filters( 'porto_infinite_scroll_params', $params );
13. porto\inc\lib\live-search\live-search.php
// Filters ajax search query.
apply_filters( 'porto_ajax_search_query', sanitize_text_field( $_REQUEST['query'] ) );
// Filters post type on search form.
apply_filters( 'porto_ajax_search_post_type', $post_type );
// Filters ajax search function.
apply_filters( 'porto_ajax_search_function', 'get_posts', $search_query, $args );
14. porto\inc\lib\woocommerce-pre-order\classes\class-porto-pre-order-view.php
// Filters pre-order available date.
apply_filters( 'porto_pre_order_available_date', $available_date, $product_id ) )
15. porto\index.php
// Filters whether current page has skeleton option or not.
apply_filters( 'porto_skeleton_lazyload', $value );
16. porto\woocommerce\checkout\review-order.php
// Filters product price html.
apply_filters( 'porto_get_price_html', WC()->cart->get_cart_subtotal() );
17. porto\woocommerce\content-product-cat.php
// Filters product filter categories list args.
apply_filters( 'porto_products_filter_categories_list_args', $list_args );
18. porto\woocommerce\myaccount\dashboard.php
// Filters account subpage.
apply_filters( 'porto_woocommerce_account_box_items', $account_arr );
19. porto\woocommerce\single-product\product-thumbnails.php
// Filters html after thumbnails on single product page.
apply_filters( 'porto_single_product_after_thumbnails', '' );
20. porto-functionality\builders\elements\header\elementor\menu-icon.php
// Filters mobile toggle shortcode render in header builder.
apply_filters( 'porto_header_builder_mobile_toggle', $html );
21. porto-functionality\builders\elements\product\init.php
// Filters product upsell args.
apply_filters( 'porto_woocommerce_upsell_display_args', $args );
22. porto-functionality\builders\init.php
// Filters template builder type( header, footer, single product, product archive, block, popup builder ).
apply_filters( 'porto_templates_builder_types', $this->builder_types );
// Filters default meta in new template builder.
apply_filters( 'porto_create_new_builder_meta', array() );
23. porto-functionality\builders\lib\class-condition.php
// Filters global var for porto builder.
apply_filters( 'porto_builder', array() );
24. porto-functionality\builders\views\condition_template.php
// Filters list of post types for display condition.
apply_filters( 'porto_builder_post_types', $post_types );
// Filters taxonomy array for display condition.
apply_filters( 'porto_builder_condition_types', $taxonomies );
25. porto-functionality\meta_boxes\lib\meta_fields.php
// Filters page metabox fields.
apply_filters( 'porto_view_meta_fields', $fields );
// Filters page skin metabox fields.( page background color, page js, page css and so on )
apply_filters( 'porto_skin_meta_fields', $return );
26. porto-functionality\shortcodes\lib\functions.php
// Filters presets of creative grid layouts.
apply_filters( 'porto_creative_grid_layouts', false, $layout );
27. porto-functionality\shortcodes\woo_templates\porto_products.php
// Filters whether products have sticky option or not in porto products shortcode.
apply_filters( 'porto_wooocommerce_products_shortcode_sticky_filter', false ) );
// Filters categories html render.
apply_filters( 'porto_wooocommerce_products_shortcode_categories_html', $category_html );
28. porto-functionality\shortcodes\woo_templates\porto_products_filter.php
// Filters products price range.
apply_filters( 'porto_products_filter_price_range', $steps );
// Filters products price range html(render).
apply_filters( 'porto_products_filter_price_range_html', $format_text, $step );
Actions List
1. porto\content-archive-portfolio-fullscreen.php
// Fires after rendering portfolio content.
do_action( 'porto_portfolio_after_content' );
2. porto\footer.php
// Fires after rendering content main.
do_action( 'porto_after_main' );
// Fires elementor pro alert on footer.
do_action( 'porto_elementor_pro_footer_location' );
// Fires after rendering footer template.
do_action( 'porto_after_wrapper' );
3. porto\functions.php
// Fires enqueue css after loaded porto theme css.
do_action( 'porto_enqueue_css' );
4. porto\header\header_before.php
// Fires before 'div' tag which has page-wrapper class.
do_action( 'porto_before_wrapper' );
// Fires after 'div' tag which has page-wrapper class.
do_action( 'porto_wrapper_start' );
// Fires before rendering header template.
do_action( 'porto_before_header' );
// Fires before rendering banner template.
do_action( 'porto_before_banner' );
// Fires after rendering banner template.
do_action( 'porto_after_banner' );
// Fires before rendering content top template.
do_action( 'porto_before_content_top' );
// Fires after rendering content top template.
do_action( 'porto_after_content_top' );
// Fires before rendering main content template.
do_action( 'porto_before_content' );
// Fires before rendering content inner top template.
do_action( 'porto_before_content_inner_top' );
// Fires after rendering content inner top template.
do_action( 'porto_after_content_inner_top' );
5. porto\inc\admin\admin_pages\class-tools.php
// Fires after saving theme option.
do_action( 'porto_admin_save_theme_settings' );
6. porto\inc\admin\setup_wizard\setup_wizard.php
// Fires before resetting menus on demo importing.
do_action( 'porto_importer_before_reset_menus' );
// Fires before importing widgets.
do_action( 'porto_importer_before_import_widgets' );
// Fires importing revolution slider.
do_action( 'porto_importer_import_revslider' );
// Fires before importing options.
do_action( 'porto_importer_before_import_options' );
7. porto\inc\functions\layout.php
// Fires rendering header elements.
do_action( 'porto_header_elements', $key, $value );
8. porto\inc\functions\layout\breadcrumbs.php
// Fires before rendering breadcrumb template.
do_action( 'porto_before_breadcrumbs' );
9. porto\sidebar.php
// Fires before rendering sidebar.
do_action( 'porto_before_sidebar' );
// Fires after rendering sidebar.
do_action( 'porto_after_sidebar' );
// Fires after rendering main content.
do_action( 'porto_after_content' );
// Fires before rendering content bottom.
do_action( 'porto_before_content_bottom' );
// Fires after rendering content bottom.
do_action( 'porto_after_content_bottom' );
10. porto-functionality\builders\lib\class-condition.php
// Fires before enqueuing theme scripts for builder condition.
do_action( 'porto_builder_condition_pre_enqueue' );
Js Hook List
1. porto\js\admin\admin.js
// Fires when woocommerce plugin is loaded for swatch.
$wrapper.trigger( 'plugin_init' );
2. porto\js\theme-async.js
// Fires when login popup is loaded.
$( window ).trigger( 'porto_login_popup_opened' );
3. porto\js\theme.js
// Fires when shortcode is added or deleted in wpb frontend editor.
$( document.body ).trigger( 'porto_refresh_vc_content', [ $elements ] );
// Fires before executing init function of theme.js
$wrap.trigger( 'porto_init_start' );
// Fires after executing init function of theme.js
jQuery( document.body ).trigger( 'porto_init', [ $wrap ] );
// Fires after fully initializing theme main javascript.
$( document ).trigger( 'porto_theme_init' );
// Fires when real content is loaded but skeleton screen is shown still. You can mostly use when you want to execute javascript module in real content of skeleton screen.
$real.trigger( 'skeleton-loaded' );
// Fires before executing skeleton module.
$wrapper.trigger( 'skeleton:initialised' );
// Fires when countdown is initialized.
$( document.body ).trigger( 'porto_init_countdown', [ $( '.quickview-wrap-' + pid ) ] );
// Fires when products are updated. e.g: In category filter(ajax filter), top rated or best selling filter(ajax filter)
$el.trigger( 'porto_update_products', [ data, '' ] );

Share this post