/** * Checks if a product contains at least one active part * @param type $product_id Product ID * @return boolean */ public static function has_part($product_id) { $parts = get_option("wpc-parts"); $wc_product = wc_get_product($product_id); $wpc_metas = get_post_meta($product_id, 'wpc-metas', true); if ($wc_product->product_type == "variable") { $variations = $wc_product->get_available_variations(); foreach ($variations as $variation) { $variation_id = $variation['variation_id']; foreach ($parts as $part) { $part_key = sanitize_title($part); if (WPD_Admin::get_proper_value($wpc_metas, $variation_id, array()) && WPD_Admin::get_proper_value($wpc_metas[$variation_id], 'parts', array()) && WPD_Admin::get_proper_value($wpc_metas[$variation_id]['parts'], $part_key, array())) { $part_media_id = WPD_Admin::get_proper_value($wpc_metas[$variation_id]['parts'][$part_key], 'bg-inc', ""); } else { $part_media_id = ""; } if ($part_media_id || $part_media_id == "0") { return true; } } } } else { foreach ($parts as $part) { $part_key = sanitize_title($part); if (WPD_Admin::get_proper_value($wpc_metas, $product_id, array()) && WPD_Admin::get_proper_value($wpc_metas[$product_id], 'parts', array()) && WPD_Admin::get_proper_value($wpc_metas[$product_id]['parts'], $part_key, array())) { $part_media_id = WPD_Admin::get_proper_value($wpc_metas[$product_id]['parts'][$part_key], 'bg-inc', ""); } else { $part_media_id = ""; } if ($part_media_id || $part_media_id == "0") { return true; } } } return false; }
private function generate_pdf_layers($variation_id, $layers_array, $output_file) { global $wpc_options_settings; $product_id = WPD_Product::get_parent($variation_id); $wpc_metas = get_post_meta($product_id, 'wpc-metas', true); $product_metas = WPD_Admin::get_proper_value($wpc_metas, $variation_id, array()); $variation_output_settings = WPD_Admin::get_proper_value($product_metas, "output-settings", array()); $global_output_settings = $wpc_options_settings['wpc-output-options']; $pdf_format = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-format", "A0"); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-format", "A0"); $pdf_orientation = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-orientation", "P"); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-orientation", "P"); $pdf_margin_lr = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-margin-lr", 20); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-margin-lr", 20); $pdf_margin_tb = WPD_Product::get_option($variation_output_settings, $global_output_settings, "pdf-margin-tb", 20); //WPD_Admin::get_proper_value($wpc_output_options, "pdf-margin-tb", 20); /*if ($nbCol <= 0 || $total <= 0) { $nbCol = 1; $total = 1; }*/ $pdf = new TCPDF($pdf_orientation, PDF_UNIT, $pdf_format, true, 'UTF-8', false); $pdf->SetCreator("Woocommerce Products Designer by ORION"); $pdf->SetAuthor('Woocommerce Products Designer by ORION'); $pdf->SetTitle('Output'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins($pdf_margin_lr, $pdf_margin_tb, -1, true); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } $pdf->AddPage(); //$pdf->Image($input_file, '', '', '', '', '', false, 'C', false, 300, 'C', false, false, 0, false, false, false); $layers_id = 0; foreach ($layers_array as $layer) { $pdf->startLayer('layer' . $layers_id, true, true, false); $pdf->Image($layer, '', '', '', '', '', '', 'C', true, 300, 'C', false, false, 0, '', false, false); $pdf->endLayer(); $layers_id++; } // $defaultImageSize = getimagesize($img_output_file_path); // $pageWidth = $pdf->getPageWidth(); // $pagHeight = $pdf->getPageHeight(); // // $nblign = $total / $nbCol; // $marge = 10; // // //Set width and height // $w = ($pageWidth - $marge * ($nbCol + 1)) / $nbCol; // $h = ($defaultImageSize[1] * $w) / $defaultImageSize[0]; // if ($h * ($nblign + 1) + 20 > $pagHeight) { // $h = ($pagHeight - 2 * ($nblign + 1) - 20) / ($nblign + 1); // $w = ($defaultImageSize[0] * $h) / $defaultImageSize[1]; // $marge = ($pageWidth - ($w * $nbCol)) / ($nbCol + 1); // } // // //Print images // $x = $marge; // $y = 20; // $i = 0; // $layers_id = 0; // while ($i < $total) { // for ($i2 = 0; $i2 < $nbCol; $i2++) { // if ($i < $total) { // foreach ($layers_array as $layer) { // $pdf->startLayer('layer' . $layers_id, true, true, false); // $pdf->Image($layer, $x, $y, $w, $h, '', '', '', true, 300, '', false, false, 0, '', false, false); // $pdf->endLayer(); // $layers_id ++; // } // // $x += ($w + $marge); // $i ++; // } // } // $x = $marge; // $y += $h; // } $pdf->Output($output_file, 'F'); }
private function get_parts() { $parts = get_option("wpc-parts"); $is_first = true; $wpc_metas = get_post_meta($this->root_item_id, 'wpc-metas', true); ?> <div id="product-part-container"> <ul id="wpc-parts-bar"> <?php foreach ($parts as $part) { $part_key = sanitize_title($part); if (WPD_Admin::get_proper_value($wpc_metas, $this->item_id, array()) && WPD_Admin::get_proper_value($wpc_metas[$this->item_id], 'parts', array()) && WPD_Admin::get_proper_value($wpc_metas[$this->item_id]['parts'], $part_key, array())) { $part_media_id = WPD_Admin::get_proper_value($wpc_metas[$this->item_id]['parts'][$part_key], 'bg-inc'); $part_bg_img = WPD_Admin::get_proper_value($wpc_metas[$this->item_id]['parts'][$part_key], 'bg-not-inc'); if (WPD_Admin::get_proper_value($wpc_metas[$this->item_id]['parts'][$part_key], 'ov')) { $part_ov_img = WPD_Admin::get_proper_value($wpc_metas[$this->item_id]['parts'][$part_key]['ov'], 'img'); $overlay_included = WPD_Admin::get_proper_value($wpc_metas[$this->item_id]['parts'][$part_key]['ov'], 'inc', 1); } } if (!($part_media_id || $part_media_id == "0")) { continue; } $class = ""; if ($is_first) { $class = "class='active'"; } $is_first = false; $img_ov_src = ""; if (isset($part_ov_img)) { $img_ov_src = wp_get_attachment_url($part_ov_img); } $img_bg_src = ""; if (!empty($part_bg_img)) { $img_bg_src = wp_get_attachment_url($part_bg_img); } if ($part_media_id == "0") { $final_img_url = ""; $part_img = $part; } else { $final_img_url = wp_get_attachment_url($part_media_id); $part_img = '<img src="' . $final_img_url . '">'; } ?> <li data-id="<?php echo $part_key; ?> " data-url="<?php echo $final_img_url; ?> " <?php echo $class; ?> data-placement="top" data-original-title="<?php echo $part; ?> " data-bg="<?php echo $img_bg_src; ?> " data-ov="<?php echo $img_ov_src; ?> " data-ovni="<?php echo $overlay_included; ?> "> <?php echo $part_img; ?> </li> <?php } ?> </ul> </div> <?php }
function get_products_display($atts) { global $wpdb; extract(shortcode_atts(array('cat' => '', 'products' => '', 'cols' => '3'), $atts, 'wpc-products')); $where = ""; if (!empty($cat)) { $where .= " AND {$wpdb->term_relationships}.term_taxonomy_id IN ({$cat})"; } else { if (!empty($products)) { $where .= " AND p.ID IN ({$products})"; } else { $where = ""; } } $search = '"is-customizable";s:1:"1"'; $products = $wpdb->get_results("\n SELECT distinct p.id\n FROM {$wpdb->posts} p\n JOIN {$wpdb->postmeta} pm on pm.post_id = p.id\n INNER JOIN {$wpdb->term_relationships} ON (p.ID = {$wpdb->term_relationships}.object_id\t) \n WHERE p.post_type = 'product'\n AND p.post_status = 'publish'\n AND pm.meta_key = 'wpc-metas'\n {$where}\n AND pm.meta_value like '%{$search}%'\n "); ob_start(); ?> <div class='container wp-products-container wpc-grid wpc-grid-pad'> <?php $shop_currency_symbol = get_woocommerce_currency_symbol(); foreach ($products as $product) { $prod = wc_get_product($product->id); $url = get_permalink($product->id); $wpc_metas = get_post_meta($product->id, 'wpc-metas', true); $can_design_from_blank = WPD_Admin::get_proper_value($wpc_metas, 'can-design-from-blank', ""); ?> <div class='wpc-col-1-<?php echo $cols; ?> cat-item-ctn'> <div class='cat-item'> <h3><?php echo $prod->post->post_title; ?> <span><?php echo $shop_currency_symbol . '' . $prod->price; ?> </span> </h3> <?php echo get_the_post_thumbnail($product->id, 'medium'); ?> <hr> <?php if (!empty($can_design_from_blank)) { ?> <a href="<?php echo WPD_Product::get_url($product->id); ?> " class='btn-choose'> <?php _e("Design from blank", "wpd"); ?> </a><?php } ?> </div> </div> <?php } ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Outputs the settings fields * @param array $options Settings to output */ public static function admin_fields($options, $metas = false) { foreach ($options as $value) { if (!isset($value['type'])) { continue; } if (!isset($value['id'])) { $value['id'] = ''; } if (!isset($value['name'])) { $value['name'] = $value['id']; } if (!isset($value['title'])) { $value['title'] = isset($value['name']) ? $value['name'] : ''; } if (!isset($value['class'])) { $value['class'] = ''; } if (!isset($value['css'])) { $value['css'] = ''; } if (!isset($value['default'])) { $value['default'] = ''; } if (!isset($value['desc'])) { $value['desc'] = ''; } if (!isset($value['desc_tip'])) { $value['desc_tip'] = false; } // Custom attribute handling $custom_attributes = array(); if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) { foreach ($value['custom_attributes'] as $attribute => $attribute_value) { $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; } } // Description handling if ($value['desc_tip'] === true) { $description = ''; $tip = $value['desc']; } elseif (!empty($value['desc_tip'])) { $description = $value['desc']; $tip = $value['desc_tip']; } elseif (!empty($value['desc'])) { $description = $value['desc']; $tip = ''; } else { $description = $tip = ''; } if ($description && in_array($value['type'], array('textarea', 'radio'))) { $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>'; } elseif ($description && in_array($value['type'], array('checkbox'))) { $description = wp_kses_post($description); } elseif ($description) { $description = '<span class="description">' . wp_kses_post($description) . '</span>'; } if ($tip && in_array($value['type'], array('checkbox'))) { $tip = '<p class="description">' . $tip . '</p>'; } elseif ($tip) { $tip = '<img class="help_tip" data-tip="' . esc_attr($tip) . '" src="' . WPD_URL . 'admin/images/help.png" height="16" width="16" />'; } // Metas attributes if ($metas) { $wpc_metas = get_post_meta(get_the_ID(), 'wpc-metas', true); $variations_metas = WPD_Admin::get_proper_value($wpc_metas, $value['data-id'], array()); $wpc_output_product_settings = WPD_Admin::get_proper_value($variations_metas, $value['data-option'], array()); $option_value = WPD_Admin::get_proper_value($wpc_output_product_settings, $value['data-field'], $value['default']); } else { $option_value = self::get_option($value['id'], $value['default']); } // Switch based on type switch ($value['type']) { // Section Titles case 'title': if (!empty($value['title'])) { echo '<h3>' . esc_html($value['title']) . '</h3>'; } if (!empty($value['desc'])) { echo wpautop(wptexturize(wp_kses_post($value['desc']))); } echo '<table class="form-table">' . "\n\n"; if (!empty($value['id'])) { do_action('wpc_settings_' . sanitize_title($value['id'])); } break; // Section Ends // Section Ends case 'sectionend': if (!empty($value['id'])) { do_action('wpc_settings_' . sanitize_title($value['id']) . '_end'); } echo '</table>'; if (!empty($value['id'])) { do_action('wpc_settings_' . sanitize_title($value['id']) . '_after'); } break; // Standard text inputs and subtypes like 'number' // Standard text inputs and subtypes like 'number' case 'text': case 'email': case 'number': case 'color': case 'password': $type = $value['type']; $class = ''; // $option_value = self::wpc_get_option($value['id'], $value['default']); if ($value['type'] == 'color') { $type = 'text'; $value['class'] .= 'colorpick'; $description .= '<div id="colorPickerDiv_' . esc_attr($value['id']) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>'; } ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <input name="<?php echo esc_attr($value['name']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="<?php echo esc_attr($type); ?> " style="<?php echo esc_attr($value['css']); ?> " value="<?php echo esc_attr($option_value); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> /> <?php echo $description; ?> </td> </tr><?php break; // Textarea // Textarea case 'textarea': // $option_value = wpc_get_option($value['id'], $value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <?php echo $description; ?> <textarea name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> ><?php echo esc_textarea($option_value); ?> </textarea> </td> </tr><?php break; // Select boxes // Select boxes case 'select': case 'multiselect': // $option_value = self::wpc_get_option($value['id'], $value['default']); // if($metas) // $option_value=WPD_Admin::get_proper_value($wpc_output_product_settings,$value['data-field'],$value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <select name="<?php echo esc_attr($value['id']); if ($value['type'] == 'multiselect') { echo '[]'; } ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php if ($value['type'] == 'multiselect') { echo 'multiple="multiple"'; } ?> > <?php foreach ($value['options'] as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php if (is_array($option_value)) { selected(in_array($key, $option_value), true); } else { selected($option_value, $key); } ?> ><?php echo $val; ?> </option> <?php } ?> </select> <?php echo $description; ?> </td> </tr><?php break; case 'groupedselect': // $option_value = self::wpc_get_option($value['id'], $value['default']); // if($metas) // $option_value=WPD_Admin::get_proper_value($wpc_output_product_settings,$value['data-field'],$value['default']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <select name="<?php echo esc_attr($value['id']); if ($value['type'] == 'multiselect') { echo '[]'; } ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php if ($value['type'] == 'multiselect') { echo 'multiple="multiple"'; } ?> > <?php foreach ($value['options'] as $group => $group_values) { ?> <optgroup label="<?php echo $group; ?> "><?php foreach ($group_values as $key => $val) { ?> <option value="<?php echo esc_attr($key); ?> " <?php if (is_array($option_value)) { selected(in_array($key, $option_value), true); } else { selected($option_value, $key); } ?> ><?php echo $val; ?> </option> <?php } ?> </optgroup><?php } ?> </select> <?php echo $description; ?> </td> </tr><?php break; // Radio inputs // Radio inputs case 'radio': // $option_value = self::wpc_get_option($value['id'], $value['default']); // if($metas) // $option_value=WPD_Admin::get_proper_value($wpc_output_product_settings,$value['data-field'],""); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tip; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <fieldset> <?php echo $description; ?> <ul> <?php foreach ($value['options'] as $key => $val) { ?> <li> <label><input name="<?php echo esc_attr($value['id']); ?> " value="<?php echo $key; ?> " type="radio" style="<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> <?php checked($key, $option_value); ?> /> <?php echo $val; ?> </label> </li> <?php } ?> </ul> </fieldset> </td> </tr><?php break; // Checkbox input // Checkbox input case 'checkbox': $visbility_class = array(); if (!isset($value['hide_if_checked'])) { $value['hide_if_checked'] = false; } if (!isset($value['show_if_checked'])) { $value['show_if_checked'] = false; } if ($value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes') { $visbility_class[] = 'hidden_option'; } if ($value['hide_if_checked'] == 'option') { $visbility_class[] = 'hide_options_if_checked'; } if ($value['show_if_checked'] == 'option') { $visbility_class[] = 'show_options_if_checked'; } if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) { ?> <tr valign="top" class="<?php echo esc_attr(implode(' ', $visbility_class)); ?> "> <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?> </th> <td class="forminp forminp-checkbox"> <fieldset> <?php } else { ?> <fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?> "> <?php } if (!empty($value['title'])) { ?> <legend class="screen-reader-text"><span><?php echo esc_html($value['title']); ?> </span></legend> <?php } ?> <label for="<?php echo $value['id']; ?> "> <input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="checkbox" value="1" <?php checked($option_value, 'yes'); ?> <?php echo implode(' ', $custom_attributes); ?> /> <?php echo $description; ?> </label> <?php echo $tip; ?> <?php if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) { ?> </fieldset> </td> </tr> <?php } else { ?> </fieldset> <?php } break; // Image width settings // Image width settings case 'image_width': $width = $this->wpc_get_option($value['id'] . '[width]', $value['default']['width']); $height = $this->wpc_get_option($value['id'] . '[height]', $value['default']['height']); $crop = checked(1, $this->wpc_get_option($value['id'] . '[crop]', $value['default']['crop']), false); ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?> <?php echo $tip; ?> </th> <td class="forminp image_width_settings"> <input name="<?php echo esc_attr($value['id']); ?> [width]" id="<?php echo esc_attr($value['id']); ?> -width" type="text" size="3" value="<?php echo $width; ?> " /> × <input name="<?php echo esc_attr($value['id']); ?> [height]" id="<?php echo esc_attr($value['id']); ?> -height" type="text" size="3" value="<?php echo $height; ?> " />px <label><input name="<?php echo esc_attr($value['id']); ?> [crop]" id="<?php echo esc_attr($value['id']); ?> -crop" type="checkbox" <?php echo $crop; ?> /> <?php _e('Hard Crop?', 'wpd'); ?> </label> </td> </tr><?php break; // Single page selects // Single page selects case 'single_select_page': $args = array('name' => $value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, 'selected' => absint(self::get_option($value['id']))); if (isset($value['args'])) { $args = wp_parse_args($value['args'], $args); } ?> <tr valign="top" class="single_select_page"> <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?> <?php echo $tip; ?> </th> <td class="forminp"> <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page…', 'wpd') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?> </td> </tr><?php break; /* // Single country selects case 'single_select_country' : $country_setting = (string) $this->wpc_get_option( $value['id'] ); $countries = WC()->countries->countries; if ( strstr( $country_setting, ':' ) ) { $country_setting = explode( ':', $country_setting ); $country = current( $country_setting ); $state = end( $country_setting ); } else { $country = $country_setting; $state = '*'; } ?><tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> <?php echo $tip; ?> </th> <td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php _e( 'Choose a country…', 'wpd' ); ?>" title="Country" class="chosen_select"> <?php WC()->countries->country_dropdown_options( $country, $state ); ?> </select> <?php echo $description; ?> </td> </tr><?php break; // Country multiselects case 'multi_select_countries' : $selections = (array) $this->wpc_get_option( $value['id'] ); if ( ! empty( $value['options'] ) ) $countries = $value['options']; else $countries = WC()->countries->countries; asort( $countries ); ?><tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> <?php echo $tip; ?> </th> <td class="forminp"> <select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php _e( 'Choose countries…', 'wpd' ); ?>" title="Country" class="chosen_select"> <?php if ( $countries ) foreach ( $countries as $key => $val ) echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ).'>' . $val . '</option>'; ?> </select> <?php if ( $description ) echo $description; ?> </br><a class="select_all button" href="#"><?php _e( 'Select all', 'wpd' ); ?></a> <a class="select_none button" href="#"><?php _e( 'Select none', 'wpd' ); ?></a> </td> </tr><?php break; */ // Default: run an action /* // Single country selects case 'single_select_country' : $country_setting = (string) $this->wpc_get_option( $value['id'] ); $countries = WC()->countries->countries; if ( strstr( $country_setting, ':' ) ) { $country_setting = explode( ':', $country_setting ); $country = current( $country_setting ); $state = end( $country_setting ); } else { $country = $country_setting; $state = '*'; } ?><tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> <?php echo $tip; ?> </th> <td class="forminp"><select name="<?php echo esc_attr( $value['id'] ); ?>" style="<?php echo esc_attr( $value['css'] ); ?>" data-placeholder="<?php _e( 'Choose a country…', 'wpd' ); ?>" title="Country" class="chosen_select"> <?php WC()->countries->country_dropdown_options( $country, $state ); ?> </select> <?php echo $description; ?> </td> </tr><?php break; // Country multiselects case 'multi_select_countries' : $selections = (array) $this->wpc_get_option( $value['id'] ); if ( ! empty( $value['options'] ) ) $countries = $value['options']; else $countries = WC()->countries->countries; asort( $countries ); ?><tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> <?php echo $tip; ?> </th> <td class="forminp"> <select multiple="multiple" name="<?php echo esc_attr( $value['id'] ); ?>[]" style="width:350px" data-placeholder="<?php _e( 'Choose countries…', 'wpd' ); ?>" title="Country" class="chosen_select"> <?php if ( $countries ) foreach ( $countries as $key => $val ) echo '<option value="' . esc_attr( $key ) . '" ' . selected( in_array( $key, $selections ), true, false ).'>' . $val . '</option>'; ?> </select> <?php if ( $description ) echo $description; ?> </br><a class="select_all button" href="#"><?php _e( 'Select all', 'wpd' ); ?></a> <a class="select_none button" href="#"><?php _e( 'Select none', 'wpd' ); ?></a> </td> </tr><?php break; */ // Default: run an action default: do_action('wpc_admin_field_' . $value['type'], $value); break; } } }