Avada Hooks: Actions and Filters

Avada 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 Avada to allow hooking into Avada specific functionality so that you can modify it in a child theme or even a plugin.
Click Here To View The Fusion Builder Hooks ArticleOverviewHow To Use A Hook/Filter?How To Add Code After The Opening Body TagConversion For Child Themes
Actions List

Filters List
How To Use a Hook Or A Filter?So, let』s assume you want to add a banner ad before the entire header. There are three ways to do that:
1. Edit the parent theme』s code and add the code in the header file
2. Copy the header file into the child theme and modify the code in that file
3. Use an action in a child theme』s functions.php
With the #1 and #2 above, there is a high possibility that the edit would be lost during an update. By using an action, you don』t edit or overwrite the core code which is why, your code will rarely need to be changed.
To add a banner ad before the entire header, we need to use the 「avada_before_header_wrapper」 action in the functions.php of the child theme. Following is an example code:
Copy to Clipboardadd_action( 'avada_before_header_wrapper', 'avada_add_banner' );
function avada_add_banner() {
echo 'Ad Banner';
} 1add_action( 'avada_before_header_wrapper', 'avada_add_banner' );2function avada_add_banner() {3 echo 'Ad Banner';4}Filters are similar to the actions but instead of 『hooking』 into the code, you are simply changing the final output. You can read more about the difference difference between actions and filters from the beginner』s guide.
How To Add Code After The Opening Body TagTo add code, such as GTM script, after the opening
Copy to Clipboard1 1tag, you will have to use the 「avada_before_body_content」 filter. If you』re not familiar with editing child theme files or you don』t have a child theme installed, you can install the Code Snippets plugin then add this code to it:
Copy to Clipboardfunction my_custom_head_function_for_avada() {
?>

ADD YOUR CONTENT HERE

3​4ADD YOUR CONTENT HERE5​6 $this->options['breacrumb_prefix'], 'separator' => $this->options['breadcrumb_separator'], 'show_post_type_archive' => $this->options['breadcrumb_show_post_type_archive'], 'show_terms' => $this->options['breadcrumb_show_categories'], 'home_label' => __( 'Home', 'Avada' ), 'tag_archive_prefix' => __( 'Tag:', 'Avada' ), 'search_prefix' => __( 'Search:', 'Avada' ), 'error_prefix' => __( '404 - Page not Found', 'Avada' ), );,Copy to Clipboardavada_dynamic_cssxxxxxxxxxx avada_dynamic_css File: Avada/includes/class-avada-dynamic-css.php
Description: Applied to the final compiled CSS from dynamic CSS.
Default Value: $css,Copy to Clipboardavada_dynamic_css_arrayxxxxxxxxxx avada_dynamic_css_array File: Avada/includes/dynamic_css.php
Description: Applied to the dynamic CSS array.
Default Value: $css,Copy to Clipboardavada_embeds_consent_textxxxxxxxxxx avada_embeds_consent_text File: Avada/includes/class-avada-privacy-embeds.php
Description: Applies to iframe placeholder consent text when privacy mode is active.
Params: $content: Existing content.
$label: Label text of particular embed type.
$type: Type slug of embed type.

