public function meta_box($post)
 {
     if ($this->is_wpml) {
         global $wp_post_types;
         $post_type_label = $wp_post_types[TM_EPO_GLOBAL_POST_TYPE]->labels->singular_name != "" ? $wp_post_types[TM_EPO_GLOBAL_POST_TYPE]->labels->singular_name : $wp_post_types[TM_EPO_GLOBAL_POST_TYPE]->labels->name;
         $tmparentpostid = 0;
         $tmaddlang = '';
         $tm_meta_lang = get_post_meta($post->ID, TM_EPO_WPML_LANG_META, true);
         $tm_meta_parent_post_id = get_post_meta($post->ID, TM_EPO_WPML_PARENT_POSTID, true);
         $is_original = false;
         $is_added_translation = false;
         $is_original_lang = '';
         $active_languages = $this->get_active_languages();
         $is_new = false;
         $is_add = false;
         // existing global epo before WPML || new global epo after WPML
         if (!empty($post->ID) && empty($tm_meta_lang) && empty($tm_meta_parent_post_id) || !empty($post->ID) && $tm_meta_parent_post_id === 0 && !empty($tm_meta_lang) || !empty($post->ID) && $tm_meta_parent_post_id == $post->ID) {
             $is_original = true;
         }
         if (!empty($_GET['tmparentpostid']) && !empty($_GET['tmaddlang']) && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add')) {
             $tmparentpostid = (int) $_GET['tmparentpostid'];
             $tmaddlang = $_GET['tmaddlang'];
             $is_added_translation = true;
             $is_original_lang = get_post_meta($tmparentpostid, TM_EPO_WPML_LANG_META, true);
             if (empty($is_original_lang)) {
                 $is_original_lang = $this->get_default_lang();
             }
             if ($is_original_lang != $tmaddlang) {
                 $is_original = false;
             }
             $is_add = true;
         } else {
             if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
                 if (empty($_GET['tmparentpostid']) || empty($_GET['tmaddlang'])) {
                     $is_original = true;
                     $is_original_lang = $tm_meta_lang = $tmaddlang = $this->get_lang();
                     $is_new = true;
                 }
             } else {
             }
         }
         if ($is_original && empty($tm_meta_lang)) {
             $is_original_lang = $tm_meta_lang = $tmaddlang = $this->get_default_lang();
         }
         if ($is_original && empty($tmparentpostid)) {
             $tmparentpostid = $post->ID;
         }
         if (!$is_original && empty($is_original_lang) && !empty($tm_meta_parent_post_id)) {
             $is_original_lang = get_post_meta($tm_meta_parent_post_id, TM_EPO_WPML_LANG_META, true);
             if (empty($is_original_lang)) {
                 $is_original_lang = $this->get_default_lang();
             }
             if (empty($tmparentpostid)) {
                 $tmparentpostid = $tm_meta_parent_post_id;
             }
         }
         if (!$is_original && empty($tmaddlang)) {
             $tmaddlang = $tm_meta_lang;
         }
         TM_EPO_HTML()->tm_make_field(array("nodiv" => 1, "id" => "tmparentpostid", "default" => $tmparentpostid, "type" => "hidden", "tags" => array("id" => TM_EPO_WPML_PARENT_POSTID, "name" => TM_EPO_WPML_PARENT_POSTID)), 1);
         TM_EPO_HTML()->tm_make_field(array("nodiv" => 1, "id" => "tmaddlang", "default" => $tmaddlang, "type" => "hidden", "tags" => array("id" => TM_EPO_WPML_LANG_META, "name" => TM_EPO_WPML_LANG_META)), 1);
         echo '<div class="tm-meta-wpml-lang">';
         echo '<strong>' . sprintf(__('Language of this %s', 'sitepress'), $post_type_label) . '</strong>: ';
         if (!empty($_GET['tmparentpostid']) && !empty($_GET['tmaddlang']) && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add')) {
             echo $this->get_flag($_GET['tmaddlang']);
         } else {
             echo $this->get_flag($tm_meta_lang);
         }
         echo '</div>';
         if (!$is_original) {
             echo '<div class="tm-meta-wpml-translation">';
             echo __('This is a translation of', 'sitepress');
             echo ': <div class="tm-title added">' . $this->get_flag($is_original_lang) . ' ' . get_the_title($tmparentpostid) . $this->edit_lang_link($tmparentpostid, $is_original_lang, $active_languages[$is_original_lang], $tmparentpostid, true) . '</div>';
             echo '</div>';
             $args = array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'date', 'order' => 'asc');
             if (!$is_add) {
                 foreach ($active_languages as $key => $value) {
                     if ($key != $tm_meta_lang && $key != $is_original_lang) {
                         $class = "tm-title";
                         $args['meta_query'] = TM_EPO_HELPER()->build_meta_query('AND', TM_EPO_WPML_LANG_META, $key, '=', 'EXISTS');
                         $other_translations = get_posts($args);
                         if (!empty($other_translations) && isset($other_translations[0]) && is_object($other_translations[0]) && property_exists($other_translations[0], 'ID')) {
                             //has $key code translation
                             $link = $this->edit_lang_link($other_translations[0]->ID, $key, $active_languages[$key], $tmparentpostid, true);
                             $class = "tm-title added";
                         } else {
                             // no translation
                             $link = $this->add_lang_link($tmparentpostid, $key, $active_languages[$key]);
                         }
                         echo '<div class="' . $class . '">' . $this->get_flag($key) . ' ' . $value['display_name'];
                         echo $link . '</div>';
                     }
                 }
             }
         } elseif ($is_original && !$is_new) {
             echo '<div class="tm-meta-wpml-translation">';
             echo __('Translations', 'sitepress');
             $args = array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'date', 'order' => 'asc');
             foreach ($active_languages as $key => $value) {
                 if ($key != $tm_meta_lang) {
                     $class = "tm-title";
                     $args['meta_query'] = TM_EPO_HELPER()->build_meta_query('AND', TM_EPO_WPML_LANG_META, $key, '=', 'EXISTS');
                     $args['meta_query'][] = array('key' => TM_EPO_WPML_PARENT_POSTID, 'value' => $tmparentpostid, 'compare' => '=');
                     $other_translations = get_posts($args);
                     if (!empty($other_translations) && isset($other_translations[0]) && is_object($other_translations[0]) && property_exists($other_translations[0], 'ID')) {
                         //has $key code translation
                         $link = $this->edit_lang_link($other_translations[0]->ID, $key, $active_languages[$key], $tmparentpostid, true);
                         $class = "tm-title added";
                     } else {
                         // no translation
                         $link = $this->add_lang_link($tmparentpostid, $key, $active_languages[$key]);
                     }
                     echo '<div class="' . $class . '">' . $this->get_flag($key) . ' ' . $value['display_name'];
                     echo $link . '</div>';
                 }
             }
             echo '</div>';
         }
     }
 }
 private function _get_setting_upload($setting, $label)
 {
     $html = TM_EPO_HELPER()->file_manager(TM_EPO()->upload_dir, '');
     $_upload_settings = array(array('type' => 'tm_title', 'id' => 'epo_page_options', 'title' => $label), array('title' => __('Upload folder', TM_EPO_TRANSLATION), 'desc' => '<span>' . __('Changing this will only affect future uploads.', TM_EPO_TRANSLATION) . '</span>', 'id' => 'tm_epo_upload_folder', 'default' => 'extra_product_options', 'type' => 'text', 'desc_tip' => false), array('type' => 'tm_html', 'id' => 'epo_page_options_html', 'title' => __('File manager', TM_EPO_TRANSLATION), 'html' => $html), array('type' => 'tm_sectionend', 'id' => 'epo_page_options'));
     return $_upload_settings;
 }
 public function tm_list_column($column, $post_id)
 {
     switch ($column) {
         case 'tm_icl_translations':
             $main_post_id = 0;
             $tm_meta_lang = get_post_meta($post_id, TM_EPO_WPML_LANG_META, true);
             if (empty($tm_meta_lang)) {
                 $tm_meta_lang = TM_EPO_WPML()->get_default_lang();
                 $main_post_id = $post_id;
             }
             if (empty($main_post_id)) {
                 $main_post_id = get_post_meta($post_id, TM_EPO_WPML_PARENT_POSTID, true);
             }
             echo TM_EPO_WPML()->get_flag($tm_meta_lang);
             foreach (TM_EPO_WPML()->get_active_languages() as $key => $value) {
                 if ($key != $tm_meta_lang || TM_EPO_WPML()->get_lang() == 'all') {
                     if ($key == TM_EPO_WPML()->get_default_lang()) {
                         $query = new WP_Query(array('post_type' => TM_EPO_GLOBAL_POST_TYPE, 'post_status' => array('publish'), 'numberposts' => -1, 'orderby' => 'date', 'order' => 'asc', 'p' => $main_post_id));
                     } else {
                         $meta_query = TM_EPO_HELPER()->build_meta_query('AND', TM_EPO_WPML_LANG_META, $key, '=', 'EXISTS');
                         $meta_query[] = array('key' => TM_EPO_WPML_PARENT_POSTID, 'value' => $main_post_id, 'compare' => '=');
                         /*if ($key==TM_EPO_WPML()->get_default_lang()){
                               $meta_query=TM_EPO_HELPER()->build_meta_query('OR',TM_EPO_WPML_LANG_META,$tm_meta_lang,'=', 'NOT EXISTS');
                           }*/
                         $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)) {
                         echo TM_EPO_WPML()->edit_lang_link($query->post->ID, $key, $value, $main_post_id);
                     } elseif (empty($query->posts)) {
                         echo TM_EPO_WPML()->add_lang_link($main_post_id, $key, $value);
                     }
                 }
             }
             break;
         case 'product_cat':
             $tm_meta = get_post_meta($post_id, 'tm_meta_disable_categories', true);
             if ($tm_meta) {
                 echo '<span class="tm_color_pomegranate">' . __('Disabled', TM_EPO_TRANSLATION) . '</span>';
             } else {
                 $terms = get_the_term_list($post_id, 'product_cat', '', ' , ', '');
                 if (is_string($terms)) {
                     echo $terms;
                 }
             }
             break;
         case 'priority':
             $post_id = TM_EPO_WPML()->get_original_id($post_id, TM_EPO_GLOBAL_POST_TYPE);
             $tm_meta = get_post_meta($post_id, 'tm_meta', true);
             if (is_array($tm_meta)) {
                 if (is_array($tm_meta['priority'])) {
                     $tm_meta['priority'] = $tm_meta['priority'][0];
                 }
                 echo $tm_meta['priority'];
             }
             break;
         case 'product_ids':
             $tm_meta = get_post_meta($post_id, 'tm_meta_product_ids', true);
             if (!empty($tm_meta)) {
                 if (is_array($tm_meta)) {
                     if (count($tm_meta) == 1 && !empty($tm_meta[0])) {
                         $title = get_the_title($tm_meta[0]);
                         $tm_meta[0] = '<a title="' . esc_attr($title) . '" href="' . admin_url('post.php?action=edit&post=' . $tm_meta[0]) . '">' . $title . '</a>';
                     } else {
                         foreach ($tm_meta as $key => $value) {
                             if (!empty($value)) {
                                 $title = get_the_title($value);
                                 $tm_meta[$key] = '<a class="tm-tooltip" title="' . esc_attr($title) . '" href="' . admin_url('post.php?action=edit&post=' . $value) . '">' . $value . '</a>';
                             }
                         }
                     }
                     echo implode(" , ", $tm_meta);
                 } else {
                     echo '';
                 }
             }
             break;
     }
 }
 /**
  * Generates element sub-options for selectbox, checkbox and radio buttons.
  *
  * @since 1.0.0
  * @access private
  */
 private function builder_sub_options($options = array(), $name = "multiple_selectbox_options", $counter = NULL, $default_value = NULL)
 {
     $o = array();
     $upload = "";
     $uploadp = "";
     $class = "";
     $additional_currencies = TM_EPO_HELPER()->wc_aelia_cs_enabled_currencies();
     if ($name == "multiple_radiobuttons_options" || $name == "multiple_checkboxes_options") {
         if ($name == "multiple_radiobuttons_options") {
             $upload = '&nbsp;<span data-tm-tooltip-html="' . esc_attr(__("Choose the image to use in place of the radio button.", TM_EPO_TRANSLATION)) . '" class="tm_upload_button cp_button tm-tooltip"><i class="tcfa tcfa-upload"></i></span>';
         } elseif ($name == "multiple_checkboxes_options") {
             $upload = '&nbsp;<span data-tm-tooltip-html="' . esc_attr(__("Choose the image to use in place of the checkbox.", TM_EPO_TRANSLATION)) . '" class="tm_upload_button cp_button tm-tooltip"><i class="tcfa tcfa-upload"></i></span>';
         }
         $uploadp = '&nbsp;<span data-tm-tooltip-html="' . esc_attr(__("Choose the image to replace the product image with.", TM_EPO_TRANSLATION)) . '" class="tm_upload_button tm_upload_buttonp cp_button tm-tooltip"><i class="tcfa tcfa-upload"></i></span>';
         $class = " withupload";
     }
     if ($name == "multiple_selectbox_options") {
         $uploadp = '&nbsp;<span data-tm-tooltip-html="' . esc_attr(__("Choose the image to replace the product image with.", TM_EPO_TRANSLATION)) . '" class="tm_upload_button tm_upload_buttonp cp_button tm-tooltip"><i class="tcfa tcfa-upload"></i></span>';
         $class = " withupload";
     }
     $o["title"] = array("id" => $name . "_title", "default" => "", "type" => "text", "nodiv" => 1, "tags" => array("class" => "t tm_option_title", "id" => $name . "_title", "name" => $name . "_title", "value" => ""));
     $o["value"] = array("id" => $name . "_value", "default" => "", "type" => "text", "nodiv" => 1, "tags" => array("class" => "t tm_option_value", "id" => $name . "_value", "name" => $name . "_value"));
     $o["price"] = array("id" => $name . "_price", "default" => "", "type" => "number", "nodiv" => 1, "tags" => array("class" => "n tm_option_price", "id" => $name . "_price", "name" => $name . "_price"));
     $o["sale_price"] = array("id" => $name . "_sale_price", "default" => "", "type" => "number", "nodiv" => 1, "tags" => array("class" => "n tm_option_sale_price", "id" => $name . "_price", "name" => $name . "_price"));
     $o["image"] = array("id" => $name . "_image", "default" => "", "type" => "hidden", "nodiv" => 1, "tags" => array("class" => "n tm_option_image" . $class, "id" => $name . "_image", "name" => $name . "_image"), "extra" => $upload);
     $o["imagep"] = array("id" => $name . "_imagep", "default" => "", "type" => "hidden", "nodiv" => 1, "tags" => array("class" => "n tm_option_image tm_option_imagep" . $class, "id" => $name . "_imagep", "name" => $name . "_imagep"));
     $o["price_type"] = array("id" => $name . "_price_type", "default" => "", "type" => "select", "options" => array(array("text" => __("Fixed amount", TM_EPO_TRANSLATION), "value" => ""), array("text" => __("Percent of the original price", TM_EPO_TRANSLATION), "value" => "percent"), array("text" => __("Percent of the original price + options", TM_EPO_TRANSLATION), "value" => "percentcurrenttotal")), "nodiv" => 1, "tags" => array("class" => "n tm_option_price_type " . $name, "id" => $name . "_price_type", "name" => $name . "_price_type"));
     $o["url"] = array("id" => $name . "_url", "default" => "", "type" => "text", "nodiv" => 1, "tags" => array("class" => "t tm_option_url", "id" => $name . "_url", "name" => $name . "_url", "value" => ""));
     $o["description"] = array("id" => $name . "_description", "default" => "", "type" => "text", "nodiv" => 1, "tags" => array("class" => "t tm_option_description", "id" => $name . "_description", "name" => $name . "_description", "value" => ""));
     if ($this->woo_subscriptions_check && $name != "multiple_selectbox_options") {
         $o["price_type"]['options'][] = array("text" => __("Subscription fee", TM_EPO_TRANSLATION), "value" => "subscriptionfee");
     }
     if ($name != "multiple_selectbox_options") {
         $o["price_type"]['options'][] = array("text" => __("Fee", TM_EPO_TRANSLATION), "value" => "fee");
     }
     if (!$options) {
         $options = array("title" => array(""), "value" => array(""), "price" => array(""), "sale_price" => array(""), "image" => array(""), "imagep" => array(""), "price_type" => array(""), "url" => array(""), "description" => array(""));
     }
     $del = TM_EPO_HTML()->tm_make_button(array("text" => "<i class='tcfa tcfa-times'></i>", "tags" => array("href" => "#delete", "class" => "button button-secondary button-small builder_panel_delete")), 0);
     $drag = TM_EPO_HTML()->tm_make_button(array("text" => "<i class='tcfa tcfa-sort'></i>", "tags" => array("href" => "#move", "class" => "builder_panel_move")), 0);
     $out = "<div class='tm-row nopadding multiple_options tc-clearfix'>" . "<div class='tm-cell col-auto tm_cell_move'>&nbsp;</div>" . "<div class='tm-cell col-auto tm_cell_default'>" . ($name == "multiple_checkboxes_options" ? __("Checked", TM_EPO_TRANSLATION) : __("Default", TM_EPO_TRANSLATION)) . "</div>" . "<div class='tm-cell col-3 tm_cell_title'>" . __("Label", TM_EPO_TRANSLATION) . "</div>" . "<div class='tm-cell col-2 tm_cell_images'>" . __("Images", TM_EPO_TRANSLATION) . "</div>" . "<div class='tm-cell col-0 tm_cell_value'>" . __("Value", TM_EPO_TRANSLATION) . "</div>" . "<div class='tm-cell col-auto tm_cell_price'>" . __("Price", TM_EPO_TRANSLATION) . "</div>" . "<div class='tm-cell col-auto tm_cell_delete'><span class='tm-button button button-primary button-large builder_panel_delete_all'>" . __("Delete all options", TM_EPO_TRANSLATION) . "</span></div>" . "</div>" . "<div class='panels_wrap nof_wrapper'>";
     $d_counter = 0;
     foreach ($options["title"] as $ar => $el) {
         $out .= "<div class='options_wrap'>" . "<div class='tm-row nopadding tc-clearfix'>";
         $o["title"]["default"] = $options["title"][$ar];
         //label
         $o["title"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_title][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["title"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["title"]["tags"]["name"]) . "_" . $ar;
         $o["value"]["default"] = $options["value"][$ar];
         //value
         $o["value"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_value][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["value"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["value"]["tags"]["name"]) . "_" . $ar;
         $o["price"]["default"] = $options["price"][$ar];
         //price
         $o["price"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_price][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["price"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["price"]["tags"]["name"]) . "_" . $ar;
         $o["sale_price"]["default"] = $options["sale_price"][$ar];
         //sale_price
         $o["sale_price"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_sale_price][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["sale_price"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["sale_price"]["tags"]["name"]) . "_" . $ar;
         $o["image"]["default"] = $options["image"][$ar];
         //image
         $o["image"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_image][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["image"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["image"]["tags"]["name"]) . "_" . $ar;
         $o["image"]["extra"] = $upload . '<span class="tm_upload_image"><img class="tm_upload_image_img" alt="" src="' . $options["image"][$ar] . '" /></span>';
         $o["imagep"]["default"] = $options["imagep"][$ar];
         //imagep
         $o["imagep"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_imagep][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["imagep"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["imagep"]["tags"]["name"]) . "_" . $ar;
         $o["imagep"]["extra"] = $uploadp . '<span class="tm_upload_image tm_upload_imagep"><img class="tm_upload_image_img" alt="" src="' . $options["imagep"][$ar] . '" /></span>';
         $o["price_type"]["default"] = $options["price_type"][$ar];
         //price type
         $o["price_type"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_price_type][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["price_type"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["price_type"]["tags"]["name"]) . "_" . $ar;
         $o["url"]["default"] = $options["url"][$ar];
         //url
         $o["url"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_url][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["url"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["url"]["tags"]["name"]) . "_" . $ar;
         $o["description"]["default"] = $options["description"][$ar];
         //description
         $o["description"]["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_description][" . (is_null($counter) ? 0 : $counter) . "][]";
         $o["description"]["tags"]["id"] = str_replace(array("[", "]"), "", $o["description"]["tags"]["name"]) . "_" . $ar;
         if ($name == "multiple_checkboxes_options") {
             $default_select = '<input type="checkbox" value="' . $d_counter . '" name="tm_meta[tmfbuilder][' . $name . '_default_value][' . (is_null($counter) ? 0 : $counter) . '][]" class="tm-default-checkbox" ' . checked(is_null($counter) ? "" : isset($default_value[$counter]) ? in_array($d_counter, $default_value[$counter]) : "", true, 0) . '>';
         } else {
             $default_select = '<input type="radio" value="' . $d_counter . '" name="tm_meta[tmfbuilder][' . $name . '_default_value][' . (is_null($counter) ? 0 : $counter) . ']" class="tm-default-radio" ' . checked(is_null($counter) ? "" : isset($default_value[$counter]) && !is_array($default_value[$counter]) ? (string) $default_value[$counter] : "", $d_counter, 0) . '>';
         }
         $default_select = '<span class="tm-hidden-inline">' . ($name == "multiple_checkboxes_options" ? __("Checked", TM_EPO_TRANSLATION) : __("Default", TM_EPO_TRANSLATION)) . '</span>' . $default_select;
         $out .= "<div class='tm-cell col-auto tm_cell_move'>" . $drag . "</div>";
         $out .= "<div class='tm-cell col-auto tm_cell_default'>" . $default_select . "</div>";
         $out .= "<div class='tm-cell col-3 tm_cell_title'>" . TM_EPO_HTML()->tm_make_field($o["title"], 0) . "</div>";
         $out .= "<div class='tm-cell col-2 tm_cell_images'>" . TM_EPO_HTML()->tm_make_field($o["image"], 0) . TM_EPO_HTML()->tm_make_field($o["imagep"], 0) . "</div>";
         $out .= "<div class='tm-cell col-0 tm_cell_value'>" . TM_EPO_HTML()->tm_make_field($o["value"], 0) . "</div>";
         $out .= "<div class='tm-cell col-auto tm_cell_price'>";
         if (!empty($additional_currencies) && is_array($additional_currencies)) {
             $_copy_value = $o["price"];
             $_sale_copy_value = $o["sale_price"];
             $o["price"]["html_before_field"] = '<span class="tm-choice-currency">' . TM_EPO_HELPER()->wc_base_currency() . '</span>';
             $o["sale_price"]["html_before_field"] = '<span class="tm-choice-currency">' . TM_EPO_HELPER()->wc_base_currency() . '</span>' . '<span class="tm-choice-sale">' . __("Sale", TM_EPO_TRANSLATION) . '</span>';
             $out .= TM_EPO_HTML()->tm_make_field($o["price"], 0);
             $out .= TM_EPO_HTML()->tm_make_field($o["sale_price"], 0);
             foreach ($additional_currencies as $ckey => $currency) {
                 $mt_prefix = TM_EPO_HELPER()->get_currency_price_prefix($currency);
                 $copy_value = $_copy_value;
                 $copy_value["default"] = isset($options["price_" . $currency][$ar]) ? $options["price" . $mt_prefix][$ar] : "";
                 $copy_value["id"] .= $mt_prefix;
                 $copy_value["html_before_field"] = '<span class="tm-choice-currency">' . $currency . '</span>';
                 $copy_value["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_price" . $mt_prefix . "][" . (is_null($counter) ? 0 : $counter) . "][]";
                 $copy_value["tags"]["id"] = str_replace(array("[", "]"), "", $copy_value["tags"]["name"]) . "_" . $ar;
                 $out .= TM_EPO_HTML()->tm_make_field($copy_value, 0);
                 $copy_value = $_sale_copy_value;
                 $copy_value["default"] = isset($options["sale_price_" . $currency][$ar]) ? $options["sale_price" . $mt_prefix][$ar] : "";
                 $copy_value["id"] .= $mt_prefix;
                 $copy_value["html_before_field"] = '<span class="tm-choice-currency">' . $currency . '</span>' . '<span class="tm-choice-sale">' . __("Sale", TM_EPO_TRANSLATION) . '</span>';
                 $copy_value["tags"]["name"] = "tm_meta[tmfbuilder][" . $name . "_sale_price" . $mt_prefix . "][" . (is_null($counter) ? 0 : $counter) . "][]";
                 $copy_value["tags"]["id"] = str_replace(array("[", "]"), "", $copy_value["tags"]["name"]) . "_" . $ar;
                 $out .= TM_EPO_HTML()->tm_make_field($copy_value, 0);
             }
         } else {
             $out .= TM_EPO_HTML()->tm_make_field($o["price"], 0);
             $o["sale_price"]["html_before_field"] = '<span class="tm-choice-sale">' . __("Sale", TM_EPO_TRANSLATION) . '</span>';
             $out .= TM_EPO_HTML()->tm_make_field($o["sale_price"], 0);
         }
         $out .= TM_EPO_HTML()->tm_make_field($o["price_type"], 0) . "</div>";
         $out .= "<div class='tm-cell col-auto tm_cell_delete'>" . $del . "</div>";
         $out .= "<div class='tm-cell col-12 tm_cell_description'><span class='tm-inline-label bsbb'>" . __("Description", TM_EPO_TRANSLATION) . "</span>" . TM_EPO_HTML()->tm_make_field($o["description"], 0) . "</div>";
         $out .= "<div class='tm-cell col-12 tm_cell_url'><span class='tm-inline-label bsbb'>" . __("URL", TM_EPO_TRANSLATION) . "</span>" . TM_EPO_HTML()->tm_make_field($o["url"], 0) . "</div>";
         $out .= "</div></div>";
         $d_counter++;
     }
     $out .= "</div>";
     $out .= ' <a class="tm-button button button-primary button-large builder-panel-add" href="#">' . __("Add item", TM_EPO_TRANSLATION) . '</a>';
     $out .= ' <a class="tm-button button button-primary button-large builder-panel-mass-add" href="#">' . __("Mass add", TM_EPO_TRANSLATION) . '</a>';
     return $out;
 }
 public function validate_product_id($product_id, $qty, $form_prefix = "")
 {
     $passed = true;
     if ($form_prefix) {
         $form_prefix = "_" . $form_prefix;
     }
     $cpf_price_array = $this->get_product_tm_epos($product_id);
     $global_price_array = $cpf_price_array['global'];
     $local_price_array = $cpf_price_array['local'];
     if (empty($global_price_array) && empty($local_price_array)) {
         return $passed;
     }
     $global_prices = array('before' => array(), 'after' => array());
     $global_sections = array();
     foreach ($global_price_array as $priority => $priorities) {
         foreach ($priorities as $pid => $field) {
             if (isset($field['sections'])) {
                 foreach ($field['sections'] as $section_id => $section) {
                     if (isset($section['sections_placement'])) {
                         $global_prices[$section['sections_placement']][$priority][$pid]['sections'][$section_id] = $section;
                         $global_sections[$section['sections_uniqid']] = $section;
                     }
                 }
             }
         }
     }
     if (!empty($global_price_array) && is_array($global_price_array) && count($global_price_array) > 0 || !empty($local_price_array) && is_array($local_price_array) && count($local_price_array) > 0) {
         $tmcp_post_fields = TM_EPO_HELPER()->array_filter_key($_POST);
         if (is_array($tmcp_post_fields) && !empty($tmcp_post_fields) && count($tmcp_post_fields) > 0) {
             $tmcp_post_fields = array_map('stripslashes_deep', $tmcp_post_fields);
         }
         $loop = -1;
         $_return = $this->validate_product_id_loop($global_sections, $global_prices, 'before', $tmcp_post_fields, $passed, $loop, $form_prefix);
         extract($_return, EXTR_OVERWRITE);
         // todo: move this code to a function
         if (!empty($local_price_array) && is_array($local_price_array) && count($local_price_array) > 0) {
             foreach ($local_price_array as $tmcp) {
                 if (in_array($tmcp['type'], $this->element_post_types)) {
                     $loop++;
                 }
                 if (empty($tmcp['type']) || empty($tmcp['required'])) {
                     continue;
                 }
                 if ($tmcp['required']) {
                     $tmcp_attributes = $this->translate_fields($tmcp['attributes'], $tmcp['type'], $loop, $form_prefix);
                     $_passed = true;
                     switch ($tmcp['type']) {
                         case "checkbox":
                             $_check = array_intersect($tmcp_attributes, array_keys($tmcp_post_fields));
                             if (empty($_check) || count($_check) == 0) {
                                 $_passed = false;
                             }
                             break;
                         case "radio":
                             foreach ($tmcp_attributes as $attribute) {
                                 if (!isset($tmcp_post_fields[$attribute])) {
                                     $_passed = false;
                                 }
                             }
                             break;
                         case "select":
                             foreach ($tmcp_attributes as $attribute) {
                                 if (!isset($tmcp_post_fields[$attribute]) || $tmcp_post_fields[$attribute] == "") {
                                     $_passed = false;
                                 }
                             }
                             break;
                     }
                     if (!$_passed) {
                         $passed = false;
                         wc_add_notice(sprintf(__('"%s" is a required field.', TM_EPO_TRANSLATION), $tmcp['label']), 'error');
                     }
                 }
             }
         }
         $_return = $this->validate_product_id_loop($global_sections, $global_prices, 'after', $tmcp_post_fields, $passed, $loop, $form_prefix);
         extract($_return, EXTR_OVERWRITE);
     }
     return $passed;
 }
 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;
 }