Menu

Abweb

22KB Diff snippet created on May 23rd 2016.

Actions
Index: bp-xprofile/bp-xprofile-admin.php
IDEA additional info: Date xprofile field enhancement 
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bp-xprofile/bp-xprofile-admin.php	(revision f8b3b6243a5a0c1ba45e9ebcc5fb134834754c32)
+++ bp-xprofile/bp-xprofile-admin.php	(revision )
@@ -331,6 +331,56 @@
 	xprofile_admin( $message, $type );
 }
 
+	function xprofile_admin_manage_datebox_option( $message ) {
+		if( empty( $_POST['datebox_option'] ) ) return;
+
+		$_POST['datebox_option'][0] = isset( $_POST['datebox_option'][0] ) ? 'yes' : 'no';
+
+		$_POST['datebox_option'][1] = ( isset( $_POST['datebox_option'][1] ) || $_POST['datebox_option'][7] == 'elapsed' ) ? 'yes' : 'no';
+
+		$_POST['datebox_option'][2] = ( isset( $_POST['datebox_option'][2] ) && $_POST['datebox_option'][2] == 'year' ) ? 'year' : 'ago';
+
+		$message .= ( $_POST['datebox_option'][3] == '' ) ? __( 'Field "Max years ago" - required! ', 'buddypress' ) : '';
+		$_POST['datebox_option'][3] =	isset( $_POST['datebox_option'][3] ) ? mb_substr( abs ( intval ( $_POST['datebox_option'][3] ) ), 0, 4, 'UTF-8' ) : 100;
+
+		$message .= ( $_POST['datebox_option'][4] == '' ) ? __( 'Field "Min years ago" - required! ', 'buddypress' ) : '';
+		$_POST['datebox_option'][4] =
+			isset( $_POST['datebox_option'][4] ) ? mb_substr( intval( $_POST['datebox_option'][4] ), 0, 5, 'UTF-8' ) : 18;
+
+		if ( isset( $_POST['datebox_option_3_from_type'] ) && $_POST['datebox_option_3_from_type'] ) {
+			$test_from = intval( date('Y') + $_POST['datebox_option'][3] );
+		} else {
+			$test_from = intval( date('Y') - $_POST['datebox_option'][3] );
+			$_POST['datebox_option'][3] = -intval( $_POST['datebox_option'][3] );
+		}
+
+		if ( isset( $_POST['datebox_option_3_to_type'] ) && $_POST['datebox_option_3_to_type'] ) {
+			$test_to = intval( date('Y') + $_POST['datebox_option'][4] );
+		} else {
+			$test_to = intval( date('Y') - $_POST['datebox_option'][4] );
+			$_POST['datebox_option'][4] = -intval( $_POST['datebox_option'][4] );
+		}
+
+		$message .= ( $test_from < $test_to ) ? __( 'Wrong year range! ', 'buddypress' ) : '';
+
+		$message .= ( $_POST['datebox_option'][5] == '' ) ? __( 'Field "Erliest" - required! ', 'buddypress' ) : '';
+		$_POST['datebox_option'][5] = ( isset( $_POST['datebox_option'][5] ) )
+			? mb_substr( intval($_POST['datebox_option'][5] ), 0, 5, 'UTF-8' ) : date("Y") - 100;
+
+		$message .= ( $_POST['datebox_option'][5] == '' ) ? __( 'Field "Latest" - required! ', 'buddypress' ) : '';
+		$_POST['datebox_option'][6] = ( isset($_POST['datebox_option'][6] ) )
+			? mb_substr( abs( intval( $_POST['datebox_option'][6] ) ), 0, 4, 'UTF-8') : date("Y") - 18;
+
+		$message .= ( $_POST['datebox_option'][5] > $_POST['datebox_option'][6] ) ? __( 'Wrong Erliest/Latest range! ', 'buddypress' ) : '';
+
+		ksort( $_POST['datebox_option'], SORT_NUMERIC );
+		reset( $_POST['datebox_option'] );
+
+		if(!empty($message)){
+			$GLOBALS['message'] = $message;
+		}
+	}
+
 /**
  * Handles the adding or editing of profile field data for a user.
  *
@@ -351,6 +401,8 @@
 	$field->group_id = $group_id;
 
 	if ( isset( $_POST['saveField'] ) ) {
+		xprofile_admin_manage_datebox_option($message);
+
 		if ( BP_XProfile_Field::admin_validate() ) {
 			$field->is_required = $_POST['required'];
 			$field->type        = $_POST['fieldtype'];
Index: bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php	(revision f8b3b6243a5a0c1ba45e9ebcc5fb134834754c32)
+++ bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php	(revision )
@@ -28,6 +28,8 @@
 		$this->category = _x( 'Single Fields', 'xprofile field type category', 'buddypress' );
 		$this->name     = _x( 'Date Selector', 'xprofile field type', 'buddypress' );
 
+		$this->supports_options = true; # This parameter - added
+
 		$this->set_format( '/^\d{4}-\d{1,2}-\d{1,2} 00:00:00$/', 'replace' ); // "Y-m-d 00:00:00"
 
 		/**
@@ -41,6 +43,13 @@
 		do_action( 'bp_xprofile_field_type_datebox', $this );
 	}
 
+	public function is_valid($value) {
+		if ($value) {
+			return true;
+		}
+		return false;
+	}
+
 	/**
 	 * Output the edit field HTML for this field type.
 	 *
@@ -162,9 +171,10 @@
 
 			// If MySQL timestamp.
 			} else {
-				$day   = mysql2date( 'j', $date );
-				$month = mysql2date( 'F', $date, false ); // Not localized, so that selected() works below.
-				$year  = mysql2date( 'Y', $date );
+				$DT = new DateTime($date); // problem 2038 year http://php.net/manual/en/class.datetime.php
+				$day = $DT->format('j');
+				$month = $DT->format('F');
+				$year = $DT->format('Y');
 			}
 		}
 
@@ -226,9 +236,40 @@
 			case 'year':
 				$html = sprintf( '<option value="" %1$s>%2$s</option>', selected( $year, 0, false ), /* translators: no option picked in select box */ __( '----', 'buddypress' ) );
 
