PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/shop quần áo starloveshop.com/wp-content/plugins/woocommerce/includes/admin/wc-meta-box-functions.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 223 lines | 128 code | 44 blank | 51 comment | 21 complexity | b9fdc3d1992602511e8a39c36282cec9 MD5 | raw file
  1. <?php
  2. /**
  3. * WooCommerce Meta Box Functions
  4. *
  5. * @author WooThemes
  6. * @category Core
  7. * @package WooCommerce/Admin/Functions
  8. * @version 2.1.0
  9. */
  10. if ( ! defined( 'ABSPATH' ) ) {
  11. exit; // Exit if accessed directly
  12. }
  13. /**
  14. * Output a text input box.
  15. *
  16. * @access public
  17. * @param array $field
  18. * @return void
  19. */
  20. function woocommerce_wp_text_input( $field ) {
  21. global $thepostid, $post;
  22. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
  23. $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
  24. $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
  25. $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
  26. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
  27. $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
  28. $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text';
  29. $data_type = empty( $field['data_type'] ) ? '' : $field['data_type'];
  30. switch ( $data_type ) {
  31. case 'price' :
  32. $field['class'] .= ' wc_input_price';
  33. $field['value'] = wc_format_localized_price( $field['value'] );
  34. break;
  35. case 'decimal' :
  36. $field['class'] .= ' wc_input_decimal';
  37. $field['value'] = wc_format_localized_decimal( $field['value'] );
  38. break;
  39. case 'stock' :
  40. $field['class'] .= ' wc_input_stock';
  41. $field['value'] = wc_stock_amount( $field['value'] );
  42. break;
  43. default :
  44. break;
  45. }
  46. // Custom attribute handling
  47. $custom_attributes = array();
  48. if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) )
  49. foreach ( $field['custom_attributes'] as $attribute => $value )
  50. $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
  51. echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><input type="' . esc_attr( $field['type'] ) . '" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . implode( ' ', $custom_attributes ) . ' /> ';
  52. if ( ! empty( $field['description'] ) ) {
  53. if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
  54. echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( WC()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
  55. } else {
  56. echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
  57. }
  58. }
  59. echo '</p>';
  60. }
  61. /**
  62. * Output a hidden input box.
  63. *
  64. * @access public
  65. * @param array $field
  66. * @return void
  67. */
  68. function woocommerce_wp_hidden_input( $field ) {
  69. global $thepostid, $post;
  70. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
  71. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
  72. $field['class'] = isset( $field['class'] ) ? $field['class'] : '';
  73. echo '<input type="hidden" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['value'] ) . '" /> ';
  74. }
  75. /**
  76. * Output a textarea input box.
  77. *
  78. * @access public
  79. * @param array $field
  80. * @return void
  81. */
  82. function woocommerce_wp_textarea_input( $field ) {
  83. global $thepostid, $post;
  84. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
  85. $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
  86. $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
  87. $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
  88. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
  89. echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><textarea class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="2" cols="20">' . esc_textarea( $field['value'] ) . '</textarea> ';
  90. if ( ! empty( $field['description'] ) ) {
  91. if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
  92. echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( WC()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
  93. } else {
  94. echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
  95. }
  96. }
  97. echo '</p>';
  98. }
  99. /**
  100. * Output a checkbox input box.
  101. *
  102. * @access public
  103. * @param array $field
  104. * @return void
  105. */
  106. function woocommerce_wp_checkbox( $field ) {
  107. global $thepostid, $post;
  108. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
  109. $field['class'] = isset( $field['class'] ) ? $field['class'] : 'checkbox';
  110. $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
  111. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
  112. $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'yes';
  113. $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
  114. echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><input type="checkbox" class="' . esc_attr( $field['class'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $field['cbvalue'] ) . '" ' . checked( $field['value'], $field['cbvalue'], false ) . ' /> ';
  115. if ( ! empty( $field['description'] ) ) echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
  116. echo '</p>';
  117. }
  118. /**
  119. * Output a select input box.
  120. *
  121. * @access public
  122. * @param array $field
  123. * @return void
  124. */
  125. function woocommerce_wp_select( $field ) {
  126. global $thepostid, $post;
  127. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
  128. $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
  129. $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
  130. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
  131. echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label><select id="' . esc_attr( $field['id'] ) . '" name="' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $field['class'] ) . '">';
  132. foreach ( $field['options'] as $key => $value ) {
  133. echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
  134. }
  135. echo '</select> ';
  136. if ( ! empty( $field['description'] ) ) {
  137. if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
  138. echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( WC()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
  139. } else {
  140. echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
  141. }
  142. }
  143. echo '</p>';
  144. }
  145. /**
  146. * Output a radio input box.
  147. *
  148. * @access public
  149. * @param array $field
  150. * @return void
  151. */
  152. function woocommerce_wp_radio( $field ) {
  153. global $thepostid, $post;
  154. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
  155. $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short';
  156. $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
  157. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true );
  158. $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
  159. echo '<fieldset class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend><ul class="wc-radios">';
  160. foreach ( $field['options'] as $key => $value ) {
  161. echo '<li><label><input
  162. name="' . esc_attr( $field['name'] ) . '"
  163. value="' . esc_attr( $key ) . '"
  164. type="radio"
  165. class="' . esc_attr( $field['class'] ) . '"
  166. ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '
  167. /> ' . esc_html( $value ) . '</label>
  168. </li>';
  169. }
  170. echo '</ul>';
  171. if ( ! empty( $field['description'] ) ) {
  172. if ( isset( $field['desc_tip'] ) && false !== $field['desc_tip'] ) {
  173. echo '<img class="help_tip" data-tip="' . esc_attr( $field['description'] ) . '" src="' . esc_url( WC()->plugin_url() ) . '/assets/images/help.png" height="16" width="16" />';
  174. } else {
  175. echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
  176. }
  177. }
  178. echo '</fieldset>';
  179. }