select-row.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * select row
  4. */
  5. global $post;
  6. ?>
  7. <div class="vamtam-config-row <?php echo esc_attr( $class ) ?> select-row clearfix">
  8. <div class="rtitle">
  9. <h4><?php echo esc_html( $name ) ?></h4>
  10. <?php vamtam_description( '', $desc ) ?>
  11. </div>
  12. <div class="rcontent">
  13. <?php foreach ( $selects as $id => $s ) : ?>
  14. <?php
  15. if ( isset( $s['target'] ) ) {
  16. if ( isset( $s['options'] ) ) {
  17. $s['options'] = $s['options'] + VamtamConfigGenerator::get_select_target_config( $s['target'] );
  18. } else {
  19. $s['options'] = VamtamConfigGenerator::get_select_target_config( $s['target'] );
  20. }
  21. }
  22. if ( isset( $GLOBALS['vamtam_in_metabox'] ) ) {
  23. $selected = get_post_meta( $post->ID, $id, true );
  24. } else {
  25. $selected = vamtam_get_option( $id, $s['default'] );
  26. }
  27. ?>
  28. <div class="single-option">
  29. <div class="single-desc"><?php echo wp_kses_post( $s['desc'] ) ?></div>
  30. <select name="<?php echo esc_attr( $id ) ?>" id="<?php echo esc_attr( $id ) ?>" class="<?php vamtam_static( $value )?>">
  31. <?php if ( isset( $s['prompt'] ) ) : ?>
  32. <option value=""><?php echo esc_html( $s['prompt'] ) ?></option>
  33. <?php endif ?>
  34. <?php foreach ( $s['options'] as $key => $option ) : ?>
  35. <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $selected, $key ) ?>><?php echo esc_html( $option ) ?></option>
  36. <?php endforeach ?>
  37. <?php
  38. if ( isset( $s['page'] ) ) {
  39. $args = array(
  40. 'depth' => $s['page'],
  41. 'child_of' => 0,
  42. 'selected' => $selected,
  43. 'echo' => 1,
  44. 'name' => 'page_id',
  45. 'id' => '',
  46. 'show_option_none' => '',
  47. 'show_option_no_change' => '',
  48. 'option_none_value' => '',
  49. );
  50. $pages = get_pages( $args );
  51. echo walk_page_dropdown_tree( $pages,$depth,$args ); // xss ok
  52. }
  53. ?>
  54. </select>
  55. </div>
  56. <?php endforeach ?>
  57. </div>
  58. </div>