.icl-st-table textarea { font-size: 12px !important; } '; } function wpb_adding_scripts() { wp_register_script('my_amazing_script', get_stylesheet_directory_uri() . '/js/tbl-fluid.js', array('jquery'),'1.1', true); wp_enqueue_script('my_amazing_script'); wp_register_script( 'collapsable-area', get_stylesheet_directory_uri() . '/js/collapsable-area.js', [ 'jquery-ui-accordion' ] ); wp_enqueue_script( 'collapsable-area' ); wp_register_script( 'form-fields-background', get_stylesheet_directory_uri() . '/js/form-fields-background.js', [ 'jquery' ] ); wp_enqueue_script( 'form-fields-background' ); } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' ); function my_myme_types($mime_types){ $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension return $mime_types; } add_filter('upload_mimes', 'my_myme_types', 1, 1); // fix menu html -- start class FASOON_Walker_Nav_Menu extends Walker_Nav_Menu { public function start_lvl( &$output, $depth = 0, $args = array() ) { if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; } else { $t = "\t"; $n = "\n"; } $indent = str_repeat( $t, $depth ); if ( $depth > 0 ) { $output .= "{$n}{$indent}
{$n}"; } else { $output .= "$indent{$n}"; } } } add_filter( 'wp_nav_menu_objects', function ( $sorted_menu_items, $args ) { $args->walker = new FASOON_Walker_Nav_Menu(); return $sorted_menu_items; }, 10, 2 ); // fix menu html -- finish function get_featured_post_query() { static $query; if (null === $query) { global $wp_query; $query_vars = $wp_query->query_vars; $query_vars['posts_per_page'] = 1; $query_vars['orderby'] = 'post_date'; $query_vars['order'] = 'DESC'; $query = new WP_Query( $query_vars ); } return $query; } if ( ! function_exists( 'et_strip_shortcodes' ) ) { /** * оригінальна фукнція з /wp-content/themes/Divi/includes/builder/functions.php хріново фільтрує шорткоди */ function et_strip_shortcodes( $content, $truncate_post_based_shortcodes_only = false ) { global $shortcode_tags; $content = trim( $content ); $strip_content_shortcodes = array( 'et_pb_code', 'et_pb_fullwidth_code' ); // list of post-based shortcodes if ( $truncate_post_based_shortcodes_only ) { $strip_content_shortcodes = array( 'et_pb_post_slider', 'et_pb_fullwidth_post_slider', 'et_pb_blog', 'et_pb_comments', ); } foreach ( $strip_content_shortcodes as $shortcode_name ) { $regex = sprintf( '(\[%1$s[^\]]*\][^\[]*\[\/%1$s\]|\[%1$s[^\]]*\])', esc_html( $shortcode_name ) ); $content = preg_replace( $regex, '', $content ); } // do not proceed if we need to truncate post-based shortcodes only if ( $truncate_post_based_shortcodes_only ) { return $content; } $shortcode_tag_names = array(); foreach ( $shortcode_tags as $shortcode_tag_name => $shortcode_tag_cb ) { if ( 0 !== strpos( $shortcode_tag_name, 'et_pb_' ) ) { continue; } $shortcode_tag_names[] = $shortcode_tag_name; } $et_shortcodes = implode( '|', $shortcode_tag_names ); // ------------------ // поміняв тільки цю стрічку //$regex_opening_shortcodes = sprintf( '(\[(%1$s)[^\]]+\])', esc_html( $et_shortcodes ) ); $regex_opening_shortcodes = sprintf( '(\[(%1$s)[^\]]*\])', esc_html( $et_shortcodes ) ); // ------------------ $regex_closing_shortcodes = sprintf( '(\[\/(%1$s)\])', esc_html( $et_shortcodes ) ); $content = preg_replace( $regex_opening_shortcodes, '', $content ); $content = preg_replace( $regex_closing_shortcodes, '', $content ); return $content; } } add_action( 'pre_get_posts', function (WP_Query $query) { if ( ( $query->is_home() || $query->is_category() ) && $query->is_main_query() ) { $featured = get_featured_post_query(); if ( $featured->have_posts() ) { $query->query_vars['post__not_in'] = [ $featured->posts[0]->ID ]; } } } ); if ( ! function_exists( 'img_resize' ) ) { /** * https://github.com/developerbmw/img_resize/blob/master/img_resize.php * * @param $imageURL * @param $width * @param $height * @param bool $crop * @return bool|string */ function img_resize( $imageURL, $width, $height, $crop = false ) { $imageBase = str_replace( basename( $imageURL ), '', $imageURL ); $imageURLParts = parse_url( $imageURL ); $imagePath = $_SERVER['DOCUMENT_ROOT'] . $imageURLParts['path']; if ( ! is_file( $imagePath ) ) { return false; } $originalSize = getimagesize( $imagePath ); if ( $originalSize[0] <= $width ) { return $imageURL; } if ( ! $height ) { $height = round( $originalSize[1] / $originalSize[0] * $width ); } $pathInfo = pathinfo( $imagePath ); $resizedImageFileName = $pathInfo['filename'] . '-' . $width . 'x' . $height . '.' . $pathInfo['extension']; $resizedImageURL = $imageBase . $resizedImageFileName; $resizedImagePath = $pathInfo['dirname'] . '/' . $resizedImageFileName; if ( is_file( $resizedImagePath ) ) { return $resizedImageURL; } $editor = wp_get_image_editor( $imagePath ); if ( is_wp_error( $editor ) ) { return false; } $editor->resize( $width, $height, $crop ? [ 'center', 'center' ] : false ); $editor->save( $resizedImagePath ); return $resizedImageURL; } } function fasoon_localize_theme() { load_theme_textdomain( 'fasoon', get_stylesheet_directory() . '/lang' ); } add_action( 'after_setup_theme', 'fasoon_localize_theme' ); function fasoon_post_types_builder( $post_types ) { $post_types[] = 'fasoon_partner'; return $post_types; } add_filter( 'et_builder_post_types', 'fasoon_post_types_builder' ); //require_once 'speed-insights.php'; //require_once 'speed-insights-admin.php'; // Enable DIVI Builder for Custom Widgets function my_et_builder_post_types( $post_types ) { $post_types[] = 'content_block'; return $post_types; } add_filter( 'et_builder_post_types', 'my_et_builder_post_types' ); /** * [optional] ACF Options Pages */ add_action('init', 'enable_acf_options_page'); function enable_acf_options_page() { if (function_exists('acf_add_options_page')) { acf_add_options_page(); acf_add_options_sub_page('Preise'); acf_add_options_sub_page('Contact Person'); acf_add_options_sub_page('Founders'); acf_add_options_sub_page('Footer'); } }