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/clone/wp-inclu...
File: functions.php
* @see _is_utf8_charset
[7500] Fix | Delete
*
[7501] Fix | Delete
* @param string|null $blog_charset Optional. Slug representing a text character encoding, or "charset".
[7502] Fix | Delete
* E.g. "UTF-8", "Windows-1252", "ISO-8859-1", "SJIS".
[7503] Fix | Delete
* Default value is to infer from "blog_charset" option.
[7504] Fix | Delete
* @return bool Whether the slug represents the UTF-8 encoding.
[7505] Fix | Delete
*/
[7506] Fix | Delete
function is_utf8_charset( $blog_charset = null ) {
[7507] Fix | Delete
return _is_utf8_charset( $blog_charset ?? get_option( 'blog_charset' ) );
[7508] Fix | Delete
}
[7509] Fix | Delete
[7510] Fix | Delete
/**
[7511] Fix | Delete
* Retrieves a canonical form of the provided charset appropriate for passing to PHP
[7512] Fix | Delete
* functions such as htmlspecialchars() and charset HTML attributes.
[7513] Fix | Delete
*
[7514] Fix | Delete
* @since 3.6.0
[7515] Fix | Delete
* @access private
[7516] Fix | Delete
*
[7517] Fix | Delete
* @see https://core.trac.wordpress.org/ticket/23688
[7518] Fix | Delete
*
[7519] Fix | Delete
* @param string $charset A charset name, e.g. "UTF-8", "Windows-1252", "SJIS".
[7520] Fix | Delete
* @return string The canonical form of the charset.
[7521] Fix | Delete
*/
[7522] Fix | Delete
function _canonical_charset( $charset ) {
[7523] Fix | Delete
if ( is_utf8_charset( $charset ) ) {
[7524] Fix | Delete
return 'UTF-8';
[7525] Fix | Delete
}
[7526] Fix | Delete
[7527] Fix | Delete
/*
[7528] Fix | Delete
* Normalize the ISO-8859-1 family of languages.
[7529] Fix | Delete
*
[7530] Fix | Delete
* This is not required for htmlspecialchars(), as it properly recognizes all of
[7531] Fix | Delete
* the input character sets that here are transformed into "ISO-8859-1".
[7532] Fix | Delete
*
[7533] Fix | Delete
* @todo Should this entire check be removed since it's not required for the stated purpose?
[7534] Fix | Delete
* @todo Should WordPress transform other potential charset equivalents, such as "latin1"?
[7535] Fix | Delete
*/
[7536] Fix | Delete
if (
[7537] Fix | Delete
( 0 === strcasecmp( 'iso-8859-1', $charset ) ) ||
[7538] Fix | Delete
( 0 === strcasecmp( 'iso8859-1', $charset ) )
[7539] Fix | Delete
) {
[7540] Fix | Delete
return 'ISO-8859-1';
[7541] Fix | Delete
}
[7542] Fix | Delete
[7543] Fix | Delete
return $charset;
[7544] Fix | Delete
}
[7545] Fix | Delete
[7546] Fix | Delete
/**
[7547] Fix | Delete
* Sets the mbstring internal encoding to a binary safe encoding when func_overload
[7548] Fix | Delete
* is enabled.
[7549] Fix | Delete
*
[7550] Fix | Delete
* When mbstring.func_overload is in use for multi-byte encodings, the results from
[7551] Fix | Delete
* strlen() and similar functions respect the utf8 characters, causing binary data
[7552] Fix | Delete
* to return incorrect lengths.
[7553] Fix | Delete
*
[7554] Fix | Delete
* This function overrides the mbstring encoding to a binary-safe encoding, and
[7555] Fix | Delete
* resets it to the users expected encoding afterwards through the
[7556] Fix | Delete
* `reset_mbstring_encoding` function.
[7557] Fix | Delete
*
[7558] Fix | Delete
* It is safe to recursively call this function, however each
[7559] Fix | Delete
* `mbstring_binary_safe_encoding()` call must be followed up with an equal number
[7560] Fix | Delete
* of `reset_mbstring_encoding()` calls.
[7561] Fix | Delete
*
[7562] Fix | Delete
* @since 3.7.0
[7563] Fix | Delete
*
[7564] Fix | Delete
* @see reset_mbstring_encoding()
[7565] Fix | Delete
*
[7566] Fix | Delete
* @param bool $reset Optional. Whether to reset the encoding back to a previously-set encoding.
[7567] Fix | Delete
* Default false.
[7568] Fix | Delete
*/
[7569] Fix | Delete
function mbstring_binary_safe_encoding( $reset = false ) {
[7570] Fix | Delete
static $encodings = array();
[7571] Fix | Delete
static $overloaded = null;
[7572] Fix | Delete
[7573] Fix | Delete
if ( is_null( $overloaded ) ) {
[7574] Fix | Delete
if ( function_exists( 'mb_internal_encoding' )
[7575] Fix | Delete
&& ( (int) ini_get( 'mbstring.func_overload' ) & 2 ) // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
[7576] Fix | Delete
) {
[7577] Fix | Delete
$overloaded = true;
[7578] Fix | Delete
} else {
[7579] Fix | Delete
$overloaded = false;
[7580] Fix | Delete
}
[7581] Fix | Delete
}
[7582] Fix | Delete
[7583] Fix | Delete
if ( false === $overloaded ) {
[7584] Fix | Delete
return;
[7585] Fix | Delete
}
[7586] Fix | Delete
[7587] Fix | Delete
if ( ! $reset ) {
[7588] Fix | Delete
$encoding = mb_internal_encoding();
[7589] Fix | Delete
array_push( $encodings, $encoding );
[7590] Fix | Delete
mb_internal_encoding( 'ISO-8859-1' );
[7591] Fix | Delete
}
[7592] Fix | Delete
[7593] Fix | Delete
if ( $reset && $encodings ) {
[7594] Fix | Delete
$encoding = array_pop( $encodings );
[7595] Fix | Delete
mb_internal_encoding( $encoding );
[7596] Fix | Delete
}
[7597] Fix | Delete
}
[7598] Fix | Delete
[7599] Fix | Delete
/**
[7600] Fix | Delete
* Resets the mbstring internal encoding to a users previously set encoding.
[7601] Fix | Delete
*
[7602] Fix | Delete
* @see mbstring_binary_safe_encoding()
[7603] Fix | Delete
*
[7604] Fix | Delete
* @since 3.7.0
[7605] Fix | Delete
*/
[7606] Fix | Delete
function reset_mbstring_encoding() {
[7607] Fix | Delete
mbstring_binary_safe_encoding( true );
[7608] Fix | Delete
}
[7609] Fix | Delete
[7610] Fix | Delete
/**
[7611] Fix | Delete
* Filters/validates a variable as a boolean.
[7612] Fix | Delete
*
[7613] Fix | Delete
* Alternative to `filter_var( $value, FILTER_VALIDATE_BOOLEAN )`.
[7614] Fix | Delete
*
[7615] Fix | Delete
* @since 4.0.0
[7616] Fix | Delete
*
[7617] Fix | Delete
* @param mixed $value Boolean value to validate.
[7618] Fix | Delete
* @return bool Whether the value is validated.
[7619] Fix | Delete
*/
[7620] Fix | Delete
function wp_validate_boolean( $value ) {
[7621] Fix | Delete
if ( is_bool( $value ) ) {
[7622] Fix | Delete
return $value;
[7623] Fix | Delete
}
[7624] Fix | Delete
[7625] Fix | Delete
if ( is_string( $value ) && 'false' === strtolower( $value ) ) {
[7626] Fix | Delete
return false;
[7627] Fix | Delete
}
[7628] Fix | Delete
[7629] Fix | Delete
return (bool) $value;
[7630] Fix | Delete
}
[7631] Fix | Delete
[7632] Fix | Delete
/**
[7633] Fix | Delete
* Deletes a file.
[7634] Fix | Delete
*
[7635] Fix | Delete
* @since 4.2.0
[7636] Fix | Delete
*
[7637] Fix | Delete
* @param string $file The path to the file to delete.
[7638] Fix | Delete
*/
[7639] Fix | Delete
function wp_delete_file( $file ) {
[7640] Fix | Delete
/**
[7641] Fix | Delete
* Filters the path of the file to delete.
[7642] Fix | Delete
*
[7643] Fix | Delete
* @since 2.1.0
[7644] Fix | Delete
*
[7645] Fix | Delete
* @param string $file Path to the file to delete.
[7646] Fix | Delete
*/
[7647] Fix | Delete
$delete = apply_filters( 'wp_delete_file', $file );
[7648] Fix | Delete
if ( ! empty( $delete ) ) {
[7649] Fix | Delete
@unlink( $delete );
[7650] Fix | Delete
}
[7651] Fix | Delete
}
[7652] Fix | Delete
[7653] Fix | Delete
/**
[7654] Fix | Delete
* Deletes a file if its path is within the given directory.
[7655] Fix | Delete
*
[7656] Fix | Delete
* @since 4.9.7
[7657] Fix | Delete
*
[7658] Fix | Delete
* @param string $file Absolute path to the file to delete.
[7659] Fix | Delete
* @param string $directory Absolute path to a directory.
[7660] Fix | Delete
* @return bool True on success, false on failure.
[7661] Fix | Delete
*/
[7662] Fix | Delete
function wp_delete_file_from_directory( $file, $directory ) {
[7663] Fix | Delete
if ( wp_is_stream( $file ) ) {
[7664] Fix | Delete
$real_file = $file;
[7665] Fix | Delete
$real_directory = $directory;
[7666] Fix | Delete
} else {
[7667] Fix | Delete
$real_file = realpath( wp_normalize_path( $file ) );
[7668] Fix | Delete
$real_directory = realpath( wp_normalize_path( $directory ) );
[7669] Fix | Delete
}
[7670] Fix | Delete
[7671] Fix | Delete
if ( false !== $real_file ) {
[7672] Fix | Delete
$real_file = wp_normalize_path( $real_file );
[7673] Fix | Delete
}
[7674] Fix | Delete
[7675] Fix | Delete
if ( false !== $real_directory ) {
[7676] Fix | Delete
$real_directory = wp_normalize_path( $real_directory );
[7677] Fix | Delete
}
[7678] Fix | Delete
[7679] Fix | Delete
if ( false === $real_file || false === $real_directory || ! str_starts_with( $real_file, trailingslashit( $real_directory ) ) ) {
[7680] Fix | Delete
return false;
[7681] Fix | Delete
}
[7682] Fix | Delete
[7683] Fix | Delete
wp_delete_file( $file );
[7684] Fix | Delete
[7685] Fix | Delete
return true;
[7686] Fix | Delete
}
[7687] Fix | Delete
[7688] Fix | Delete
/**
[7689] Fix | Delete
* Outputs a small JS snippet on preview tabs/windows to remove `window.name` when a user is navigating to another page.
[7690] Fix | Delete
*
[7691] Fix | Delete
* This prevents reusing the same tab for a preview when the user has navigated away.
[7692] Fix | Delete
*
[7693] Fix | Delete
* @since 4.3.0
[7694] Fix | Delete
*
[7695] Fix | Delete
* @global WP_Post $post Global post object.
[7696] Fix | Delete
*/
[7697] Fix | Delete
function wp_post_preview_js() {
[7698] Fix | Delete
global $post;
[7699] Fix | Delete
[7700] Fix | Delete
if ( ! is_preview() || empty( $post ) ) {
[7701] Fix | Delete
return;
[7702] Fix | Delete
}
[7703] Fix | Delete
[7704] Fix | Delete
// Has to match the window name used in post_submit_meta_box().
[7705] Fix | Delete
$name = 'wp-preview-' . (int) $post->ID;
[7706] Fix | Delete
[7707] Fix | Delete
ob_start();
[7708] Fix | Delete
?>
[7709] Fix | Delete
<script>
[7710] Fix | Delete
( function() {
[7711] Fix | Delete
var query = document.location.search;
[7712] Fix | Delete
[7713] Fix | Delete
if ( query && query.indexOf( 'preview=true' ) !== -1 ) {
[7714] Fix | Delete
window.name = '<?php echo $name; ?>';
[7715] Fix | Delete
}
[7716] Fix | Delete
[7717] Fix | Delete
if ( window.addEventListener ) {
[7718] Fix | Delete
window.addEventListener( 'pagehide', function() { window.name = ''; } );
[7719] Fix | Delete
}
[7720] Fix | Delete
}());
[7721] Fix | Delete
</script>
[7722] Fix | Delete
<?php
[7723] Fix | Delete
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) );
[7724] Fix | Delete
}
[7725] Fix | Delete
[7726] Fix | Delete
/**
[7727] Fix | Delete
* Parses and formats a MySQL datetime (Y-m-d H:i:s) for ISO8601 (Y-m-d\TH:i:s).
[7728] Fix | Delete
*
[7729] Fix | Delete
* Explicitly strips timezones, as datetimes are not saved with any timezone
[7730] Fix | Delete
* information. Including any information on the offset could be misleading.
[7731] Fix | Delete
*
[7732] Fix | Delete
* Despite historical function name, the output does not conform to RFC3339 format,
[7733] Fix | Delete
* which must contain timezone.
[7734] Fix | Delete
*
[7735] Fix | Delete
* @since 4.4.0
[7736] Fix | Delete
*
[7737] Fix | Delete
* @param string $date_string Date string to parse and format.
[7738] Fix | Delete
* @return string Date formatted for ISO8601 without time zone.
[7739] Fix | Delete
*/
[7740] Fix | Delete
function mysql_to_rfc3339( $date_string ) {
[7741] Fix | Delete
return mysql2date( 'Y-m-d\TH:i:s', $date_string, false );
[7742] Fix | Delete
}
[7743] Fix | Delete
[7744] Fix | Delete
/**
[7745] Fix | Delete
* Attempts to raise the PHP memory limit for memory intensive processes.
[7746] Fix | Delete
*
[7747] Fix | Delete
* Only allows raising the existing limit and prevents lowering it.
[7748] Fix | Delete
*
[7749] Fix | Delete
* @since 4.6.0
[7750] Fix | Delete
*
[7751] Fix | Delete
* @param string $context Optional. Context in which the function is called. Accepts either 'admin',
[7752] Fix | Delete
* 'image', 'cron', or an arbitrary other context. If an arbitrary context is passed,
[7753] Fix | Delete
* the similarly arbitrary {@see '$context_memory_limit'} filter will be
[7754] Fix | Delete
* invoked. Default 'admin'.
[7755] Fix | Delete
* @return int|string|false The limit that was set or false on failure.
[7756] Fix | Delete
*/
[7757] Fix | Delete
function wp_raise_memory_limit( $context = 'admin' ) {
[7758] Fix | Delete
// Exit early if the limit cannot be changed.
[7759] Fix | Delete
if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
[7760] Fix | Delete
return false;
[7761] Fix | Delete
}
[7762] Fix | Delete
[7763] Fix | Delete
$current_limit = ini_get( 'memory_limit' );
[7764] Fix | Delete
$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
[7765] Fix | Delete
[7766] Fix | Delete
if ( -1 === $current_limit_int ) {
[7767] Fix | Delete
return false;
[7768] Fix | Delete
}
[7769] Fix | Delete
[7770] Fix | Delete
$wp_max_limit = WP_MAX_MEMORY_LIMIT;
[7771] Fix | Delete
$wp_max_limit_int = wp_convert_hr_to_bytes( $wp_max_limit );
[7772] Fix | Delete
$filtered_limit = $wp_max_limit;
[7773] Fix | Delete
[7774] Fix | Delete
switch ( $context ) {
[7775] Fix | Delete
case 'admin':
[7776] Fix | Delete
/**
[7777] Fix | Delete
* Filters the maximum memory limit available for administration screens.
[7778] Fix | Delete
*
[7779] Fix | Delete
* This only applies to administrators, who may require more memory for tasks
[7780] Fix | Delete
* like updates. Memory limits when processing images (uploaded or edited by
[7781] Fix | Delete
* users of any role) are handled separately.
[7782] Fix | Delete
*
[7783] Fix | Delete
* The `WP_MAX_MEMORY_LIMIT` constant specifically defines the maximum memory
[7784] Fix | Delete
* limit available when in the administration back end. The default is 256M
[7785] Fix | Delete
* (256 megabytes of memory) or the original `memory_limit` php.ini value if
[7786] Fix | Delete
* this is higher.
[7787] Fix | Delete
*
[7788] Fix | Delete
* @since 3.0.0
[7789] Fix | Delete
* @since 4.6.0 The default now takes the original `memory_limit` into account.
[7790] Fix | Delete
*
[7791] Fix | Delete
* @param int|string $filtered_limit The maximum WordPress memory limit. Accepts an integer
[7792] Fix | Delete
* (bytes), or a shorthand string notation, such as '256M'.
[7793] Fix | Delete
*/
[7794] Fix | Delete
$filtered_limit = apply_filters( 'admin_memory_limit', $filtered_limit );
[7795] Fix | Delete
break;
[7796] Fix | Delete
[7797] Fix | Delete
case 'image':
[7798] Fix | Delete
/**
[7799] Fix | Delete
* Filters the memory limit allocated for image manipulation.
[7800] Fix | Delete
*
[7801] Fix | Delete
* @since 3.5.0
[7802] Fix | Delete
* @since 4.6.0 The default now takes the original `memory_limit` into account.
[7803] Fix | Delete
*
[7804] Fix | Delete
* @param int|string $filtered_limit Maximum memory limit to allocate for image processing.
[7805] Fix | Delete
* Default `WP_MAX_MEMORY_LIMIT` or the original
[7806] Fix | Delete
* php.ini `memory_limit`, whichever is higher.
[7807] Fix | Delete
* Accepts an integer (bytes), or a shorthand string
[7808] Fix | Delete
* notation, such as '256M'.
[7809] Fix | Delete
*/
[7810] Fix | Delete
$filtered_limit = apply_filters( 'image_memory_limit', $filtered_limit );
[7811] Fix | Delete
break;
[7812] Fix | Delete
[7813] Fix | Delete
case 'cron':
[7814] Fix | Delete
/**
[7815] Fix | Delete
* Filters the memory limit allocated for WP-Cron event processing.
[7816] Fix | Delete
*
[7817] Fix | Delete
* @since 6.3.0
[7818] Fix | Delete
*
[7819] Fix | Delete
* @param int|string $filtered_limit Maximum memory limit to allocate for WP-Cron.
[7820] Fix | Delete
* Default `WP_MAX_MEMORY_LIMIT` or the original
[7821] Fix | Delete
* php.ini `memory_limit`, whichever is higher.
[7822] Fix | Delete
* Accepts an integer (bytes), or a shorthand string
[7823] Fix | Delete
* notation, such as '256M'.
[7824] Fix | Delete
*/
[7825] Fix | Delete
$filtered_limit = apply_filters( 'cron_memory_limit', $filtered_limit );
[7826] Fix | Delete
break;
[7827] Fix | Delete
[7828] Fix | Delete
default:
[7829] Fix | Delete
/**
[7830] Fix | Delete
* Filters the memory limit allocated for an arbitrary context.
[7831] Fix | Delete
*
[7832] Fix | Delete
* The dynamic portion of the hook name, `$context`, refers to an arbitrary
[7833] Fix | Delete
* context passed on calling the function. This allows for plugins to define
[7834] Fix | Delete
* their own contexts for raising the memory limit.
[7835] Fix | Delete
*
[7836] Fix | Delete
* @since 4.6.0
[7837] Fix | Delete
*
[7838] Fix | Delete
* @param int|string $filtered_limit Maximum memory limit to allocate for this context.
[7839] Fix | Delete
* Default WP_MAX_MEMORY_LIMIT` or the original php.ini `memory_limit`,
[7840] Fix | Delete
* whichever is higher. Accepts an integer (bytes), or a
[7841] Fix | Delete
* shorthand string notation, such as '256M'.
[7842] Fix | Delete
*/
[7843] Fix | Delete
$filtered_limit = apply_filters( "{$context}_memory_limit", $filtered_limit );
[7844] Fix | Delete
break;
[7845] Fix | Delete
}
[7846] Fix | Delete
[7847] Fix | Delete
$filtered_limit_int = wp_convert_hr_to_bytes( $filtered_limit );
[7848] Fix | Delete
[7849] Fix | Delete
if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) {
[7850] Fix | Delete
if ( false !== ini_set( 'memory_limit', $filtered_limit ) ) {
[7851] Fix | Delete
return $filtered_limit;
[7852] Fix | Delete
} else {
[7853] Fix | Delete
return false;
[7854] Fix | Delete
}
[7855] Fix | Delete
} elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) {
[7856] Fix | Delete
if ( false !== ini_set( 'memory_limit', $wp_max_limit ) ) {
[7857] Fix | Delete
return $wp_max_limit;
[7858] Fix | Delete
} else {
[7859] Fix | Delete
return false;
[7860] Fix | Delete
}
[7861] Fix | Delete
}
[7862] Fix | Delete
[7863] Fix | Delete
return false;
[7864] Fix | Delete
}
[7865] Fix | Delete
[7866] Fix | Delete
/**
[7867] Fix | Delete
* Generates a random UUID (version 4).
[7868] Fix | Delete
*
[7869] Fix | Delete
* @since 4.7.0
[7870] Fix | Delete
*
[7871] Fix | Delete
* @return string UUID.
[7872] Fix | Delete
*/
[7873] Fix | Delete
function wp_generate_uuid4() {
[7874] Fix | Delete
return sprintf(
[7875] Fix | Delete
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
[7876] Fix | Delete
mt_rand( 0, 0xffff ),
[7877] Fix | Delete
mt_rand( 0, 0xffff ),
[7878] Fix | Delete
mt_rand( 0, 0xffff ),
[7879] Fix | Delete
mt_rand( 0, 0x0fff ) | 0x4000,
[7880] Fix | Delete
mt_rand( 0, 0x3fff ) | 0x8000,
[7881] Fix | Delete
mt_rand( 0, 0xffff ),
[7882] Fix | Delete
mt_rand( 0, 0xffff ),
[7883] Fix | Delete
mt_rand( 0, 0xffff )
[7884] Fix | Delete
);
[7885] Fix | Delete
}
[7886] Fix | Delete
[7887] Fix | Delete
/**
[7888] Fix | Delete
* Validates that a UUID is valid.
[7889] Fix | Delete
*
[7890] Fix | Delete
* @since 4.9.0
[7891] Fix | Delete
*
[7892] Fix | Delete
* @param mixed $uuid UUID to check.
[7893] Fix | Delete
* @param int $version Specify which version of UUID to check against. Default is none,
[7894] Fix | Delete
* to accept any UUID version. Otherwise, only version allowed is `4`.
[7895] Fix | Delete
* @return bool The string is a valid UUID or false on failure.
[7896] Fix | Delete
*/
[7897] Fix | Delete
function wp_is_uuid( $uuid, $version = null ) {
[7898] Fix | Delete
[7899] Fix | Delete
if ( ! is_string( $uuid ) ) {
[7900] Fix | Delete
return false;
[7901] Fix | Delete
}
[7902] Fix | Delete
[7903] Fix | Delete
if ( is_numeric( $version ) ) {
[7904] Fix | Delete
if ( 4 !== (int) $version ) {
[7905] Fix | Delete
_doing_it_wrong( __FUNCTION__, __( 'Only UUID V4 is supported at this time.' ), '4.9.0' );
[7906] Fix | Delete
return false;
[7907] Fix | Delete
}
[7908] Fix | Delete
$regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/';
[7909] Fix | Delete
} else {
[7910] Fix | Delete
$regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/';
[7911] Fix | Delete
}
[7912] Fix | Delete
[7913] Fix | Delete
return (bool) preg_match( $regex, $uuid );
[7914] Fix | Delete
}
[7915] Fix | Delete
[7916] Fix | Delete
/**
[7917] Fix | Delete
* Gets unique ID.
[7918] Fix | Delete
*
[7919] Fix | Delete
* This is a PHP implementation of Underscore's uniqueId method. A static variable
[7920] Fix | Delete
* contains an integer that is incremented with each call. This number is returned
[7921] Fix | Delete
* with the optional prefix. As such the returned value is not universally unique,
[7922] Fix | Delete
* but it is unique across the life of the PHP process.
[7923] Fix | Delete
*
[7924] Fix | Delete
* @since 5.0.3
[7925] Fix | Delete
*
[7926] Fix | Delete
* @param string $prefix Prefix for the returned ID.
[7927] Fix | Delete
* @return string Unique ID.
[7928] Fix | Delete
*/
[7929] Fix | Delete
function wp_unique_id( $prefix = '' ) {
[7930] Fix | Delete
static $id_counter = 0;
[7931] Fix | Delete
return $prefix . (string) ++$id_counter;
[7932] Fix | Delete
}
[7933] Fix | Delete
[7934] Fix | Delete
/**
[7935] Fix | Delete
* Generates an incremental ID that is independent per each different prefix.
[7936] Fix | Delete
*
[7937] Fix | Delete
* It is similar to `wp_unique_id`, but each prefix has its own internal ID
[7938] Fix | Delete
* counter to make each prefix independent from each other. The ID starts at 1
[7939] Fix | Delete
* and increments on each call. The returned value is not universally unique,
[7940] Fix | Delete
* but it is unique across the life of the PHP process and it's stable per
[7941] Fix | Delete
* prefix.
[7942] Fix | Delete
*
[7943] Fix | Delete
* @since 6.4.0
[7944] Fix | Delete
*
[7945] Fix | Delete
* @param string $prefix Optional. Prefix for the returned ID. Default empty string.
[7946] Fix | Delete
* @return string Incremental ID per prefix.
[7947] Fix | Delete
*/
[7948] Fix | Delete
function wp_unique_prefixed_id( $prefix = '' ) {
[7949] Fix | Delete
static $id_counters = array();
[7950] Fix | Delete
[7951] Fix | Delete
if ( ! is_string( $prefix ) ) {
[7952] Fix | Delete
wp_trigger_error(
[7953] Fix | Delete
__FUNCTION__,
[7954] Fix | Delete
sprintf( 'The prefix must be a string. "%s" data type given.', gettype( $prefix ) )
[7955] Fix | Delete
);
[7956] Fix | Delete
$prefix = '';
[7957] Fix | Delete
}
[7958] Fix | Delete
[7959] Fix | Delete
if ( ! isset( $id_counters[ $prefix ] ) ) {
[7960] Fix | Delete
$id_counters[ $prefix ] = 0;
[7961] Fix | Delete
}
[7962] Fix | Delete
[7963] Fix | Delete
$id = ++$id_counters[ $prefix ];
[7964] Fix | Delete
[7965] Fix | Delete
return $prefix . (string) $id;
[7966] Fix | Delete
}
[7967] Fix | Delete
[7968] Fix | Delete
/**
[7969] Fix | Delete
* Gets last changed date for the specified cache group.
[7970] Fix | Delete
*
[7971] Fix | Delete
* @since 4.7.0
[7972] Fix | Delete
*
[7973] Fix | Delete
* @param string $group Where the cache contents are grouped.
[7974] Fix | Delete
* @return string UNIX timestamp with microseconds representing when the group was last changed.
[7975] Fix | Delete
*/
[7976] Fix | Delete
function wp_cache_get_last_changed( $group ) {
[7977] Fix | Delete
$last_changed = wp_cache_get( 'last_changed', $group );
[7978] Fix | Delete
[7979] Fix | Delete
if ( $last_changed ) {
[7980] Fix | Delete
return $last_changed;
[7981] Fix | Delete
}
[7982] Fix | Delete
[7983] Fix | Delete
return wp_cache_set_last_changed( $group );
[7984] Fix | Delete
}
[7985] Fix | Delete
[7986] Fix | Delete
/**
[7987] Fix | Delete
* Sets last changed date for the specified cache group to now.
[7988] Fix | Delete
*
[7989] Fix | Delete
* @since 6.3.0
[7990] Fix | Delete
*
[7991] Fix | Delete
* @param string $group Where the cache contents are grouped.
[7992] Fix | Delete
* @return string UNIX timestamp when the group was last changed.
[7993] Fix | Delete
*/
[7994] Fix | Delete
function wp_cache_set_last_changed( $group ) {
[7995] Fix | Delete
$previous_time = wp_cache_get( 'last_changed', $group );
[7996] Fix | Delete
[7997] Fix | Delete
$time = microtime();
[7998] Fix | Delete
[7999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function