ReduxFramework_ace_editor

The Gravity Forms Advanced File Uploader ReduxFramework ace editor class.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/fields/ace_editor/field_ace_editor.php  
  1. class ReduxFramework_ace_editor { 
  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 ReduxFramework 1.0.0 
  7. */ 
  8. function __construct( $field = array(), $value = '', $parent ) { 
  9. $this->parent = $parent; 
  10. $this->field = $field; 
  11. $this->value = $value; 
  12.  
  13. if ( is_array( $this->value ) ) { 
  14. $this->value = ''; 
  15. } else { 
  16. $this->value = trim( $this->value ); 
  17.  
  18. if ( ! empty( $this->field['options'] ) ) { 
  19. $this->field['args'] = $this->field['options']; 
  20. unset( $this->field['options'] ); 
  21.  
  22.  
  23. /** 
  24. * Field Render Function. 
  25. * Takes the vars and outputs the HTML for the field in the settings 
  26. * @since ReduxFramework 1.0.0 
  27. */ 
  28. function render() { 
  29.  
  30. if ( ! isset( $this->field['mode'] ) ) { 
  31. $this->field['mode'] = 'javascript'; 
  32. if ( ! isset( $this->field['theme'] ) ) { 
  33. $this->field['theme'] = 'monokai'; 
  34.  
  35. $params = array( 
  36. 'minLines' => 10,  
  37. 'maxLines' => 30,  
  38. ); 
  39.  
  40. if ( isset( $this->field['args'] ) && ! empty( $this->field['args'] ) && is_array( $this->field['args'] ) ) { 
  41. $params = wp_parse_args( $this->field['args'], $params ); 
  42.  
  43. ?> 
  44. <div class="ace-wrapper"> 
  45. <input type="hidden" class="localize_data" 
  46. value="<?php echo htmlspecialchars( json_encode( $params ) ); ?>"/> 
  47. <textarea name="<?php echo $this->field['name'] . $this->field['name_suffix']; ?>" 
  48. id="<?php echo $this->field['id']; ?>-textarea" 
  49. class="ace-editor hide <?php echo $this->field['class']; ?>" 
  50. data-editor="<?php echo $this->field['id']; ?>-editor" 
  51. data-mode="<?php echo $this->field['mode']; ?>" 
  52. data-theme="<?php echo $this->field['theme']; ?>"> 
  53. <?php echo $this->value; ?> 
  54. </textarea> 
  55. <pre id="<?php echo $this->field['id']; ?>-editor" 
  56. class="ace-editor-area"><?php echo htmlspecialchars( $this->value ); ?></pre> 
  57. </div> 
  58. <?php 
  59.  
  60. /** 
  61. * Enqueue Function. 
  62. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  63. * @since 1.0.0 
  64. * @access public 
  65. * @return void 
  66. */ 
  67. public function enqueue() { 
  68.  
  69. redux_enqueue_style( 
  70. $this->parent,  
  71. 'redux-field-ace-editor-css',  
  72. ReduxFramework::$_url . 'inc/fields/ace_editor/field_ace_editor.css',  
  73. ReduxFramework::$_dir . 'inc/fields/ace_editor',  
  74. array(),  
  75. time(),  
  76. false 
  77. ); 
  78.  
  79. wp_enqueue_script( 
  80. 'ace-editor-js',  
  81. ReduxFramework::$_url . 'inc/fields/ace_editor/vendor/ace.js',  
  82. array( 'jquery' ),  
  83. filemtime( ReduxFramework::$_dir . 'inc/fields/ace_editor/vendor/ace.js' ),  
  84. true 
  85. ); 
  86.  
  87. wp_enqueue_script( 
  88. 'redux-field-ace-editor-js',  
  89. ReduxFramework::$_url . 'inc/fields/ace_editor/field_ace_editor' . Redux_Functions::isMin() . '.js',  
  90. array( 'jquery', 'ace-editor-js', 'redux-js' ),  
  91. time(),  
  92. true 
  93. );