<?php
defined('ABSPATH') or die("No script kiddies please!");

$wpfm_template_check_main_array = $this->global_template_display_condition_check();

//Template 17 bubble menu remained

if (!isset($_GET['wpfmp_preview']) && !isset($_GET['menu_id'])) {
    ?>
    <div class="wpfm-floating-wh-wrapper <?php
    if (is_user_logged_in()) {
        echo 'wpfm-logged-in';
    }
    ?>" <?php
    if (isset($disp_class_name) && $disp_class_name == 'show-no-menu') {
        echo 'style="display:none;"';
    }
    ?>>
             <?php
             //Default Value for version < 1.1.7
             if ($show_hide_default_menu == "show_default_menu" && $load_default_menu == 1) {
                 $defaultt_menu = $ddefault_menu;
                 $get_data_from_table = $this->get_menu_data($defaultt_menu);
                 if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                     $menu_data = $get_data_from_table[0];
                     $menu_structure_detail = unserialize($menu_data->menu_details);
                     $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                     if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                         $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                     } else {
                         $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                     }
                     if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                         include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                     } else {
                         $template = $menu_design_detail['menu_design']['template_number'];
                         if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                             $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                         } else {
                             $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                         }
                         if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                             include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                         } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                             include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                         } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                             include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                         } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                             include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                         } else {
                             ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Middle Right
        if ($show_hide_middle_right_menu == "show_middle_right_menu" && $load_default_middle_right_menu == 1) {
            $mr_menu_id = $middle_right_menu;
            $get_data_from_table = $this->get_menu_data($mr_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];
                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && $menu_design_detail['menu_design']['template_number'] == 'template-11' ||
                            isset($menu_design_detail['menu_design']['template_number']) && $menu_design_detail['menu_design']['template_number'] == 'template-12' ||
                            isset($menu_design_detail['menu_design']['template_number']) && $menu_design_detail['menu_design']['template_number'] == 'template-13') {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Top Right
        if ($show_hide_top_right_menu == "show_top_right_menu" && $load_default_top_right_menu == 1) {
            $tr_menu_id = $top_right_menu;
            $get_data_from_table = $this->get_menu_data($tr_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];
                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Bottom Right
        if ($show_hide_bottom_right_menu == "show_bottom_right_menu" && $load_default_bottom_right_menu == 1) {
            $br_menu_id = $bottom_right_menu;
            $get_data_from_table = $this->get_menu_data($br_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];
                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Middle Left
        if ($show_hide_middle_left_menu == "show_middle_left_menu" && $load_default_middle_left_menu == 1) {
            $ml_menu_id = $middle_left_menu;
            $get_data_from_table = $this->get_menu_data($ml_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];

                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Top Left
        if ($show_hide_top_left_menu == "show_top_left_menu" && $load_default_top_left_menu == 1) {
            $tl_menu_id = $top_left_menu;
            $get_data_from_table = $this->get_menu_data($tl_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];
                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Bottom Left
        if ($show_hide_bottom_left_menu == "show_bottom_left_menu" && $load_default_bottom_left_menu == 1) {
            $bl_menu_id = $bottom_left_menu;
            $get_data_from_table = $this->get_menu_data($bl_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];
                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }

//Bottom Center
        if ($show_hide_bottom_center_menu == "show_bottom_center_menu" && $load_default_bottom_center_menu == 1) {
            $bc_menu_id = $bottom_center_menu;
            $get_data_from_table = $this->get_menu_data($bc_menu_id);
            if (isset($get_data_from_table[0]) && !empty($get_data_from_table[0])) {
                $menu_data = $get_data_from_table[0];
                $menu_structure_detail = unserialize($menu_data->menu_details);
                $menu_design_detail = unserialize($menu_data->menu_display_setting_details);
                if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                } else {
                    $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                }
                if ($menu_design_detail['menu_design']['menu_template_style'] == 'custom-template') {
                    include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/custom-template.php';
                } else {
                    $template = $menu_design_detail['menu_design']['template_number'];
                    if (isset($menu_design_detail['menu_design']['template_number']) && in_array($menu_design_detail['menu_design']['template_number'], $wpfm_template_check_main_array['wpfm_position_check_array'])) {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['cmenu_placement']);
                    } else {
                        $menu_position = esc_attr($menu_design_detail['menu_design']['menu_placement']);
                    }
                    if (isset($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-1.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_2'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-2.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_3'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-3.php';
                    } else if (!empty($template) && in_array($template, $wpfm_template_check_main_array['wpfm_template_check_array_4'])) {
                        include WPFM_PRO_FILE_ROOT_DIR . 'inc/frontend/templates/template-4.php';
                    } else {
                        ?> 
                        <div class="error notice">
                            <p>
                                <?php echo __('No such floating menu template found. Please check and try again', 'wp-floating-menu-pro'); ?>
                            </p>
                        </div>
                        <?php
                    } /* Template if end */
                } /* Not custom template then implement default template end else */
            } /* Get data from table end if */
        }
        ?>
    </div>
    <?php
}