ReduxFramework_multi_text

Main ReduxFramework_multi_text class.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/fields/multi_text/field_multi_text.php  
  1. class ReduxFramework_multi_text { 
  2.  
  3. /** 
  4. * Field Constructor. 
  5. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function 
  6. * @since 1.0.0 
  7. * @access public 
  8. * @return void 
  9. */ 
  10. function __construct( $field = array(), $value = '', $parent ) { 
  11. $this->parent = $parent; 
  12. $this->field = $field; 
  13. $this->value = $value; 
  14.  
  15. /** 
  16. * Field Render Function. 
  17. * Takes the vars and outputs the HTML for the field in the settings 
  18. * @since 1.0.0 
  19. * @access public 
  20. * @return void 
  21. */ 
  22. public function render() { 
  23.  
  24. $this->add_text = ( isset( $this->field['add_text'] ) ) ? $this->field['add_text'] : __( 'Add More', 'redux-framework' ); 
  25. $this->show_empty = ( isset( $this->field['show_empty'] ) ) ? $this->field['show_empty'] : true; 
  26.  
  27. echo '<ul id="' . $this->field['id'] . '-ul" class="redux-multi-text">'; 
  28.  
  29. if ( isset( $this->value ) && is_array( $this->value ) ) { 
  30. foreach ( $this->value as $k => $value ) { 
  31. if ( $value != '' ) { 
  32. echo '<li><input type="text" id="' . $this->field['id'] . '-' . $k . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[]' . '" value="' . esc_attr( $value ) . '" class="regular-text ' . $this->field['class'] . '" /> <a href="javascript:void(0);" class="deletion redux-multi-text-remove">' . __( 'Remove', 'redux-framework' ) . '</a></li>'; 
  33. } elseif ( $this->show_empty == true ) { 
  34. echo '<li><input type="text" id="' . $this->field['id'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[]' . '" value="" class="regular-text ' . $this->field['class'] . '" /> <a href="javascript:void(0);" class="deletion redux-multi-text-remove">' . __( 'Remove', 'redux-framework' ) . '</a></li>'; 
  35.  
  36. echo '<li style="display:none;"><input type="text" id="' . $this->field['id'] . '" name="" value="" class="regular-text" /> <a href="javascript:void(0);" class="deletion redux-multi-text-remove">' . __( 'Remove', 'redux-framework' ) . '</a></li>'; 
  37.  
  38. echo '</ul>'; 
  39. $this->field['add_number'] = ( isset( $this->field['add_number'] ) && is_numeric( $this->field['add_number'] ) ) ? $this->field['add_number'] : 1; 
  40. echo '<a href="javascript:void(0);" class="button button-primary redux-multi-text-add" data-add_number="' . $this->field['add_number'] . '" data-id="' . $this->field['id'] . '-ul" data-name="' . $this->field['name'] . $this->field['name_suffix'] . '[]">' . $this->add_text . '</a><br/>'; 
  41.  
  42. /** 
  43. * Enqueue Function. 
  44. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  45. * @since 1.0.0 
  46. * @access public 
  47. * @return void 
  48. */ 
  49. public function enqueue() { 
  50.  
  51. wp_enqueue_script( 
  52. 'redux-field-multi-text-js',  
  53. ReduxFramework::$_url . 'inc/fields/multi_text/field_multi_text' . Redux_Functions::isMin() . '.js',  
  54. array( 'jquery', 'redux-js' ),  
  55. time(),  
  56. true 
  57. ); 
  58.  
  59. redux_enqueue_style( 
  60. $this->parent,  
  61. 'redux-field-multi-text-css',  
  62. ReduxFramework::$_url . 'inc/fields/multi_text/field_multi_text.css',  
  63. ReduxFramework::$_dir . 'inc/fields/multi_text',  
  64. array(),  
  65. time(),  
  66. false 
  67. );  
  68.  
  69. // wp_enqueue_style( 
  70. // 'redux-field-multi-text-css',  
  71. // ReduxFramework::$_url . 'inc/fields/multi_text/field_multi_text.css',  
  72. // time(),  
  73. // true 
  74. // );