Skip to:
Content

BuddyPress.org

Ticket #5184: 0003-Add-the-ability-to-specify-the-placeholder-text-for-.patch

File 0003-Add-the-ability-to-specify-the-placeholder-text-for-.patch, 4.0 KB (added by haykayltduk, 10 years ago)

display, save and set the 'placeholder' meta value

  • bp-xprofile/bp-xprofile-admin.php

    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 ) { 
    247247                        $field->is_required = wp_filter_kses( $_POST['required'] );
    248248                        $field->type        = wp_filter_kses( $_POST['fieldtype'] );
    249249
     250                        $field->placeholder = wp_filter_kses( $_POST["placeholder_{$field->type}"] );
     251
    250252                        if ( !empty( $_POST["sort_order_{$field->type}"] ) )
    251253                                $field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] );
    252254
    function xprofile_admin_manage_field( $group_id, $field_id = null ) { 
    283285                                        bp_xprofile_update_field_meta( $field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility'] );
    284286                                }
    285287
     288                                bp_xprofile_update_field_meta( $field_id, 'placeholder', $_POST["placeholder_{$field->type}"] );
     289
    286290                                unset( $_GET['mode'] );
    287291
    288292                                do_action( 'xprofile_fields_saved_field', $field );
  • bp-xprofile/bp-xprofile-classes.php

    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 { 
    478478                                $this->data          = $this->get_field_data( $user_id );
    479479                        }
    480480
     481                        $this->placeholder = bp_xprofile_get_meta( $id, 'field', 'placeholder' );
     482
    481483                        $this->default_visibility = bp_xprofile_get_meta( $id, 'field', 'default_visibility' );
    482484
    483485                        if ( empty( $this->default_visibility ) ) {
    class BP_XProfile_Field { 
    519521                $this->order_by    = apply_filters( 'xprofile_field_order_by_before_save',    $this->order_by,    $this->id );
    520522                $this->field_order = apply_filters( 'xprofile_field_field_order_before_save', $this->field_order, $this->id );
    521523                $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 );
    522525
    523526                do_action_ref_array( 'xprofile_field_before_save', array( $this ) );
    524527
    class BP_XProfile_Field { 
    617620                                }
    618621                        }
    619622
     623                        bp_xprofile_update_field_meta( $field_id, 'placeholder', $field->placeholder);
     624
    620625                        do_action_ref_array( 'xprofile_field_after_save', array( $this ) );
    621626
    622627                        return $field_id;
    class BP_XProfile_Field { 
    754759                                <h3><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h3>
    755760                                <div class="inside">
    756761                                        <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>
    757766                                                <label for="sort_order_<?php echo esc_attr( $type ); ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label>
    758767                                                <select name="sort_order_<?php echo esc_attr( $type ); ?>" id="sort_order_<?php echo esc_attr( $type ); ?>" >
    759768                                                        <option value="custom" <?php selected( 'custom', $this->order_by ); ?>><?php _e( 'Custom',     'buddypress' ); ?></option>
    class BP_XProfile_Field { 
    828837                                $this->description = $_POST['description'];
    829838                                $this->is_required = $_POST['required'];
    830839                                $this->type        = $_POST['fieldtype'];
     840                                $this->placeholder = $_POST["placeholder_{$this->type}"];
    831841                                $this->order_by    = $_POST["sort_order_{$this->type}"];
    832842                                $this->field_order = $_POST['field_order'];
    833843                        }