background.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. $fields = array(
  3. 'color' => esc_html__( 'Color:', 'vamtam-consulting' ),
  4. 'image' => esc_html__( 'Image / pattern:', 'vamtam-consulting' ),
  5. 'repeat' => esc_html__( 'Repeat:', 'vamtam-consulting' ),
  6. 'attachment' => esc_html__( 'Attachment:', 'vamtam-consulting' ),
  7. 'position' => esc_html__( 'Position:', 'vamtam-consulting' ),
  8. 'size' => esc_html__( 'Size:', 'vamtam-consulting' ),
  9. );
  10. $sep = isset( $sep ) ? $sep : '-';
  11. $current = array();
  12. if ( ! isset( $only ) ) {
  13. if ( isset( $show ) ) {
  14. $only = explode( ',', $show );
  15. } else {
  16. $only = array();
  17. }
  18. } else {
  19. $only = explode( ',', $only );
  20. }
  21. $show = array();
  22. global $post;
  23. foreach ( $fields as $field => $fname ) {
  24. if ( isset( $GLOBALS['vamtam_in_metabox'] ) ) {
  25. $current[ $field ] = get_post_meta( $post->ID, "$id-$field", true );
  26. } else {
  27. $current[ $field ] = vamtam_get_option( "$id-$field" );
  28. }
  29. $show[ $field ] = ( in_array( $field, $only ) || count( $only ) === 0 );
  30. }
  31. $selects = array(
  32. 'repeat' => array(
  33. 'no-repeat' => esc_html__( 'No repeat', 'vamtam-consulting' ),
  34. 'repeat-x' => esc_html__( 'Repeat horizontally', 'vamtam-consulting' ),
  35. 'repeat-y' => esc_html__( 'Repeat vertically', 'vamtam-consulting' ),
  36. 'repeat' => esc_html__( 'Repeat both', 'vamtam-consulting' ),
  37. ),
  38. 'attachment' => array(
  39. 'scroll' => esc_html__( 'scroll', 'vamtam-consulting' ),
  40. 'fixed' => esc_html__( 'fixed', 'vamtam-consulting' ),
  41. ),
  42. 'position' => array(
  43. 'left center' => esc_html__( 'left center', 'vamtam-consulting' ),
  44. 'left top' => esc_html__( 'left top', 'vamtam-consulting' ),
  45. 'left bottom' => esc_html__( 'left bottom', 'vamtam-consulting' ),
  46. 'center center' => esc_html__( 'center center', 'vamtam-consulting' ),
  47. 'center top' => esc_html__( 'center top', 'vamtam-consulting' ),
  48. 'center bottom' => esc_html__( 'center bottom', 'vamtam-consulting' ),
  49. 'right center' => esc_html__( 'right center', 'vamtam-consulting' ),
  50. 'right top' => esc_html__( 'right top', 'vamtam-consulting' ),
  51. 'right bottom' => esc_html__( 'right bottom', 'vamtam-consulting' ),
  52. ),
  53. );
  54. ?>
  55. <div class="vamtam-config-row background clearfix <?php echo esc_attr( $class ) ?>">
  56. <div class="rtitle">
  57. <h4><?php echo esc_html( $name ) ?></h4>
  58. <?php vamtam_description( $id, $desc ) ?>
  59. </div>
  60. <div class="rcontent">
  61. <div class="bg-inner-row">
  62. <?php if ( $show['color'] ) : ?>
  63. <div class="bg-block color">
  64. <div class="single-desc"><?php esc_html_e( 'Color:', 'vamtam-consulting' ) ?></div>
  65. <input name="<?php echo esc_attr( $id . $sep . 'color' ) ?>" id="<?php echo esc_attr( $id ) ?>-color" type="text" data-hex="true" value="<?php echo esc_attr( $current['color'] ) ?>" class="vamtam-color-input" />
  66. </div>
  67. <?php endif ?>
  68. </div>
  69. <div class="bg-inner-row">
  70. <?php if ( $show['image'] ) : ?>
  71. <div class="bg-block bg-image">
  72. <div class="single-desc"><?php esc_html_e( 'Image / pattern:', 'vamtam-consulting' ) ?></div>
  73. <?php $_id = $id;
  74. $id .= $sep . 'image'; // temporary change the id so that we can reuse the upload field ?>
  75. <div class="image <?php vamtam_static( $value ) ?>">
  76. <?php include VAMTAM_ADMIN_CGEN . 'upload-basic.php'; ?>
  77. </div>
  78. <?php $id = $_id;
  79. unset( $_id ); ?>
  80. </div>
  81. <?php endif ?>
  82. <?php if ( $show['size'] ) : ?>
  83. <div class="bg-block bg-size">
  84. <div class="single-desc"><?php esc_html_e( 'Cover:', 'vamtam-consulting' ) ?></div>
  85. <label class="toggle-radio">
  86. <input type="radio" name="<?php echo esc_attr( $id . $sep ) ?>size" value="cover" <?php checked( $current['size'], 'cover' ) ?>/>
  87. <span><?php esc_html_e( 'On', 'vamtam-consulting' ) ?></span>
  88. </label>
  89. <label class="toggle-radio">
  90. <input type="radio" name="<?php echo esc_attr( $id . $sep ) ?>size" value="auto" <?php checked( $current['size'], 'auto' ) ?>/>
  91. <span><?php esc_html_e( 'Off', 'vamtam-consulting' ) ?></span>
  92. </label>
  93. </div>
  94. <?php endif ?>
  95. <?php foreach ( $selects as $s => $options ) : ?>
  96. <?php if ( $show[ $s ] ) : ?>
  97. <div class="bg-block bg-<?php echo esc_attr( $s )?>">
  98. <div class="single-desc"><?php echo wp_kses_post( $fields[ $s ] ) ?></div>
  99. <select name="<?php echo esc_attr( $id . $sep . $s ) ?>" class="bg-<?php echo esc_attr( $s ) ?>">
  100. <?php foreach ( $options as $val => $opt ) : ?>
  101. <option value="<?php echo esc_attr( $val ) ?>" <?php selected( $val, $current[ $s ] ) ?>><?php echo esc_html( $opt ) ?></option>
  102. <?php endforeach ?>
  103. </select>
  104. </div>
  105. <?php endif ?>
  106. <?php endforeach ?>
  107. </div>
  108. </div>
  109. </div>