Default Value: None,Copy to Clipboardavada_h1_typography_elementsxxxxxxxxxx avada_h1_typography_elementsCopy to Clipboardavada_h2_typography_elementsxxxxxxxxxx avada_h2_typography_elementsCopy to Clipboardavada_h3_typography_elementsxxxxxxxxxx avada_h3_typography_elementsCopy to Clipboardavada_h4_typography_elementsxxxxxxxxxx avada_h4_typography_elementsCopy to Clipboardavada_h5_typography_elementsxxxxxxxxxx avada_h5_typography_elementsCopy to Clipboardavada_h6_typography_elementsxxxxxxxxxx avada_h6_typography_elementsCopy to Clipboardavada_post_title_typography_elementsxxxxxxxxxx avada_post_title_typography_elementsCopy to Clipboardavada_post_title_extras_typography_elementsxxxxxxxxxx avada_post_title_extras_typography_elements File: Avada/includes/options/typography.php
Description: Applies to the array of all the elements that will be targeted from the typography settings.
Default Value: $typography_elements,Copy to Clipboardavada_header_contact_info_emailxxxxxxxxxx avada_header_contact_info_email File: Avada/includes/avada-functions.php
Description: Applied to the email address in top header.
Default Value: %s,Copy to Clipboardavada_header_separatorxxxxxxxxxx avada_header_separator File: Avada/includes/avada-functions.php
Description: Separator for top header content, not menu.
Default Value: |,Copy to Clipboardavada_load_more_posts_namexxxxxxxxxx avada_load_more_posts_name Files:
Avada/templates/blog-layout.php
fusion-builder/front-end/templates/fusion-recent-posts.php
fusion-builder/shortcodes/fusion-blog.php
fusion-builder/shortcodes/fusion-recent-posts.php
Description: Applied to the text for the load more button.
Default Value: __( 'Load More Posts', 'Avada' ),Copy to Clipboardavada_logo_alt_tagxxxxxxxxxx avada_logo_alt_tag File: Avada/templates/logo.php
Description: Filters the alt attribute added to the main site logo image.
Default Value: get_bloginfo( 'name', 'display' ) . ' ' . __( 'Logo', 'Avada' ).,Copy to Clipboardavada_metabox_tabsxxxxxxxxxx avada_metabox_tabs File: Avada/includes/metaboxes/metaboxes.php
Description: Allows developers to add their own tabs to the Fusion Page Options setup.
Arguments: $tabs $post_type
Example Usage Code: In child theme's function.php, this would add a new section to portfolio post type: https://gist.github.com/ilicfilip/8c4221bbb6eeb7aafe3e14ba95e18f46.
In a separate file, this defines the actual options: https://gist.github.com/ilicfilip/9a7becc01bf53dda0fb4edf42268da7c.
In any child theme template file, the developer can access the settings like this e.g: get_post_meta( $post->ID, 'pyre_child_video', true );,Copy to Clipboardavada_menu_metaxxxxxxxxxx avada_menu_meta File: Avada/includes/lib/inc/class-fusion-nav-walker.php
Description: Allows developers to modify meta data of menu items.
Arguments: $fusion_meta $item_id,Copy to Clipboardfusion_get_all_metaxxxxxxxxxx fusion_get_all_meta File: Avada/includes/lib/inc/class-fusion-data-postmeta.php
Description: Allows developers to modify meta data of a post/page.
Arguments: $data $post_id,Copy to Clipboardavada_logo_anchor_tag_attributesxxxxxxxxxx avada_logo_anchor_tag_attributes File: Avada/templates/logo.php
Description: Filters the HTML attributes on the site logo anchor tag.
Default Value: array( 'class' => 'fusion-logo-link', 'href' => ( $custom_link = Avada()->settings->get( 'logo_custom_link' ) ) ? esc_url( $custom_link ) : esc_url( home_url( '/' ) ), ),Copy to Clipboardavada_middle_logo_menu_break_pointxxxxxxxxxx avada_middle_logo_menu_break_point File: Avada/includes/lib/inc/class-fusion-nav-walker.php
Description: Filters the menu item index after wich the logo will be displayed.
Default Value: $middle_logo_menu_break_point, value depending on amount of set menu items.,Copy to Clipboardavada_page_title_bar_contentsxxxxxxxxxx avada_page_title_bar_contents File: Avada/includes/lib/inc/class-fusion-helper.php
Description: Allows for easy filtering of the page title bar markup and contents.
Default Value: array( $title, $subtitle, $secondary_content ),Copy to Clipboardavada_search_results_post_typesxxxxxxxxxx avada_search_results_post_types File: Avada/includes/class-avada-init.php
Description: Filter is used to modify search results content by post type.
Arguments: $post_types (string | array ),Copy to Clipboardavada_secondary_header_contentxxxxxxxxxx avada_secondary_header_contentFile: Avada/includes/avada-functions.php
Description: Filters the left/right content output in the secondary (top) header.
Arguments: $secondary_content:string. The actual content to be output.
$content_area:string. The content area where content should be displayed.
$content_to_display:string. The kind of content to be retrieved.

