[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress XProfile Classes. 4 * 5 * @package BuddyPress 6 * @subpackage XProfileClasses 7 * @since 2.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Textarea xprofile field type. 15 * 16 * @since 2.0.0 17 */ 18 class BP_XProfile_Field_Type_Textarea extends BP_XProfile_Field_Type { 19 20 /** 21 * Constructor for the textarea field type. 22 * 23 * @since 2.0.0 24 */ 25 public function __construct() { 26 parent::__construct(); 27 28 $this->category = _x( 'Single Fields', 'xprofile field type category', 'buddypress' ); 29 $this->name = _x( 'Multi-line Text Area', 'xprofile field type', 'buddypress' ); 30 $this->supports_richtext = true; 31 32 $this->set_format( '/^.*$/m', 'replace' ); 33 34 /** 35 * Fires inside __construct() method for BP_XProfile_Field_Type_Textarea class. 36 * 37 * @since 2.0.0 38 * 39 * @param BP_XProfile_Field_Type_Textarea $this Current instance of 40 * the field type textarea. 41 */ 42 do_action( 'bp_xprofile_field_type_textarea', $this ); 43 } 44 45 /** 46 * Output the edit field HTML for this field type. 47 * 48 * Must be used inside the {@link bp_profile_fields()} template loop. 49 * 50 * @since 2.0.0 51 * 52 * @param array $raw_properties Optional key/value array of 53 * {@link http://dev.w3.org/html5/markup/textarea.html permitted attributes} 54 * that you want to add. 55 */ 56 public function edit_field_html( array $raw_properties = array() ) { 57 58 // User_id is a special optional parameter that certain other fields 59 // types pass to {@link bp_the_profile_field_options()}. 60 if ( isset( $raw_properties['user_id'] ) ) { 61 unset( $raw_properties['user_id'] ); 62 } 63 64 $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field(); ?> 65 66 <legend id="<?php bp_the_profile_field_input_name(); ?>-1"> 67 <?php bp_the_profile_field_name(); ?> 68 <?php bp_the_profile_field_required_label(); ?> 69 </legend> 70 71 <?php 72 73 /** This action is documented in bp-xprofile/bp-xprofile-classes */ 74 do_action( bp_get_the_profile_field_errors_action() ); 75 76 if ( ! $richtext_enabled ) { 77 $r = bp_parse_args( 78 $raw_properties, 79 array( 80 'cols' => 40, 81 'rows' => 5, 82 ) 83 ); 84 ?> 85 86 <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?> aria-labelledby="<?php bp_the_profile_field_input_name(); ?>-1" aria-describedby="<?php bp_the_profile_field_input_name(); ?>-3"><?php bp_the_profile_field_edit_value(); ?></textarea> 87 88 <?php 89 90 } else { 91 92 /** 93 * Filters the arguments passed to `wp_editor()` in richtext xprofile fields. 94 * 95 * @since 2.4.0 96 * 97 * @param array $args { 98 * Array of optional arguments. See `wp_editor()`. 99 * @type bool $teeny Whether to use the teeny version of TinyMCE. Default true. 100 * @type bool $media_buttons Whether to show media buttons. Default false. 101 * @type bool $quicktags Whether to show the quicktags buttons. Default true. 102 * @type int $textarea_rows Number of rows to display in the editor. Defaults to 1 in the 103 * 'admin' context, and 10 in the 'edit' context. 104 * } 105 * @param string $context The display context. 'edit' when the markup is intended for the 106 * profile edit screen, 'admin' when intended for the Profile Fields 107 * Dashboard panel. 108 */ 109 $editor_args = apply_filters( 'bp_xprofile_field_type_textarea_editor_args', array( 110 'teeny' => true, 111 'media_buttons' => false, 112 'quicktags' => true, 113 'textarea_rows' => 10, 114 ), 'edit' ); 115 116 wp_editor( 117 bp_get_the_profile_field_edit_value(), 118 bp_get_the_profile_field_input_name(), 119 $editor_args 120 ); 121 } 122 123 if ( bp_get_the_profile_field_description() ) : ?> 124 <p class="description" id="<?php bp_the_profile_field_input_name(); ?>-3"><?php bp_the_profile_field_description(); ?></p> 125 <?php endif; 126 } 127 128 /** 129 * Output HTML for this field type on the wp-admin Profile Fields screen. 130 * 131 * Must be used inside the {@link bp_profile_fields()} template loop. 132 * 133 * @since 2.0.0 134 * 135 * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. 136 */ 137 public function admin_field_html( array $raw_properties = array() ) { 138 $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field(); 139 140 if ( ! $richtext_enabled ) { 141 142 $r = bp_parse_args( 143 $raw_properties, 144 array( 145 'cols' => 40, 146 'rows' => 5, 147 ) 148 ); 149 ?> 150 151 <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>></textarea> 152 153 <?php 154 } else { 155 156 /** This filter is documented in bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php */ 157 $editor_args = apply_filters( 'bp_xprofile_field_type_textarea_editor_args', array( 158 'teeny' => true, 159 'media_buttons' => false, 160 'quicktags' => true, 161 'textarea_rows' => 1, 162 ), 'admin' ); 163 164 wp_editor( 165 '', 166 'xprofile_textarea_' . bp_get_the_profile_field_id(), 167 $editor_args 168 ); 169 } 170 } 171 172 /** 173 * This method usually outputs HTML for this field type's children options on the wp-admin Profile Fields 174 * "Add Field" and "Edit Field" screens, but for this field type, we don't want it, so it's stubbed out. 175 * 176 * @since 2.0.0 177 * 178 * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen. 179 * @param string $control_type Optional. HTML input type used to render the current 180 * field's child options. 181 */ 182 public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {} 183 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |