/** * Show custom text * * @since 1.0 * @package WooCommerce - PDF Vouchers */ public function woo_vou_add_text($args, $echo = true) { $html = ''; $new_field = array('type' => 'text', 'name' => 'Text Field'); $field = array_merge($new_field, $args); $meta = woo_vou_meta_value($field); $html .= '<div class="' . $field['id'] . '_field ' . $field['wrap_class'] . '" style="display: inline-block;">'; $html .= '<label style="display: block; float: none; width: auto !important;" for="' . $field['id'] . '">' . $field['label'] . '</label>'; $html .= "<input type='text' class='woo-vou-meta-text {$field['class']}' name='{$field['id']}' id='{$field['id']}' value='{$meta}' />"; if (isset($field['description']) && $field['description']) { $html .= '<span class="description description-custom">' . $field['description'] . '</span>'; } $html .= '</div>'; $html .= woo_vou_show_field_end($field); if ($echo) { echo $html; } else { return $html; } }
/** * Show Background Pattern Field * * @param string $field * @param string $meta * @since 1.0 * @access public */ function woo_vou_add_bg_pattern($args, $echo = true) { $html = ''; $new_field = array('type' => 'text', 'name' => 'Background Pattern Field'); $field = array_merge($new_field, $args); $all_background_patterns = isset($field['options']) ? $field['options'] : array(); $default_meta = isset($field['default']) ? $field['default'] : ''; $meta = woo_vou_meta_value($field); $meta = !empty($meta) ? $meta : $default_meta; $html .= woo_vou_show_field_begin($field); if (!empty($all_background_patterns)) { // Check pattern options are not empty foreach ($all_background_patterns as $pattern) { $background_pattern_css = $meta == $pattern ? 'woo-vou-meta-bg-pattern-selected' : ''; $html .= '<img class="woo-vou-meta-bg-patterns ' . $background_pattern_css . '" id="woo_vou_meta_img_' . $pattern . '" src="' . WOO_VOU_IMG_URL . '/patterns/' . $pattern . '.png' . '" data-pattern="' . $pattern . '" alt="' . ucwords($pattern) . '" title="' . ucwords($pattern) . '" />'; } } $html .= '<input class="woo-vou-meta-bg-patterns-opt" type="hidden" id="' . $field['id'] . '" name="' . $field['id'] . '" value="' . $meta . '" />'; $html .= woo_vou_show_field_end($field); if ($echo) { echo $html; } else { return $html; } }