| @@ -298,9 +298,9 @@ | ||
| 298 | 298 | public static function fsi_should_exit() { |
| 299 | 299 | if (defined('TEMPLATELY_START_TIME') && ini_get('max_execution_time')) { |
| 300 | 300 | $max_time = ini_get('max_execution_time'); |
| 301 | 301 | $elapsed = microtime(true) - TEMPLATELY_START_TIME; |
| 302 | - $delay = max(5, $max_time / 20); | |
| 302 | + $delay = max(5, $max_time * 20 / 100); | |
| 303 | 303 | |
| 304 | 304 | // Check if elapsed time is close to max execution time |
| 305 | 305 | if ($max_time - $elapsed <= $delay) { |
| 306 | 306 | return ['max_time' => $max_time, 'elapsed' => $elapsed, 'delay' => $delay]; |
| @@ -325,5 +325,28 @@ | ||
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | return false; |
| 328 | 328 | } |
| 329 | + | |
| 330 | + /** | |
| 331 | + * Undocumented function | |
| 332 | + * | |
| 333 | + * @param [type] $args | |
| 334 | + * @param [type] $defaults | |
| 335 | + * @return array | |
| 336 | + */ | |
| 337 | + public static function recursive_wp_parse_args( $args, $defaults ) { | |
| 338 | + $args = (array) $args; | |
| 339 | + $defaults = (array) $defaults; | |
| 340 | + $r = $defaults; | |
| 341 | + foreach ( $args as $key => $value ) { | |
| 342 | + if ( is_array( $value ) && isset( $r[ $key ] ) ) { | |
| 343 | + $r[ $key ] = self::recursive_wp_parse_args( $value, $r[ $key ] ); | |
| 344 | + } | |
| 345 | + else { | |
| 346 | + $r[$key] = $value; | |
| 347 | + } | |
| 348 | + } | |
| 349 | + return $r; | |
| 350 | + } | |
| 351 | + | |
| 329 | 352 | } |