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 / 100); // 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; } /** * Enable Elementor Container * This function will enable the Elementor Container feature. * Without this feature, some of the templates may not work properly. * * @return boolean */ public static function enable_elementor_container(){ if(class_exists('Elementor\Plugin')) { $control_name = Plugin::instance()->experiments->get_feature_option_key( 'container' ); if(get_option( $control_name ) === 'inactive') { update_option( $control_name, 'active' ); return true; } } return false; } /** * Undocumented function * * @param [type] $args * @param [type] $defaults * @return array */ public static function recursive_wp_parse_args( $args, $defaults ) { $args = (array) $args; $defaults = (array) $defaults; $r = $defaults; foreach ( $args as $key => $value ) { if ( is_array( $value ) && isset( $r[ $key ] ) ) { $r[ $key ] = self::recursive_wp_parse_args( $value, $r[ $key ] ); } else { $r[$key] = $value; } } return $r; } }