asset_manager()->reset_db_asset_list(); } } if( ! function_exists( 'av_asset_merging_settings' ) ) { /** * Adjust the level of file merging in asset-manager.class.php by taking the backend options into account and filtering the file compression function * * @since 4.3 * @added_by Kriesi * @param array $which_files * @return array */ function av_asset_merging_settings( $which_files ) { $css_merging = avia_get_option('merge_css', 'avia'); $js_merging = avia_get_option('merge_js', 'avia'); if(av_count_untested_plugins() == 0) { if($css_merging == 'avia') $css_merging = "all"; if($js_merging == 'avia') $js_merging = "all"; } $which_files['css'] = $css_merging; $which_files['js'] = $js_merging; return $which_files; } add_filter( 'avf_merge_assets', 'av_asset_merging_settings', 10, 1 ); } if( ! function_exists( 'av_delete_asset_switch' ) ) { /** * Changes if the theme deletes generated css and js files * * @since 4.3 * @added_by Kriesi * @param bool $delete * @return bool */ function av_delete_asset_switch( $delete ) { $delete = avia_get_option('delete_assets_after_save', false); if($delete === false || $delete == "disabled") { $delete = false; } else { $delete = true; } return $delete; } add_filter( 'avf_delete_assets', 'av_delete_asset_switch', 10, 1 ); } if( ! function_exists( 'av_disable_emojis' ) ) { /** * Disable the emoji's. based on: https://kinsta.com/knowledgebase/disable-emojis-wordpress/ * * @since 4.3 * @added_by Kriesi */ function av_disable_emojis() { if(avia_get_option('disable_emoji') != "disable_emoji") return false; remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); add_filter( 'tiny_mce_plugins', 'av_disable_emojis_tinymce' ); add_filter( 'wp_resource_hints', 'av_disable_emojis_remove_dns_prefetch', 10, 2 ); if(get_option('use_smilies') === "1") { update_option('use_smilies', "0"); } } add_action( 'init', 'av_disable_emojis' ); } if( ! function_exists( 'av_disable_emojis_tinymce' ) ) { /** * Filter function used to remove the tinymce emoji plugin. * * @since 4.3 * @added_by Kriesi * @param array $plugins * @return array Difference betwen the two arrays */ function av_disable_emojis_tinymce( $plugins ) { if ( is_array( $plugins ) ) { return array_diff( $plugins, array( 'wpemoji' ) ); } else { return array(); } } } if( ! function_exists( 'av_disable_emojis_remove_dns_prefetch' ) ) { /** * Remove emoji CDN hostname from DNS prefetching hints. * * @since 4.3 * @added_by Kriesi * @param array $urls URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed for. * @return array Difference betwen the two arrays. */ function av_disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { if ( 'dns-prefetch' == $relation_type ) { /** This filter is documented in wp-includes/formatting.php */ $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' ); $urls = array_diff( $urls, array( $emoji_svg_url ) ); } return $urls; } } if( ! function_exists( 'av_disable_unused_assets' ) ) { /** * Disable unused assets based on option settings * * @since 4.3 * @added_by Kriesi */ function av_disable_unused_assets( $disabled ) { if( is_admin() ) { return $disabled; } // for preview we need to load all elements because we did not adjust used elements if( is_preview() ) { return array(); } //special use cases: audio and blog - they only can be disabled manually if(avia_get_option('disable_mediaelement') == 'disable_mediaelement') { $disabled['av_audio'] = true; if(avia_get_option('disable_video') == 'disable_video') { $disabled['av_video'] = true; } } if(avia_get_option('disable_blog') == 'disable_blog') { $disabled['av_blog'] = true; $disabled['av_comments_list'] = true; } //auto disabling on $disabling_alb = avia_get_option('disable_alb_elements', 'auto'); if("auto" == $disabling_alb) { $elements = Avia_Builder()->element_manager()->get_elements_state( 'blog' ); $may_be_disabled = Avia_Builder()->may_be_disabled_automatically; if(!empty($elements)) { foreach($elements as $key => $value) { if(empty($value) && in_array($key, $may_be_disabled) ) $disabled[$key] = true; } } //check if the mailchimp widget is used. if so we do not disable that element if ( is_active_widget(false, false, 'avia_mailchimp_widget', true) && isset($disabled['av_mailchimp'])) { unset($disabled['av_mailchimp']); } //check if background video is used. if so we need the slideshow if(av_slideshow_required()) { unset($disabled['av_slideshow']); } } else if("manually" == $disabling_alb) //manually disabling on { $options = avia_get_option(); foreach($options as $key => $option) { if( strpos($key, "av_alb_disable_") !== false) { $shortcode = str_replace("av_alb_disable_", "", $key); if($option == $key) { $disabled[$shortcode] = true; } } } } //tabs can be necessary for the cookie bar setting if(avia_get_option('cookie_consent') == "cookie_consent") { $buttons = json_encode(avia_get_option('msg_bar_buttons', array())); if(strpos($buttons, 'info_modal') !== false) { unset($disabled['av_heading']); unset($disabled['av_hr']); unset($disabled['av_tab_container']); } } return $disabled; } add_filter( 'avf_disable_frontend_assets', 'av_disable_unused_assets', 10, 1 ); } if( ! function_exists( 'av_disable_button_in_backend' ) ) { /** * Disable button in backend if the user has manually set them to be disabled * * @since 4.3 * @added_by Kriesi */ function av_disable_button_in_backend( $shortcode ) { $key = 'av_alb_disable_'.$shortcode['shortcode']; $disabled = avia_get_option($key); if($key == $disabled && !empty( $shortcode['disabling_allowed'] )) { $shortcode['disabled'] = array( 'condition' => true, 'text' => __( 'This element is disabled in your theme options. You can enable it in Enfold » Performance', 'avia_framework' )); } return $shortcode; } if( avia_get_option('disable_alb_elements') == "manually" ) { add_filter( 'avf_shortcode_insert_button_backend', 'av_disable_button_in_backend', 10, 1 ); } } if( ! function_exists( 'av_video_assets_required' ) ) { /** * Checks the entries for the current page for av_video, av_audio,