private function _get_setting_display($setting, $label)
 {
     return array(array('type' => 'tm_title', 'id' => 'epo_page_options', 'title' => $label), array('title' => __('Display', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('This controls how your fields are displayed on the front-end.<br />If you choose "Show using action hooks" you have to manually write the code to your theme or plugin to display the fields and the placement settings below will not work. <br />If you use Composite Products extension you must leave this setting to "Normal" otherwise the extra options cannot be displayed on the composite product bundles.<br />See more at the documentation.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_display', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'normal', 'type' => 'select', 'options' => array('normal' => __('Normal', TM_EPO_TRANSLATION), 'action' => __('Show using action hooks', TM_EPO_TRANSLATION)), 'desc_tip' => false), array('title' => __('Extra Options placement', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Select where you want the extra options to appear.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_options_placement', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'woocommerce_before_add_to_cart_button', 'type' => 'select', 'options' => array('woocommerce_before_add_to_cart_button' => __('Before add to cart button', TM_EPO_TRANSLATION), 'woocommerce_after_add_to_cart_button' => __('After add to cart button', TM_EPO_TRANSLATION), 'woocommerce_before_add_to_cart_form' => __('Before cart form', TM_EPO_TRANSLATION), 'woocommerce_after_add_to_cart_form' => __('After cart form', TM_EPO_TRANSLATION), 'woocommerce_before_single_product' => __('Before product', TM_EPO_TRANSLATION), 'woocommerce_after_single_product' => __('After product', TM_EPO_TRANSLATION), 'woocommerce_before_single_product_summary' => __('Before product summary', TM_EPO_TRANSLATION), 'woocommerce_after_single_product_summary' => __('After product summary', TM_EPO_TRANSLATION), 'woocommerce_product_thumbnails' => __('After product image', TM_EPO_TRANSLATION), 'custom' => __('Custom hook', TM_EPO_TRANSLATION)), 'desc_tip' => false), array('title' => __('Extra Options placement custom hook', TM_EPO_TRANSLATION), 'desc' => '', 'id' => 'tm_epo_options_placement_custom_hook', 'default' => '', 'type' => 'text', 'desc_tip' => false), array('title' => __('Totals box placement', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Select where you want the Totals box to appear.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_totals_box_placement', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'woocommerce_before_add_to_cart_button', 'type' => 'select', 'options' => array('woocommerce_before_add_to_cart_button' => __('Before add to cart button', TM_EPO_TRANSLATION), 'woocommerce_after_add_to_cart_button' => __('After add to cart button', TM_EPO_TRANSLATION), 'woocommerce_before_add_to_cart_form' => __('Before cart form', TM_EPO_TRANSLATION), 'woocommerce_after_add_to_cart_form' => __('After cart form', TM_EPO_TRANSLATION), 'woocommerce_before_single_product' => __('Before product', TM_EPO_TRANSLATION), 'woocommerce_after_single_product' => __('After product', TM_EPO_TRANSLATION), 'woocommerce_before_single_product_summary' => __('Before product summary', TM_EPO_TRANSLATION), 'woocommerce_after_single_product_summary' => __('After product summary', TM_EPO_TRANSLATION), 'woocommerce_product_thumbnails' => __('After product image', TM_EPO_TRANSLATION), 'custom' => __('Custom hook', TM_EPO_TRANSLATION)), 'desc_tip' => false), array('title' => __('Totals box placement custom hook', TM_EPO_TRANSLATION), 'desc' => '', 'id' => 'tm_epo_totals_box_placement_custom_hook', 'default' => '', 'type' => 'text', 'desc_tip' => false), array('title' => __('Floating Totals box', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('This will enable a floating box to display your totals box.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_floating_totals_box', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'disable', 'type' => 'select', 'options' => array('disable' => __('Disable', TM_EPO_TRANSLATION), 'bottom right' => __('Bottom right', TM_EPO_TRANSLATION), 'bottom left' => __('Bottom left', TM_EPO_TRANSLATION), 'top right' => __('Top right', TM_EPO_TRANSLATION), 'top left' => __('Top left', TM_EPO_TRANSLATION)), 'desc_tip' => false), array('title' => __('Force Select Options', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('This changes the add to cart button to display select options when the product has extra product options.<br />Enabling this will remove the ajax functionality.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_force_select_options', 'class' => 'chosen_select', 'css' => 'min-width:300px;', 'default' => 'normal', 'type' => 'select', 'options' => array('normal' => __('Disable', TM_EPO_TRANSLATION), 'display' => __('Enable', TM_EPO_TRANSLATION)), 'desc_tip' => false), array('title' => __('Enable extra options in shop and category view', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Check to enable the display of extra options on the shop page and category view. This setting is theme dependent and some aspect may not work as expected.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_enable_in_shop', 'default' => 'no', 'type' => 'checkbox', 'desc_tip' => false), array('title' => __('Remove Free price label', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Check to remove Free price label when product has extra options', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_remove_free_price_label', 'default' => 'no', 'type' => 'checkbox', 'desc_tip' => false), array('title' => __('Hide uploaded file path', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Check to hide the uploaded file path from users.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_hide_upload_file_path', 'default' => 'yes', 'type' => 'checkbox', 'desc_tip' => false), array('title' => __('Show quantity selector only for elements with a value', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Check show quantity selector only for elements with a value.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_show_only_active_quantities', 'default' => 'yes', 'type' => 'checkbox', 'desc_tip' => false), array('title' => __('Hide add-to-cart button until an option is chosen', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Check this to show the add to cart button only when at least one option is filled.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_hide_add_cart_button', 'default' => 'no', 'type' => 'checkbox', 'desc_tip' => false), array('title' => __('Auto hide price if zero', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Check this to globally hide the price display if it is zero.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_auto_hide_price_if_zero', 'default' => 'no', 'type' => 'checkbox', 'desc_tip' => false), TM_EPO_WPML()->is_active() ? array('title' => __('Use translated values when possible on admin Order', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Please note that if the options on the Order change or get deleted you will get wrong results by enabling this!', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_wpml_order_translate', 'default' => 'no', 'type' => 'checkbox', 'desc_tip' => false) : array(), array('type' => 'tm_sectionend', 'id' => 'epo_page_options'));
 }
 /**
  * Init List table class
  */
 public function admin_screen()
 {
     global $bulk_counts, $bulk_messages, $general_messages;
     $post_type = $this->tm_list_table->screen->post_type;
     $post_type_object = get_post_type_object($post_type);
     $parent_file = "edit.php?post_type=product&page=" . TM_EPO_GLOBAL_POST_TYPE_PAGE_HOOK;
     $submenu_file = "edit.php?post_type=product&page=" . TM_EPO_GLOBAL_POST_TYPE_PAGE_HOOK;
     $post_new_file = "edit.php?post_type=product&page=" . TM_EPO_GLOBAL_POST_TYPE_PAGE_HOOK . "&action=add";
     $doaction = $this->tm_list_table->current_action();
     if ($doaction && in_array($doaction, array('add', 'export', 'clone', 'trash', 'untrash', 'delete', 'editpost', 'edit', 'import', 'download'))) {
         $screen = get_current_screen();
         // edit screen
         if ($_REQUEST['action'] == 'edit' && (isset($_REQUEST['post']) || isset($_POST['post_ID']))) {
             if (isset($_GET['post'])) {
                 $post_id = $post_ID = (int) $_GET['post'];
             } elseif (isset($_POST['post_ID'])) {
                 $post_id = $post_ID = (int) $_POST['post_ID'];
             }
             if (!empty($post_id)) {
                 $editing = true;
                 $post = get_post($post_id, OBJECT, 'edit');
                 if ($post) {
                     $post_type = $post->post_type;
                     $post_type_object = get_post_type_object($post_type);
                     $title = $post_type_object->labels->edit_item;
                     $nonce_action = 'update-post_' . $post_ID;
                     $original_id = $post_ID;
                     if (!TM_EPO_WPML()->is_original_product($post->ID, $post->post_type)) {
                         $original_id = TM_EPO_WPML()->get_original_id($post->ID, $post->post_type);
                         $original_post = get_post($original_id, OBJECT, 'edit');
                     }
                     $_meta = get_post_meta($original_id, 'tm_meta');
                     $_meta_product_ids = get_post_meta($original_id, 'tm_meta_product_ids', true);
                     $_meta_disable_categories = get_post_meta($original_id, 'tm_meta_disable_categories', true);
                     $meta_fields = array('priority' => 10, 'can_publish' => current_user_can($post_type_object->cap->publish_posts));
                     $meta = array();
                     foreach ($meta_fields as $key => $value) {
                         $meta[$key] = isset($_meta[0][$key]) ? maybe_unserialize($_meta[0][$key]) : $value;
                     }
                     unset($_meta);
                     $meta['product_ids'] = $_meta_product_ids;
                     $meta['disable_categories'] = $_meta_disable_categories;
                     $post->tm_meta = $meta;
                     unset($meta);
                     wp_enqueue_script('post');
                     include 'views/html-tm-epo-fields-edit.php';
                 }
             }
             // add screen
         } elseif ($_REQUEST['action'] == 'add') {
             $post_type = $this->tm_list_table->screen->post_type;
             $post_type_object = get_post_type_object($post_type);
             $parent_post_meta = array();
             $parent_post_meta_product_ids = array();
             $parent_post_meta_disable_categories = 0;
             // WPML
             if (TM_EPO_WPML()->is_active()) {
                 if (isset($_GET['tmparentpostid'])) {
                     $parent_post = get_post((int) $_GET['tmparentpostid'], OBJECT, 'edit');
                     $parent_post_meta = get_post_meta($parent_post->ID, 'tm_meta');
                     $parent_post_meta_product_ids = get_post_meta($parent_post->ID, 'tm_meta_product_ids', true);
                     $parent_post_meta_disable_categories = get_post_meta($parent_post->ID, 'tm_meta_disable_categories', true);
                     TM_EPO_WPML()->apply_wp_terms_checklist_args_filter((int) $_GET['tmparentpostid']);
                 }
             }
             $post = get_default_post_to_edit($post_type, true);
             if ($post) {
                 $post_ID = $post_id = $post->ID;
                 // WPML
                 if (!empty($parent_post)) {
                     $post->post_title = $parent_post->post_title;
                     $post->post_excerpt = $parent_post->post_excerpt;
                 }
                 $title = $post_type_object->labels->add_new;
                 $nonce_action = 'update-post_' . $post_ID;
                 $_meta = array();
                 $meta_fields = array_merge(array('priority' => 10, 'can_publish' => current_user_can($post_type_object->cap->publish_posts)), $parent_post_meta);
                 $meta = array();
                 foreach ($meta_fields as $key => $value) {
                     $meta[$key] = isset($_meta[0][$key]) ? maybe_unserialize($_meta[0][$key]) : $value;
                 }
                 unset($_meta);
                 $meta['product_ids'] = $parent_post_meta_product_ids;
                 $meta['disable_categories'] = $parent_post_meta_disable_categories;
                 $post->tm_meta = $meta;
                 unset($meta);
                 wp_enqueue_script('post');
                 include 'views/html-tm-epo-fields-edit.php';
             }
         }
         // list screen
     } else {
         $this->tm_list_table->prepare_items();
         wp_enqueue_script('inline-edit-post');
         //list
         add_action('tm_list_table_action', array($this, 'tm_list_table_action'), 10, 2);
         include 'views/html-tm-epo-fields.php';
     }
 }
}
?>
        </div>
        <div class="tm_mode_settings tm_options_group woocommerce_options_panel tm_wrapper">
        <?php 
if (TM_EPO_WPML()->is_original_product($post_id)) {
    /* Include additional Global forms */
    $args = array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'asc');
    $tmp_tmglobalprices = get_posts($args);
    echo '<div class="message0x0 tc-clearfix">' . '<div class="message2x1">' . '<label for="tm_meta_cpf_exclude"><span>' . __('Include additional Global forms', TM_EPO_TRANSLATION) . '</span></label>' . '<div class="messagexdesc">&nbsp;</div>' . '</div>' . '<div class="message2x2">';
    if ($tmp_tmglobalprices) {
        echo '<div class="wp-tab-panel"><ul>';
        $wpml_tmp_tmglobalprices = array();
        $wpml_tmp_tmglobalprices_added = array();
        foreach ($tmp_tmglobalprices as $price) {
            $original_product_id = floatval(TM_EPO_WPML()->get_original_id($price->ID, $price->post_type));
            if ($original_product_id == $price->ID) {
                $tm_global_forms = isset($tm_meta_cpf['global_forms']) && is_array($tm_meta_cpf['global_forms']) ? in_array($price->ID, $tm_meta_cpf['global_forms']) : false;
                echo '<li><label>';
                echo '<input type="checkbox" value="' . $price->ID . '" id="tm_meta_cpf_global_forms_' . $price->ID . '" name="tm_meta_cpf[global_forms][]" class="checkbox" ' . checked($tm_global_forms, true, 0) . '>';
                echo ' ' . $price->post_title . '</label></li>';
            }
        }
        echo '</ul></div>';
    }
    echo '</div>' . '</div>';
    /* Ouput Exclude */
    $tm_exclude = isset($tm_meta_cpf['exclude']) ? $tm_meta_cpf['exclude'] : '';
    echo '<div class="message0x0 tc-clearfix">' . '<div class="message2x1">' . '<label for="tm_meta_cpf_exclude"><span>' . __('Exclude from Global Extra Product Options', TM_EPO_TRANSLATION) . '</span></label>' . '<div class="messagexdesc">&nbsp;</div>' . '</div>' . '<div class="message2x2">' . '<input type="checkbox" value="1" id="tm_meta_cpf_exclude" name="tm_meta_cpf[exclude]" class="checkbox" ' . checked($tm_exclude, '1', 0) . '>' . '</div>' . '</div>';
    /* Ouput Override */
    $tm_override_display = isset($tm_meta_cpf['override_display']) ? $tm_meta_cpf['override_display'] : '';
 /**
  * Gets a list of all the Extra Product Options (local and global)
  * for the specific $post_id.
  */
 public function get_product_tm_epos($post_id = 0, $form_prefix = "")
 {
     if (empty($post_id)) {
         return array();
     }
     if (!empty($this->cpf[$post_id])) {
         return $this->cpf[$post_id];
     }
     $in_cat = array();
     $tmglobalprices = array();
     $terms = get_the_terms($post_id, 'product_cat');
     if ($terms) {
         foreach ($terms as $term) {
             $in_cat[] = $term->term_id;
         }
     }
     // get all categories (no matter the language)
     $_all_categories = TM_EPO_WPML()->get_terms(null, 'product_cat', array('fields' => "ids", 'hide_empty' => false));
     if (!$_all_categories) {
         $_all_categories = array();
     }
     /* Get Local options */
     $args = array('post_type' => TM_EPO_LOCAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'asc', 'suppress_filters' => true, 'post_parent' => floatval(TM_EPO_WPML()->get_original_id($post_id)));
     TM_EPO_WPML()->remove_sql_filter();
     $tmlocalprices = get_posts($args);
     TM_EPO_WPML()->restore_sql_filter();
     $this->set_tm_meta($post_id);
     $tm_meta_cpf_global_forms = isset($this->tm_meta_cpf['global_forms']) && is_array($this->tm_meta_cpf['global_forms']) ? $this->tm_meta_cpf['global_forms'] : array();
     foreach ($tm_meta_cpf_global_forms as $key => $value) {
         $tm_meta_cpf_global_forms[$key] = absint($value);
     }
     $tm_meta_cpf_global_forms_added = array();
     if (!$this->tm_meta_cpf['exclude']) {
         $meta_array = TM_EPO_HELPER()->build_meta_query('OR', 'tm_meta_disable_categories', 1, '!=', 'NOT EXISTS');
         $args = array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'date', 'order' => 'asc', 'meta_query' => $meta_array);
         $tmp_tmglobalprices = get_posts($args);
         if ($tmp_tmglobalprices) {
             $wpml_tmp_tmglobalprices = array();
             $wpml_tmp_tmglobalprices_added = array();
             foreach ($tmp_tmglobalprices as $price) {
                 /* Get Global options that belong to the product categories */
                 if (!empty($in_cat) && has_term($in_cat, 'product_cat', $price)) {
                     $tmglobalprices[] = $price;
                     $tm_meta_cpf_global_forms_added[] = $price->ID;
                 }
                 /* Get Global options that have no catergory set (they apply to all products) */
                 if (!has_term($_all_categories, 'product_cat', $price)) {
                     if (TM_EPO_WPML()->is_active()) {
                         $price_meta_lang = get_post_meta($price->ID, TM_EPO_WPML_LANG_META, true);
                         $original_product_id = floatval(TM_EPO_WPML()->get_original_id($price->ID, $price->post_type));
                         if ($price_meta_lang == TM_EPO_WPML()->get_lang() || $price_meta_lang == '' && TM_EPO_WPML()->get_lang() == TM_EPO_WPML()->get_default_lang()) {
                             $tmglobalprices[] = $price;
                             $tm_meta_cpf_global_forms_added[] = $price->ID;
                             if ($price_meta_lang != TM_EPO_WPML()->get_default_lang() && $price_meta_lang != '') {
                                 $wpml_tmp_tmglobalprices_added[$original_product_id] = $price;
                             }
                         } else {
                             if ($price_meta_lang == TM_EPO_WPML()->get_default_lang() || $price_meta_lang == '') {
                                 $wpml_tmp_tmglobalprices[$original_product_id] = $price;
                             }
                         }
                     } else {
                         $tmglobalprices[] = $price;
                         $tm_meta_cpf_global_forms_added[] = $price->ID;
                     }
                 }
             }
             // replace missing translation with original
             if (TM_EPO_WPML()->is_active()) {
                 $wpml_gp_keys = array_keys($wpml_tmp_tmglobalprices);
                 foreach ($wpml_gp_keys as $key => $value) {
                     if (!isset($wpml_tmp_tmglobalprices_added[$value])) {
                         $tmglobalprices[] = $wpml_tmp_tmglobalprices[$value];
                         $tm_meta_cpf_global_forms_added[] = $price->ID;
                     }
                 }
             }
         }
         /* Get Global options that apply to the product */
         $args = array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'date', 'order' => 'asc', 'meta_query' => array(array('key' => 'tm_meta_product_ids', 'value' => '"' . $post_id . '";', 'compare' => 'LIKE')));
         $tmglobalprices_products = get_posts($args);
         /* Merge Global options */
         if ($tmglobalprices_products) {
             $global_id_array = array();
             if (isset($tmglobalprices)) {
                 foreach ($tmglobalprices as $price) {
                     $global_id_array[] = $price->ID;
                 }
             } else {
                 $tmglobalprices = array();
             }
             foreach ($tmglobalprices_products as $price) {
                 if (!in_array($price->ID, $global_id_array)) {
                     $tmglobalprices[] = $price;
                     $tm_meta_cpf_global_forms_added[] = $price->ID;
                 }
             }
         }
     }
     $tm_meta_cpf_global_forms_added = array_unique($tm_meta_cpf_global_forms_added);
     foreach ($tm_meta_cpf_global_forms as $key => $value) {
         if (!in_array($value, $tm_meta_cpf_global_forms_added)) {
             if (TM_EPO_WPML()->is_active()) {
                 $tm_meta_lang = get_post_meta($value, TM_EPO_WPML_LANG_META, true);
                 if (empty($tm_meta_lang)) {
                     $tm_meta_lang = TM_EPO_WPML()->get_default_lang();
                 }
                 $meta_query = TM_EPO_HELPER()->build_meta_query('AND', TM_EPO_WPML_LANG_META, TM_EPO_WPML()->get_lang(), '=', 'EXISTS');
                 $meta_query[] = array('key' => TM_EPO_WPML_PARENT_POSTID, 'value' => $value, 'compare' => '=');
                 $query = new WP_Query(array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'date', 'order' => 'asc', 'meta_query' => $meta_query));
                 if (!empty($query->posts)) {
                     $tmglobalprices[] = get_post($query->post->ID);
                 } elseif (empty($query->posts)) {
                     $tmglobalprices[] = get_post($value);
                 }
             } else {
                 $tmglobalprices[] = get_post($value);
             }
         }
     }
     // Add current product to Global options array (has to be last to not conflict)
     $tmglobalprices[] = get_post($post_id);
     // End of DB init
     $product_epos = array();
     $global_epos = array();
     $epos_prices = array();
     if ($tmglobalprices) {
         $wpml_section_fields = array();
         foreach (TM_EPO_BUILDER()->_section_elements as $key => $value) {
             if (isset($value['id']) && empty($value['wpmldisable'])) {
                 $wpml_section_fields[$value['id']] = $value['id'];
             }
         }
         foreach ($tmglobalprices as $price) {
             if (!is_object($price)) {
                 continue;
             }
             $original_product_id = $price->ID;
             if (TM_EPO_WPML()->is_active()) {
                 $wpml_is_original_product = TM_EPO_WPML()->is_original_product($price->ID, $price->post_type);
                 if (!$wpml_is_original_product) {
                     $original_product_id = floatval(TM_EPO_WPML()->get_original_id($price->ID, $price->post_type));
                 }
             }
             $tmcp_id = absint($original_product_id);
             $tmcp_meta = get_post_meta($original_product_id, 'tm_meta', true);
             $current_builder = get_post_meta($price->ID, 'tm_meta_wpml', true);
             if (!$current_builder) {
                 $current_builder = array();
             } else {
                 if (!isset($current_builder['tmfbuilder'])) {
                     $current_builder['tmfbuilder'] = array();
                 }
                 $current_builder = $current_builder['tmfbuilder'];
             }
             $priority = isset($tmcp_meta['priority']) ? absint($tmcp_meta['priority']) : 1000;
             if (isset($tmcp_meta['tmfbuilder'])) {
                 $global_epos[$priority][$tmcp_id]['is_form'] = 1;
                 $global_epos[$priority][$tmcp_id]['is_taxonomy'] = 0;
                 $global_epos[$priority][$tmcp_id]['name'] = $price->post_title;
                 $global_epos[$priority][$tmcp_id]['description'] = $price->post_excerpt;
                 $global_epos[$priority][$tmcp_id]['sections'] = array();
                 $builder = $tmcp_meta['tmfbuilder'];
                 if (is_array($builder) && count($builder) > 0 && isset($builder['element_type']) && is_array($builder['element_type']) && count($builder['element_type']) > 0) {
                     // All the elements
                     $_elements = $builder['element_type'];
                     // All element sizes
                     $_div_size = $builder['div_size'];
                     // All sections (holds element count for each section)
                     $_sections = $builder['sections'];
                     // All section sizes
                     $_sections_size = $builder['sections_size'];
                     // All section styles
                     $_sections_style = $builder['sections_style'];
                     // All section placements
                     $_sections_placement = $builder['sections_placement'];
                     $_sections_slides = isset($builder['sections_slides']) ? $builder['sections_slides'] : '';
                     if (!is_array($_sections)) {
                         $_sections = array(count($_elements));
                     }
                     if (!is_array($_sections_size)) {
                         $_sections_size = array_fill(0, count($_sections), "w100");
                     }
                     if (!is_array($_sections_style)) {
                         $_sections_style = array_fill(0, count($_sections), "");
                     }
                     if (!is_array($_sections_placement)) {
                         $_sections_placement = array_fill(0, count($_sections), "before");
                     }
                     if (!is_array($_sections_slides)) {
                         $_sections_slides = array_fill(0, count($_sections), "");
                     }
                     $_helper_counter = 0;
                     $_counter = array();
                     for ($_s = 0; $_s < count($_sections); $_s++) {
                         $_sections_uniqid = $this->get_builder_element('sections_uniqid', $builder, $current_builder, $_s, TM_EPO_HELPER()->tm_temp_uniqid(count($_sections)), $wpml_section_fields);
                         $global_epos[$priority][$tmcp_id]['sections'][$_s] = array('total_elements' => $_sections[$_s], 'sections_size' => $_sections_size[$_s], 'sections_slides' => $_sections_slides[$_s], 'sections_style' => $_sections_style[$_s], 'sections_placement' => $_sections_placement[$_s], 'sections_uniqid' => $_sections_uniqid, 'sections_clogic' => $this->get_builder_element('sections_clogic', $builder, $current_builder, $_s, false, $wpml_section_fields), 'sections_logic' => $this->get_builder_element('sections_logic', $builder, $current_builder, $_s, "", $wpml_section_fields), 'sections_class' => $this->get_builder_element('sections_class', $builder, $current_builder, $_s, "", $wpml_section_fields), 'sections_type' => $this->get_builder_element('sections_type', $builder, $current_builder, $_s, "", $wpml_section_fields), 'label_size' => $this->get_builder_element('section_header_size', $builder, $current_builder, $_s, "", $wpml_section_fields), 'label' => $this->get_builder_element('section_header_title', $builder, $current_builder, $_s, "", $wpml_section_fields), 'label_color' => $this->get_builder_element('section_header_title_color', $builder, $current_builder, $_s, "", $wpml_section_fields), 'description' => $this->get_builder_element('section_header_subtitle', $builder, $current_builder, $_s, "", $wpml_section_fields), 'description_position' => $this->get_builder_element('section_header_subtitle_position', $builder, $current_builder, $_s, "", $wpml_section_fields), 'description_color' => $this->get_builder_element('section_header_subtitle_color', $builder, $current_builder, $_s, "", $wpml_section_fields), 'divider_type' => $this->get_builder_element('section_divider_type', $builder, $current_builder, $_s, "", $wpml_section_fields));
                         for ($k0 = $_helper_counter; $k0 < intval($_helper_counter + intval($_sections[$_s])); $k0++) {
                             $current_element = $_elements[$k0];
                             $wpml_element_fields = array();
                             if (isset(TM_EPO_BUILDER()->elements_array[$current_element])) {
                                 foreach (TM_EPO_BUILDER()->elements_array[$current_element] as $key => $value) {
                                     if (isset($value['id']) && empty($value['wpmldisable'])) {
                                         $wpml_element_fields[$value['id']] = $value['id'];
                                     }
                                 }
                             }
                             if (isset($current_element) && isset($this->tm_original_builder_elements[$current_element])) {
                                 if (!isset($_counter[$current_element])) {
                                     $_counter[$current_element] = 0;
                                 } else {
                                     $_counter[$current_element]++;
                                 }
                                 $current_counter = $_counter[$current_element];
                                 $_options = array();
                                 $_regular_price = array();
                                 $_regular_price_filtered = array();
                                 $_regular_price_type = array();
                                 $_new_type = $current_element;
                                 $_prefix = "";
                                 $_min_price0 = '';
                                 $_min_price = '';
                                 $_max_price = '';
                                 $_regular_currencies = array();
                                 $price_per_currencies = array();
                                 $_description = false;
                                 $_use_lightbox = '';
                                 if ($this->tm_original_builder_elements[$current_element]) {
                                     if ($this->tm_original_builder_elements[$current_element]["type"] == "single") {
                                         $_prefix = $current_element . "_";
                                         $_is_field_required = $this->get_builder_element($_prefix . 'required', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         $_changes_product_image = $this->get_builder_element($_prefix . 'changes_product_image', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         $_use_images = $this->get_builder_element($_prefix . 'use_images', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         if (empty($builder[$current_element . '_price'][$current_counter])) {
                                             $builder[$current_element . '_price'][$current_counter] = 0;
                                         }
                                         $new_currency = false;
                                         $mt_prefix = TM_EPO_HELPER()->get_currency_price_prefix();
                                         $_price = $builder[$current_element . '_price'][$current_counter];
                                         if (isset($builder[$current_element . '_sale_price'][$current_counter]) && $builder[$current_element . '_sale_price'][$current_counter] !== '') {
                                             $_price = $builder[$current_element . '_sale_price'][$current_counter];
                                         }
                                         $_current_currency_price = isset($builder[$current_element . '_price' . $mt_prefix]) ? $builder[$current_element . '_price' . $mt_prefix][$current_counter] : '';
                                         $_current_currency_sale_price = isset($builder[$current_element . '_sale_price' . $mt_prefix]) ? $builder[$current_element . '_sale_price' . $mt_prefix][$current_counter] : '';
                                         if ($mt_prefix !== '' && $_current_currency_price && $_current_currency_price !== '') {
                                             $_price = $_current_currency_price;
                                             if ($_current_currency_sale_price && $_current_currency_sale_price !== '') {
                                                 $_price = $_current_currency_sale_price;
                                             }
                                             $_regular_currencies = array(get_woocommerce_currency());
                                             $new_currency = true;
                                         }
                                         foreach (TM_EPO_HELPER()->get_currencies() as $currency) {
                                             $mt_prefix = TM_EPO_HELPER()->get_currency_price_prefix($currency);
                                             $_current_currency_price = isset($builder[$current_element . '_price' . $mt_prefix][$current_counter]) ? $builder[$current_element . '_price' . $mt_prefix][$current_counter] : '';
                                             $_current_currency_sale_price = isset($builder[$current_element . '_sale_price' . $mt_prefix][$current_counter]) ? $builder[$current_element . '_sale_price' . $mt_prefix][$current_counter] : '';
                                             if ($_current_currency_sale_price && $_current_currency_sale_price !== '') {
                                                 $_current_currency_price = $_current_currency_sale_price;
                                             }
                                             $price_per_currencies[$currency] = array(array(wc_format_decimal($_current_currency_price, false, true)));
                                         }
                                         $_regular_price = array(array(wc_format_decimal($_price, false, true)));
                                         $_regular_price_type = isset($builder[$current_element . '_price_type'][$current_counter]) ? array(array($builder[$current_element . '_price_type'][$current_counter])) : array();
                                         $_for_filter_price_type = isset($builder[$current_element . '_price_type'][$current_counter]) ? $builder[$current_element . '_price_type'][$current_counter] : "";
                                         if (!$new_currency) {
                                             $_price = apply_filters('woocommerce_tm_epo_price2', $_price, $_for_filter_price_type);
                                         }
                                         if ($_price !== '' && isset($builder[$current_element . '_price_type'][$current_counter]) && $builder[$current_element . '_price_type'][$current_counter] == '') {
                                             $_min_price = $_max_price = wc_format_decimal($_price, false, true);
                                             if ($_is_field_required) {
                                                 $_min_price0 = $_min_price;
                                             } else {
                                                 $_min_price0 = 0;
                                             }
                                         } else {
                                             $_min_price = $_max_price = false;
                                             $_min_price0 = 0;
                                         }
                                         $_regular_price_filtered = array(array(wc_format_decimal($_price, false, true)));
                                     } elseif ($this->tm_original_builder_elements[$current_element]["type"] == "multiple" || $this->tm_original_builder_elements[$current_element]["type"] == "multipleall" || $this->tm_original_builder_elements[$current_element]["type"] == "multiplesingle") {
                                         $_prefix = $current_element . "_";
                                         $_is_field_required = $this->get_builder_element($_prefix . 'required', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         $_changes_product_image = $this->get_builder_element($_prefix . 'changes_product_image', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         $_use_images = $this->get_builder_element($_prefix . 'use_images', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         $_use_lightbox = $this->get_builder_element($_prefix . 'use_lightbox', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element);
                                         if (isset($builder['multiple_' . $current_element . '_options_price'][$current_counter])) {
                                             if (empty($builder['multiple_' . $current_element . '_options_price'][$current_counter])) {
                                                 $builder['multiple_' . $current_element . '_options_price'][$current_counter] = 0;
                                             }
                                             $_prices = $builder['multiple_' . $current_element . '_options_price'][$current_counter];
                                             $_sale_prices = $_prices;
                                             if (isset($builder['multiple_' . $current_element . '_options_sale_price'][$current_counter])) {
                                                 $_sale_prices = $builder['multiple_' . $current_element . '_options_sale_price'][$current_counter];
                                             }
                                             $_prices = TM_EPO_HELPER()->merge_price_array($_prices, $_sale_prices);
                                             $mt_prefix = TM_EPO_HELPER()->get_currency_price_prefix();
                                             $_current_currency_prices = isset($builder['multiple_' . $current_element . '_options_price' . $mt_prefix][$current_counter]) ? $builder['multiple_' . $current_element . '_options_price' . $mt_prefix][$current_counter] : '';
                                             $_current_currency_sale_prices = isset($builder['multiple_' . $current_element . '_options_sale_price' . $mt_prefix][$current_counter]) ? $builder['multiple_' . $current_element . '_options_sale_price' . $mt_prefix][$current_counter] : '';
                                             $_values = $this->get_builder_element('multiple_' . $current_element . '_options_value', $builder, $current_builder, $current_counter, "", true, $current_element);
                                             $_titles = $this->get_builder_element('multiple_' . $current_element . '_options_title', $builder, $current_builder, $current_counter, "", true, $current_element);
                                             $_images = $this->get_builder_element('multiple_' . $current_element . '_options_image', $builder, $current_builder, $current_counter, array(), true, $current_element, 'tm_image_url');
                                             $_imagesp = $this->get_builder_element('multiple_' . $current_element . '_options_imagep', $builder, $current_builder, $current_counter, array(), true, $current_element, 'tm_image_url');
                                             foreach (TM_EPO_HELPER()->get_currencies() as $currency) {
                                                 $mt_prefix = TM_EPO_HELPER()->get_currency_price_prefix($currency);
                                                 $_current_currency_price = isset($builder['multiple_' . $current_element . '_options_price' . $mt_prefix][$current_counter]) ? $builder['multiple_' . $current_element . '_options_price' . $mt_prefix][$current_counter] : '';
                                                 $_current_currency_sale_price = isset($builder['multiple_' . $current_element . '_options_sale_price' . $mt_prefix][$current_counter]) ? $builder['multiple_' . $current_element . '_options_sale_price' . $mt_prefix][$current_counter] : '';
                                                 $_current_currency_price = TM_EPO_HELPER()->merge_price_array($_current_currency_price, $_current_currency_sale_price);
                                                 $price_per_currencies[$currency] = $_current_currency_price;
                                                 foreach ($_prices as $_n => $_price) {
                                                     $to_price = '';
                                                     if (is_array($_current_currency_price) && isset($_current_currency_price[$_n])) {
                                                         $to_price = $_current_currency_price[$_n];
                                                     }
                                                     $price_per_currencies[$currency][esc_attr($_values[$_n]) . "_" . $_n] = array(wc_format_decimal($to_price, false, true));
                                                 }
                                             }
                                             if ($_changes_product_image == "images" && $_use_images == "") {
                                                 $_imagesp = $_images;
                                                 $_images = array();
                                                 $_changes_product_image = "custom";
                                             }
                                             if ($_use_images == "") {
                                                 $_use_lightbox = "";
                                             }
                                             $_url = $this->get_builder_element('multiple_' . $current_element . '_options_url', $builder, $current_builder, $current_counter, array(), true, $current_element);
                                             $_description = $this->get_builder_element('multiple_' . $current_element . '_options_description', $builder, $current_builder, $current_counter, array(), true, $current_element);
                                             $_prices_type = $this->get_builder_element('multiple_' . $current_element . '_options_price_type', $builder, $current_builder, $current_counter, array(), true, $current_element);
                                             $_values_c = $_values;
                                             $mt_prefix = TM_EPO_HELPER()->get_currency_price_prefix();
                                             foreach ($_prices as $_n => $_price) {
                                                 $new_currency = false;
                                                 if ($mt_prefix !== '' && $_current_currency_prices !== '' && is_array($_current_currency_prices) && isset($_current_currency_prices[$_n]) && $_current_currency_prices[$_n] != '') {
                                                     $new_currency = true;
                                                     $_price = $_current_currency_prices[$_n];
                                                     $_regular_currencies[esc_attr($_values[$_n]) . "_" . $_n] = array(get_woocommerce_currency());
                                                 }
                                                 $_f_price = wc_format_decimal($_price, false, true);
                                                 $_regular_price[esc_attr($_values[$_n]) . "_" . $_n] = array($_f_price);
                                                 $_for_filter_price_type = isset($_prices_type[$_n]) ? $_prices_type[$_n] : "";
                                                 if (!$new_currency) {
                                                     $_price = apply_filters('woocommerce_tm_epo_price2', $_price, $_for_filter_price_type);
                                                 }
                                                 $_regular_price_filtered[esc_attr($_values[$_n]) . "_" . $_n] = array(wc_format_decimal($_price, false, true));
                                                 $_regular_price_type[esc_attr($_values[$_n]) . "_" . $_n] = isset($_prices_type[$_n]) ? array($_prices_type[$_n]) : array('');
                                                 $_options[esc_attr($_values[$_n]) . "_" . $_n] = $_titles[$_n];
                                                 $_values_c[$_n] = $_values[$_n] . "_" . $_n;
                                                 if (isset($_prices_type[$_n]) && $_prices_type[$_n] == '') {
                                                     if ($_min_price !== false && $_price !== '') {
                                                         if ($_min_price === '') {
                                                             $_min_price = $_f_price;
                                                         } else {
                                                             if ($_min_price > $_f_price) {
                                                                 $_min_price = $_f_price;
                                                             }
                                                         }
                                                         if ($_min_price0 === '') {
                                                             if ($_is_field_required) {
                                                                 $_min_price0 = floatval($_min_price);
                                                             } else {
                                                                 $_min_price0 = 0;
                                                             }
                                                         } else {
                                                             if ($_is_field_required && $_min_price0 > floatval($_min_price)) {
                                                                 $_min_price0 = floatval($_min_price);
                                                             }
                                                         }
                                                         if ($_max_price === '') {
                                                             $_max_price = $_f_price;
                                                         } else {
                                                             if ($_max_price < $_f_price) {
                                                                 $_max_price = $_f_price;
                                                             }
                                                         }
                                                     } else {
                                                         if ($_price === '') {
                                                             $_min_price0 = 0;
                                                         }
                                                     }
                                                 } else {
                                                     $_min_price = $_max_price = false;
                                                     if ($_min_price0 === '') {
                                                         $_min_price0 = 0;
                                                     } else {
                                                         if ($_min_price0 > floatval($_min_price)) {
                                                             $_min_price0 = floatval($_min_price);
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $default_value = "";
                                 if (isset($builder['multiple_' . $current_element . '_options_default_value'][$current_counter])) {
                                     $default_value = $builder['multiple_' . $current_element . '_options_default_value'][$current_counter];
                                 } elseif (isset($builder[$_prefix . 'default_value']) && isset($builder[$_prefix . 'default_value'][$current_counter])) {
                                     $default_value = $builder[$_prefix . 'default_value'][$current_counter];
                                 }
                                 $selectbox_fee = false;
                                 $selectbox_cart_fee = false;
                                 switch ($current_element) {
                                     case "selectbox":
                                         $_new_type = "select";
                                         $selectbox_fee = isset($builder[$current_element . '_price_type'][$current_counter]) ? array(array($builder[$current_element . '_price_type'][$current_counter])) : false;
                                         $selectbox_cart_fee = isset($builder[$current_element . '_price_type'][$current_counter]) ? array(array($builder[$current_element . '_price_type'][$current_counter])) : false;
                                         break;
                                     case "radiobuttons":
                                         $_new_type = "radio";
                                         break;
                                     case "checkboxes":
                                         $_new_type = "checkbox";
                                         break;
                                 }
                                 $_rules = $_regular_price;
                                 $_rules_filtered = $_regular_price_filtered;
                                 foreach ($_regular_price as $key => $value) {
                                     foreach ($value as $k => $v) {
                                         $_regular_price[$key][$k] = wc_format_localized_price($v);
                                         $_regular_price_filtered[$key][$k] = wc_format_localized_price($v);
                                     }
                                 }
                                 $_rules_type = $_regular_price_type;
                                 foreach ($_regular_price_type as $key => $value) {
                                     foreach ($value as $k => $v) {
                                         $_regular_price_type[$key][$k] = $v;
                                     }
                                 }
                                 $epos_prices[] = array("min" => floatval($_min_price0), "max" => floatval($_max_price), "logic" => $this->get_builder_element($_prefix . 'logic', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element));
                                 if ($_min_price !== false) {
                                     $_min_price = wc_format_localized_price($_min_price);
                                 }
                                 if ($_max_price !== false) {
                                     $_max_price = wc_format_localized_price($_max_price);
                                 }
                                 if ($current_element != "header" && $current_element != "divider") {
                                     $global_epos[$priority][$tmcp_id]['sections'][$_s]['elements'][] = array_merge(TM_EPO_BUILDER()->get_custom_properties($builder, $_prefix, $_counter, $_elements, $k0), array('_' => TM_EPO_BUILDER()->get_default_properties($builder, $_prefix, $_counter, $_elements, $k0), 'internal_name' => $this->get_builder_element($_prefix . 'internal_name', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'builder' => isset($wpml_is_original_product) && empty($wpml_is_original_product) ? $current_builder : $builder, 'section' => $_sections_uniqid, 'type' => $_new_type, 'size' => $_div_size[$k0], 'required' => $this->get_builder_element($_prefix . 'required', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'use_images' => $_use_images, 'use_lightbox' => $_use_lightbox, 'use_url' => $this->get_builder_element($_prefix . 'use_url', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'items_per_row' => $this->get_builder_element($_prefix . 'items_per_row', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label_size' => $this->get_builder_element($_prefix . 'header_size', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label' => $this->get_builder_element($_prefix . 'header_title', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label_position' => $this->get_builder_element($_prefix . 'header_title_position', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label_color' => $this->get_builder_element($_prefix . 'header_title_color', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'description' => $this->get_builder_element($_prefix . 'header_subtitle', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'description_position' => $this->get_builder_element($_prefix . 'header_subtitle_position', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'description_color' => $this->get_builder_element($_prefix . 'header_subtitle_color', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'divider_type' => $this->get_builder_element($_prefix . 'divider_type', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'placeholder' => $this->get_builder_element($_prefix . 'placeholder', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'min_chars' => $this->get_builder_element($_prefix . 'min_chars', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'max_chars' => $this->get_builder_element($_prefix . 'max_chars', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'hide_amount' => $this->get_builder_element($_prefix . 'hide_amount', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'text_before_price' => $this->get_builder_element($_prefix . 'text_before_price', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'text_after_price' => $this->get_builder_element($_prefix . 'text_after_price', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'options' => $_options, 'min_price' => $_min_price, 'max_price' => $_max_price, 'rules' => $_rules, 'price_rules' => $_regular_price, 'rules_filtered' => $_rules_filtered, 'price_rules_filtered' => $_regular_price_filtered, 'price_rules_type' => $_regular_price_type, 'rules_type' => $_rules_type, 'currencies' => $_regular_currencies, 'price_per_currencies' => $price_per_currencies, 'images' => isset($_images) ? $_images : "", 'imagesp' => isset($_imagesp) ? $_imagesp : "", 'url' => isset($_url) ? $_url : "", 'cdescription' => $_description !== false ? $_description : "", 'limit' => $this->get_builder_element($_prefix . 'limit_choices', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'exactlimit' => $this->get_builder_element($_prefix . 'exactlimit_choices', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'minimumlimit' => $this->get_builder_element($_prefix . 'minimumlimit_choices', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'clear_options' => $this->get_builder_element($_prefix . 'clear_options', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'option_values' => isset($_values_c) ? $_values_c : array(), 'button_type' => $this->get_builder_element($_prefix . 'button_type', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'uniqid' => $this->get_builder_element($_prefix . 'uniqid', $builder, $current_builder, $current_counter, uniqid('', true), $wpml_element_fields, $current_element), 'clogic' => $this->get_builder_element($_prefix . 'clogic', $builder, $current_builder, $current_counter, false, $wpml_element_fields, $current_element), 'logic' => $this->get_builder_element($_prefix . 'logic', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'format' => $this->get_builder_element($_prefix . 'format', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'start_year' => $this->get_builder_element($_prefix . 'start_year', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'end_year' => $this->get_builder_element($_prefix . 'end_year', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'min_date' => $this->get_builder_element($_prefix . 'min_date', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'max_date' => $this->get_builder_element($_prefix . 'max_date', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'disabled_dates' => $this->get_builder_element($_prefix . 'disabled_dates', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'enabled_only_dates' => $this->get_builder_element($_prefix . 'enabled_only_dates', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'disabled_weekdays' => $this->get_builder_element($_prefix . 'disabled_weekdays', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'theme' => $this->get_builder_element($_prefix . 'theme', $builder, $current_builder, $current_counter, "epo", $wpml_element_fields, $current_element), 'theme_size' => $this->get_builder_element($_prefix . 'theme_size', $builder, $current_builder, $current_counter, "medium", $wpml_element_fields, $current_element), 'theme_position' => $this->get_builder_element($_prefix . 'theme_position', $builder, $current_builder, $current_counter, "normal", $wpml_element_fields, $current_element), 'tranlation_day' => $this->get_builder_element($_prefix . 'tranlation_day', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'tranlation_month' => $this->get_builder_element($_prefix . 'tranlation_month', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'tranlation_year' => $this->get_builder_element($_prefix . 'tranlation_year', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), "default_value" => $default_value, 'text_after_price' => $this->get_builder_element($_prefix . 'text_before_price', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'text_after_price' => $this->get_builder_element($_prefix . 'text_after_price', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'selectbox_fee' => $selectbox_fee, 'selectbox_cart_fee' => $selectbox_cart_fee, 'class' => $this->get_builder_element($_prefix . 'class', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'swatchmode' => $this->get_builder_element($_prefix . 'swatchmode', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'changes_product_image' => $_changes_product_image, 'min' => $this->get_builder_element($_prefix . 'min', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'max' => $this->get_builder_element($_prefix . 'max', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'step' => $this->get_builder_element($_prefix . 'step', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'pips' => $this->get_builder_element($_prefix . 'pips', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'show_picker_value' => $this->get_builder_element($_prefix . 'show_picker_value', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'quantity' => $this->get_builder_element($_prefix . 'quantity', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'quantity_min' => $this->get_builder_element($_prefix . 'quantity_min', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'quantity_max' => $this->get_builder_element($_prefix . 'quantity_max', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'quantity_step' => $this->get_builder_element($_prefix . 'quantity_step', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'quantity_default_value' => $this->get_builder_element($_prefix . 'quantity_default_value', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'validation1' => $this->get_builder_element($_prefix . 'validation1', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element)));
                                 } elseif ($current_element == "header") {
                                     $global_epos[$priority][$tmcp_id]['sections'][$_s]['elements'][] = array('internal_name' => $this->get_builder_element($_prefix . 'internal_name', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'section' => $_sections_uniqid, 'type' => $_new_type, 'size' => $_div_size[$k0], 'required' => "", 'use_images' => "", 'use_url' => "", 'items_per_row' => "", 'label_size' => $this->get_builder_element($_prefix . 'header_size', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label' => $this->get_builder_element($_prefix . 'header_title', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label_position' => $this->get_builder_element($_prefix . 'header_title_position', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'label_color' => $this->get_builder_element($_prefix . 'header_title_color', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'description' => $this->get_builder_element($_prefix . 'header_subtitle', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'description_color' => $this->get_builder_element($_prefix . 'header_subtitle_color', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'description_position' => $this->get_builder_element($_prefix . 'header_subtitle_position', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'divider_type' => "", 'placeholder' => "", 'max_chars' => "", 'hide_amount' => "", "options" => $_options, 'min_price' => $_min_price, 'max_price' => $_max_price, 'rules' => $_rules, 'price_rules' => $_regular_price, 'rules_filtered' => $_rules_filtered, 'price_rules_filtered' => $_regular_price_filtered, 'price_rules_type' => $_regular_price_type, 'rules_type' => $_rules_type, 'images' => "", 'limit' => "", 'exactlimit' => "", 'minimumlimit' => "", 'option_values' => array(), 'button_type' => '', 'class' => $this->get_builder_element('header_class', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'uniqid' => $this->get_builder_element('header_uniqid', $builder, $current_builder, $current_counter, uniqid('', true), $wpml_element_fields, $current_element), 'clogic' => $this->get_builder_element('header_clogic', $builder, $current_builder, $current_counter, false, $wpml_element_fields, $current_element), 'logic' => $this->get_builder_element('header_logic', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'format' => '', 'start_year' => '', 'end_year' => '', 'tranlation_day' => '', 'tranlation_month' => '', 'tranlation_year' => '', 'swatchmode' => "", 'changes_product_image' => "", 'min' => "", 'max' => "", 'step' => "", 'pips' => "");
                                 } elseif ($current_element == "divider") {
                                     $global_epos[$priority][$tmcp_id]['sections'][$_s]['elements'][] = array('internal_name' => $this->get_builder_element($_prefix . 'internal_name', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'section' => $_sections_uniqid, 'type' => $_new_type, 'size' => $_div_size[$k0], 'required' => "", 'use_images' => "", 'use_url' => "", 'items_per_row' => "", 'label_size' => "", 'label' => "", 'label_color' => "", 'label_position' => "", 'description' => "", 'description_color' => "", 'divider_type' => $this->get_builder_element($_prefix . 'divider_type', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'placeholder' => "", 'max_chars' => "", 'hide_amount' => "", "options" => $_options, 'min_price' => $_min_price, 'max_price' => $_max_price, 'rules' => $_rules, 'price_rules' => $_regular_price, 'rules_filtered' => $_rules_filtered, 'price_rules_filtered' => $_regular_price_filtered, 'price_rules_type' => $_regular_price_type, 'rules_type' => $_rules_type, 'images' => "", 'limit' => "", 'exactlimit' => "", 'minimumlimit' => "", 'option_values' => array(), 'button_type' => '', 'class' => $this->get_builder_element('divider_class', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'uniqid' => $this->get_builder_element('divider_uniqid', $builder, $current_builder, $current_counter, uniqid('', true), $wpml_element_fields, $current_element), 'clogic' => $this->get_builder_element('divider_clogic', $builder, $current_builder, $current_counter, false, $wpml_element_fields, $current_element), 'logic' => $this->get_builder_element('divider_logic', $builder, $current_builder, $current_counter, "", $wpml_element_fields, $current_element), 'format' => '', 'start_year' => '', 'end_year' => '', 'tranlation_day' => '', 'tranlation_month' => '', 'tranlation_year' => '', 'swatchmode' => "", 'changes_product_image' => "", 'min' => "", 'max' => "", 'step' => "", 'pips' => "");
                                 }
                             }
                         }
                         $_helper_counter = intval($_helper_counter + intval($_sections[$_s]));
                     }
                 }
             }
         }
     }
     ksort($global_epos);
     if ($tmlocalprices) {
         TM_EPO_WPML()->remove_sql_filter();
         $attributes = maybe_unserialize(get_post_meta(floatval(TM_EPO_WPML()->get_original_id($post_id)), '_product_attributes', true));
         $wpml_attributes = maybe_unserialize(get_post_meta($post_id, '_product_attributes', true));
         foreach ($tmlocalprices as $price) {
             $tmcp_id = absint($price->ID);
             $tmcp_required = get_post_meta($tmcp_id, 'tmcp_required', true);
             $tmcp_hide_price = get_post_meta($tmcp_id, 'tmcp_hide_price', true);
             $tmcp_limit = get_post_meta($tmcp_id, 'tmcp_limit', true);
             $product_epos[$tmcp_id]['is_form'] = 0;
             $product_epos[$tmcp_id]['required'] = empty($tmcp_required) ? 0 : 1;
             $product_epos[$tmcp_id]['hide_price'] = empty($tmcp_hide_price) ? 0 : 1;
             $product_epos[$tmcp_id]['limit'] = empty($tmcp_limit) ? "" : $tmcp_limit;
             $product_epos[$tmcp_id]['name'] = get_post_meta($tmcp_id, 'tmcp_attribute', true);
             $product_epos[$tmcp_id]['is_taxonomy'] = get_post_meta($tmcp_id, 'tmcp_attribute_is_taxonomy', true);
             $product_epos[$tmcp_id]['label'] = wc_attribute_label($product_epos[$tmcp_id]['name']);
             $product_epos[$tmcp_id]['type'] = get_post_meta($tmcp_id, 'tmcp_type', true);
             // Retrieve attributes
             $product_epos[$tmcp_id]['attributes'] = array();
             $product_epos[$tmcp_id]['attributes_wpml'] = array();
             if ($product_epos[$tmcp_id]['is_taxonomy']) {
                 if (!$attributes[$product_epos[$tmcp_id]['name']]['is_variation']) {
                     $all_terms = TM_EPO_WPML()->get_terms(null, $attributes[$product_epos[$tmcp_id]['name']]['name'], 'orderby=name&hide_empty=0');
                     if ($all_terms) {
                         foreach ($all_terms as $term) {
                             $has_term = has_term((int) $term->term_id, $attributes[$product_epos[$tmcp_id]['name']]['name'], floatval(TM_EPO_WPML()->get_original_id($post_id))) ? 1 : 0;
                             $wpml_term_id = TM_EPO_WPML()->is_active() ? icl_object_id($term->term_id, $attributes[$product_epos[$tmcp_id]['name']]['name'], false) : false;
                             if ($has_term) {
                                 $product_epos[$tmcp_id]['attributes'][esc_attr($term->slug)] = apply_filters('woocommerce_tm_epo_option_name', esc_html($term->name));
                                 if ($wpml_term_id) {
                                     $wpml_term = get_term($wpml_term_id, $attributes[$product_epos[$tmcp_id]['name']]['name']);
                                     $product_epos[$tmcp_id]['attributes_wpml'][esc_attr($term->slug)] = apply_filters('woocommerce_tm_epo_option_name', esc_html($wpml_term->name));
                                 } else {
                                     $product_epos[$tmcp_id]['attributes_wpml'][esc_attr($term->slug)] = $product_epos[$tmcp_id]['attributes'][esc_attr($term->slug)];
                                 }
                             }
                         }
                     }
                 }
             } else {
                 if (isset($attributes[$product_epos[$tmcp_id]['name']])) {
                     $options = array_map('trim', explode(WC_DELIMITER, $attributes[$product_epos[$tmcp_id]['name']]['value']));
                     $wpml_options = array_map('trim', explode(WC_DELIMITER, $wpml_attributes[$product_epos[$tmcp_id]['name']]['value']));
                     foreach ($options as $k => $option) {
                         $product_epos[$tmcp_id]['attributes'][esc_attr(sanitize_title($option))] = esc_html(apply_filters('woocommerce_tm_epo_option_name', $option));
                         $product_epos[$tmcp_id]['attributes_wpml'][esc_attr(sanitize_title($option))] = esc_html(apply_filters('woocommerce_tm_epo_option_name', isset($wpml_options[$k]) ? $wpml_options[$k] : $option));
                     }
                 }
             }
             // Retrieve price rules
             $_regular_price = get_post_meta($tmcp_id, '_regular_price', true);
             $_regular_price_type = get_post_meta($tmcp_id, '_regular_price_type', true);
             $product_epos[$tmcp_id]['rules'] = $_regular_price;
             $_regular_price_filtered = TM_EPO_HELPER()->array_map_deep($_regular_price, $_regular_price_type, array($this, 'tm_epo_price_filtered'));
             $product_epos[$tmcp_id]['rules_filtered'] = $_regular_price_filtered;
             $product_epos[$tmcp_id]['rules_type'] = $_regular_price_type;
             if (!is_array($_regular_price)) {
                 $_regular_price = array();
             }
             if (!is_array($_regular_price_type)) {
                 $_regular_price_type = array();
             }
             foreach ($_regular_price as $key => $value) {
                 foreach ($value as $k => $v) {
                     $_regular_price[$key][$k] = wc_format_localized_price($v);
                 }
             }
             foreach ($_regular_price_type as $key => $value) {
                 foreach ($value as $k => $v) {
                     $_regular_price_type[$key][$k] = $v;
                 }
             }
             $product_epos[$tmcp_id]['price_rules'] = $_regular_price;
             $product_epos[$tmcp_id]['price_rules_filtered'] = $_regular_price_filtered;
             $product_epos[$tmcp_id]['price_rules_type'] = $_regular_price_type;
         }
         TM_EPO_WPML()->restore_sql_filter();
     }
     $global_epos = $this->tm_fill_element_names($post_id, $global_epos, $product_epos, $form_prefix);
     $epos = array('global' => $global_epos, 'local' => $product_epos, 'price' => $epos_prices);
     $this->cpf[$post_id] = $epos;
     return $epos;
 }
 public function wp_count_posts($type = 'post', $perm = '')
 {
     global $wpdb;
     if (!post_type_exists($type)) {
         return new stdClass();
     }
     $cache_key = $this->_count_posts_cache_key($type, $perm);
     // WPML
     $_lang = TM_EPO_WPML()->get_lang();
     if (TM_EPO_WPML()->is_active() && TM_EPO_WPML()->get_lang() != 'all' && $_lang == TM_EPO_WPML()->get_default_lang()) {
         $query = "SELECT p.post_status, COUNT( DISTINCT ID ) AS num_posts FROM {$wpdb->posts} p";
     } else {
         $query = "SELECT p.post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} p";
     }
     // WPML
     if (TM_EPO_WPML()->is_active() && TM_EPO_WPML()->get_lang() != 'all') {
         if ($_lang == TM_EPO_WPML()->get_default_lang()) {
             $query .= " LEFT JOIN {$wpdb->postmeta} ON (p.ID = {$wpdb->postmeta}.post_id)" . " LEFT JOIN {$wpdb->postmeta} AS mt1 ON (p.ID = mt1.post_id AND mt1.meta_key = '" . TM_EPO_WPML_LANG_META . "')";
         } else {
             $query .= " JOIN  {$wpdb->postmeta} pm";
         }
     }
     // WPML
     if (TM_EPO_WPML()->is_active() && TM_EPO_WPML()->get_lang() != 'all' && $_lang == TM_EPO_WPML()->get_default_lang()) {
         $query .= " WHERE 1=1 AND p.post_type = %s";
     } else {
         $query .= " WHERE p.post_type = %s";
     }
     if ('readable' == $perm && is_user_logged_in()) {
         $post_type_object = get_post_type_object($type);
         if (!current_user_can($post_type_object->cap->read_private_posts)) {
             $query .= $wpdb->prepare(" AND (p.post_status != 'private' OR ( p.post_author = %d AND p.post_status = 'private' ))", get_current_user_id());
         }
     }
     // WPML
     if (TM_EPO_WPML()->is_active() && TM_EPO_WPML()->get_lang() != 'all') {
         if ($_lang == TM_EPO_WPML()->get_default_lang()) {
             $query .= " AND ( ( " . $wpdb->prefix . "postmeta.meta_key = '" . TM_EPO_WPML_LANG_META . "' AND CAST(" . $wpdb->prefix . "postmeta.meta_value AS CHAR) = '" . TM_EPO_WPML()->get_lang() . "' ) OR mt1.post_id IS NULL ) ";
         } else {
             $query .= " AND pm.meta_key = '" . TM_EPO_WPML_LANG_META . "' AND pm.meta_value = '" . TM_EPO_WPML()->get_lang() . "'";
         }
     }
     $query .= ' GROUP BY p.post_status';
     $counts = wp_cache_get($cache_key, 'counts');
     if (false === $counts) {
         $results = (array) $wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A);
         $counts = array_fill_keys(get_post_stati(), 0);
         foreach ($results as $row) {
             $counts[$row['post_status']] = $row['num_posts'];
         }
         $counts = (object) $counts;
         wp_cache_set($cache_key, $counts, 'counts');
     }
     return apply_filters('wp_count_posts', $counts, $type, $perm);
 }
 function get_views()
 {
     global $locked_post_status, $avail_post_stati;
     $post_type = $this->screen->post_type;
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     if (TM_EPO_WPML()->is_active()) {
         $num_posts = TM_EPO_HELPER()->wp_count_posts($post_type, 'readable');
     } else {
         $num_posts = wp_count_posts($post_type, 'readable');
     }
     $class = '';
     $allposts = '';
     $current_user_id = get_current_user_id();
     if ($this->user_posts_count) {
         if (isset($_GET['author']) && $_GET['author'] == $current_user_id) {
             $class = ' class="current"';
         }
         $status_links['mine'] = "<a href='edit.php?post_type=product&amp;page=tm-global-epo&author={$current_user_id}'{$class}>" . sprintf(_nx('Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts'), number_format_i18n($this->user_posts_count)) . '</a>';
         $allposts = '&all_posts=1';
     }
     $total_posts = array_sum((array) $num_posts);
     // Subtract post types that are not included in the admin all list.
     foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
         $total_posts -= $num_posts->{$state};
     }
     $class = empty($class) && empty($_REQUEST['post_status']) && empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
     $status_links['all'] = "<a href='edit.php?post_type=product&amp;page=tm-global-epo{$allposts}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts'), number_format_i18n($total_posts)) . '</a>';
     foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
         $class = '';
         $status_name = $status->name;
         if (!in_array($status_name, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             continue;
         }
         if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
             $class = ' class="current"';
         }
         $status_links[$status_name] = "<a href='edit.php?post_status={$status_name}&amp;post_type=product&amp;page=tm-global-epo'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     if (!empty($this->sticky_posts_count)) {
         $class = !empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
         $sticky_link = array('sticky' => "<a href='edit.php?post_type=product&amp;page=tm-global-epo&amp;show_sticky=1'{$class}>" . sprintf(_nx('Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts'), number_format_i18n($this->sticky_posts_count)) . '</a>');
         // Sticky comes after Publish, or if not listed, after All.
         $split = 1 + array_search(isset($status_links['publish']) ? 'publish' : 'all', array_keys($status_links));
         $status_links = array_merge(array_slice($status_links, 0, $split), $sticky_link, array_slice($status_links, $split));
     }
     return $status_links;
 }