[ 'post_id' => $previous_slider_nav_dark, 'class' => 'slider', 'button' => 'previous', ], 'previous_slider_nav_light' => [ 'post_id' => $previous_slider_nav_light, 'class' => 'slider-nav-light', 'button' => 'previous', ], 'next_slider_nav_dark' => [ 'post_id' => $next_slider_nav_dark, 'class' => 'slider', 'button' => 'next', ], 'next_slider_nav_light' => [ 'post_id' => $next_slider_nav_light, 'class' => 'slider-nav-light', 'button' => 'next', ], ]; foreach ($array as $key => $data) { if ($data['post_id']) { $url = get_post_field('guid', $data['post_id']); if ($url) { add_action('wp_footer', function () use ($url, $data, $key) { echo << .{$data['class']} .flickity-prev-next-button.{$data['button']} svg { visibility: hidden; } .{$data['class']} .flickity-prev-next-button.{$data['button']} { background-image: url({$url}); background-repeat: no-repeat; background-size: contain; background-position: center center; } HTML; }); } } } } function fix_custom_footer_block_action_hooks() { // fix lỗi khi chọn custom footer block thì ko chạy vào hook flatsome_before_footer và flatsome_after_footer // lấy ra id của block // dùng filter hook để custom output của nó // wp-content\themes\flatsome\inc\structure\structure-footer.php // function: flatsome_page_footer // do_shortcode( '[block id="' . $block . '"]' ); $block = get_theme_mod('footer_block'); add_filter('do_shortcode_tag', function ($output, $tag, $attr, $m) use ($block) { if ($tag === 'block' && ($attr['id'] ?? '') == $block) { ob_start(); do_action('flatsome_before_footer'); echo do_shortcode($output); do_action('flatsome_after_footer'); $output = ob_get_clean(); } return $output; }, 10, 4); } function fix_payment_icons_custom() { if (get_theme_mod('payment_icons_custom')) { adminz_add_body_class('adminz_payment_icons_custom'); } } function fix_archive_query() { // default template taxonomy add_action('pre_get_posts', function ($query) { // wp-content\themes\flatsome\inc\shortcodes\blog_posts.php:208 // chỉ fix cho shortcode blog_posts if ( isset($query->query_vars['orderby']) and $query->query_vars['orderby'] == 'post__in' ) { $post_types = array_merge(array_keys(get_post_types()), (array) $query->get('post_type')); // echo "
"; print_r('fix_archive_query'); echo "";
// echo ""; print_r($post_types); echo ""; $query->set('post_type', $post_types); } }); } function fix_tag_query() { add_action('pre_get_posts', function ($query) { if ( !is_admin() && $query->is_main_query() && is_tag() ) { // get all post types that support "post_tag" $post_types = get_post_types(['public' => true], 'names'); $with_tag = ['post']; foreach ($post_types as $pt) { $obj = get_post_type_object($pt); if (!empty($obj->taxonomies) && in_array('post_tag', $obj->taxonomies)) { $with_tag[] = $pt; } // fix if post is not registed with post_tag if ($pt == 'post') { $with_tag[] = $pt; } } // apply $with_tag = array_merge($with_tag, (array) $query->get('post_type')); $with_tag = array_unique(array_filter($with_tag)); // echo "
"; print_r('fix_tag_query'); echo "";
// echo ""; print_r($with_tag); echo ""; $query->set('post_type', $with_tag); } }); } function create_addition_menus() { $this->adminz_theme_locations = [ 'desktop' => [ 'additional-menu' => '[Adminz] Additional Menu', 'another-menu' => '[Adminz] Another Menu', 'extra-menu' => '[Adminz] Extra Menu', ], 'sidebar' => [ 'additional-menu-sidebar' => '[Adminz] Additional Menu - Sidebar', 'another-menu-sidebar' => '[Adminz] Another Menu - Sidebar', 'extra-menu-sidebar' => '[Adminz] Extra Menu - Sidebar', ], ]; add_filter('flatsome_header_element', function ($arr) { foreach ($this->adminz_theme_locations as $navtype => $navgroup) { foreach ($navgroup as $key => $value) { $arr[$key] = $value; } } return $arr; }); add_action('flatsome_header_elements', function ($slug) { foreach ($this->adminz_theme_locations as $navtype => $navgroup) { foreach ($navgroup as $key => $value) { $walker = 'FlatsomeNavDropdown'; if ($navtype == 'sidebar') $walker = 'FlatsomeNavSidebar'; if ($slug == $key) { flatsome_header_nav($key, $walker); // phpcs:ignore } } } }); foreach ($this->adminz_theme_locations as $key => $value) { register_nav_menus($value); } } function fix_logo_mobile_width() { add_action('customize_register', function ($wp_customize) { $wp_customize->add_setting( 'adminz_logo_mobile_max_width', array('default' => '') ); $wp_customize->add_control('adminz_logo_mobile_max_width', array( 'label' => __('Adminz Logo max width. Ex: 100'), 'section' => 'header_mobile', )); }); add_action('wp_footer', function () { if ($maxwidth = get_theme_mod('adminz_logo_mobile_max_width')) { $maxwidth .= 'px'; echo << @media only screen and (max-width: 48em) { #logo { max-width:$maxwidth; } } HTML; } }); } // MENU overlay public $menu_overlay_id; function create_menu_overlay() { $this->menu_overlay_id = 'adminz_menu_overlay_' . wp_rand(); \Flatsome_Option::add_field('option', array( 'type' => 'radio-image', 'settings' => 'adminz_mobile_overlay', 'label' => __('Adminz Menu Overlay'), 'section' => 'header_mobile', 'transport' => 'postMessage', 'default' => 'left', 'choices' => array( '' => get_template_directory_uri() . '/inc/admin/customizer/img/disabled.svg', '01' => ADMINZ_DIR_URL . 'assets/image/relative.svg', // default '02' => ADMINZ_DIR_URL . 'assets/image/absolute.svg', // absolute // '03' => ADMINZ_DIR_URL . 'assets/image/option-03.svg', ), )); // ------------------------ add new menu icon and add_filter('flatsome_header_element', function ($arr) { $arr['adminz_nav_icon'] = '☰ Adminz Nav Icon'; return $arr; }); // ------------------------ html for new menu icon add_action('flatsome_header_elements', function ($slug) { if ($slug == 'adminz_nav_icon') { $icon_style = get_theme_mod('menu_icon_style'); $div_start = $icon_style ? '' : ''; $class = get_flatsome_icon_class($icon_style, 'small'); echo << $div_start $div_end HTML; } }); if (get_theme_mod('adminz_mobile_overlay', '')) { add_filter('body_class', function ($classes) { $levels = get_theme_mod('mobile_submenu_levels', '1'); $classes[] = 'mobile-submenu-slide'; $classes[] = 'mobile-submenu-slide-levels-' . $levels; return $classes; }, 10, 1); // move current mobile menu remove_action('wp_footer', 'flatsome_mobile_menu', 7); add_action('wp_footer', function () { $text = adminz_test(['content' => 'Removed by administrator z.