load_settings(); $this->after_setup_theme(); } function load_settings() { $this->settings = get_option($this->option_name, []); } function after_setup_theme() { // remove_action('admin_notices', 'flatsome_status_check_admin_notice'); remove_action('admin_notices', 'flatsome_maintenance_admin_notice'); // CSS add_action('init', function () { adminz_add_body_class('blog_layout_divider_' . get_theme_mod('blog_layout_divider')); if (get_theme_mod('mobile_overlay_bg')) { adminz_add_body_class('adminz_fix_mobile_overlay_bg'); } if (wp_script_is('select2')) { adminz_add_body_class('adminz_select2'); } if (get_theme_mod('blog_post_layout') == 'no-sidebar') { adminz_add_body_class('blog_post_layout_no_sidebar'); } if (get_theme_mod('blog_layout') == 'no-sidebar') { adminz_add_body_class('blog_layout_no_sidebar'); } }); add_action('wp_enqueue_scripts', function () { wp_enqueue_script( 'adminz_flatsome_adminz_js', ADMINZ_DIR_URL . "assets/js/adminz_flatsome.js", [], ADMINZ_VERSION, true ); wp_enqueue_style( 'adminz_flatsome_adminz_css', ADMINZ_DIR_URL . "assets/css/flatsome/flatsome_fix.css", [], ADMINZ_VERSION, 'all' ); $secondary_color = get_theme_mod('color_secondary', \Flatsome_Default::COLOR_SECONDARY); $success_color = get_theme_mod('color_success', \Flatsome_Default::COLOR_SUCCESS); $alert_color = get_theme_mod('color_alert', \Flatsome_Default::COLOR_ALERT); $header_height = get_theme_mod('header_mobile', 90); $header_mobile_height = get_theme_mod('header_height_mobile', 70); $hide_footer_absolute = (!get_theme_mod('footer_left_text') && !get_theme_mod('footer_right_text')) ? 'none' : 'block'; $mobile_overlay_bg = get_theme_mod('mobile_overlay_bg', '#232323'); $site_width = get_theme_mod('site_width', '1000') . "px"; $css = <<settings['adminz_banner_post_types'] ?? [])) { foreach ((array) $this->settings['adminz_banner_post_types'] as $key => $value) { if ($value) { $a = new \Adminz\Helper\FlatsomeBanner; $a->post_type = $value; $a->init(); } } } // if ($hooks = ($this->settings['adminz_flatsome_action_hook'] ?? "")) { foreach ($hooks as $key => $value) { if ($value['key'] ?? '' and $value['value'] ?? '') { $hook = $value['key'] ?? ''; $shortcode = $value['value'] ?? ''; $priority = $value['priority'] ?? 10; // add_action($hook, function () use ($shortcode) { // adminz_fix_override_post_global($shortcode); echo do_shortcode($shortcode); }, $priority); } } } // if (($this->settings['create_addition_menus'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->create_addition_menus(); } // if (($this->settings['fix_logo_mobile_width'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->fix_logo_mobile_width(); } // if (($this->settings['create_menu_overlay'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->create_menu_overlay(); } // if (($this->settings['fix_payment_icons_custom'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->fix_payment_icons_custom(); } // if (($this->settings['fix_custom_footer_block_action_hooks'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->fix_custom_footer_block_action_hooks(); } // if (($this->settings['fix_blog_divider'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->fix_blog_divider(); } // if (($this->settings['fix_mobile_overlay'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->fix_mobile_overlay(); } // if (($this->settings['fix_select2'] ?? "") == "on") { $a = new \Adminz\Helper\Flatsome(); $a->fix_select2(); } // if ($this->settings['adminz_flatsome_portfolio_name'] ?? "") { $a = new \Adminz\Helper\FlatsomePortfolio(); $a->rename_post_type($this->settings['adminz_flatsome_portfolio_name']); } // if ($this->settings['adminz_flatsome_portfolio_category'] ?? "") { $a = new \Adminz\Helper\FlatsomePortfolio(); $a->rename_category($this->settings['adminz_flatsome_portfolio_category']); } // if ($this->settings['adminz_flatsome_portfolio_tag'] ?? "") { $a = new \Adminz\Helper\FlatsomePortfolio(); $a->rename_tag($this->settings['adminz_flatsome_portfolio_tag']); } // if ($this->settings['adminz_flatsome_portfolio_product_tax'] ?? "") { $product_taxonomy = $this->settings['adminz_flatsome_portfolio_product_tax']; $portfolio_post_type = 'featured_item'; if ($this->settings['adminz_flatsome_portfolio_name'] ?? "") { $portfolio_post_type = $this->settings['adminz_flatsome_portfolio_name']; } new \Adminz\Helper\TaxonomySync($portfolio_post_type, $product_taxonomy); } // if ($this->settings['post_type_support'] ?? []) { foreach ($this->settings['post_type_support'] as $post_type) { if ($post_type) { $xxx = new \Adminz\Helper\FlatsomeUxBuilder; $xxx->post_type = $post_type; $xxx->post_type_content_support(); } } } // if ($post_id_template = ($this->settings['post_id_template'] ?? [])) { foreach ($post_id_template as $value) { $post_id = $value['key'] ?? ''; $template = $value['value'] ?? ''; $source = $value['source'] ?? ''; if ($post_id) { $xxx = new \Adminz\Helper\FlatsomeUxBuilder; $xxx->post_id = $post_id; $xxx->template_block_id = $template; $xxx->source = $source; $xxx->post_id_layout_support(); } } } // if ($post_type_template = ($this->settings['post_type_template'] ?? [])) { foreach ($post_type_template as $value) { $post_type = $value['key'] ?? ''; $template = $value['value'] ?? ''; $source = $value['source'] ?? ''; if ($template and $post_type) { $xxx = new \Adminz\Helper\FlatsomeUxBuilder; $xxx->post_type = $post_type; $xxx->template_block_id = $template; $xxx->source = $source; $xxx->post_type_layout_support(); } } } // if ($post_type_archive_template = ($this->settings['post_type_archive_template'] ?? [])) { foreach ($post_type_archive_template as $value) { $post_type = $value['key'] ?? ''; $template = $value['value'] ?? ''; $source = $value['source'] ?? ''; if ($template and $post_type) { $xxx = new \Adminz\Helper\FlatsomeUxBuilder; $xxx->post_type = $post_type; $xxx->template_block_id = $template; $xxx->source = $source; $xxx->post_type_archive_layout_support(); } } } // if ($taxonomy_layout_support = ($this->settings['taxonomy_layout_support'] ?? [])) { foreach ($taxonomy_layout_support as $value) { $tax = $value['key'] ?? ''; $template = $value['value'] ?? ''; $source = $value['source'] ?? ''; if ($template) { $xxx = new \Adminz\Helper\FlatsomeUxBuilder; $xxx->taxonomy = $tax; $xxx->tax_template_block_id = $template; $xxx->source = $source; $xxx->taxonomy_layout_support(); } } } // if ($pack = ($this->settings['adminz_choose_stylesheet'] ?? "")) { adminz_add_body_class($pack); adminz_add_body_class( apply_filters('adminz_pack1_enable_sidebar', true) ? 'enable_sidebar_pack1' : false ); adminz_add_body_class( apply_filters('adminz_pack2_enable_sidebar', true) ? 'enable_sidebar_pack2' : false ); add_action('wp_enqueue_scripts', function () use ($pack) { if ($pack == 'pack1') { $big_radius = apply_filters('adminz_pack1_big-radius', '10px'); $small_radius = apply_filters('adminz_pack1_small-radius', '5px'); $form_controls_radius = apply_filters('adminz_pack1_form-controls-radius', '5px'); $main_gray = apply_filters('adminz_pack1_main-gray', '#0000000a'); $border_color = apply_filters('adminz_pack1_border-color', 'transparent'); echo << :root { --big-radius: $big_radius; --small-radius: $small_radius; --form-controls-radius: $form_controls_radius; --main-gray: $main_gray; --border-color: $border_color; } HTML; } wp_enqueue_style( 'adminz_flatsome_css_' . $pack, ADMINZ_DIR_URL . "assets/css/pack/$pack.css", [], ADMINZ_VERSION, 'all' ); }); } // if ($this->settings['adminz_tiny_mce_plugins'] ?? []) { foreach ((array) $this->settings['adminz_tiny_mce_plugins'] as $key => $value) { if ($value) { $a = new \Adminz\Helper\TinyMce; $a->add_extra($value); } } } // if ($this->settings['custom_editor_class'] ?? []) { add_filter('flatsome_text_formats', function ($arr) { $data = [ 'title' => 'Adminz custom class', 'items' => [], ]; $list = $this->settings['custom_editor_class'] ?? []; $list = array_unique($list); foreach ((array) $list as $value) { if ($value) { $data['items'][] = [ 'title' => $value, 'inline' => 'span', 'classes' => $value, ]; } } $arr[] = $data; return $arr; }); } // if (($this->settings['adminz_flatsome_viewport_meta'] ?? "") == "on") { add_filter('flatsome_viewport_meta', function () { return null; }); } // if (($this->settings['adminz_flatsome_lightbox_close_btn_inside'] ?? "") == "on") { add_filter('flatsome_lightbox_close_btn_inside', function () { return true; }); } // if ($this->settings['previous_slider_nav_dark'] ?? "") { $xxx = new \Adminz\Helper\Flatsome; $xxx->set_slider_flickity_button_icon( $this->settings['previous_slider_nav_dark'] ?? '', $this->settings['previous_slider_nav_light'] ?? '', $this->settings['next_slider_nav_dark'] ?? '', $this->settings['next_slider_nav_light'] ?? '', ); } // if (($this->settings['navigation_item_span'] ?? "") == "on") { adminz_navigation_item_span(); } // if (($this->settings['menu_dropdown_fullwidth_container'] ?? "") == "on") { adminz_add_body_class('menu_dropdown_fullwidth_container'); } // if (!empty($this->settings['do_shortcode_tag_wp_kses_post'] ?? [])) { add_filter('do_shortcode_tag', function ($output, $tag, $attr) { if (in_array($tag, $this->settings['do_shortcode_tag_wp_kses_post'])) { foreach ((array)$attr as $key => $value) { $output = str_replace(esc_html($attr[$key]), wp_kses_post($attr[$key]), $output); } } return $output; }, 10, 3); } // if (($this->settings['fix_archive_query'] ?? '') == 'on') { $x = new \Adminz\Helper\Flatsome; $x->fix_archive_query(); } // if (($this->settings['fix_tag_query'] ?? '') == 'on') { $x = new \Adminz\Helper\Flatsome; $x->fix_tag_query(); } // if (($this->settings['adminz_enable_zalo_support'] ?? "") == "on") { adminz_enable_zalo_support(); } // if ($this->settings['custom_follows'] ?? []) { foreach ((array) $this->settings['custom_follows'] as $item) { if ($item) { $xxx = new \Adminz\Helper\FlatsomeFollows; $xxx->name = $item['key']; $xxx->icon = $item['value']; $xxx->init(); } } } // if (($this->settings['adminz_hide_headermain_on_scroll'] ?? "") == "on") { adminz_add_body_class('adminz_hide_headermain_on_scroll'); } // if (($this->settings['adminz_menu_item_active_anchor'] ?? "") == "on") { adminz_add_body_class('adminz_menu_item_active_anchor'); } // if (($this->settings['adminz_minimal_page_shop_title'] ?? "") == "on") { adminz_add_body_class('adminz_minimal_page_shop_title'); } // if (($this->settings['adminz_section_padding_top'] ?? "") == "on") { adminz_add_body_class('adminz_section_padding_top'); } // if (($this->settings['adminz_banner_font_size'] ?? "") == "on") { adminz_add_body_class('adminz_banner_font_size'); } // if (($this->settings['blog_2_columns_mobile'] ?? "") == "on") { add_action('flatsome_before_blog', function () { ob_start(); // Bắt đầu buffering }); add_action('flatsome_after_blog', function () { $output = ob_get_clean(); echo preg_replace( '/(row .*) small-columns-1/', '$1 small-columns-2', $output ); }); } // if (($this->settings['blog_col_large_10_full_width'] ?? "") == "on") { adminz_add_body_class('blog_col_large_10_full_width'); } // if (($this->settings['slider_post_item_width_75vw'] ?? "") == "on") { adminz_add_body_class('slider_post_item_width_75vw'); } // if (($this->settings['nav_in_pagination'] ?? "") == "on") { adminz_add_body_class('nav_in_pagination'); } // if ($pages = ($this->settings['page_for_transparent'] ?? [])) { foreach ((array) $pages as $page) { if ($page) { $x = new \Adminz\Helper\FlatsomeHeaderTransparent(); $x->object_id = $page; $x->search = [ '