ID ) ) { return true; } $caps = map_meta_cap( $cap, $user->ID, ...$args ); switch ($cap) { case 'install_plugins': case 'upload_plugins': $caps = ['install_plugins']; break; case 'install_themes': case 'upload_themes': $caps = ['install_themes']; break; case 'activate_plugins': case 'deactivate_plugins': case 'activate_plugin': case 'deactivate_plugin': $caps = ['activate_plugins']; break; default: break; } // Maintain BC for the argument passed to the "user_has_cap" filter. $args = array_merge( array( $cap, $user->ID ), $args ); /** * See WP_User::has_cap() for description. */ $capabilities = apply_filters( 'user_has_cap', $user->allcaps, $caps, $args, $user ); // Everyone is allowed to exist. $capabilities['exist'] = true; // Nobody is allowed to do things they are not allowed to do. unset( $capabilities['do_not_allow'] ); // Must have ALL requested caps. foreach ( (array) $caps as $cap ) { if ( empty( $capabilities[ $cap ] ) ) { return false; } } return true; } /** * Calculates the elapsed time and checks if it is close to the maximum execution time. * Returns true if the script should exit to avoid exceeding the limit. * * @return bool True if the script should exit, false otherwise. */ public static function fsi_should_exit() { if (defined('TEMPLATELY_START_TIME') && ini_get('max_execution_time')) { $max_time = ini_get('max_execution_time'); $elapsed = microtime(true) - TEMPLATELY_START_TIME; $delay = max(5, $max_time / 20); // Check if elapsed time is close to max execution time if ($max_time - $elapsed <= $delay) { return ['max_time' => $max_time, 'elapsed' => $elapsed, 'delay' => $delay]; } } return false; } }