-				for ( $i = 2037; $i > 1901; $i-- ) {
+				$ord = bp_xprofile_get_meta( 'bp_date_field', 'field', 'BPOptRegData' );
+				$ord = unserialize($ord);
+				$opt = $this->field_obj->get_children();
+
+				if(isset($opt[2]->name)){
+					$ord['range-curr'] = ($opt[2]->name == 'year') ? 'year' : 'ago';
+				} else {
+					$ord['range-curr'] = 'ago';
+				}
+
+				if(isset($opt[3]->name)) {
+					$ord['range-year']['ago']['max'] = $opt[3]->name;
+				}
+
+				if(isset($opt[4]->name)){
+					$ord['range-year']['ago']['min'] = $opt[4]->name;
+				}
+
+				if(isset($opt[5]->name)){
+					$ord['range-year']['year']['earliest'] = $opt[5]->name;
+				}
+
+				if(isset($opt[6]->name)){
+					$ord['range-year']['year']['latest'] = $opt[6]->name;
+				}
+
+				if($ord['range-curr'] == 'ago'){
+					$ord['range-year']['year']['latest'] = date("Y") + $ord['range-year']['ago']['min'];
+					$ord['range-year']['year']['earliest'] = date("Y") + $ord['range-year']['ago']['max'];
+				}
+
+				for ( $i = $ord['range-year']['year']['latest']; $i > ($ord['range-year']['year']['earliest']-1); $i-- ) {
-					$html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', (int) $i, selected( $year, $i, false ), (int) $i );
-				}
+ 					$html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', (int) $i, selected( $year, $i, false ), (int) $i );
+ 				}
 			break;
 		}
 
@@ -272,23 +313,69 @@
 		$year_r = bp_parse_args( $raw_properties, array(
 			'id'   => bp_get_the_profile_field_input_name() . '_year',
 			'name' => bp_get_the_profile_field_input_name() . '_year'
-		) ); ?>
+		) );
 
-		<label for="<?php bp_the_profile_field_input_name(); ?>_day" class="screen-reader-text"><?php esc_html_e( 'Select day', 'buddypress' ); ?></label>
+		// Change the location of selects, depending on the "date_format"
+
+		ob_start();
+		?>
-		<select <?php echo $this->get_edit_field_html_elements( $day_r ); ?>>
-			<?php bp_the_profile_field_options( array( 'type' => 'day' ) ); ?>
-		</select>
+	    <select <?php echo $this->get_edit_field_html_elements( $day_r ); ?>>
+ 			<?php bp_the_profile_field_options( array( 'type' => 'day' ) ); ?>
+	    </select>
+		<?php
+		$selectDay = ob_get_contents();
+		ob_end_clean();
 
-		<label for="<?php bp_the_profile_field_input_name(); ?>_month" class="screen-reader-text"><?php esc_html_e( 'Select month', 'buddypress' ); ?></label>
+		ob_start();
+		?>
-		<select <?php echo $this->get_edit_field_html_elements( $month_r ); ?>>
-			<?php bp_the_profile_field_options( array( 'type' => 'month' ) ); ?>
-		</select>
+	    <select <?php echo $this->get_edit_field_html_elements( $month_r ); ?>>
+ 			<?php bp_the_profile_field_options( array( 'type' => 'month' ) ); ?>
+	    </select>
+		<?php
+		$selectMonth = ob_get_contents();
+		ob_end_clean();
 
-		<label for="<?php bp_the_profile_field_input_name(); ?>_year" class="screen-reader-text"><?php esc_html_e( 'Select year', 'buddypress' ); ?></label>
+		ob_start();
+		?>
-		<select <?php echo $this->get_edit_field_html_elements( $year_r ); ?>>
-			<?php bp_the_profile_field_options( array( 'type' => 'year' ) ); ?>
-		</select>
+	    <select <?php echo $this->get_edit_field_html_elements( $year_r ); ?>>
+ 			<?php bp_the_profile_field_options( array( 'type' => 'year' ) ); ?>
+	    </select>
+		<?php
+		$selectYear = ob_get_contents();
+		ob_end_clean();
 
+		// Change the location of selects, depending on the "date_format"
+
+		$format = get_option('date_format', 'd/m/Y');
+
+		switch( $format )
+		{
+			case 'm/d/Y';#m/d/Y
+			case 'm-d-Y';
+			case 'm.d.Y';
+				echo $selectMonth;
+				echo $selectDay;
+				echo $selectYear;
+				break;
+
+			case 'd/m/Y'; #d/m/Y
+			case 'd-m-Y';
+			case 'd.m.Y';
+				echo $selectDay;
+				echo $selectMonth;
+				echo $selectYear;
+				break;
+
+			default; #Y-m-d
+				echo $selectYear;
+				echo $selectMonth;
+				echo $selectDay;
+				break;
+		}
+
+		?>
+
+
 	<?php
 	}
 
@@ -302,8 +389,169 @@
 	 * @param string            $control_type  Optional. HTML input type used to render the current
 	 *                                         field's child options.
 	 */
