Skip to:
Content

BuddyPress.org

Ticket #5184: full-patch

File full-patch, 4.7 KB (added by haykayltduk, 11 years ago)

the full patch

Line 
1diff --git a/bp-xprofile/bp-xprofile-admin.php b/bp-xprofile/bp-xprofile-admin.php
2index 95151ea..4eca6e7 100644
3--- a/bp-xprofile/bp-xprofile-admin.php
4+++ b/bp-xprofile/bp-xprofile-admin.php
5@@ -247,6 +247,8 @@ function xprofile_admin_manage_field( $group_id, $field_id = null ) {
6                        $field->is_required = wp_filter_kses( $_POST['required'] );
7                        $field->type        = wp_filter_kses( $_POST['fieldtype'] );
8 
9+                       $field->placeholder = wp_filter_kses( $_POST["placeholder_{$field->type}"] );
10+
11                        if ( !empty( $_POST["sort_order_{$field->type}"] ) )
12                                $field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] );
13 
14@@ -283,6 +285,8 @@ function xprofile_admin_manage_field( $group_id, $field_id = null ) {
15                                        bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] );
16                                }
17 
18+                               bp_xprofile_update_field_meta( $field_id, 'placeholder', $_POST["placeholder_{$field->type}"] );
19+
20                                unset( $_GET['mode'] );
21 
22                                do_action( 'xprofile_fields_saved_field', $field );
23diff --git a/bp-xprofile/bp-xprofile-classes.php b/bp-xprofile/bp-xprofile-classes.php
24index 84df571..46d5dde 100644
25--- a/bp-xprofile/bp-xprofile-classes.php
26+++ b/bp-xprofile/bp-xprofile-classes.php
27@@ -478,6 +478,8 @@ class BP_XProfile_Field {
28                                $this->data          = $this->get_field_data( $user_id );
29                        }
30 
31+                       $this->placeholder = bp_xprofile_get_meta( $id, 'field', 'placeholder' );
32+
33                        $this->default_visibility = bp_xprofile_get_meta( $id, 'field', 'default_visibility' );
34 
35                        if ( empty( $this->default_visibility ) ) {
36@@ -519,6 +521,7 @@ class BP_XProfile_Field {
37                $this->order_by    = apply_filters( 'xprofile_field_order_by_before_save',    $this->order_by,    $this->id );
38                $this->field_order = apply_filters( 'xprofile_field_field_order_before_save', $this->field_order, $this->id );
39                $this->can_delete  = apply_filters( 'xprofile_field_can_delete_before_save',  $this->can_delete,  $this->id );
40+               $this->placeholder = apply_filters( 'xprofile_field_placeholder_before_save', $this->placeholder, $this->id );
41 
42                do_action_ref_array( 'xprofile_field_before_save', array( $this ) );
43 
44@@ -617,6 +620,8 @@ class BP_XProfile_Field {
45                                }
46                        }
47 
48+                       bp_xprofile_update_field_meta( $field_id, 'placeholder', $field->placeholder);
49+
50                        do_action_ref_array( 'xprofile_field_after_save', array( $this ) );
51 
52                        return $field_id;
53@@ -754,6 +759,10 @@ class BP_XProfile_Field {
54                                <h3><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h3>
55                                <div class="inside">
56                                        <p>
57+                                               <label for="placeholder_text_<?php echo esc_attr( $type ); ?>"><?php _e( 'Placeholder text:', 'buddypress' ); ?></label>
58+                                               <input type="text" name="placeholder_text_<?php echo esc_attr( $type ); ?>" id="placeholder_text_<?php echo esc_attr( $type ); ?>" value=<?php _e( '----', 'buddypress' ); ?> />
59+                                       </p>
60+                                       <p>
61                                                <label for="sort_order_<?php echo esc_attr( $type ); ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label>
62                                                <select name="sort_order_<?php echo esc_attr( $type ); ?>" id="sort_order_<?php echo esc_attr( $type ); ?>" >
63                                                        <option value="custom" <?php selected( 'custom', $this->order_by ); ?>><?php _e( 'Custom',     'buddypress' ); ?></option>
64@@ -828,6 +837,7 @@ class BP_XProfile_Field {
65                                $this->description = $_POST['description'];
66                                $this->is_required = $_POST['required'];
67                                $this->type        = $_POST['fieldtype'];
68+                               $this->placeholder = $_POST["placeholder_{$this->type}"];
69                                $this->order_by    = $_POST["sort_order_{$this->type}"];
70                                $this->field_order = $_POST['field_order'];
71                        }
72diff --git a/bp-xprofile/bp-xprofile-template.php b/bp-xprofile/bp-xprofile-template.php
73index a82db1c..ab2af1a 100644
74--- a/bp-xprofile/bp-xprofile-template.php
75+++ b/bp-xprofile/bp-xprofile-template.php
76@@ -420,6 +420,15 @@ function bp_get_the_profile_field_errors_action() {
77 function bp_the_profile_field_options( $args = '' ) {
78        echo bp_get_the_profile_field_options( $args );
79 }
80+
81+function bp_get_placeholder_text_for_field( $field ) {
82+    if ($field->placeholder) {
83+               return $field->placeholder;
84+    } else {
85+               return /* translators: no option picked in select box */ __( '----', 'buddypress' ) ;
86+    }
87+}
88+
89        /**
90         * bp_get_the_profile_field_options()
91         *
92@@ -468,7 +477,7 @@ function bp_the_profile_field_options( $args = '' ) {
93                switch ( $field->type ) {
94                        case 'selectbox':
95 
96-                               $html .= '<option value="">' . /* translators: no option picked in select box */ __( '----', 'buddypress' ) . '</option>';
97+                               $html .= '<option value="">' . esc_html( bp_get_placeholder_text_for_field($field) ) . '</option>';
98 
99                                $original_option_values = '';
100                                $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) );