From 35eed3cac4bb023cc54d622392356f28c7040e8e Mon Sep 17 00:00:00 2001
From: Anand Kumria <akumria@acm.org>
Date: Sun, 24 Nov 2013 15:36:56 +0000
Subject: [PATCH 3/4] Add the ability to specify the placeholder text for a
field.
We save this as a meta field option, so I assume that standard field id
changes will be propagated throughout the various tables.
---
bp-xprofile/bp-xprofile-admin.php | 4 ++++
bp-xprofile/bp-xprofile-classes.php | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/bp-xprofile/bp-xprofile-admin.php b/bp-xprofile/bp-xprofile-admin.php
index 95151ea..4eca6e7 100644
a
|
b
|
function xprofile_admin_manage_field( $group_id, $field_id = null ) { |
247 | 247 | $field->is_required = wp_filter_kses( $_POST['required'] ); |
248 | 248 | $field->type = wp_filter_kses( $_POST['fieldtype'] ); |
249 | 249 | |
| 250 | $field->placeholder = wp_filter_kses( $_POST["placeholder_{$field->type}"] ); |
| 251 | |
250 | 252 | if ( !empty( $_POST["sort_order_{$field->type}"] ) ) |
251 | 253 | $field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] ); |
252 | 254 | |
… |
… |
function xprofile_admin_manage_field( $group_id, $field_id = null ) { |
283 | 285 | bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] ); |
284 | 286 | } |
285 | 287 | |
| 288 | bp_xprofile_update_field_meta( $field_id, 'placeholder', $_POST["placeholder_{$field->type}"] ); |
| 289 | |
286 | 290 | unset( $_GET['mode'] ); |
287 | 291 | |
288 | 292 | do_action( 'xprofile_fields_saved_field', $field ); |
diff --git a/bp-xprofile/bp-xprofile-classes.php b/bp-xprofile/bp-xprofile-classes.php
index 84df571..46d5dde 100644
a
|
b
|
class BP_XProfile_Field { |
478 | 478 | $this->data = $this->get_field_data( $user_id ); |
479 | 479 | } |
480 | 480 | |
| 481 | $this->placeholder = bp_xprofile_get_meta( $id, 'field', 'placeholder' ); |
| 482 | |
481 | 483 | $this->default_visibility = bp_xprofile_get_meta( $id, 'field', 'default_visibility' ); |
482 | 484 | |
483 | 485 | if ( empty( $this->default_visibility ) ) { |
… |
… |
class BP_XProfile_Field { |
519 | 521 | $this->order_by = apply_filters( 'xprofile_field_order_by_before_save', $this->order_by, $this->id ); |
520 | 522 | $this->field_order = apply_filters( 'xprofile_field_field_order_before_save', $this->field_order, $this->id ); |
521 | 523 | $this->can_delete = apply_filters( 'xprofile_field_can_delete_before_save', $this->can_delete, $this->id ); |
| 524 | $this->placeholder = apply_filters( 'xprofile_field_placeholder_before_save', $this->placeholder, $this->id ); |
522 | 525 | |
523 | 526 | do_action_ref_array( 'xprofile_field_before_save', array( $this ) ); |
524 | 527 | |
… |
… |
class BP_XProfile_Field { |
617 | 620 | } |
618 | 621 | } |
619 | 622 | |
| 623 | bp_xprofile_update_field_meta( $field_id, 'placeholder', $field->placeholder); |
| 624 | |
620 | 625 | do_action_ref_array( 'xprofile_field_after_save', array( $this ) ); |
621 | 626 | |
622 | 627 | return $field_id; |
… |
… |
class BP_XProfile_Field { |
754 | 759 | <h3><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h3> |
755 | 760 | <div class="inside"> |
756 | 761 | <p> |
| 762 | <label for="placeholder_text_<?php echo esc_attr( $type ); ?>"><?php _e( 'Placeholder text:', 'buddypress' ); ?></label> |
| 763 | <input type="text" name="placeholder_text_<?php echo esc_attr( $type ); ?>" id="placeholder_text_<?php echo esc_attr( $type ); ?>" value=<?php _e( '----', 'buddypress' ); ?> /> |
| 764 | </p> |
| 765 | <p> |
757 | 766 | <label for="sort_order_<?php echo esc_attr( $type ); ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label> |
758 | 767 | <select name="sort_order_<?php echo esc_attr( $type ); ?>" id="sort_order_<?php echo esc_attr( $type ); ?>" > |
759 | 768 | <option value="custom" <?php selected( 'custom', $this->order_by ); ?>><?php _e( 'Custom', 'buddypress' ); ?></option> |
… |
… |
class BP_XProfile_Field { |
828 | 837 | $this->description = $_POST['description']; |
829 | 838 | $this->is_required = $_POST['required']; |
830 | 839 | $this->type = $_POST['fieldtype']; |
| 840 | $this->placeholder = $_POST["placeholder_{$this->type}"]; |
831 | 841 | $this->order_by = $_POST["sort_order_{$this->type}"]; |
832 | 842 | $this->field_order = $_POST['field_order']; |
833 | 843 | } |