'fudu-sections', 'title' => __( 'Fudu Sections', 'aztecs' ), 'icon' => 'sos', ), ), $categories ); } } add_filter( 'block_categories', 'aztecs_fudu_sections_category', 10, 2); add_action( 'enqueue_block_editor_assets', 'aztecs_editable_editor_assets' ); if (!function_exists('aztecs_editable_editor_assets')) { function aztecs_editable_editor_assets() { wp_enqueue_script( 'aztecs-block-editable', get_template_directory_uri() . '/fst-framework/fst-page-builder/blocks.js', array('wp-i18n', 'wp-blocks', 'wp-editor', 'wp-components'), '1.0.1', 'all' ); $fudu_sections = array(); $settings_arr = array(); if (class_exists('AztecsFramework')) { $font_icons = ""; if (function_exists('aztecs_icons_array')) { $font_icons = aztecs_icons_array(); } $font_family = ""; if (function_exists('aztecs_customizer_library_get_font_choices')) { $font_family = aztecs_customizer_library_get_font_choices(); } $sections = AztecsFramework::aztecs_load_page_gutenberg_sections( 'front_page' ); $sections = apply_filters('aztecs_home_page_sections', $sections); if (count($sections)>0) { foreach ($sections as $key => $value) { if ( !isset($value['slug']) || $value['slug'] == '' ) continue; $fudu_sections[] = array( 'sec_title' => $value['title'], 'slug' => $value['slug'], 'icon' => $value['icon'] ); $keys_arr['slug']['type'] = 'String' ; if ($value['settings']) { foreach ($value['settings'] as $settings_key => $settings_value) { $choices = ""; $default = ""; if ($settings_value['type'] == 'select') { if (isset($settings_value['choices'])) { $choices = $settings_value['choices']; } } else if ($settings_value['type'] == 'font_family') { if ($font_family) { $choices = $font_family; } } if (isset($settings_value['default'])) { $default = $settings_value['default']; } if (strpos($default, '{{stylesheet_path}}') !== false) { $default = str_replace('{{stylesheet_path}}', get_template_directory_uri(), $default); } $settings_arr[] = array( 'slug' => $value['slug'], 'label' => $settings_value['label'], 'default' => $default, 'type' => $settings_value['type'], 'key' => $settings_key, 'option' => $choices, 'font_icons' => $font_icons ); $keys_arr[$settings_key]['type'] = 'String' ; } } } } } wp_localize_script( 'aztecs-block-editable','fudu_sections',$fudu_sections); wp_localize_script( 'aztecs-block-editable','settings_arr', $settings_arr ); wp_localize_script( 'aztecs-block-editable','keys_arr', $keys_arr ); } } if (!function_exists('aztecs_render_fst_sections')) { function aztecs_render_fst_sections( $attributes ) { ob_start(); global $section; $defaultData = ''; $defaultValues = AztecsFramework::aztecs_get_section_default_values($defaultData); $finalData = array_merge($defaultValues, $attributes); $section_slug = $attributes['slug']; $section['section_settings'] = $finalData; $section['section_settings']['as'] = 'block'; $section['html_class'] = "fst_section_".$section_slug; if ($section_slug && !is_admin()) { if (function_exists('aztecs_blocks_css')) { aztecs_blocks_css($section_slug,$attributes); } get_template_part('template-parts/homepage/'.$section_slug); } $contents=ob_get_clean(); return $contents; } } if(!function_exists('aztecs_blocks_css')) { function aztecs_blocks_css($section_slug,$attributes){ if ($attributes) { if ($section_slug == 'home_section_2') { ?> 0) { foreach ($sections as $key => $value) { if (function_exists('register_block_type')) { register_block_type( 'fst-sections/section-'.$i , array( 'editor_script' => 'aztecs-block-editable', 'render_callback' => 'aztecs_render_fst_sections', ) ); } $i++; } } } } add_action( 'init', 'aztecs_register_fst_sections' ); ?>