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/clone/wp-conte.../plugins/popup-ma.../trunk/includes
File: compat.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// SPL can be disabled on PHP 5.2
[2] Fix | Delete
if ( ! function_exists( 'spl_autoload_register' ) ) {
[3] Fix | Delete
$_wp_spl_autoloaders = [];
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Registers a function to be autoloaded.
[7] Fix | Delete
*
[8] Fix | Delete
* @since 4.6.0
[9] Fix | Delete
*
[10] Fix | Delete
* @param callable $autoload_function The function to register.
[11] Fix | Delete
* @param bool $throw Optional. Whether the function should throw an exception
[12] Fix | Delete
* if the function isn't callable. Default true.
[13] Fix | Delete
* @param bool $prepend Whether the function should be prepended to the stack.
[14] Fix | Delete
* Default false.
[15] Fix | Delete
*
[16] Fix | Delete
* @throws Exception
[17] Fix | Delete
*/
[18] Fix | Delete
function spl_autoload_register( $autoload_function, $throw = true, $prepend = false ) {
[19] Fix | Delete
if ( $throw && ! is_callable( $autoload_function ) ) {
[20] Fix | Delete
// String not translated to match PHP core.
[21] Fix | Delete
throw new Exception( 'Function not callable' );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
global $_wp_spl_autoloaders;
[25] Fix | Delete
[26] Fix | Delete
// Don't allow multiple registration.
[27] Fix | Delete
if ( in_array( $autoload_function, $_wp_spl_autoloaders ) ) {
[28] Fix | Delete
return;
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
if ( $prepend ) {
[32] Fix | Delete
array_unshift( $_wp_spl_autoloaders, $autoload_function );
[33] Fix | Delete
} else {
[34] Fix | Delete
$_wp_spl_autoloaders[] = $autoload_function;
[35] Fix | Delete
}
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Unregisters an autoloader function.
[40] Fix | Delete
*
[41] Fix | Delete
* @since 4.6.0
[42] Fix | Delete
*
[43] Fix | Delete
* @param callable $function The function to unregister.
[44] Fix | Delete
*
[45] Fix | Delete
* @return bool True if the function was unregistered, false if it could not be.
[46] Fix | Delete
*/
[47] Fix | Delete
function spl_autoload_unregister( $function ) {
[48] Fix | Delete
global $_wp_spl_autoloaders;
[49] Fix | Delete
foreach ( $_wp_spl_autoloaders as &$autoloader ) {
[50] Fix | Delete
if ( $autoloader === $function ) {
[51] Fix | Delete
unset( $autoloader );
[52] Fix | Delete
[53] Fix | Delete
return true;
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
return false;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Retrieves the registered autoloader functions.
[62] Fix | Delete
*
[63] Fix | Delete
* @since 4.6.0
[64] Fix | Delete
*
[65] Fix | Delete
* @return array List of autoloader functions.
[66] Fix | Delete
*/
[67] Fix | Delete
function spl_autoload_functions() {
[68] Fix | Delete
return $GLOBALS['_wp_spl_autoloaders'];
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
if ( ! function_exists( 'current_action' ) ) {
[73] Fix | Delete
function current_action() {
[74] Fix | Delete
return current_filter();
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if ( ! function_exists( 'get_called_class' ) ) {
[79] Fix | Delete
function get_called_class( $bt = false, $l = 1 ) {
[80] Fix | Delete
if ( ! $bt ) {
[81] Fix | Delete
$bt = debug_backtrace();
[82] Fix | Delete
}
[83] Fix | Delete
if ( ! isset( $bt[ $l ] ) ) {
[84] Fix | Delete
throw new Exception( 'Cannot find called class -> stack level too deep.' );
[85] Fix | Delete
}
[86] Fix | Delete
if ( ! isset( $bt[ $l ]['type'] ) ) {
[87] Fix | Delete
throw new Exception( 'type not set' );
[88] Fix | Delete
} else {
[89] Fix | Delete
switch ( $bt[ $l ]['type'] ) {
[90] Fix | Delete
case '::':
[91] Fix | Delete
$lines = file( $bt[ $l ]['file'] );
[92] Fix | Delete
$i = 0;
[93] Fix | Delete
$callerLine = '';
[94] Fix | Delete
do {
[95] Fix | Delete
$i ++;
[96] Fix | Delete
$callerLine = $lines[ $bt[ $l ]['line'] - $i ] . $callerLine;
[97] Fix | Delete
} while ( stripos( $callerLine, $bt[ $l ]['function'] ) === false );
[98] Fix | Delete
preg_match( '/([a-zA-Z0-9\_]+)::' . $bt[ $l ]['function'] . '/', $callerLine, $matches );
[99] Fix | Delete
if ( ! isset( $matches[1] ) ) {
[100] Fix | Delete
// must be an edge case.
[101] Fix | Delete
throw new Exception( 'Could not find caller class: originating method call is obscured.' );
[102] Fix | Delete
}
[103] Fix | Delete
switch ( $matches[1] ) {
[104] Fix | Delete
case 'self':
[105] Fix | Delete
case 'parent':
[106] Fix | Delete
return get_called_class( $bt, $l + 1 );
[107] Fix | Delete
default:
[108] Fix | Delete
return $matches[1];
[109] Fix | Delete
}
[110] Fix | Delete
// won't get here.
[111] Fix | Delete
case '->':
[112] Fix | Delete
switch ( $bt[ $l ]['function'] ) {
[113] Fix | Delete
case '__get':
[114] Fix | Delete
// edge case -> get class of calling object
[115] Fix | Delete
if ( ! is_object( $bt[ $l ]['object'] ) ) {
[116] Fix | Delete
throw new Exception( 'Edge case fail. __get called on non object.' );
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
return get_class( $bt[ $l ]['object'] );
[120] Fix | Delete
default:
[121] Fix | Delete
return get_class( $bt[ $l ]['object'] );
[122] Fix | Delete
}
[123] Fix | Delete
default:
[124] Fix | Delete
throw new Exception( 'Unknown backtrace method type' );
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
if ( ! function_exists( 'get_term_name' ) ) {
[131] Fix | Delete
function get_term_name( $term_id, $taxonomy ) {
[132] Fix | Delete
$term = get_term_by( 'id', absint( $term_id ), $taxonomy );
[133] Fix | Delete
[134] Fix | Delete
return $term->name;
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
// For WP versions before 3.6
[139] Fix | Delete
if ( ! function_exists( 'has_shortcode' ) ) {
[140] Fix | Delete
function has_shortcode( $content, $tag ) {
[141] Fix | Delete
if ( false === strpos( $content, '[' ) ) {
[142] Fix | Delete
return false;
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
if ( shortcode_exists( $tag ) ) {
[146] Fix | Delete
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
[147] Fix | Delete
if ( empty( $matches ) ) {
[148] Fix | Delete
return false;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
foreach ( $matches as $shortcode ) {
[152] Fix | Delete
if ( $tag === $shortcode[2] ) {
[153] Fix | Delete
return true;
[154] Fix | Delete
} elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) {
[155] Fix | Delete
return true;
[156] Fix | Delete
}
[157] Fix | Delete
}
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
return false;
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
if ( ! function_exists( 'shortcode_exists' ) ) {
[165] Fix | Delete
function shortcode_exists( $tag ) {
[166] Fix | Delete
global $shortcode_tags;
[167] Fix | Delete
[168] Fix | Delete
return array_key_exists( $tag, $shortcode_tags );
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Deprecated PHP v5.3 functions.
[174] Fix | Delete
*/
[175] Fix | Delete
if ( ! function_exists( 'array_replace_recursive' ) ) {
[176] Fix | Delete
function array_replace_recursive( $array, $array1 ) {
[177] Fix | Delete
// handle the arguments, merge one by one
[178] Fix | Delete
$args = func_get_args();
[179] Fix | Delete
$array = $args[0];
[180] Fix | Delete
if ( ! is_array( $array ) ) {
[181] Fix | Delete
return $array;
[182] Fix | Delete
}
[183] Fix | Delete
for ( $i = 1; $i < count( $args ); $i ++ ) {
[184] Fix | Delete
if ( is_array( $args[ $i ] ) ) {
[185] Fix | Delete
$array = recurse( $array, $args[ $i ] );
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
return $array;
[190] Fix | Delete
}
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
if ( ! function_exists( 'recurse' ) ) {
[194] Fix | Delete
function recurse( $array, $array1 ) {
[195] Fix | Delete
foreach ( $array1 as $key => $value ) {
[196] Fix | Delete
// create new key in $array, if it is empty or not an array
[197] Fix | Delete
if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
[198] Fix | Delete
$array[ $key ] = [];
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
// overwrite the value in the base array
[202] Fix | Delete
if ( is_array( $value ) ) {
[203] Fix | Delete
$value = recurse( $array[ $key ], $value );
[204] Fix | Delete
}
[205] Fix | Delete
$array[ $key ] = $value;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
return $array;
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
if ( ! function_exists( 'write_log' ) ) {
[213] Fix | Delete
function write_log( $log ) {
[214] Fix | Delete
if ( is_array( $log ) || is_object( $log ) ) {
[215] Fix | Delete
error_log( print_r( $log, true ) );
[216] Fix | Delete
} else {
[217] Fix | Delete
error_log( $log );
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
if ( ! function_exists( 'boolval' ) ) {
[223] Fix | Delete
function boolval( $val ) {
[224] Fix | Delete
return (bool) $val;
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
if ( ! function_exists( 'maybe_json_attr' ) ) {
[229] Fix | Delete
function maybe_json_attr( $value, $encode = false ) {
[230] Fix | Delete
if ( is_object( $value ) || is_array( $value ) ) {
[231] Fix | Delete
return $encode ? htmlspecialchars( wp_json_encode( $value ) ) : wp_json_encode( $value );
[232] Fix | Delete
}
[233] Fix | Delete
return $value;
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
if ( ! function_exists( 'has_blocks' ) ) {
[238] Fix | Delete
/**
[239] Fix | Delete
* Determine whether a post or content string has blocks.
[240] Fix | Delete
*
[241] Fix | Delete
* This test optimizes for performance rather than strict accuracy, detecting
[242] Fix | Delete
* the pattern of a block but not validating its structure. For strict accuracy,
[243] Fix | Delete
* you should use the block parser on post content.
[244] Fix | Delete
*
[245] Fix | Delete
* @since 5.0.0
[246] Fix | Delete
* @see parse_blocks()
[247] Fix | Delete
*
[248] Fix | Delete
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
[249] Fix | Delete
* @return bool Whether the post has blocks.
[250] Fix | Delete
*/
[251] Fix | Delete
function has_blocks( $post = null ) {
[252] Fix | Delete
if ( ! is_string( $post ) ) {
[253] Fix | Delete
$wp_post = get_post( $post );
[254] Fix | Delete
if ( $wp_post instanceof WP_Post ) {
[255] Fix | Delete
$post = $wp_post->post_content;
[256] Fix | Delete
}
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
return false !== strpos( (string) $post, '<!-- wp:' );
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* Aweful hack for backward compatibility with WP <5.3.
[265] Fix | Delete
*/
[266] Fix | Delete
if ( ! function_exists( 'wp_date' ) ) {
[267] Fix | Delete
function wp_date( $format, $timestamp = null, $timezone = null ) {
[268] Fix | Delete
global $wp_locale;
[269] Fix | Delete
[270] Fix | Delete
if ( null === $timestamp ) {
[271] Fix | Delete
$timestamp = time();
[272] Fix | Delete
} elseif ( ! is_numeric( $timestamp ) ) {
[273] Fix | Delete
return false;
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
if ( ! $timezone ) {
[277] Fix | Delete
if ( function_exists( 'wp_timezone' ) ) {
[278] Fix | Delete
$timezone = wp_timezone();
[279] Fix | Delete
} else {
[280] Fix | Delete
// Get the server timezone
[281] Fix | Delete
$server_timezone = get_option( 'timezone_string' );
[282] Fix | Delete
[283] Fix | Delete
// If timezone_string is not set, get the default timezone of the server
[284] Fix | Delete
if ( empty( $server_timezone ) ) {
[285] Fix | Delete
$server_timezone = date_default_timezone_get();
[286] Fix | Delete
}
[287] Fix | Delete
[288] Fix | Delete
$timezone = new DateTimeZone( $server_timezone );
[289] Fix | Delete
}
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
$datetime = date_create( '@' . $timestamp );
[293] Fix | Delete
$datetime->setTimezone( $timezone );
[294] Fix | Delete
[295] Fix | Delete
if ( empty( $wp_locale->month ) || empty( $wp_locale->weekday ) ) {
[296] Fix | Delete
$date = $datetime->format( $format );
[297] Fix | Delete
} else {
[298] Fix | Delete
// We need to unpack shorthand `r` format because it has parts that might be localized.
[299] Fix | Delete
$format = preg_replace( '/(?<!\\\\)r/', DATE_RFC2822, $format );
[300] Fix | Delete
[301] Fix | Delete
$new_format = '';
[302] Fix | Delete
$format_length = strlen( $format );
[303] Fix | Delete
$month = $wp_locale->get_month( $datetime->format( 'm' ) );
[304] Fix | Delete
$weekday = $wp_locale->get_weekday( $datetime->format( 'w' ) );
[305] Fix | Delete
[306] Fix | Delete
for ( $i = 0; $i < $format_length; $i++ ) {
[307] Fix | Delete
switch ( $format[ $i ] ) {
[308] Fix | Delete
case 'D':
[309] Fix | Delete
$new_format .= addcslashes( $wp_locale->get_weekday_abbrev( $weekday ), '\\A..Za..z' );
[310] Fix | Delete
break;
[311] Fix | Delete
case 'F':
[312] Fix | Delete
$new_format .= addcslashes( $month, '\\A..Za..z' );
[313] Fix | Delete
break;
[314] Fix | Delete
case 'l':
[315] Fix | Delete
$new_format .= addcslashes( $weekday, '\\A..Za..z' );
[316] Fix | Delete
break;
[317] Fix | Delete
case 'M':
[318] Fix | Delete
$new_format .= addcslashes( $wp_locale->get_month_abbrev( $month ), '\\A..Za..z' );
[319] Fix | Delete
break;
[320] Fix | Delete
case 'a':
[321] Fix | Delete
$new_format .= addcslashes( $wp_locale->get_meridiem( $datetime->format( 'a' ) ), '\\A..Za..z' );
[322] Fix | Delete
break;
[323] Fix | Delete
case 'A':
[324] Fix | Delete
$new_format .= addcslashes( $wp_locale->get_meridiem( $datetime->format( 'A' ) ), '\\A..Za..z' );
[325] Fix | Delete
break;
[326] Fix | Delete
case '\\':
[327] Fix | Delete
$new_format .= $format[ $i ];
[328] Fix | Delete
[329] Fix | Delete
// If character follows a slash, we add it without translating.
[330] Fix | Delete
if ( $i < $format_length ) {
[331] Fix | Delete
$new_format .= $format[ ++$i ];
[332] Fix | Delete
}
[333] Fix | Delete
break;
[334] Fix | Delete
default:
[335] Fix | Delete
$new_format .= $format[ $i ];
[336] Fix | Delete
break;
[337] Fix | Delete
}
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
$date = $datetime->format( $new_format );
[341] Fix | Delete
$date = wp_maybe_decline_date( $date, $format );
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
/**
[345] Fix | Delete
* Filters the date formatted based on the locale.
[346] Fix | Delete
*
[347] Fix | Delete
* @since 5.3.0
[348] Fix | Delete
*
[349] Fix | Delete
* @param string $date Formatted date string.
[350] Fix | Delete
* @param string $format Format to display the date.
[351] Fix | Delete
* @param int $timestamp Unix timestamp.
[352] Fix | Delete
* @param DateTimeZone $timezone Timezone.
[353] Fix | Delete
*/
[354] Fix | Delete
$date = apply_filters( 'wp_date', $date, $format, $timestamp, $timezone );
[355] Fix | Delete
[356] Fix | Delete
return $date;
[357] Fix | Delete
}
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function