Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-inclu.../customiz...
File: class-wp-customize-date-time-control.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Customize API: WP_Customize_Date_Time_Control class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Customize
[5] Fix | Delete
* @since 4.9.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Customize Date Time Control class.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 4.9.0
[12] Fix | Delete
*
[13] Fix | Delete
* @see WP_Customize_Control
[14] Fix | Delete
*/
[15] Fix | Delete
class WP_Customize_Date_Time_Control extends WP_Customize_Control {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Customize control type.
[19] Fix | Delete
*
[20] Fix | Delete
* @since 4.9.0
[21] Fix | Delete
* @var string
[22] Fix | Delete
*/
[23] Fix | Delete
public $type = 'date_time';
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Minimum Year.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 4.9.0
[29] Fix | Delete
* @var int
[30] Fix | Delete
*/
[31] Fix | Delete
public $min_year = 1000;
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Maximum Year.
[35] Fix | Delete
*
[36] Fix | Delete
* @since 4.9.0
[37] Fix | Delete
* @var int
[38] Fix | Delete
*/
[39] Fix | Delete
public $max_year = 9999;
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Allow past date, if set to false user can only select future date.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 4.9.0
[45] Fix | Delete
* @var bool
[46] Fix | Delete
*/
[47] Fix | Delete
public $allow_past_date = true;
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Whether hours, minutes, and meridian should be shown.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 4.9.0
[53] Fix | Delete
* @var bool
[54] Fix | Delete
*/
[55] Fix | Delete
public $include_time = true;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* If set to false the control will appear in 24 hour format,
[59] Fix | Delete
* the value will still be saved in Y-m-d H:i:s format.
[60] Fix | Delete
*
[61] Fix | Delete
* @since 4.9.0
[62] Fix | Delete
* @var bool
[63] Fix | Delete
*/
[64] Fix | Delete
public $twelve_hour_format = true;
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Don't render the control's content - it's rendered with a JS template.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 4.9.0
[70] Fix | Delete
*/
[71] Fix | Delete
public function render_content() {}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Export data to JS.
[75] Fix | Delete
*
[76] Fix | Delete
* @since 4.9.0
[77] Fix | Delete
* @return array
[78] Fix | Delete
*/
[79] Fix | Delete
public function json() {
[80] Fix | Delete
$data = parent::json();
[81] Fix | Delete
[82] Fix | Delete
$data['maxYear'] = (int) $this->max_year;
[83] Fix | Delete
$data['minYear'] = (int) $this->min_year;
[84] Fix | Delete
$data['allowPastDate'] = (bool) $this->allow_past_date;
[85] Fix | Delete
$data['twelveHourFormat'] = (bool) $this->twelve_hour_format;
[86] Fix | Delete
$data['includeTime'] = (bool) $this->include_time;
[87] Fix | Delete
[88] Fix | Delete
return $data;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Renders a JS template for the content of date time control.
[93] Fix | Delete
*
[94] Fix | Delete
* @since 4.9.0
[95] Fix | Delete
*/
[96] Fix | Delete
public function content_template() {
[97] Fix | Delete
$data = array_merge( $this->json(), $this->get_month_choices() );
[98] Fix | Delete
$timezone_info = $this->get_timezone_info();
[99] Fix | Delete
[100] Fix | Delete
$date_format = get_option( 'date_format' );
[101] Fix | Delete
$date_format = preg_replace( '/(?<!\\\\)[Yyo]/', '%1$s', $date_format );
[102] Fix | Delete
$date_format = preg_replace( '/(?<!\\\\)[FmMn]/', '%2$s', $date_format );
[103] Fix | Delete
$date_format = preg_replace( '/(?<!\\\\)[jd]/', '%3$s', $date_format );
[104] Fix | Delete
[105] Fix | Delete
// Fallback to ISO date format if year, month, or day are missing from the date format.
[106] Fix | Delete
if ( 1 !== substr_count( $date_format, '%1$s' ) || 1 !== substr_count( $date_format, '%2$s' ) || 1 !== substr_count( $date_format, '%3$s' ) ) {
[107] Fix | Delete
$date_format = '%1$s-%2$s-%3$s';
[108] Fix | Delete
}
[109] Fix | Delete
?>
[110] Fix | Delete
[111] Fix | Delete
<# _.defaults( data, <?php echo wp_json_encode( $data ); ?> ); #>
[112] Fix | Delete
<# var idPrefix = _.uniqueId( 'el' ) + '-'; #>
[113] Fix | Delete
[114] Fix | Delete
<# if ( data.label ) { #>
[115] Fix | Delete
<span class="customize-control-title">
[116] Fix | Delete
{{ data.label }}
[117] Fix | Delete
</span>
[118] Fix | Delete
<# } #>
[119] Fix | Delete
<div class="customize-control-notifications-container"></div>
[120] Fix | Delete
<# if ( data.description ) { #>
[121] Fix | Delete
<span class="description customize-control-description">{{ data.description }}</span>
[122] Fix | Delete
<# } #>
[123] Fix | Delete
<div class="date-time-fields {{ data.includeTime ? 'includes-time' : '' }}">
[124] Fix | Delete
<fieldset class="day-row">
[125] Fix | Delete
<legend class="title-day {{ ! data.includeTime ? 'screen-reader-text' : '' }}"><?php esc_html_e( 'Date' ); ?></legend>
[126] Fix | Delete
<div class="day-fields clear">
[127] Fix | Delete
<?php ob_start(); ?>
[128] Fix | Delete
<label for="{{ idPrefix }}date-time-month" class="screen-reader-text">
[129] Fix | Delete
<?php
[130] Fix | Delete
/* translators: Hidden accessibility text. */
[131] Fix | Delete
esc_html_e( 'Month' );
[132] Fix | Delete
?>
[133] Fix | Delete
</label>
[134] Fix | Delete
<select id="{{ idPrefix }}date-time-month" class="date-input month" data-component="month">
[135] Fix | Delete
<# _.each( data.month_choices, function( choice ) {
[136] Fix | Delete
if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) {
[137] Fix | Delete
text = choice.text;
[138] Fix | Delete
value = choice.value;
[139] Fix | Delete
}
[140] Fix | Delete
#>
[141] Fix | Delete
<option value="{{ value }}" >
[142] Fix | Delete
{{ text }}
[143] Fix | Delete
</option>
[144] Fix | Delete
<# } ); #>
[145] Fix | Delete
</select>
[146] Fix | Delete
<?php $month_field = trim( ob_get_clean() ); ?>
[147] Fix | Delete
[148] Fix | Delete
<?php ob_start(); ?>
[149] Fix | Delete
<label for="{{ idPrefix }}date-time-day" class="screen-reader-text">
[150] Fix | Delete
<?php
[151] Fix | Delete
/* translators: Hidden accessibility text. */
[152] Fix | Delete
esc_html_e( 'Day' );
[153] Fix | Delete
?>
[154] Fix | Delete
</label>
[155] Fix | Delete
<input id="{{ idPrefix }}date-time-day" type="number" size="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31" />
[156] Fix | Delete
<?php $day_field = trim( ob_get_clean() ); ?>
[157] Fix | Delete
[158] Fix | Delete
<?php ob_start(); ?>
[159] Fix | Delete
<label for="{{ idPrefix }}date-time-year" class="screen-reader-text">
[160] Fix | Delete
<?php
[161] Fix | Delete
/* translators: Hidden accessibility text. */
[162] Fix | Delete
esc_html_e( 'Year' );
[163] Fix | Delete
?>
[164] Fix | Delete
</label>
[165] Fix | Delete
<input id="{{ idPrefix }}date-time-year" type="number" size="4" autocomplete="off" class="date-input year" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}">
[166] Fix | Delete
<?php $year_field = trim( ob_get_clean() ); ?>
[167] Fix | Delete
[168] Fix | Delete
<?php printf( $date_format, $year_field, $month_field, $day_field ); ?>
[169] Fix | Delete
</div>
[170] Fix | Delete
</fieldset>
[171] Fix | Delete
<# if ( data.includeTime ) { #>
[172] Fix | Delete
<fieldset class="time-row clear">
[173] Fix | Delete
<legend class="title-time"><?php esc_html_e( 'Time' ); ?></legend>
[174] Fix | Delete
<div class="time-fields clear">
[175] Fix | Delete
<label for="{{ idPrefix }}date-time-hour" class="screen-reader-text">
[176] Fix | Delete
<?php
[177] Fix | Delete
/* translators: Hidden accessibility text. */
[178] Fix | Delete
esc_html_e( 'Hour' );
[179] Fix | Delete
?>
[180] Fix | Delete
</label>
[181] Fix | Delete
<# var maxHour = data.twelveHourFormat ? 12 : 23; #>
[182] Fix | Delete
<# var minHour = data.twelveHourFormat ? 1 : 0; #>
[183] Fix | Delete
<input id="{{ idPrefix }}date-time-hour" type="number" size="2" autocomplete="off" class="date-input hour" data-component="hour" min="{{ minHour }}" max="{{ maxHour }}">
[184] Fix | Delete
:
[185] Fix | Delete
<label for="{{ idPrefix }}date-time-minute" class="screen-reader-text">
[186] Fix | Delete
<?php
[187] Fix | Delete
/* translators: Hidden accessibility text. */
[188] Fix | Delete
esc_html_e( 'Minute' );
[189] Fix | Delete
?>
[190] Fix | Delete
</label>
[191] Fix | Delete
<input id="{{ idPrefix }}date-time-minute" type="number" size="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59">
[192] Fix | Delete
<# if ( data.twelveHourFormat ) { #>
[193] Fix | Delete
<label for="{{ idPrefix }}date-time-meridian" class="screen-reader-text">
[194] Fix | Delete
<?php
[195] Fix | Delete
/* translators: Hidden accessibility text. */
[196] Fix | Delete
esc_html_e( 'Meridian' );
[197] Fix | Delete
?>
[198] Fix | Delete
</label>
[199] Fix | Delete
<select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian">
[200] Fix | Delete
<option value="am"><?php esc_html_e( 'AM' ); ?></option>
[201] Fix | Delete
<option value="pm"><?php esc_html_e( 'PM' ); ?></option>
[202] Fix | Delete
</select>
[203] Fix | Delete
<# } #>
[204] Fix | Delete
<p><?php echo $timezone_info['description']; ?></p>
[205] Fix | Delete
</div>
[206] Fix | Delete
</fieldset>
[207] Fix | Delete
<# } #>
[208] Fix | Delete
</div>
[209] Fix | Delete
<?php
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Generate options for the month Select.
[214] Fix | Delete
*
[215] Fix | Delete
* Based on touch_time().
[216] Fix | Delete
*
[217] Fix | Delete
* @since 4.9.0
[218] Fix | Delete
*
[219] Fix | Delete
* @see touch_time()
[220] Fix | Delete
*
[221] Fix | Delete
* @global WP_Locale $wp_locale WordPress date and time locale object.
[222] Fix | Delete
*
[223] Fix | Delete
* @return array
[224] Fix | Delete
*/
[225] Fix | Delete
public function get_month_choices() {
[226] Fix | Delete
global $wp_locale;
[227] Fix | Delete
$months = array();
[228] Fix | Delete
for ( $i = 1; $i < 13; $i++ ) {
[229] Fix | Delete
$month_text = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
[230] Fix | Delete
[231] Fix | Delete
/* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */
[232] Fix | Delete
$months[ $i ]['text'] = sprintf( __( '%1$s-%2$s' ), $i, $month_text );
[233] Fix | Delete
$months[ $i ]['value'] = $i;
[234] Fix | Delete
}
[235] Fix | Delete
return array(
[236] Fix | Delete
'month_choices' => $months,
[237] Fix | Delete
);
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
/**
[241] Fix | Delete
* Get timezone info.
[242] Fix | Delete
*
[243] Fix | Delete
* @since 4.9.0
[244] Fix | Delete
*
[245] Fix | Delete
* @return array {
[246] Fix | Delete
* Timezone info. All properties are optional.
[247] Fix | Delete
*
[248] Fix | Delete
* @type string $abbr Timezone abbreviation. Examples: PST or CEST.
[249] Fix | Delete
* @type string $description Human-readable timezone description as HTML.
[250] Fix | Delete
* }
[251] Fix | Delete
*/
[252] Fix | Delete
public function get_timezone_info() {
[253] Fix | Delete
$tz_string = get_option( 'timezone_string' );
[254] Fix | Delete
$timezone_info = array();
[255] Fix | Delete
[256] Fix | Delete
if ( $tz_string ) {
[257] Fix | Delete
try {
[258] Fix | Delete
$tz = new DateTimeZone( $tz_string );
[259] Fix | Delete
} catch ( Exception $e ) {
[260] Fix | Delete
$tz = '';
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
if ( $tz ) {
[264] Fix | Delete
$now = new DateTime( 'now', $tz );
[265] Fix | Delete
$formatted_gmt_offset = $this->format_gmt_offset( $tz->getOffset( $now ) / HOUR_IN_SECONDS );
[266] Fix | Delete
$tz_name = str_replace( '_', ' ', $tz->getName() );
[267] Fix | Delete
$timezone_info['abbr'] = $now->format( 'T' );
[268] Fix | Delete
[269] Fix | Delete
$timezone_info['description'] = sprintf(
[270] Fix | Delete
/* translators: 1: Timezone name, 2: Timezone abbreviation, 3: UTC abbreviation and offset, 4: UTC offset. */
[271] Fix | Delete
__( 'Your timezone is set to %1$s (%2$s), currently %3$s (Coordinated Universal Time %4$s).' ),
[272] Fix | Delete
$tz_name,
[273] Fix | Delete
'<abbr>' . $timezone_info['abbr'] . '</abbr>',
[274] Fix | Delete
'<abbr>UTC</abbr>' . $formatted_gmt_offset,
[275] Fix | Delete
$formatted_gmt_offset
[276] Fix | Delete
);
[277] Fix | Delete
} else {
[278] Fix | Delete
$timezone_info['description'] = '';
[279] Fix | Delete
}
[280] Fix | Delete
} else {
[281] Fix | Delete
$formatted_gmt_offset = $this->format_gmt_offset( (int) get_option( 'gmt_offset', 0 ) );
[282] Fix | Delete
[283] Fix | Delete
$timezone_info['description'] = sprintf(
[284] Fix | Delete
/* translators: 1: UTC abbreviation and offset, 2: UTC offset. */
[285] Fix | Delete
__( 'Your timezone is set to %1$s (Coordinated Universal Time %2$s).' ),
[286] Fix | Delete
'<abbr>UTC</abbr>' . $formatted_gmt_offset,
[287] Fix | Delete
$formatted_gmt_offset
[288] Fix | Delete
);
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
return $timezone_info;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
/**
[295] Fix | Delete
* Format GMT Offset.
[296] Fix | Delete
*
[297] Fix | Delete
* @since 4.9.0
[298] Fix | Delete
*
[299] Fix | Delete
* @see wp_timezone_choice()
[300] Fix | Delete
*
[301] Fix | Delete
* @param float $offset Offset in hours.
[302] Fix | Delete
* @return string Formatted offset.
[303] Fix | Delete
*/
[304] Fix | Delete
public function format_gmt_offset( $offset ) {
[305] Fix | Delete
if ( 0 <= $offset ) {
[306] Fix | Delete
$formatted_offset = '+' . (string) $offset;
[307] Fix | Delete
} else {
[308] Fix | Delete
$formatted_offset = (string) $offset;
[309] Fix | Delete
}
[310] Fix | Delete
$formatted_offset = str_replace(
[311] Fix | Delete
array( '.25', '.5', '.75' ),
[312] Fix | Delete
array( ':15', ':30', ':45' ),
[313] Fix | Delete
$formatted_offset
[314] Fix | Delete
);
[315] Fix | Delete
return $formatted_offset;
[316] Fix | Delete
}
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function