Layers_Form_Elements

Form Element Class File.

Defined (1)

The class is defined in the following location(s).

/core/helpers/forms.php  
  1. class Layers_Form_Elements { 
  2.  
  3. /** 
  4. * Load control title HTML 
  5. * @param array $args Configuration arguments. 
  6. * @echo string Title HTML 
  7. */ 
  8.  
  9. public function header( $args = array() ) { 
  10.  
  11. $defaults = array( 
  12. 'title' => __( 'Widget' , 'layerswp' ),  
  13. 'icon_class' => '' 
  14. ); 
  15.  
  16. $header = (object) wp_parse_args( $args, $defaults ); ?> 
  17.  
  18. <div class="layers-controls-title"> 
  19. <h2 class="layers-heading"> 
  20. <?php echo esc_html( $header->title ); ?> 
  21. </h2> 
  22. </div> 
  23.  
  24. <?php } 
  25.  
  26. /** 
  27. * Accordian Title 
  28. * @param array $args Configuration arguments. 
  29. * @echo string HTML for a widget accordian title. 
  30. */ 
  31.  
  32. public function accordian_title( $args = array() ) { 
  33.  
  34. $accordian_title = (object) wp_parse_args( $args, array() ); ?> 
  35.  
  36. <a class="layers-accordion-title"> 
  37. <span><?php echo esc_html( $accordian_title->title ); ?></span> 
  38. </a> 
  39. <?php } 
  40.  
  41. /** 
  42. * Panel/Section Title 
  43. * @param array $args Configuration arguments. 
  44. * @echo string HTML for a widget accordian title. 
  45. */ 
  46.  
  47. public function section_panel_title( $args = array() ) { 
  48.  
  49. $defaults = array( 
  50. 'type' => 'section' 
  51. ); 
  52.  
  53. $panel_title = (object) wp_parse_args( $args, $defaults ); ?> 
  54. <div class="layers-<?php echo esc_attr( $panel_title->type ); ?>-title"> 
  55. <h4 class="heading"><?php echo esc_html( $panel_title->title ); ?></h4> 
  56. </div> 
  57. <?php } 
  58.  
  59. /** 
  60. * Generate incremental options 
  61. * @param array $options() Existing option array if exists (optional) 
  62. * @param int $min Minimum number to start with 
  63. * @param int $max End point, included in the options with <= 
  64. * @param int $increment How are we counting up? 
  65. * @return array $options() Array of options 
  66. */ 
  67.  
  68. public function get_incremental_options( $options = array() , $min = 1 , $max = 10 , $increment = 1 ) { 
  69. $i = $min; 
  70. while ( $i <= $max ) { 
  71. $options[ $i ] = $i; 
  72. $i=($i+$increment); 
  73. return $options; 
  74.  
  75. /** 
  76. * Generate default WP post sort options 
  77. * @param array $options() Existing option array if exists (optional) 
  78. * @return array $options() Array of options 
  79. */ 
  80.  
  81. public function get_sort_options( $options = array() ) { 
  82. $options[ json_encode( array( 'orderby' => 'date', 'order' => 'desc' ) ) ] = __( 'Newest First' , 'layerswp' ); 
  83. $options[ json_encode( array( 'orderby' => 'date', 'order' => 'asc' ) ) ] = __( 'Oldest First' , 'layerswp' ); 
  84. $options[ json_encode( array( 'orderby' => 'rand', 'order' => 'desc' ) ) ] = __( 'Random' , 'layerswp' ); 
  85. $options[ json_encode( array( 'orderby' => 'title', 'order' => 'asc' ) ) ] = __( 'Titles A-Z' , 'layerswp' ); 
  86. $options[ json_encode( array( 'orderby' => 'title', 'order' => 'desc' ) ) ] = __( 'Titles Z-A' , 'layerswp' ); 
  87. $options[ json_encode( array( 'orderby' => 'comment_count', 'order' => 'desc' ) ) ] = __( 'Most Comments' , 'layerswp' ); 
  88. $options[ json_encode( array( 'orderby' => 'menu_order', 'order' => 'desc' ) ) ] = __( 'Custom Order' , 'layerswp' ); 
  89. return $options; 
  90.  
  91. /** 
  92. * Load input HTML 
  93. * @param array $array() Existing option array if exists (optional) 
  94. * @return array $array Array of options, all standard DOM input options 
  95. */ 
  96.  
  97. public function input( $args = array() ) { 
  98. global $wp_customize; 
  99.  
  100. $defaults = array( 
  101. 'type' => 'text',  
  102. 'name' => NULL ,  
  103. 'id' => NULL ,  
  104. 'placeholder' => NULL,  
  105. 'data' => NULL,  
  106. 'value' => NULL ,  
  107. 'class' => NULL,  
  108. 'options' => array(),  
  109. 'sync_setting' => NULL,  
  110. 'mimic_setting' => NULL,  
  111. ); 
  112.  
  113. // Convert 'choices' to 'options' - so you can use same naming as the controls which use 'options'. 
  114. if ( isset( $args['choices'] ) && ! empty( $args['choices'] ) && ! isset ( $args['options'] ) ) { 
  115. $args['options'] = $args['choices']; 
  116. unset( $args['choices'] ); 
  117.  
  118. // Turn $args into their own variables 
  119. $input = (object) wp_parse_args( $args, $defaults ); 
  120.  
  121. // If the value of this element is in fact a collection of inputs, turn it into an object, it's nicer to work with 
  122. if( NULL != $input->value && is_array( $input->value ) ) $input->value = (object) $input->value; 
  123.  
  124. if( !is_object( $input->value ) ) $input->value = stripslashes( $input->value ); 
  125.  
  126. // Create the input attributes 
  127. $input_props = array(); 
  128. $input_props['id'] = ( NULL != $input->id && 'select-icons' != $input->type ) ? 'id="' . $input->id . '"' : NULL ; 
  129. $input_props['name'] = ( NULL != $input->name ) ? 'name="' . $input->name . '"' : NULL ; 
  130. $input_props['placeholder'] = ( NULL !== $input->placeholder ) ? 'placeholder="' . esc_attr( $input->placeholder ) . '"' : NULL ; 
  131. $input_props['class'] = ( NULL != $input->class ) ? 'class="' . $input->class . '"' : NULL ; 
  132. $input_props['disabled'] = isset( $input->disabled ) ? 'disabled="disabled"' : NULL ; 
  133. $input_props['sync-setting'] = isset( $input->sync_setting ) ? 'data-sync-setting="' . $input->sync_setting . '"' : NULL ; 
  134. $input_props['mimic-setting'] = isset( $input->mimic_setting ) ? 'data-mimic-setting="' . $input->mimic_setting . '"' : NULL ; 
  135.  
  136. if( NULL != $input->data ) { foreach( $input->data as $data_key => $data_value ) { $input_props[ 'data-' . $data_key ] = 'data-' . $data_key . '="' . esc_attr( $data_value ) . '"'; } } 
  137.  
  138. // Switch our input type 
  139. switch( $input->type ) { 
  140. case 'text' : ?> 
  141. <input type="text" <?php echo implode ( ' ' , $input_props ); ?> value="<?php echo esc_attr( $input->value ); ?>" /> 
  142. <?php break; 
  143. /** 
  144. * Number Inputs 
  145. */ 
  146. case 'number' : 
  147. $input_props['min'] = ( isset( $input->min ) ) ? 'min="' . $input->min . '"' : NULL ; 
  148. $input_props['max'] = ( isset( $input->max ) ) ? 'max="' . $input->max . '"' : NULL ; 
  149. $input_props['step'] = ( isset( $input->step ) ) ? 'step="' . $input->step . '"' : NULL ; ?> 
  150. <input type="number" <?php echo implode ( ' ' , $input_props ); ?> value="<?php echo $input->value; ?>" /> 
  151. <?php break; 
  152. /** 
  153. * Range Inputs 
  154. */ 
  155. case 'range' : 
  156.  
  157. $range_input_props = array(); 
  158. $number_input_props = array(); 
  159.  
  160. $number_input_props['step'] = ( isset( $input->step ) ) ? 'step="' . $input->step . '"' : NULL ; 
  161.  
  162. $range_input_props['min'] = ( NULL !== $input->min ) ? 'min="' . $input->min . '"' : NULL ; 
  163. $range_input_props['max'] = ( NULL !== $input->max ) ? 'max="' . $input->max . '"' : NULL ; 
  164. $range_input_props['step'] = ( NULL !== $input->step ) ? 'step="' . $input->step . '"' : NULL ; 
  165. $range_input_props['placeholder'] = ( NULL !== $input->placeholder ) ? 'placeholder="' . $input->placeholder . '"' : NULL ; 
  166.  
  167. if ( isset( $input->value ) && '' !== $input->value ) 
  168. $range_input_props['value'] = 'value="' . $input->value . '"'; 
  169. elseif ( isset( $input->placeholder ) ) 
  170. $range_input_props['value'] = 'value="' . $input->placeholder . '"'; 
  171.  
  172. // Add the disabled to the number field if a placeholder is set and it's the same as the value. 
  173. // the javascript does this too so it will be live applied when the range slider is dragged. 
  174. if ( isset( $input->placeholder ) && $input->placeholder == $input->value ) 
  175. $number_input_props['class'] = 'class="layers-range-disabled"'; 
  176. ?> 
  177. <div class="layers-row"> 
  178. <div class="layers-column layers-span-9"> 
  179. <input type="range" <?php echo implode ( ' ' , $range_input_props ); ?> /> 
  180. </div> 
  181. <div class="layers-column layers-span-3"> 
  182. <input type="number" <?php echo implode ( ' ' , $input_props ); ?> <?php echo implode ( ' ' , $number_input_props ); ?> value="<?php echo $input->value; ?>" /> 
  183. </div> 
  184. </div> 
  185. <?php break; 
  186. /** 
  187. * Checkboxes - here we look for on/NULL, that's how WP widgets save them 
  188. */ 
  189. case 'checkbox' : ?> 
  190. <input type="checkbox" <?php echo implode ( ' ' , $input_props ); ?> <?php checked( $input->value , 'on' ); ?>/> 
  191. <?php if( isset( $input->label ) ) { ?> 
  192. <label for="<?php echo esc_attr( $input->id ); ?>"><?php echo $input->label; ?></label> 
  193. <?php } ?> 
  194. <?php 
  195. // Prepare sibling checkbox for parity/existance check. 
  196. $duplicate_input_props = array(); 
  197. foreach ( $input_props as $key => $val ) { 
  198. if ( 0 === strpos( $val, 'id=' ) ) $duplicate_input_props[$key] = rtrim( $val, '"' ) . '-CHECKBOX"'; 
  199. else if ( 0 === strpos( $val, 'name=' ) ) $duplicate_input_props[$key] = rtrim( $val, ']"' ) . '-CHECKBOX]"'; 
  200. else $duplicate_input_props[$key] = $val; 
  201. ?> 
  202. <input type="hidden" value="on" style="display: none;" <?php echo implode ( ' ' , $duplicate_input_props ); ?> /> 
  203. <?php break; 
  204. /** 
  205. * Radio Buttons 
  206. */ 
  207. case 'radio' : ?> 
  208. <?php foreach( $input->options as $value => $label ) { ?> 
  209. <input type="radio" <?php echo implode ( ' ' , $input_props ); ?> /> 
  210. <label><?php echo esc_html( $label ); ?></label> 
  211. <?php } // foreach options ?> 
  212. <?php break; 
  213. /** 
  214. * Select boxes 
  215. */ 
  216. case 'select' : ?> 
  217. <select size="1" <?php echo implode ( ' ' , $input_props ); ?> <?php if( isset( $input->multiple ) ) echo 'multiple="multiple"'; ?>> 
  218. <?php if( NULL != $input->placeholder ) { ?> 
  219. <option value=''><?php echo esc_html( $input->placeholder ); ?></option> 
  220. <?php } // if NULL != placeholder ?> 
  221. <?php foreach( $input->options as $value => $label ) { ?> 
  222. <option value='<?php echo esc_attr( $value ); ?>' <?php if( !is_object( $input->value ) ) selected( $input->value , $value, true ); ?>> 
  223. <?php echo esc_html( $label ); ?> 
  224. </option> 
  225. <?php } // foreach options ?> 
  226. </select> 
  227. <?php break; 
  228. /** 
  229. * Multi select boxes 
  230. */ 
  231. case 'multi-select' : 
  232. // Force the selection to be an array 
  233. $select_values = (array) $input->value; ?> 
  234. <select size="1" <?php echo implode ( ' ' , $input_props ); ?> multiple="multiple"> 
  235. <?php if( NULL != $input->placeholder ) { ?> 
  236. <option value=''><?php echo esc_html( $input->placeholder ); ?></option> 
  237. <?php } // if NULL != placeholder ?> 
  238. <?php foreach( $input->options as $value => $label ) { ?> 
  239. <option value='<?php echo esc_attr( $value ); ?>' <?php if( is_array( $select_values ) && in_array( $value, $select_values ) ) echo 'selected=selected'; ?>> 
  240. <?php echo esc_html( $label ); ?> 
  241. </option> 
  242. <?php } // foreach options ?> 
  243. </select> 
  244. <?php break; 
  245. /** 
  246. * Select 'icons' such as the column selector 
  247. */ 
  248. case 'select-icons' : 
  249.  
  250. if( isset( $input->input_type ) ) { 
  251. $input_type = $input->input_type; 
  252. } else { 
  253. $input_type = ( 1 == count( $input->options ) ) ? 'checkbox' : 'radio'; 
  254. } ?> 
  255.  
  256. <div class="layers-select-icons"> 
  257. <?php foreach( $input->options as $key => $value ) { 
  258. if ( is_array( $value ) ) { 
  259. $name = ( isset( $value['name'] ) ? $value['name'] : '' ); 
  260. $class = ( isset( $value['class'] ) ? $value['class'] : '' ); 
  261. $data_string = ''; 
  262. if ( ! empty( $value['data'] ) ) { 
  263. foreach ( $value['data'] as $data_key => $data_value) { 
  264. $data_string .= 'data-' . esc_attr( $data_key ) . '="' . $data_value . '" '; 
  265. else { 
  266. $name = $value; 
  267. $class = "icon-{$key}"; 
  268. $data_string = ''; 
  269.  
  270. $data_string .= 'data-value="' . $input->value . '" '; 
  271.  
  272. // Allow for setting of a default selection. 
  273. $checked = FALSE; 
  274. if ( $input->value && $input->value == $key ) $checked = TRUE; 
  275. // elseif ( ! $input->value && isset( $input->default ) && $input->default == $key ) $checked = TRUE; // Not Using Anymore 
  276. ?> 
  277. <label 
  278. href="" 
  279. class="layers-icon-wrapper <?php if ( $checked ) echo 'layers-active'; ?>" 
  280. for="<?php echo esc_attr( $input->id ) , '-', esc_attr( $key ); ?>" 
  281. <?php echo $data_string ?> 
  282. <span class="<?php echo esc_attr( $class ); ?>"></span> 
  283. <?php if( '' != $name ) { ?> 
  284. <span class="layers-icon-description"> 
  285. <?php echo esc_html( $name ); ?> 
  286. </span> 
  287. <?php } ?> 
  288. <input type="<?php echo $input_type ?>" <?php echo implode ( ' ' , $input_props ); ?> id="<?php echo esc_attr( $input->id ), '-', esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( $checked, true, true ); ?> /> 
  289. </label> 
  290. <?php } ?> 
  291. </div> 
  292. <?php break; 
  293. /** 
  294. * Text areas 
  295. */ 
  296. case 'textarea' : ?> 
  297. <textarea <?php echo implode ( ' ' , $input_props ); ?> <?php if( isset( $input->rows ) ) echo 'rows="' , $input->rows , '"'; ?>><?php echo esc_textarea( $input->value ); ?></textarea> 
  298. <?php break; 
  299. /** 
  300. * Rich Text Editor 
  301. */ 
  302. case 'rte' : 
  303. // Apply allowed tags list 
  304. $allow_tags = ( isset( $input->allow_tags ) && is_array( $input->allow_tags ) ? implode( ', ' , $input->allow_tags ) : array() ); 
  305.  
  306. // Add custom button support 
  307. $default_allowed_buttons = array( 
  308. 'bold',  
  309. 'italic',  
  310. 'underline',  
  311. 'strikeThrough',  
  312. 'insertLink',  
  313. 'formatOL',  
  314. 'formatUL',  
  315. 'clearFormatting',  
  316. 'html' 
  317. ); 
  318.  
  319. $allow_buttons = ( isset( $input->allow_buttons ) && is_array( $input->allow_buttons ) ? $input->allow_buttons : $default_allowed_buttons ); 
  320.  
  321. // Check for disabling of standard buttons 
  322. if( isset( $input->disallow_buttons ) && is_array( $input->disallow_buttons ) ) { 
  323. foreach( $allow_buttons as $button_key => $button_value ) { 
  324. if( in_array( $button_value , $input->disallow_buttons ) ) { 
  325. unset( $allow_buttons[ $button_key ] ); 
  326. } ?> 
  327. <textarea 
  328. class="layers-textarea layers-rte" 
  329. <?php if( !empty( $allow_tags ) ) { ?>data-allowed-tags="<?php echo implode( ', ' , $allow_tags ); ?>"<?php } ?> 
  330. <?php if( !empty( $allow_buttons ) ) { ?>data-allowed-buttons="<?php echo implode( ', ' , $allow_buttons ) ; ?>"<?php } ?> 
  331. <?php if( isset( $input->rows ) ) { ?>rows="<?php echo $input->rows; ?>"<?php } ?> 
  332. <?php echo implode ( ' ' , $input_props ); ?> 
  333. ><?php echo $input->value; ?></textarea> 
  334. <?php break; 
  335. /** 
  336. * Image Uploader 
  337. */ 
  338. case 'image' : 
  339. $has_image = (bool) ( isset( $input->value ) && '' !== $input->value && NULL != $input->value ); ?> 
  340. <section class="layers-image-container <?php echo ( $has_image ) ? 'layers-has-image' : '' ; ?>"> 
  341. <div class="layers-image-display layers-image-upload-button"> 
  342. <!-- Image --> 
  343. <?php if ( $has_image ) { ?> 
  344. <?php $img = wp_get_attachment_image_src( $input->value, 'medium' ); ?> 
  345. <img <?php echo isset( $wp_customize ) ? 'data-src' : 'src' ; ?>="<?php echo $img[0]; ?>" /> 
  346. <?php } ?> 
  347. <!-- Remove button --> 
  348. <a href="#removeimage" class="layers-image-remove" href=""><?php _e( 'Remove' , 'layerswp' ); ?></a> 
  349. </div> 
  350.  
  351. <a href="#uploadimage" class="layers-image-upload-button button layers-button btn-full <?php echo ( $has_image ) ? 'layers-has-image' : '' ; ?>" 
  352. data-title="<?php _e( 'Select an Image' , 'layerswp' ); ?>" 
  353. data-button_text="<?php _e( 'Use Image' , 'layerswp' ); ?>"> 
  354. <?php echo ( isset( $input->button_label ) ? $input->button_label : __( 'Choose Media' , 'layerswp' ) ); ?> 
  355. </a> 
  356.  
  357. <?php echo $this->input( 
  358. array( 
  359. 'type' => 'hidden',  
  360. 'name' => $input->name,  
  361. 'id' => $input->id,  
  362. 'value' => ( $has_image ) ? $input->value : NULL,  
  363. 'data' => ( NULL != $input->data ) ? $input->data : NULL,  
  364. ); ?> 
  365. </section> 
  366. <?php break; 
  367. /** 
  368. * Regular Uploader 
  369. */ 
  370. case 'upload' : ?> 
  371. <section class="layers-file-container <?php if( isset( $input->value ) && NULL != $input->value ) echo 'layers-has-file'; ?>"> 
  372. <span class="layers-file-name"> 
  373. <!-- Image --> 
  374. <?php if( isset( $input->value ) ) echo wp_basename( wp_get_attachment_url( $input->value ) , true ); ?> 
  375. </span> 
  376.  
  377. <a href="#choosefile" class="layers-regular-uploader layers-button btn-medium btn-full" 
  378. data-title="<?php echo ( isset( $input->button_label ) ? esc_attr( $input->button_label ) : __( 'Choose File' , 'layerswp' ) ); ?>" 
  379. data-button_text="<?php _e( 'Use File' , 'layerswp' ); ?>"> 
  380. <?php echo ( isset( $input->button_label ) ? $input->button_label : __( 'Choose File' , 'layerswp' ) ); ?> 
  381. </a> 
  382.  
  383. <a href="#removefile" class="<?php if( !isset( $input->value ) ) echo 'hide'; ?> layers-image-remove layers-file-remove"> 
  384. <?php _e( 'Remove' , 'layerswp' ); ?> 
  385. </a> 
  386. <input type="hidden" <?php echo implode ( ' ' , $input_props ); ?> value="<?php echo $input->value; ?>" /> 
  387. </section> 
  388. <?php break; 
  389. /** 
  390. * Background Controller 
  391. */ 
  392. case 'background' : 
  393.  
  394. // Default to image if we haven't already done so 
  395. if( !isset( $input->value->type ) ) $input_type = 'image'; else $input_type = $input->value->type; ?> 
  396.  
  397. <div class="layers-media-controller" id="<?php echo esc_attr( $input->id ); ?>-controller"> 
  398. <ul class="layers-section-links layers-background-selector"> 
  399. <li <?php if( 'video' != $input_type ) echo 'class="active"'; ?> data-id="#<?php echo esc_attr( $input->id ); ?>" data-type="image"> 
  400. <a href="" class="icon-photo"></a> 
  401. </li> 
  402. <li <?php if( 'video' == $input_type ) echo 'class="active"'; ?> data-id="#<?php echo esc_attr( $input->id ); ?>" data-type="video"> 
  403. <a href="" class="icon-video"></a> 
  404. </li> 
  405. </ul> 
  406.  
  407. <!-- Background Type Input --> 
  408. <?php echo $this->input( 
  409. array( 
  410. 'type' => 'hidden',  
  411. 'name' => $input->name . '[type]' ,  
  412. 'id' => $input->id . '-type',  
  413. 'value' => ( isset( $input->value->type ) ) ? $input->value->type : 'image' 
  414. ); ?> 
  415.  
  416. <div class="layers-controller-elements"> 
  417.  
  418. <!-- Image uploader --> 
  419. <div class="layers-content <?php if( 'image' == $input_type ) echo 'section-active'; ?>"> 
  420. <div class="layers-form-item"> 
  421. <div class="layers-image-uploader layers-animate layers-push-bottom"> 
  422. <!-- Remove button --> 
  423. <a class="layers-image-remove <?php if( !isset( $input->value->image ) ) echo 'l_admin-hide'; ?>" href=""><?php _e( 'Remove' , 'layerswp' ); ?></a> 
  424.  
  425. <!-- Instructions --> 
  426. <p <?php if( isset( $input->value->image ) ) echo 'class="l_admin-hide"'; ?>> 
  427. <?php printf( __( 'Drop a file here or %s' , 'layerswp' ) , '<a href="#">select a file.</a>' ); ?> 
  428. </p> 
  429.  
  430. <!-- Input --> 
  431. <?php echo $this->input( 
  432. array( 
  433. 'type' => 'hidden',  
  434. 'name' => $input->name . '[image]' ,  
  435. 'id' => $input->id . '-image',  
  436. 'value' => ( isset( $input->value->image ) ) ? $input->value->image : NULL 
  437. ); ?> 
  438.  
  439. <!-- Image --> 
  440. <?php if( isset( $input->value->image ) ) { 
  441. $img = wp_get_attachment_image_src( $input->value->image , 'thumbnail' );?> 
  442. <img data-src="<?php echo $img[0]; ?>" /> 
  443. <?php } ?> 
  444. </div> 
  445. </div> 
  446. <div class="layers-row"> 
  447.  
  448. <p class="layers-form-item"> 
  449. <label><?php _e( 'Background Color' , 'layerswp' ); ?></label> 
  450. <?php echo $this->input( 
  451. array( 
  452. 'type' => 'color',  
  453. 'name' => $input->name . '[image_color]' ,  
  454. 'id' => $input->id . 'image-color',  
  455. 'value' => ( isset( $input->value->image_color ) ) ? $input->value->image_color : NULL,  
  456. ); ?> 
  457. </p> 
  458.  
  459. <ul class="layers-checkbox-list"> 
  460. <li class="layers-checkbox"> 
  461. <?php echo $this->input( 
  462. array( 
  463. 'type' => 'checkbox',  
  464. 'name' => $input->name . '[darken]' ,  
  465. 'id' => $input->id . '-darken',  
  466. 'value' => ( isset( $input->value->darken ) ) ? $input->value->darken : NULL,  
  467. 'label' => __( 'Darken to improve readability' , 'layerswp' ) 
  468. ); ?> 
  469. </li> 
  470. <li class="layers-checkbox"> 
  471. <?php echo $this->input( 
  472. array( 
  473. 'type' => 'checkbox',  
  474. 'name' => $input->name . '[tile_background]' ,  
  475. 'id' => $input->id . '-tile_background',  
  476. 'value' => ( isset( $input->value->tile_background ) ) ? $input->value->tile_background : NULL,  
  477. 'label' => __( 'Tile Background' , 'layerswp' ) 
  478. ); ?> 
  479. </li> 
  480. <li class="layers-checkbox"> 
  481. <?php echo $this->input( 
  482. array( 
  483. 'type' => 'checkbox',  
  484. 'name' => $input->name . '[fixed_background]' ,  
  485. 'id' => $input->id . '-fixed_background',  
  486. 'value' => ( isset( $input->value->fixed_background ) ) ? $input->value->fixed_background : NULL,  
  487. 'label' => __( 'Fixed Background' , 'layerswp' ) 
  488. ); ?> 
  489. </li> 
  490. </ul> 
  491. </div> 
  492. </div> 
  493.  
  494. <!-- Video uploader --> 
  495. <div class="layers-content <?php if( 'video' == $input->value->type ) echo 'section-active'; ?>"> 
  496. <p class="layers-form-item"> 
  497. <label><?php _e( 'Enter your .mp4 link' , 'layerswp' ); ?></label> 
  498. <?php echo $this->input( 
  499. array( 
  500. 'type' => 'upload',  
  501. 'name' => $input->name . '[mp4]' ,  
  502. 'id' => $input->id . '-mp4',  
  503. 'value' => ( isset( $input->value->mp4 ) ) ? $input->value->mp4 : NULL 
  504. ); ?> 
  505. </p> 
  506. <p class="layers-form-item"> 
  507. <label><?php _e( 'Enter your .ogv link' , 'layerswp' ); ?></label> 
  508. <?php echo $this->input( 
  509. array( 
  510. 'type' => 'upload',  
  511. 'name' => $input->name . '[ogv]' ,  
  512. 'id' => $input->id . '-ogv',  
  513. 'value' => ( isset( $input->value->ogv ) ) ? $input->value->ogv : NULL 
  514. ); ?> 
  515. </p> 
  516. <div class="layers-row"> 
  517. <p class="layers-form-item layers-no-push-bottom"> 
  518. <label><?php _e( 'Background Color' , 'layerswp' ); ?></label> 
  519. <?php echo $this->input( 
  520. array( 
  521. 'type' => 'color',  
  522. 'name' => $input->name . '[video_color]' ,  
  523. 'id' => $input->id . '-video-color',  
  524. 'value' => ( isset( $input->value->video_color ) ) ? $input->value->video_color : NULL,  
  525. ); ?> 
  526. </p> 
  527.  
  528. <ul class="layers-checkbox-list"> 
  529. <li class="layers-checkbox"> 
  530. <?php echo $this->input( 
  531. array( 
  532. 'type' => 'checkbox',  
  533. 'name' => $input->name . '[video_darken]' ,  
  534. 'id' => $input->id . '-video_darken',  
  535. 'value' => ( isset( $input->value->video_darken ) ) ? $input->value->video_darken : NULL,  
  536. 'label' => __( 'Darken to improve readability' , 'layerswp' ) 
  537. ); ?> 
  538. </li> 
  539. <li class="layers-checkbox"> 
  540. <?php echo $this->input( 
  541. array( 
  542. 'type' => 'checkbox',  
  543. 'name' => $input->name . '[video_tile_background]' ,  
  544. 'id' => $input->id . '-video_tile_background',  
  545. 'value' => ( isset( $input->value->video_tile_background ) ) ? $input->value->video_tile_background : NULL,  
  546. 'label' => __( 'Tile Background' , 'layerswp' ) 
  547. ); ?> 
  548. </li> 
  549. <li class="layers-checkbox"> 
  550. <?php echo $this->input( 
  551. array( 
  552. 'type' => 'checkbox',  
  553. 'name' => $input->name . '[video_fixed_background]' ,  
  554. 'id' => $input->id . '-video_fixed_background',  
  555. 'value' => ( isset( $input->value->video_fixed_background ) ) ? $input->value->video_fixed_background : NULL,  
  556. 'label' => __( 'Fixed Background' , 'layerswp' ) 
  557. ); ?> 
  558. </li> 
  559. </ul> 
  560. </div> 
  561. </div> 
  562.  
  563. </div> 
  564. </div> 
  565. <?php break; 
  566. /** 
  567. * Color Selector 
  568. */ 
  569. case 'color' : ?> 
  570. <input type="text" <?php echo implode ( ' ' , $input_props ); ?> value="<?php echo $input->value; ?>" class="layers-color-selector" /> 
  571. <?php break; 
  572. /** 
  573. * Button Selector 
  574. */ 
  575. case 'button' : 
  576. $tag = ( isset( $input->tag ) &&'' != $input->tag ) ? $input->tag : 'button'; 
  577. $href = ( isset( $input->href ) && '' != $input->href ) ? 'href="' . $input->href . '"' : ''; ?> 
  578. <<?php echo $tag; ?> <?php if( NULL == $input_props[ 'class' ] ) echo 'class="layers-button btn-medium"'; ?> <?php echo $href ?> <?php echo implode ( ' ' , $input_props ); ?> data-button_text="<?php echo esc_attr( $input->label ); ?>"> 
  579. <?php echo esc_attr( $input->label ); ?> 
  580. </<?php echo $tag; ?>> 
  581. <?php break; 
  582. /** 
  583. * Top / Right / Bottom / Left Fields 
  584. */ 
  585. case 'trbl-fields' : ?> 
  586.  
  587. <?php $fields = array( 
  588. 'top' => __( 'Top' , 'layerswp' ),  
  589. 'right' => __( 'Right' , 'layerswp' ),  
  590. 'bottom' => __( 'Bottom' , 'layerswp' ),  
  591. 'left' => __( 'Left' , 'layerswp' ),  
  592. ); ?> 
  593.  
  594. <?php 
  595. // If caller only wants chosen few fields can customise the labels e.g. 
  596. // (1) 'fields' => array( 'top' => 'Top (px)' ) one field 'top' with cusotmized label 'Top (px)'. 
  597. // (2) 'fields' => array( 'top' ) one field 'top' with standard label 'Top'. 
  598. if( ! empty( $input->fields ) ) { 
  599. $new_fields = array(); 
  600. foreach ( $input->fields as $key => $value ) { 
  601.  
  602. if ( is_numeric( $key ) ) { 
  603. // Array element type: [ 'bottom' ] 
  604. if ( isset( $fields[$value] ) ) { // Make sure that what the user spcified is avalid field of TRBL. 
  605. $new_fields[$value] = $fields[$value]; 
  606. else { 
  607. // Array element type: [ 'bottom' => 'Bottom (px)' ] 
  608. $new_fields[$key] = $value; 
  609. $fields = $new_fields; 
  610.  
  611. // If the fields chosen were incorrect then bail. 
  612. if ( empty( $fields ) ) return; 
  613.  
  614. // Calculate column span based on the number of resulting fields. 
  615. $field_span = ( 12 / count( $fields ) ); 
  616. ?> 
  617. <div class="layers-row layers-input layers-trbl-row"> 
  618.  
  619. <?php foreach ( $fields as $key => $label ) : ?> 
  620. <div class="layers-column-flush layers-span-<?php echo esc_attr( $field_span ); ?>"> 
  621. <?php echo $this->input( 
  622. array( 
  623. 'type' => 'number',  
  624. 'name' => ( isset( $input->name ) ) ? "{$input->name}[$key]" : '',  
  625. 'id' => "{$input->id}-{$key}",  
  626. 'value' => ( isset( $input->value->$key ) ) ? $input->value->$key : NULL,  
  627. 'class' => 'l_admin-hide-controls',  
  628. 'data' => array( 
  629. 'customize-setting-link' => "{$input->id}-{$key}",  
  630. ),  
  631. ); ?> 
  632. <label for="<?php echo esc_attr( $input->id ) . '-' . $key; ?>"><?php echo esc_html( $label ); ?></label> 
  633. </div> 
  634. <?php endforeach; ?> 
  635.  
  636. </div> 
  637.  
  638. <?php break; 
  639. /** 
  640. * Free form HTML 
  641. */ 
  642. case 'html' : ?> 
  643.  
  644. <div class="layers-row"> 
  645. <?php echo $input->html; ?> 
  646. </div> 
  647.  
  648. <?php break; 
  649.  
  650. /** 
  651. * Dynamic Linking Interface 
  652. */ 
  653. case 'link-group' : ?> 
  654. <div class="layers-form-collection layers-link-group closed"> 
  655.  
  656. <!-- Header --> 
  657. <div class="layers-form-collection-header"> 
  658. <?php echo ( isset( $input->value->link_text ) ) ? $input->value->link_text : ' ' ; ?> 
  659. </div> 
  660. <!-- / Header --> 
  661.  
  662. <!-- Content --> 
  663. <div class="layers-form-collection-content"> 
  664.  
  665. <div class="layers-row"> 
  666. <div class="layers-form-item layers-column layers-span-5"> 
  667. <label for="<?php echo "{$input->id}-link_type"; ?>"> 
  668. <?php _e( 'Link' , 'layerswp' ); ?> 
  669. </label> 
  670. <?php echo $this->input( 
  671. array( 
  672. 'type' => 'select',  
  673. 'name' => "{$input->name}[link_type]",  
  674. 'id' => "{$input->id}-link_type",  
  675. 'options' => array( 
  676. 'custom' => __( 'Custom', 'layerswp' ),  
  677. 'post' => __( 'Existing Content', 'layerswp' ), // Page, Post, Custom Post Type 
  678. // 'post_type_archive' => __( 'Post Archives (incl. Custom Post Types)', 'layerswp' ),  
  679. // 'taxonomy_archive' => __( 'Taxonomy Archives (incl. Custom Taxonomies)', 'layerswp' ),  
  680. ),  
  681. 'value' => ( isset( $input->value->link_type ) ) ? $input->value->link_type : NULL,  
  682. 'class' => 'layers-text',  
  683. 'data' => array( 
  684. 'tip' => __( 'Choose Link Type', 'layerswp' ),  
  685. ),  
  686. ); ?> 
  687. </div> 
  688. <div class="layers-form-item layers-column layers-span-7 layers-link-field-holder"> 
  689. <label for="<?php echo "{$input->id}-link_type_custom"; ?>"> 
  690.   
  691. </label> 
  692. <div class="layers-form-item layers-link-field layers-link-field-link_type_custom" data-show-if-selector= "#<?php echo "{$input->id}-link_type"; ?>" data-show-if-value="custom" data-tip="<?php _e( 'Choose Your Link', 'layerswp' ) ?>"> 
  693. <label> 
  694. <?php _e( 'Custom', 'layerswp' ) ?> 
  695. </label> 
  696. <?php echo $this->input( 
  697. array( 
  698. 'type' => 'text',  
  699. 'name' => "{$input->name}[link_type_custom]",  
  700. 'id' => "{$input->id}-link_type_custom",  
  701. 'placeholder' => __( 'http://' , 'layerswp' ),  
  702. 'value' => ( isset( $input->value->link_type_custom ) ) ? $input->value->link_type_custom : NULL,  
  703. 'class' => 'layers-text',  
  704. 'data' => array( 
  705. 'tip' => __( 'Link', 'layerswp' ),  
  706. ),  
  707. ); ?> 
  708. </div> 
  709. <div class="layers-form-item layers-link-field layers-link-field-link_type_post" data-show-if-selector= "#<?php echo "{$input->id}-link_type"; ?>" data-show-if-value="post" data-tip="<?php _e( 'Choose Your Link', 'layerswp' ) ?>"> 
  710. <label> 
  711. <?php _e( 'Post/Page', 'layerswp' ) ?> 
  712. </label> 
  713. <?php 
  714. $initial_post_id = ( isset( $input->value->link_type_post ) && '' !== $input->value->link_type_post ) ? $input->value->link_type_post : 0 ; 
  715. $initial_display = ( 0 !== $initial_post_id ) ? get_the_title( $initial_post_id ) . ' (' . get_post_type( $initial_post_id ) . ')' : '' ; 
  716. echo $this->input( 
  717. array( 
  718. 'type' => 'hidden',  
  719. 'name' => "{$input->name}[link_type_post]",  
  720. 'id' => "{$input->id}-link_type_post",  
  721. 'placeholder' => __( '-- Choose --' , 'layerswp' ),  
  722. 'value' => ( isset( $input->value->link_type_post ) ) ? $input->value->link_type_post : NULL,  
  723. 'class' => 'layers-text layers-widget-dynamic-linking-select',  
  724. 'data' => array( 
  725. 'display-text' => $initial_display,  
  726. ),  
  727. ); 
  728. ?> 
  729. </div> 
  730. <div class="layers-form-item layers-link-field layers-link-field-link_type_post_type_archive" data-show-if-selector= "#<?php echo "{$input->id}-link_type"; ?>" data-show-if-value="post_type_archive" data-tip="<?php _e( 'Choose Your Link', 'layerswp' ) ?>"> 
  731. <label> 
  732. <?php _e( 'Post Archives', 'layerswp' ) ?> 
  733. </label> 
  734. <?php echo $this->input( 
  735. array( 
  736. 'type' => 'hidden',  
  737. 'name' => "{$input->name}[link_type_post_type_archive]",  
  738. 'id' => "{$input->id}-link_type_post_type_archive",  
  739. 'placeholder' => __( 'http://' , 'layerswp' ),  
  740. 'value' => ( isset( $input->value->link_type_post_type_archive ) ) ? $input->value->link_type_post_type_archive : NULL,  
  741. 'class' => 'layers-text layers-widget-dynamic-linking-select',  
  742. ); ?> 
  743. </div> 
  744. <div class="layers-form-item layers-link-field layers-link-field-link_type_taxonomy_archive" data-show-if-selector= "#<?php echo "{$input->id}-link_type"; ?>" data-show-if-value="taxonomy_archive" data-tip="<?php _e( 'Choose Your Link', 'layerswp' ) ?>"> 
  745. <label> 
  746. <?php _e( 'Taxonomy Archives', 'layerswp' ) ?> 
  747. </label> 
  748. <?php echo $this->input( 
  749. array( 
  750. 'type' => 'hidden',  
  751. 'name' => "{$input->name}[link_type_taxonomy_archive]",  
  752. 'id' => "{$input->id}-link_type_taxonomy_archive",  
  753. 'placeholder' => __( 'http://' , 'layerswp' ),  
  754. 'value' => ( isset( $input->value->link_type_taxonomy_archive ) ) ? $input->value->link_type_taxonomy_archive : NULL,  
  755. 'class' => 'layers-text layers-widget-dynamic-linking-select',  
  756. ); ?> 
  757. </div> 
  758. <div class="layers-visuals-item layers-icon-group layers-link-field-link_target"> 
  759. <?php echo $this->input( 
  760. array( 
  761. 'type' => 'select-icons',  
  762. 'name' => "{$input->name}[link_target]",  
  763. 'id' => "{$input->id}-link_target",  
  764. 'placeholder' => __( 'e.g. http://facebook.com/oboxthemes', 'layerswp' ),  
  765. 'value' => ( isset( $input->value->link_target ) ) ? $input->value->link_target : NULL,  
  766. 'options' => array( 
  767. '_blank' => array( 
  768. 'name' => 'New Tab',  
  769. 'class' => 'fa fa-share-square-o',  
  770. 'data' => array( 
  771. 'tip' => 'Open in New Tab',  
  772. ),  
  773. ),  
  774. ) ); ?> 
  775. </div> 
  776. </div> 
  777. </div> 
  778.  
  779. <div class="layers-row"> 
  780. <div class="layers-form-item layers-column layers-span-12"> 
  781. <label for="<?php echo "{$input->id}-link_text"; ?>"> 
  782. <?php _e( 'Text' , 'layerswp' ); ?> 
  783. </label> 
  784. <?php echo $this->input( 
  785. array( 
  786. 'type' => 'text',  
  787. 'name' => "{$input->name}[link_text]",  
  788. 'id' => "{$input->id}-link_text",  
  789. 'placeholder' => __( 'e.g. "Read More"' , 'layerswp' ),  
  790. 'value' => ( isset( $input->value->link_text ) ) ? $input->value->link_text : NULL,  
  791. ); ?> 
  792. </div> 
  793. </div> 
  794.  
  795. </div> 
  796. <!-- / Content --> 
  797.  
  798. </div> 
  799.  
  800. <?php break; 
  801.  
  802. /** 
  803. * Default to hidden field 
  804. */ 
  805. default : ?> 
  806. <input type="hidden" <?php echo implode ( ' ' , $input_props ); ?> value="<?php echo $input->value; ?>" /> 
  807. <?php 
  808.  
  809.