BP_XProfile_Field_Type_Textarea

Textarea xprofile field type.

Defined (1)

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

/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php  
  1. class BP_XProfile_Field_Type_Textarea extends BP_XProfile_Field_Type { 
  2.  
  3. /** 
  4. * Constructor for the textarea field type. 
  5. * @since 2.0.0 
  6. */ 
  7. public function __construct() { 
  8. parent::__construct(); 
  9.  
  10. $this->category = _x( 'Single Fields', 'xprofile field type category', 'buddypress' ); 
  11. $this->name = _x( 'Multi-line Text Area', 'xprofile field type', 'buddypress' ); 
  12. $this->supports_richtext = true; 
  13.  
  14. $this->set_format( '/^.*$/m', 'replace' ); 
  15.  
  16. /** 
  17. * Fires inside __construct() method for BP_XProfile_Field_Type_Textarea class. 
  18. * @since 2.0.0 
  19. * @param BP_XProfile_Field_Type_Textarea $this Current instance of 
  20. * the field type textarea. 
  21. */ 
  22. do_action( 'bp_xprofile_field_type_textarea', $this ); 
  23.  
  24. /** 
  25. * Output the edit field HTML for this field type. 
  26. * Must be used inside the {@link bp_profile_fields()} template loop. 
  27. * @since 2.0.0 
  28. * @param array $raw_properties Optional key/value array of 
  29. * {@link http://dev.w3.org/html5/markup/textarea.html permitted attributes} 
  30. * that you want to add. 
  31. */ 
  32. public function edit_field_html( array $raw_properties = array() ) { 
  33.  
  34. // User_id is a special optional parameter that certain other fields 
  35. // types pass to {@link bp_the_profile_field_options()}. 
  36. if ( isset( $raw_properties['user_id'] ) ) { 
  37. unset( $raw_properties['user_id'] ); 
  38.  
  39. $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field(); ?> 
  40.  
  41. <label for="<?php bp_the_profile_field_input_name(); ?>"> 
  42. <?php bp_the_profile_field_name(); ?> 
  43. <?php bp_the_profile_field_required_label(); ?> 
  44. </label> 
  45.  
  46. <?php 
  47.  
  48. /** This action is documented in bp-xprofile/bp-xprofile-classes */ 
  49. do_action( bp_get_the_profile_field_errors_action() ); 
  50.  
  51. if ( ! $richtext_enabled ) { 
  52. $r = wp_parse_args( $raw_properties, array( 
  53. 'cols' => 40,  
  54. 'rows' => 5,  
  55. ) ); 
  56.  
  57. ?> 
  58.  
  59. <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>><?php bp_the_profile_field_edit_value(); ?></textarea> 
  60.  
  61. <?php 
  62.  
  63. } else { 
  64.  
  65. /** 
  66. * Filters the arguments passed to `wp_editor()` in richtext xprofile fields. 
  67. * @since 2.4.0 
  68. * @param array $args { 
  69. * Array of optional arguments. See `wp_editor()`. 
  70. * @type bool $teeny Whether to use the teeny version of TinyMCE. Default true. 
  71. * @type bool $media_buttons Whether to show media buttons. Default false. 
  72. * @type bool $quicktags Whether to show the quicktags buttons. Default true. 
  73. * @type int $textarea_rows Number of rows to display in the editor. Defaults to 1 in the 
  74. * 'admin' context, and 10 in the 'edit' context. 
  75. * } 
  76. * @param string $context The display context. 'edit' when the markup is intended for the 
  77. * profile edit screen, 'admin' when intended for the Profile Fields 
  78. * Dashboard panel. 
  79. */ 
  80. $editor_args = apply_filters( 'bp_xprofile_field_type_textarea_editor_args', array( 
  81. 'teeny' => true,  
  82. 'media_buttons' => false,  
  83. 'quicktags' => true,  
  84. 'textarea_rows' => 10,  
  85. ), 'edit' ); 
  86.  
  87. wp_editor( 
  88. bp_get_the_profile_field_edit_value(),  
  89. bp_get_the_profile_field_input_name(),  
  90. $editor_args 
  91. ); 
  92.  
  93. /** 
  94. * Output HTML for this field type on the wp-admin Profile Fields screen. 
  95. * Must be used inside the {@link bp_profile_fields()} template loop. 
  96. * @since 2.0.0 
  97. * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. 
  98. */ 
  99. public function admin_field_html( array $raw_properties = array() ) { 
  100. $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field(); 
  101.  
  102. if ( ! $richtext_enabled ) { 
  103.  
  104. $r = bp_parse_args( $raw_properties, array( 
  105. 'cols' => 40,  
  106. 'rows' => 5,  
  107. ) ); ?> 
  108.  
  109. <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>></textarea> 
  110.  
  111. <?php 
  112. } else { 
  113.  
  114. /** This filter is documented in bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php */ 
  115. $editor_args = apply_filters( 'bp_xprofile_field_type_textarea_editor_args', array( 
  116. 'teeny' => true,  
  117. 'media_buttons' => false,  
  118. 'quicktags' => true,  
  119. 'textarea_rows' => 1,  
  120. ), 'admin' ); 
  121.  
  122. wp_editor( 
  123. '',  
  124. 'xprofile_textarea_' . bp_get_the_profile_field_id(),  
  125. $editor_args 
  126. ); 
  127.  
  128. /** 
  129. * This method usually outputs HTML for this field type's children options on the wp-admin Profile Fields 
  130. * "Add Field" and "Edit Field" screens, but for this field type, we don't want it, so it's stubbed out. 
  131. * @since 2.0.0 
  132. * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen. 
  133. * @param string $control_type Optional. HTML input type used to render the current 
  134. * field's child options. 
  135. */ 
  136. public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {}