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/bp-xprofile/bp-xprofile-admin.php
+++ b/bp-xprofile/bp-xprofile-admin.php
@@ -247,6 +247,8 @@ function xprofile_admin_manage_field( $group_id, $field_id = null ) {
 			$field->is_required = wp_filter_kses( $_POST['required'] );
 			$field->type        = wp_filter_kses( $_POST['fieldtype'] );
 
+			$field->placeholder = wp_filter_kses( $_POST["placeholder_{$field->type}"] );
+
 			if ( !empty( $_POST["sort_order_{$field->type}"] ) )
 				$field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] );
 
@@ -283,6 +285,8 @@ function xprofile_admin_manage_field( $group_id, $field_id = null ) {
 					bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] );
 				}
 
+				bp_xprofile_update_field_meta( $field_id, 'placeholder', $_POST["placeholder_{$field->type}"] );
+
 				unset( $_GET['mode'] );
 
 				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/bp-xprofile/bp-xprofile-classes.php
+++ b/bp-xprofile/bp-xprofile-classes.php
@@ -478,6 +478,8 @@ class BP_XProfile_Field {
 				$this->data          = $this->get_field_data( $user_id );
 			}
 
+			$this->placeholder = bp_xprofile_get_meta( $id, 'field', 'placeholder' );
+
 			$this->default_visibility = bp_xprofile_get_meta( $id, 'field', 'default_visibility' );
 
 			if ( empty( $this->default_visibility ) ) {
@@ -519,6 +521,7 @@ class BP_XProfile_Field {
 		$this->order_by	   = apply_filters( 'xprofile_field_order_by_before_save',    $this->order_by,    $this->id );
 		$this->field_order = apply_filters( 'xprofile_field_field_order_before_save', $this->field_order, $this->id );
 		$this->can_delete  = apply_filters( 'xprofile_field_can_delete_before_save',  $this->can_delete,  $this->id );
+		$this->placeholder = apply_filters( 'xprofile_field_placeholder_before_save', $this->placeholder, $this->id );
 
 		do_action_ref_array( 'xprofile_field_before_save', array( $this ) );
 
@@ -617,6 +620,8 @@ class BP_XProfile_Field {
 				}
 			}
 
+			bp_xprofile_update_field_meta( $field_id, 'placeholder', $field->placeholder);
+
 			do_action_ref_array( 'xprofile_field_after_save', array( $this ) );
 
 			return $field_id;
@@ -754,6 +759,10 @@ class BP_XProfile_Field {
 				<h3><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h3>
 				<div class="inside">
 					<p>
+						<label for="placeholder_text_<?php echo esc_attr( $type ); ?>"><?php _e( 'Placeholder text:', 'buddypress' ); ?></label>
+						<input type="text" name="placeholder_text_<?php echo esc_attr( $type ); ?>" id="placeholder_text_<?php echo esc_attr( $type ); ?>" value=<?php _e( '----', 'buddypress' ); ?> />
+					</p>
+					<p>
 						<label for="sort_order_<?php echo esc_attr( $type ); ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label>
 						<select name="sort_order_<?php echo esc_attr( $type ); ?>" id="sort_order_<?php echo esc_attr( $type ); ?>" >
 							<option value="custom" <?php selected( 'custom', $this->order_by ); ?>><?php _e( 'Custom',     'buddypress' ); ?></option>
@@ -828,6 +837,7 @@ class BP_XProfile_Field {
 				$this->description = $_POST['description'];
 				$this->is_required = $_POST['required'];
 				$this->type        = $_POST['fieldtype'];
+				$this->placeholder = $_POST["placeholder_{$this->type}"];
 				$this->order_by    = $_POST["sort_order_{$this->type}"];
 				$this->field_order = $_POST['field_order'];
 			}
-- 
1.7.9.5

