Guest User

Untitled

a guest
Jun 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <?php
  2. // d.) settings
  3. add_settings_field(
  4. 'woonumday_wndtaxbase_field',
  5. esc_attr__('Tax Options', 'woonumday'),
  6. 'woonumday_wndtaxbase_field_cb',
  7. 'woonumday_options',
  8. 'woonumday_options_section',
  9. array(
  10. 'type' => 'select',
  11. 'option_group' => 'woonumday_options',
  12. 'name' => 'woonumday_wndtaxbase_field',
  13. 'value' => esc_attr(
  14. get_option( 'woonumday_options' )['woonumday_wndtaxbase_field'] ),
  15. 'options' => array(
  16. "standard" => "Standard",
  17. "reduced" => "Reduced",
  18. "zero" => "Zero" ),
  19. 'description' => esc_html__( 'This adjust the Additional Fee tax rate only
  20. - not the product tax rate.', 'woonumday' ),
  21. 'tip' => esc_attr__( 'Choices are: standard | reduced | zero
  22. See Woocommerce Settings to set taxes', 'woonumday' )
  23. )
  24. );
  25.  
  26. // Callback
  27.  
  28. /**
  29. * d.) 'select' field
  30. * @since 1.0.0
  31. */
  32. function woonumday_wndtaxbase_field_cb($args)
  33. {
  34. print('<label for="woonumday_wndtaxbase_field">');
  35. if( ! empty ( $args['options'] && is_array( $args['options'] ) ) )
  36. {
  37. $options_markup = '';
  38. $value = $args['value'];
  39. foreach( $args['options'] as $key => $label )
  40. {
  41. $options_markup .= sprintf( '<option value="%s" %s>%s</option>',
  42. $key, selected( $value, $key, false ), $label );
  43. }
  44. printf( '<select name="%1$s[%2$s]" id="%1$s-%2$s">%3$s</select>',
  45. $args['option_group'],
  46. $args['name'],
  47. $options_markup );
  48. }
  49. $tip = $args['tip'];
  50. print('<b class="wntip" title="' . esc_attr($tip) . '"> ? </b></label>');
  51. }
Add Comment
Please, Sign In to add comment