-	public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {}
+	public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) {
+		//parent::admin_new_field_html( $current_field, 'checkbox' );
+		$type = array_search( get_class( $this ), bp_xprofile_get_field_types() );
 
+		if ( false === $type ) {
+			return;
+		}
+
+		$class = $current_field->type != $type ? 'display: none;' : '';
+		$current_type_obj = bp_xprofile_create_field_type( $type );
+		$SET = $current_field->BPOptRegData;
+		$SET = unserialize( $SET );
+		$OPT = $current_field->get_children( true );
+
+
+		?>
+
+    <div id="<?php echo esc_attr( $type ); ?>" class="postbox bp-options-box" style="<?php echo esc_attr( $class ); ?> margin-top: 15px;">
+        <h3><?php esc_html_e( 'Please enter options for this Field:', 'buddypress' ); ?></h3>
+
+        <div class="inside">
+
+            <div id="datebox_div1" class="bp-option sortable">
+
+            <h2 style="font-size: 23px;">Date field</h2>
+
+            	<table class="form-table" style="margin: 8px 13px;">
+					<tr>
+						<th style="width: 100px;">Date format</th>
+						<td>
+							<fieldset>
+
+								<legend class="screen-reader-text"><span>Date format</span></legend>
+								<?php
+									$date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
+								?>
+								<?php if( !empty( $date_formats ) ): ?>
+									<?php foreach ( $date_formats as $key => $format ): ?>
+									<?php
+										$checked = '';
+										if( $OPT[7]->name == $format || ( !$OPT[7]->name && !$key ) ) {
+											$checked = 'checked';
+											$custom_format = false;
+										}
+									?>
+
+									<label title='<?=esc_attr( $format ); ?>'>
+										<input <?=$checked; ?> type='radio' name='datebox_option[7]' value='<?= esc_attr($format); ?>' />
+										<span class="date-time-text format-i18n"><?=date_i18n( $format );?></span>
+										<code><?=$format?></code>
+									</label><br/>
+
+									<?php endforeach;?>
+								<?php endif; ?>
+
+								<label>
+									<input type="radio" <?= ( $SET['show-time'] == 'yes' OR $OPT[1]->name == 'yes' ) ? ' checked="checked" ' : ''; ?> value="elapsed" id="date_format_elapsed_radio" name="datebox_option[7]">
+									Time elapsed
+									<span style="padding-left: 15px;"> Examples: </span>
+									<code>4 years ago</code>,
+									<code>4 years from now</code>
+								</label>
+
+								<label>
+									<input type="radio" <?=( $custom_format )? 'checked': ''; ?> value="custom" id="date_format_custom_radio" name="datebox_option[7]">
+									Custom:
+									<input type="text" style="width: 80px;" class="small-text" value='<?= esc_attr( $OPT[7]->name ); ?>' id="date_format_custom" name="date_format_custom">
+									<span style="padding-left: 15px;"> Example: </span>
+									<code>d.m.Y</code>
+								</label><br/>
+
+							</fieldset>
+						</td>
+					</tr>
+					<tr>
+						<th style="width: 100px;">Range</th>
+						<td>
+							<fieldset>
+								<legend class="screen-reader-text"><span>Range</span></legend>
+
+								<label>
+									<input type="radio" name="datebox_option[2]" value="year"
+										<?= ( $SET['range-curr'] == 'year' || $OPT[2]->name == 'year' ) ? ' checked="checked" ' : ''; ?> />
+
+									<span class="date-time-text format-i18n">From</span>
+									<input type="text" name="datebox_option[5]" size="3" maxlength="5"
+												value="<?= isset( $OPT[5]->name ) ? $OPT[5]->name : $SET['range-year']['year']['earliest']; ?>" />
+
+									<span class="date-time-text format-i18n" style="padding-left:7px;padding-right:7px;">to</span>
+									<input type="text" name="datebox_option[6]" size="3" maxlength="4"
+											  value="<?= isset( $OPT[6]->name ) ? $OPT[6]->name : $SET['range-year']['year']['latest']; ?>" />
+								</label><br/>
+
+								<label>
+									<input type="radio" name="datebox_option[2]"  value="ago"
+				                        <?= ( $SET['range-curr'] == 'ago' || $OPT[2]->name == 'ago' ) ? ' checked="checked" ' : ''; ?> />
+
+									<span class="date-time-text format-i18n">From</span>
+									<input type="text" name="datebox_option[3]" size="3" maxlength="4"
+			                            		value="<?= isset( $OPT[3]->name ) ? abs( $OPT[3]->name ) : $SET['range-year']['ago']['max']; ?>" />
+									<select name="datebox_option_3_from_type">
+										<option value="0" <?php if ( isset( $OPT[3]->name ) && intval( $OPT[3]->name ) < 0 ) echo 'selected="selected"'; ?>>years ago</option>
+										<option value="1" <?php if ( isset( $OPT[3]->name ) && intval( $OPT[3]->name ) > 0 ) echo 'selected="selected"'; ?>>years from now</option>
+									</select>
+
+									<span class="date-time-text format-i18n" style="padding-left:7px;padding-right:7px;">to</span>
+									<input type="text" name="datebox_option[4]" size="3" maxlength="5"
+		                                       value="<?= isset( $OPT[4]->name ) ? abs( $OPT[4]->name ) : $SET['range-year']['ago']['min']; ?>" />
+									<select name="datebox_option_3_to_type">
+		   								<option value="0" <?php if (isset( $OPT[4]->name ) && intval( $OPT[4]->name ) < 0) echo 'selected="selected"'; ?>>years ago</option>
+		   								<option value="1" <?php if (isset( $OPT[4]->name ) && intval( $OPT[4]->name ) > 0) echo 'selected="selected"'; ?>>years from now</option>
+		   							</select>
+								</label><br/>
+
+							</fieldset>
+						</td>
+					</tr>
+                    <tr>
+                        <td></td>
+                        <td colspan="3">
+													<p><a href="https://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.</p>
+													<p><b>Note</b>: Range is allowed between 1902 and 2037 years only.</p>
+												</td>
+	                </tr>
+                </table>
+         </div>
+
+            <input type="hidden" name="datebox_option_number" id="datebox_option_number" value="8"/>
+            <input type="hidden" name="sort_order_datebox" id="sort_order_datebox" value="custom"/>
+
+            <?php /*div id="datebox_more"></div>
+            <p><a href="javascript:add_option('datebox')">Add Another Option</a></p*/ ?>
+        </div>
+    </div>
+           <script>
+	           jQuery(document).ready(function($) {
+	           		$("input[name='date_format']").click(function(){
+						if ( "date_format_custom_radio" != $(this).attr("id") )
+							$( "input[name='date_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).text() );
+					});
+
+					$("input[name='date_format_custom']").focus(function(){
+						$( '#date_format_custom_radio' ).prop( 'checked', true );
+					});
+
+		           $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
+						var format = $(this);
+						$('#date_format_custom_radio' ).val(format.val());
+						format.siblings( '.spinner' ).addClass( 'is-active' );
+						$.post(ajaxurl, {
+								action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
+								date : format.val()
+								}, function(d) {
+									format.siblings( '.spinner' ).removeClass( 'is-active' ); format.siblings('.example').text(d);
+
+								} );
+						});
+		       });
+            </script>
+
+		<?php
+	}
+
 	/**
 	 * Format Date values for display.
 	 *
@@ -322,6 +570,58 @@
 			$field_value = strtotime( $field_value );
 		}
 
-		return bp_format_time( $field_value, true, false );
+		global $wpdb, $bp;
+		$option = unserialize( bp_xprofile_get_meta( 'bp_date_field', 'field', 'BPOptRegData' ) );
+		//$uid = bp_displayed_user_id();
+		$parent_id = isset( $GLOBALS['field']->id ) ? $GLOBALS['field']->id : $field_id;
+		$sort_sql = 'ORDER BY option_order ASC';
+		$sql = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_fields} WHERE parent_id = %d $sort_sql", $parent_id);
+		$opt = $wpdb->get_results( $sql );
+
+		$option['date-format'] = $opt[7]->name;
+
+		if(isset($opt[0]) && isset($opt[1])){
+			$option['show-year'] = $opt[0]->name;
+			$option['show-time'] = $opt[1]->name;
+		}
+
+
+		if($option['show-time'] == 'yes'){
+			$field_value = self::formatDateByBPOptRegData($field_value,$option, true, true);
+
+		}else {
+			$field_value = self::formatDateByBPOptRegData($field_value,$option, true, false);
+		}
+
+		return $field_value;
+	}
+
+	private function formatDateByBPOptRegData( $time, $option, $localize_time = true, $show) {
+
+			if ( ! isset( $time ) || ! is_numeric( $time ) ) {
+				return false;
+			}
+
+			if ( ! empty( $localize_time ) ) {
+				$root_blog_offset = get_blog_option( bp_get_root_blog_id(), 'gmt_offset' );
+			}else{
+				$root_blog_offset = false;
+			}
+
+			$time_offset = $time + ( $root_blog_offset * 3600 );
+
+			if($show === false){
+				$date = date_i18n( $option['date-format'], $time_offset );
+			} else {  // Here we calculate the number of years
+				$current_year = intval( date("Y") );
+				$selected_year = intval( date( "Y", $time_offset ) );
+				if ( $selected_year > $current_year ) {
+					$date = ' ' . ( $selected_year - $current_year ) . __(' years from now', 'buddypress');
+				} else {
+					$date = ' ' . ( $current_year - $selected_year ) . __(' years ago', 'buddypress');
+				}
+			}
+
+			return $date;
-	}
+		}
 }
Index: bp-xprofile/bp-xprofile-screens.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bp-xprofile/bp-xprofile-screens.php	(revision f8b3b6243a5a0c1ba45e9ebcc5fb134834754c32)
+++ bp-xprofile/bp-xprofile-screens.php	(revision )
@@ -65,6 +65,7 @@
 		return;
 	}
 
+
 	// No errors.
 	$errors = false;
 
@@ -91,10 +92,13 @@
 
 				if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) {
 					// Concatenate the values.
-					$date_value =   $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
+					$eng_months = array( 1=>'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
+					$_POST['field_' . $field_id . '_month'] = array_search( $_POST['field_' . $field_id . '_month'], $eng_months );
+					$date_value = $_POST['field_' . $field_id . '_year'] . '-' . $_POST['field_' . $field_id . '_month'] . '-' . $_POST['field_' . $field_id . '_day'];
 
 					// Turn the concatenated value into a timestamp.
-					$_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
+					$date = new DateTime( $date_value );
+					$_POST['field_' . $field_id] = $date->getTimestamp();
 				}
 
 			}
@@ -114,7 +118,6 @@
 
 			// Reset the errors var.
 			$errors = false;
-
 			// Now we've checked for required fields, lets save the values.
 			$old_values = $new_values = array();
 			foreach ( (array) $posted_field_ids as $field_id ) {
Index: bp-xprofile/classes/class-bp-xprofile-field.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bp-xprofile/classes/class-bp-xprofile-field.php	(revision f8b3b6243a5a0c1ba45e9ebcc5fb134834754c32)
+++ bp-xprofile/classes/class-bp-xprofile-field.php	(revision )
@@ -162,6 +162,10 @@
 	 */
 	protected $member_types;
 