Default Value: (The secondary header content as set in Theme Options.),avada_set_placeholder_image_heightxxxxxxxxxx avada_set_placeholder_image_height File: Avada/includes/avada-functions.php
Description: Applied to the placeholder image height.
Default Value: 150,Copy to Clipboardavada_single_post_sidebar_theme_optionxxxxxxxxxx avada_single_post_sidebar_theme_option File: Avada/includes/class-avada-layout.php
Description: Allows to filter the main sidebar settings for single post template of posts and CPTs.
Default Value: array() with indices 'global', 'sidebar_1, 'sidebar_2', 'position',Copy to Clipboardavada_the_html_classxxxxxxxxxx avada_the_html_class File: Avada/includes/avada-functions.php
Description: Applied to an array of classes added to html element.
Default Value: $classes,Copy to Clipboardavada_viewport_metaxxxxxxxxxx avada_viewport_meta File: Avada/includes/class-avada-head.php
Description: Applied to the viewport meta.
Default Value: none,Copy to Clipboardfusion_blog_read_more_excerptxxxxxxxxxx fusion_blog_read_more_excerpt Files:
Avada/includes/lib/inc/functions.php
fusion-builder/front-end/class-fusion-builder-front.php
fusion-builder/inc/helpers.php
Description: Applied to the blog Read More title text.
Default Value: [...],Copy to Clipboardfusion_compiler_filesystem_folder_namexxxxxxxxxx fusion_compiler_filesystem_folder_name Files:
Avada/includes/lib/inc/class-fusion-cache.php
Avada/includes/lib/inc/class-fusion-dynamic-css.php
Avada/includes/lib/inc/class-fusion-filesystem.php

Description: Changes the fusion-scripts and fusion-styles folders that are created inside the root paths.
Default Value: Defaults to 'fusion-scripts' for JS files and 'fusion-styles' for CSS files.,Copy to Clipboardfusion_compiler_filesystem_root_pathxxxxxxxxxx fusion_compiler_filesystem_root_path Files:
Avada/includes/lib/inc/class-fusion-cache.php
Avada/includes/lib/inc/class-fusion-filesystem.php

Description: Changes the path of the root folder where files are being compiled.
Default Value: Defaults to the full system-path of wp-content/uploads.,Copy to Clipboardfusion_compiler_filesystem_root_urlxxxxxxxxxx fusion_compiler_filesystem_root_url File: Avada/includes/lib/inc/class-fusion-filesystem.php
Description: Changes the URL of the root folder where files are being compiled.
Default Value: Defaults to the url of wp-content/uploads.,Copy to Clipboardfusion_compiler_js_file_is_readablexxxxxxxxxx fusion_compiler_js_file_is_readable Files:
Avada/includes/lib/inc/class-fusion-dynamic-js-file.php
Avada/includes/options/performance.php
Description: If the site/host falsely reports that the JS files can't be read but it still does work correctly, readability can be forced to yes through the filter and thus the compiled JS file can be loaded on the front end.
Default Value: bool, true if JS file is readable.,Copy to Clipboardfusion_faq_all_filter_namexxxxxxxxxx fusion_faq_all_filter_name File: fusion-core/shortcodes/fusion-faq.php
Description: Applied to the "All" text on the portfolio filters.
Default Value: __( 'All', 'Avada' ),Copy to Clipboardfusion_is_hundred_percent_templatexxxxxxxxxx fusion_is_hundred_percent_template Files:
Avada/includes/avada-functions.php
Avada/header.php
fusion-builder/shortcodes/fusion-container.php

