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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: formatting.php
for ( $i = 0; $i < $stop; $i++ ) {
[3500] Fix | Delete
$content = $textarr[ $i ];
[3501] Fix | Delete
[3502] Fix | Delete
// If we're in an ignore block, wait until we find its closing tag.
[3503] Fix | Delete
if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) {
[3504] Fix | Delete
$ignore_block_element = $matches[1];
[3505] Fix | Delete
}
[3506] Fix | Delete
[3507] Fix | Delete
// If it's not a tag and not in ignore block.
[3508] Fix | Delete
if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) {
[3509] Fix | Delete
$content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content );
[3510] Fix | Delete
}
[3511] Fix | Delete
[3512] Fix | Delete
// Did we exit ignore block?
[3513] Fix | Delete
if ( '' !== $ignore_block_element && '</' . $ignore_block_element . '>' === $content ) {
[3514] Fix | Delete
$ignore_block_element = '';
[3515] Fix | Delete
}
[3516] Fix | Delete
[3517] Fix | Delete
$output .= $content;
[3518] Fix | Delete
}
[3519] Fix | Delete
} else {
[3520] Fix | Delete
// Return default text.
[3521] Fix | Delete
$output = $text;
[3522] Fix | Delete
}
[3523] Fix | Delete
return $output;
[3524] Fix | Delete
}
[3525] Fix | Delete
[3526] Fix | Delete
/**
[3527] Fix | Delete
* Verifies that an email is valid.
[3528] Fix | Delete
*
[3529] Fix | Delete
* Does not grok i18n domains. Not RFC compliant.
[3530] Fix | Delete
*
[3531] Fix | Delete
* @since 0.71
[3532] Fix | Delete
*
[3533] Fix | Delete
* @param string $email Email address to verify.
[3534] Fix | Delete
* @param bool $deprecated Deprecated.
[3535] Fix | Delete
* @return string|false Valid email address on success, false on failure.
[3536] Fix | Delete
*/
[3537] Fix | Delete
function is_email( $email, $deprecated = false ) {
[3538] Fix | Delete
if ( ! empty( $deprecated ) ) {
[3539] Fix | Delete
_deprecated_argument( __FUNCTION__, '3.0.0' );
[3540] Fix | Delete
}
[3541] Fix | Delete
[3542] Fix | Delete
// Test for the minimum length the email can be.
[3543] Fix | Delete
if ( strlen( $email ) < 6 ) {
[3544] Fix | Delete
/**
[3545] Fix | Delete
* Filters whether an email address is valid.
[3546] Fix | Delete
*
[3547] Fix | Delete
* This filter is evaluated under several different contexts, such as 'email_too_short',
[3548] Fix | Delete
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
[3549] Fix | Delete
* 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context.
[3550] Fix | Delete
*
[3551] Fix | Delete
* @since 2.8.0
[3552] Fix | Delete
*
[3553] Fix | Delete
* @param string|false $is_email The email address if successfully passed the is_email() checks, false otherwise.
[3554] Fix | Delete
* @param string $email The email address being checked.
[3555] Fix | Delete
* @param string $context Context under which the email was tested.
[3556] Fix | Delete
*/
[3557] Fix | Delete
return apply_filters( 'is_email', false, $email, 'email_too_short' );
[3558] Fix | Delete
}
[3559] Fix | Delete
[3560] Fix | Delete
// Test for an @ character after the first position.
[3561] Fix | Delete
if ( strpos( $email, '@', 1 ) === false ) {
[3562] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3563] Fix | Delete
return apply_filters( 'is_email', false, $email, 'email_no_at' );
[3564] Fix | Delete
}
[3565] Fix | Delete
[3566] Fix | Delete
// Split out the local and domain parts.
[3567] Fix | Delete
list( $local, $domain ) = explode( '@', $email, 2 );
[3568] Fix | Delete
[3569] Fix | Delete
/*
[3570] Fix | Delete
* LOCAL PART
[3571] Fix | Delete
* Test for invalid characters.
[3572] Fix | Delete
*/
[3573] Fix | Delete
if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
[3574] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3575] Fix | Delete
return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
[3576] Fix | Delete
}
[3577] Fix | Delete
[3578] Fix | Delete
/*
[3579] Fix | Delete
* DOMAIN PART
[3580] Fix | Delete
* Test for sequences of periods.
[3581] Fix | Delete
*/
[3582] Fix | Delete
if ( preg_match( '/\.{2,}/', $domain ) ) {
[3583] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3584] Fix | Delete
return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
[3585] Fix | Delete
}
[3586] Fix | Delete
[3587] Fix | Delete
// Test for leading and trailing periods and whitespace.
[3588] Fix | Delete
if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
[3589] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3590] Fix | Delete
return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
[3591] Fix | Delete
}
[3592] Fix | Delete
[3593] Fix | Delete
// Split the domain into subs.
[3594] Fix | Delete
$subs = explode( '.', $domain );
[3595] Fix | Delete
[3596] Fix | Delete
// Assume the domain will have at least two subs.
[3597] Fix | Delete
if ( 2 > count( $subs ) ) {
[3598] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3599] Fix | Delete
return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
[3600] Fix | Delete
}
[3601] Fix | Delete
[3602] Fix | Delete
// Loop through each sub.
[3603] Fix | Delete
foreach ( $subs as $sub ) {
[3604] Fix | Delete
// Test for leading and trailing hyphens and whitespace.
[3605] Fix | Delete
if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
[3606] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3607] Fix | Delete
return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
[3608] Fix | Delete
}
[3609] Fix | Delete
[3610] Fix | Delete
// Test for invalid characters.
[3611] Fix | Delete
if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) {
[3612] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3613] Fix | Delete
return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
[3614] Fix | Delete
}
[3615] Fix | Delete
}
[3616] Fix | Delete
[3617] Fix | Delete
// Congratulations, your email made it!
[3618] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3619] Fix | Delete
return apply_filters( 'is_email', $email, $email, null );
[3620] Fix | Delete
}
[3621] Fix | Delete
[3622] Fix | Delete
/**
[3623] Fix | Delete
* Converts to ASCII from email subjects.
[3624] Fix | Delete
*
[3625] Fix | Delete
* @since 1.2.0
[3626] Fix | Delete
*
[3627] Fix | Delete
* @param string $subject Subject line.
[3628] Fix | Delete
* @return string Converted string to ASCII.
[3629] Fix | Delete
*/
[3630] Fix | Delete
function wp_iso_descrambler( $subject ) {
[3631] Fix | Delete
/* this may only work with iso-8859-1, I'm afraid */
[3632] Fix | Delete
if ( ! preg_match( '#\=\?(.+)\?Q\?(.+)\?\=#i', $subject, $matches ) ) {
[3633] Fix | Delete
return $subject;
[3634] Fix | Delete
}
[3635] Fix | Delete
[3636] Fix | Delete
$subject = str_replace( '_', ' ', $matches[2] );
[3637] Fix | Delete
return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject );
[3638] Fix | Delete
}
[3639] Fix | Delete
[3640] Fix | Delete
/**
[3641] Fix | Delete
* Helper function to convert hex encoded chars to ASCII.
[3642] Fix | Delete
*
[3643] Fix | Delete
* @since 3.1.0
[3644] Fix | Delete
* @access private
[3645] Fix | Delete
*
[3646] Fix | Delete
* @param array $matches The preg_replace_callback matches array.
[3647] Fix | Delete
* @return string Converted chars.
[3648] Fix | Delete
*/
[3649] Fix | Delete
function _wp_iso_convert( $matches ) {
[3650] Fix | Delete
return chr( hexdec( strtolower( $matches[1] ) ) );
[3651] Fix | Delete
}
[3652] Fix | Delete
[3653] Fix | Delete
/**
[3654] Fix | Delete
* Given a date in the timezone of the site, returns that date in UTC.
[3655] Fix | Delete
*
[3656] Fix | Delete
* Requires and returns a date in the Y-m-d H:i:s format.
[3657] Fix | Delete
* Return format can be overridden using the $format parameter.
[3658] Fix | Delete
*
[3659] Fix | Delete
* @since 1.2.0
[3660] Fix | Delete
*
[3661] Fix | Delete
* @param string $date_string The date to be converted, in the timezone of the site.
[3662] Fix | Delete
* @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'.
[3663] Fix | Delete
* @return string Formatted version of the date, in UTC.
[3664] Fix | Delete
*/
[3665] Fix | Delete
function get_gmt_from_date( $date_string, $format = 'Y-m-d H:i:s' ) {
[3666] Fix | Delete
$datetime = date_create( $date_string, wp_timezone() );
[3667] Fix | Delete
[3668] Fix | Delete
if ( false === $datetime ) {
[3669] Fix | Delete
return gmdate( $format, 0 );
[3670] Fix | Delete
}
[3671] Fix | Delete
[3672] Fix | Delete
return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( $format );
[3673] Fix | Delete
}
[3674] Fix | Delete
[3675] Fix | Delete
/**
[3676] Fix | Delete
* Given a date in UTC or GMT timezone, returns that date in the timezone of the site.
[3677] Fix | Delete
*
[3678] Fix | Delete
* Requires a date in the Y-m-d H:i:s format.
[3679] Fix | Delete
* Default return format of 'Y-m-d H:i:s' can be overridden using the `$format` parameter.
[3680] Fix | Delete
*
[3681] Fix | Delete
* @since 1.2.0
[3682] Fix | Delete
*
[3683] Fix | Delete
* @param string $date_string The date to be converted, in UTC or GMT timezone.
[3684] Fix | Delete
* @param string $format The format string for the returned date. Default 'Y-m-d H:i:s'.
[3685] Fix | Delete
* @return string Formatted version of the date, in the site's timezone.
[3686] Fix | Delete
*/
[3687] Fix | Delete
function get_date_from_gmt( $date_string, $format = 'Y-m-d H:i:s' ) {
[3688] Fix | Delete
$datetime = date_create( $date_string, new DateTimeZone( 'UTC' ) );
[3689] Fix | Delete
[3690] Fix | Delete
if ( false === $datetime ) {
[3691] Fix | Delete
return gmdate( $format, 0 );
[3692] Fix | Delete
}
[3693] Fix | Delete
[3694] Fix | Delete
return $datetime->setTimezone( wp_timezone() )->format( $format );
[3695] Fix | Delete
}
[3696] Fix | Delete
[3697] Fix | Delete
/**
[3698] Fix | Delete
* Given an ISO 8601 timezone, returns its UTC offset in seconds.
[3699] Fix | Delete
*
[3700] Fix | Delete
* @since 1.5.0
[3701] Fix | Delete
*
[3702] Fix | Delete
* @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
[3703] Fix | Delete
* @return int|float The offset in seconds.
[3704] Fix | Delete
*/
[3705] Fix | Delete
function iso8601_timezone_to_offset( $timezone ) {
[3706] Fix | Delete
// $timezone is either 'Z' or '[+|-]hhmm'.
[3707] Fix | Delete
if ( 'Z' === $timezone ) {
[3708] Fix | Delete
$offset = 0;
[3709] Fix | Delete
} else {
[3710] Fix | Delete
$sign = ( str_starts_with( $timezone, '+' ) ) ? 1 : -1;
[3711] Fix | Delete
$hours = (int) substr( $timezone, 1, 2 );
[3712] Fix | Delete
$minutes = (int) substr( $timezone, 3, 4 ) / 60;
[3713] Fix | Delete
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
[3714] Fix | Delete
}
[3715] Fix | Delete
return $offset;
[3716] Fix | Delete
}
[3717] Fix | Delete
[3718] Fix | Delete
/**
[3719] Fix | Delete
* Given an ISO 8601 (Ymd\TH:i:sO) date, returns a MySQL DateTime (Y-m-d H:i:s) format used by post_date[_gmt].
[3720] Fix | Delete
*
[3721] Fix | Delete
* @since 1.5.0
[3722] Fix | Delete
*
[3723] Fix | Delete
* @param string $date_string Date and time in ISO 8601 format {@link https://en.wikipedia.org/wiki/ISO_8601}.
[3724] Fix | Delete
* @param string $timezone Optional. If set to 'gmt' returns the result in UTC. Default 'user'.
[3725] Fix | Delete
* @return string|false The date and time in MySQL DateTime format - Y-m-d H:i:s, or false on failure.
[3726] Fix | Delete
*/
[3727] Fix | Delete
function iso8601_to_datetime( $date_string, $timezone = 'user' ) {
[3728] Fix | Delete
$timezone = strtolower( $timezone );
[3729] Fix | Delete
$wp_timezone = wp_timezone();
[3730] Fix | Delete
$datetime = date_create( $date_string, $wp_timezone ); // Timezone is ignored if input has one.
[3731] Fix | Delete
[3732] Fix | Delete
if ( false === $datetime ) {
[3733] Fix | Delete
return false;
[3734] Fix | Delete
}
[3735] Fix | Delete
[3736] Fix | Delete
if ( 'gmt' === $timezone ) {
[3737] Fix | Delete
return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( 'Y-m-d H:i:s' );
[3738] Fix | Delete
}
[3739] Fix | Delete
[3740] Fix | Delete
if ( 'user' === $timezone ) {
[3741] Fix | Delete
return $datetime->setTimezone( $wp_timezone )->format( 'Y-m-d H:i:s' );
[3742] Fix | Delete
}
[3743] Fix | Delete
[3744] Fix | Delete
return false;
[3745] Fix | Delete
}
[3746] Fix | Delete
[3747] Fix | Delete
/**
[3748] Fix | Delete
* Strips out all characters that are not allowable in an email.
[3749] Fix | Delete
*
[3750] Fix | Delete
* @since 1.5.0
[3751] Fix | Delete
*
[3752] Fix | Delete
* @param string $email Email address to filter.
[3753] Fix | Delete
* @return string Filtered email address.
[3754] Fix | Delete
*/
[3755] Fix | Delete
function sanitize_email( $email ) {
[3756] Fix | Delete
// Test for the minimum length the email can be.
[3757] Fix | Delete
if ( strlen( $email ) < 6 ) {
[3758] Fix | Delete
/**
[3759] Fix | Delete
* Filters a sanitized email address.
[3760] Fix | Delete
*
[3761] Fix | Delete
* This filter is evaluated under several contexts, including 'email_too_short',
[3762] Fix | Delete
* 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
[3763] Fix | Delete
* 'domain_no_periods', 'domain_no_valid_subs', or no context.
[3764] Fix | Delete
*
[3765] Fix | Delete
* @since 2.8.0
[3766] Fix | Delete
*
[3767] Fix | Delete
* @param string $sanitized_email The sanitized email address.
[3768] Fix | Delete
* @param string $email The email address, as provided to sanitize_email().
[3769] Fix | Delete
* @param string|null $message A message to pass to the user. null if email is sanitized.
[3770] Fix | Delete
*/
[3771] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
[3772] Fix | Delete
}
[3773] Fix | Delete
[3774] Fix | Delete
// Test for an @ character after the first position.
[3775] Fix | Delete
if ( strpos( $email, '@', 1 ) === false ) {
[3776] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3777] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
[3778] Fix | Delete
}
[3779] Fix | Delete
[3780] Fix | Delete
// Split out the local and domain parts.
[3781] Fix | Delete
list( $local, $domain ) = explode( '@', $email, 2 );
[3782] Fix | Delete
[3783] Fix | Delete
/*
[3784] Fix | Delete
* LOCAL PART
[3785] Fix | Delete
* Test for invalid characters.
[3786] Fix | Delete
*/
[3787] Fix | Delete
$local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local );
[3788] Fix | Delete
if ( '' === $local ) {
[3789] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3790] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' );
[3791] Fix | Delete
}
[3792] Fix | Delete
[3793] Fix | Delete
/*
[3794] Fix | Delete
* DOMAIN PART
[3795] Fix | Delete
* Test for sequences of periods.
[3796] Fix | Delete
*/
[3797] Fix | Delete
$domain = preg_replace( '/\.{2,}/', '', $domain );
[3798] Fix | Delete
if ( '' === $domain ) {
[3799] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3800] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' );
[3801] Fix | Delete
}
[3802] Fix | Delete
[3803] Fix | Delete
// Test for leading and trailing periods and whitespace.
[3804] Fix | Delete
$domain = trim( $domain, " \t\n\r\0\x0B." );
[3805] Fix | Delete
if ( '' === $domain ) {
[3806] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3807] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );
[3808] Fix | Delete
}
[3809] Fix | Delete
[3810] Fix | Delete
// Split the domain into subs.
[3811] Fix | Delete
$subs = explode( '.', $domain );
[3812] Fix | Delete
[3813] Fix | Delete
// Assume the domain will have at least two subs.
[3814] Fix | Delete
if ( 2 > count( $subs ) ) {
[3815] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3816] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );
[3817] Fix | Delete
}
[3818] Fix | Delete
[3819] Fix | Delete
// Create an array that will contain valid subs.
[3820] Fix | Delete
$new_subs = array();
[3821] Fix | Delete
[3822] Fix | Delete
// Loop through each sub.
[3823] Fix | Delete
foreach ( $subs as $sub ) {
[3824] Fix | Delete
// Test for leading and trailing hyphens.
[3825] Fix | Delete
$sub = trim( $sub, " \t\n\r\0\x0B-" );
[3826] Fix | Delete
[3827] Fix | Delete
// Test for invalid characters.
[3828] Fix | Delete
$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub );
[3829] Fix | Delete
[3830] Fix | Delete
// If there's anything left, add it to the valid subs.
[3831] Fix | Delete
if ( '' !== $sub ) {
[3832] Fix | Delete
$new_subs[] = $sub;
[3833] Fix | Delete
}
[3834] Fix | Delete
}
[3835] Fix | Delete
[3836] Fix | Delete
// If there aren't 2 or more valid subs.
[3837] Fix | Delete
if ( 2 > count( $new_subs ) ) {
[3838] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3839] Fix | Delete
return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );
[3840] Fix | Delete
}
[3841] Fix | Delete
[3842] Fix | Delete
// Join valid subs into the new domain.
[3843] Fix | Delete
$domain = implode( '.', $new_subs );
[3844] Fix | Delete
[3845] Fix | Delete
// Put the email back together.
[3846] Fix | Delete
$sanitized_email = $local . '@' . $domain;
[3847] Fix | Delete
[3848] Fix | Delete
// Congratulations, your email made it!
[3849] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[3850] Fix | Delete
return apply_filters( 'sanitize_email', $sanitized_email, $email, null );
[3851] Fix | Delete
}
[3852] Fix | Delete
[3853] Fix | Delete
/**
[3854] Fix | Delete
* Determines the difference between two timestamps.
[3855] Fix | Delete
*
[3856] Fix | Delete
* The difference is returned in a human-readable format such as "1 hour",
[3857] Fix | Delete
* "5 mins", "2 days".
[3858] Fix | Delete
*
[3859] Fix | Delete
* @since 1.5.0
[3860] Fix | Delete
* @since 5.3.0 Added support for showing a difference in seconds.
[3861] Fix | Delete
*
[3862] Fix | Delete
* @param int $from Unix timestamp from which the difference begins.
[3863] Fix | Delete
* @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
[3864] Fix | Delete
* @return string Human-readable time difference.
[3865] Fix | Delete
*/
[3866] Fix | Delete
function human_time_diff( $from, $to = 0 ) {
[3867] Fix | Delete
if ( empty( $to ) ) {
[3868] Fix | Delete
$to = time();
[3869] Fix | Delete
}
[3870] Fix | Delete
[3871] Fix | Delete
$diff = (int) abs( $to - $from );
[3872] Fix | Delete
[3873] Fix | Delete
if ( $diff < MINUTE_IN_SECONDS ) {
[3874] Fix | Delete
$secs = $diff;
[3875] Fix | Delete
if ( $secs <= 1 ) {
[3876] Fix | Delete
$secs = 1;
[3877] Fix | Delete
}
[3878] Fix | Delete
/* translators: Time difference between two dates, in seconds. %s: Number of seconds. */
[3879] Fix | Delete
$since = sprintf( _n( '%s second', '%s seconds', $secs ), $secs );
[3880] Fix | Delete
} elseif ( $diff < HOUR_IN_SECONDS && $diff >= MINUTE_IN_SECONDS ) {
[3881] Fix | Delete
$mins = round( $diff / MINUTE_IN_SECONDS );
[3882] Fix | Delete
if ( $mins <= 1 ) {
[3883] Fix | Delete
$mins = 1;
[3884] Fix | Delete
}
[3885] Fix | Delete
/* translators: Time difference between two dates, in minutes (min=minute). %s: Number of minutes. */
[3886] Fix | Delete
$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
[3887] Fix | Delete
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
[3888] Fix | Delete
$hours = round( $diff / HOUR_IN_SECONDS );
[3889] Fix | Delete
if ( $hours <= 1 ) {
[3890] Fix | Delete
$hours = 1;
[3891] Fix | Delete
}
[3892] Fix | Delete
/* translators: Time difference between two dates, in hours. %s: Number of hours. */
[3893] Fix | Delete
$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
[3894] Fix | Delete
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
[3895] Fix | Delete
$days = round( $diff / DAY_IN_SECONDS );
[3896] Fix | Delete
if ( $days <= 1 ) {
[3897] Fix | Delete
$days = 1;
[3898] Fix | Delete
}
[3899] Fix | Delete
/* translators: Time difference between two dates, in days. %s: Number of days. */
[3900] Fix | Delete
$since = sprintf( _n( '%s day', '%s days', $days ), $days );
[3901] Fix | Delete
} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
[3902] Fix | Delete
$weeks = round( $diff / WEEK_IN_SECONDS );
[3903] Fix | Delete
if ( $weeks <= 1 ) {
[3904] Fix | Delete
$weeks = 1;
[3905] Fix | Delete
}
[3906] Fix | Delete
/* translators: Time difference between two dates, in weeks. %s: Number of weeks. */
[3907] Fix | Delete
$since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks );
[3908] Fix | Delete
} elseif ( $diff < YEAR_IN_SECONDS && $diff >= MONTH_IN_SECONDS ) {
[3909] Fix | Delete
$months = round( $diff / MONTH_IN_SECONDS );
[3910] Fix | Delete
if ( $months <= 1 ) {
[3911] Fix | Delete
$months = 1;
[3912] Fix | Delete
}
[3913] Fix | Delete
/* translators: Time difference between two dates, in months. %s: Number of months. */
[3914] Fix | Delete
$since = sprintf( _n( '%s month', '%s months', $months ), $months );
[3915] Fix | Delete
} elseif ( $diff >= YEAR_IN_SECONDS ) {
[3916] Fix | Delete
$years = round( $diff / YEAR_IN_SECONDS );
[3917] Fix | Delete
if ( $years <= 1 ) {
[3918] Fix | Delete
$years = 1;
[3919] Fix | Delete
}
[3920] Fix | Delete
/* translators: Time difference between two dates, in years. %s: Number of years. */
[3921] Fix | Delete
$since = sprintf( _n( '%s year', '%s years', $years ), $years );
[3922] Fix | Delete
}
[3923] Fix | Delete
[3924] Fix | Delete
/**
[3925] Fix | Delete
* Filters the human-readable difference between two timestamps.
[3926] Fix | Delete
*
[3927] Fix | Delete
* @since 4.0.0
[3928] Fix | Delete
*
[3929] Fix | Delete
* @param string $since The difference in human-readable text.
[3930] Fix | Delete
* @param int $diff The difference in seconds.
[3931] Fix | Delete
* @param int $from Unix timestamp from which the difference begins.
[3932] Fix | Delete
* @param int $to Unix timestamp to end the time difference.
[3933] Fix | Delete
*/
[3934] Fix | Delete
return apply_filters( 'human_time_diff', $since, $diff, $from, $to );
[3935] Fix | Delete
}
[3936] Fix | Delete
[3937] Fix | Delete
/**
[3938] Fix | Delete
* Generates an excerpt from the content, if needed.
[3939] Fix | Delete
*
[3940] Fix | Delete
* Returns a maximum of 55 words with an ellipsis appended if necessary.
[3941] Fix | Delete
*
[3942] Fix | Delete
* The 55-word limit can be modified by plugins/themes using the {@see 'excerpt_length'} filter
[3943] Fix | Delete
* The ' [&hellip;]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter
[3944] Fix | Delete
*
[3945] Fix | Delete
* @since 1.5.0
[3946] Fix | Delete
* @since 5.2.0 Added the `$post` parameter.
[3947] Fix | Delete
* @since 6.3.0 Removes footnotes markup from the excerpt content.
[3948] Fix | Delete
*
[3949] Fix | Delete
* @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
[3950] Fix | Delete
* @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default null.
[3951] Fix | Delete
* @return string The excerpt.
[3952] Fix | Delete
*/
[3953] Fix | Delete
function wp_trim_excerpt( $text = '', $post = null ) {
[3954] Fix | Delete
$raw_excerpt = $text;
[3955] Fix | Delete
[3956] Fix | Delete
if ( '' === trim( $text ) ) {
[3957] Fix | Delete
$post = get_post( $post );
[3958] Fix | Delete
$text = get_the_content( '', false, $post );
[3959] Fix | Delete
[3960] Fix | Delete
$text = strip_shortcodes( $text );
[3961] Fix | Delete
$text = excerpt_remove_blocks( $text );
[3962] Fix | Delete
$text = excerpt_remove_footnotes( $text );
[3963] Fix | Delete
[3964] Fix | Delete
/*
[3965] Fix | Delete
* Temporarily unhook wp_filter_content_tags() since any tags
[3966] Fix | Delete
* within the excerpt are stripped out. Modifying the tags here
[3967] Fix | Delete
* is wasteful and can lead to bugs in the image counting logic.
[3968] Fix | Delete
*/
[3969] Fix | Delete
$filter_image_removed = remove_filter( 'the_content', 'wp_filter_content_tags', 12 );
[3970] Fix | Delete
[3971] Fix | Delete
/*
[3972] Fix | Delete
* Temporarily unhook do_blocks() since excerpt_remove_blocks( $text )
[3973] Fix | Delete
* handles block rendering needed for excerpt.
[3974] Fix | Delete
*/
[3975] Fix | Delete
$filter_block_removed = remove_filter( 'the_content', 'do_blocks', 9 );
[3976] Fix | Delete
[3977] Fix | Delete
/** This filter is documented in wp-includes/post-template.php */
[3978] Fix | Delete
$text = apply_filters( 'the_content', $text );
[3979] Fix | Delete
$text = str_replace( ']]>', ']]&gt;', $text );
[3980] Fix | Delete
[3981] Fix | Delete
// Restore the original filter if removed.
[3982] Fix | Delete
if ( $filter_block_removed ) {
[3983] Fix | Delete
add_filter( 'the_content', 'do_blocks', 9 );
[3984] Fix | Delete
}
[3985] Fix | Delete
[3986] Fix | Delete
/*
[3987] Fix | Delete
* Only restore the filter callback if it was removed above. The logic
[3988] Fix | Delete
* to unhook and restore only applies on the default priority of 10,
[3989] Fix | Delete
* which is generally used for the filter callback in WordPress core.
[3990] Fix | Delete
*/
[3991] Fix | Delete
if ( $filter_image_removed ) {
[3992] Fix | Delete
add_filter( 'the_content', 'wp_filter_content_tags', 12 );
[3993] Fix | Delete
}
[3994] Fix | Delete
[3995] Fix | Delete
/* translators: Maximum number of words used in a post excerpt. */
[3996] Fix | Delete
$excerpt_length = (int) _x( '55', 'excerpt_length' );
[3997] Fix | Delete
[3998] Fix | Delete
/**
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function