+
+
+	public $BPOptRegData = array();
+
 	/**
 	 * Initialize and/or populate profile field.
 	 *
@@ -181,6 +185,31 @@
 			$this->type_obj            = bp_xprofile_create_field_type( 'textbox' );
 			$this->type_obj->field_obj = $this;
 		}
+
+			$this->BPOptRegData = $this->runCheckBPOptRegDate();
+	}
+
+
+	public function runCheckBPOptRegDate() {
+
+		$BPOptRegData = bp_xprofile_get_meta( 'bp_date_field', 'field', 'BPOptRegData' );
+
+		$serialize = serialize(
+			array(
+				'show-year' => 'yes',
+				'show-time' => 'no',
+				'range-curr' => 'year',
+				'range-year' => array(
+					'ago' => array('min' => 18, 'max' => 100),
+					'year' => array('earliest' => (date("Y")-101), 'latest' => (date("Y")-18))
+				),
+				'date-format' => "Y-m-d",
+			)
+		);
+
+		bp_xprofile_update_meta( 'bp_date_field', 'field', 'BPOptRegData', $serialize );
+
+		return $serialize;
 	}
 
 	/**
Index: bp-xprofile/bp-xprofile-functions.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bp-xprofile/bp-xprofile-functions.php	(revision f8b3b6243a5a0c1ba45e9ebcc5fb134834754c32)
+++ bp-xprofile/bp-xprofile-functions.php	(revision )
@@ -434,7 +434,7 @@
 	}
 
 	// For certain fields, only certain parameters are acceptable, so add them to the whitelist.
-	if ( $field_type_obj->supports_options ) {
+	if ( $field_type_obj->supports_options && $field_type_obj->name != 'Date Selector' ) {
 		$field_type_obj->set_whitelist_values( wp_list_pluck( $field->get_children(), 'name' ) );
 	}
 

Loading
loading...
shift+enter to add a new line