Description: Applies to check if current page is a 100% width page.
Params: $value: The value from the filter.
$page_id: A custom page ID.

Default Value: None.,Copy to Clipboardfusion_options_labelxxxxxxxxxx fusion_options_label File: Avada/includes/lib/inc/class-fusion-settings.php
Description: Applies to theme options label on description texts.
Default Value: None.,Copy to Clipboardfusion_page_options_initxxxxxxxxxx fusion_page_options_init File: Avada/includes/metaboxes/metaboxes.php
Description: Adds an OR argument to the if clause deciding on what pages the Fusion Page Options should be shown.
Default Value: false,Copy to Clipboardfusion_pagination_sizexxxxxxxxxx fusion_pagination_size Files:
Avada/includes/lib/inc/functions.php
fusion-builder/inc/lib/inc/functions.php
Description: Allows to set the amount of page links shown left and right to the current element.
Params: $range
Default Value: 1,Copy to Clipboardfusion_privacy_cookie_argsxxxxxxxxxx fusion_privacy_cookie_args File: Avada/includes/class-avada-privacy-embeds.php
Description: Applies to set the args for the privacy cookie.
Default Value: $default_args = array(
'name' => 'privacy_embeds',
'days' => '30',
'path' => '/',
);,Copy to Clipboardfusion_privacy_embedsxxxxxxxxxx fusion_privacy_embeds File: Avada/includes/class-avada-privacy-embeds.php
Description: Applies to change available embeds.
Default Value: $embeds,Copy to Clipboardprivacy_iframe_embedxxxxxxxxxx privacy_iframe_embed Files:
Avada/includes/class-avada-googlemap.php
Avada/includes/lib/inc/templates/featured-image-first.php
Avada/new-slideshow.php
Avada/templates/featured-image-page.php
Avada/templates/featured-image-post.php
Avada/templates/featured-image-wpfc_sermon.php
fusion-builder/shortcodes/fusion-google-map.php
Description: Applies to replaces iframe src.
Params: $content: Existing content.

Default Value: None,Copy to Clipboardavada_privacy_placeholderxxxxxxxxxx avada_privacy_placeholder Files: Avada/includes/class-avada-privacy-embeds.php
Description: Allows custom placeholder additions.
Params: $placeholder $type $frame_width $frame_height $src,Copy to Clipboardfusion_related_posts_heading_textxxxxxxxxxx fusion_related_posts_heading_text File: Avada/includes/avada-functions.php
Default: The main heading name, dependednt on the post type.
Params: $post_type the type of the current post.,Copy to Clipboardfusion_responsive_sidebar_orderxxxxxxxxxx fusion_responsive_sidebar_order File: Avada/includes/dynamic_css.php
Description: This hook is used to modify content and sidebar order in responsive mode.
Arguments: $sidebar_order,Copy to Clipboardfusion_sharing_box_taglinexxxxxxxxxx fusion_sharing_box_tagline File: Avada/templates/social-sharing.php
Description: Sets a custom sharing box tagline. This will override the setting in Theme Options.
Default Value: "Share This Story!" (can be set in Theme Options),Copy to Clipboardfusion_sidebar_1_classxxxxxxxxxx fusion_sidebar_1_classCopy to Clipboardfusion_sidebar_2_classxxxxxxxxxx fusion_sidebar_2_class Files:
Avada/templates/sidebar-1.php
Avada/templates/sidebar-2.php
Description: Applies to add classes to first and second sidebar.
Default Value: None.,Copy to Clipboardavada_has_sidebarxxxxxxxxxx avada_has_sidebarCopy to Clipboardavada_has_double_sidebarsxxxxxxxxxx avada_has_double_sidebars Files: Avada/includes/class-avada-template.php
Description: Applies to check if current page has got single or dual sidebars.
Params: Bool, $body_classes, $sidebar_class

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注