HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/linde/wp-content/plugins/better-wp-security/core/packages/ui/src/badges/index.js
import { useSelect } from '@wordpress/data';
import { coreStore, modulesStore } from '@ithemes/security.packages.data';
import { __ } from '@wordpress/i18n';
import { StyledCheck, StyledClose } from './styles';
import { check as checkIcon, close as closeIcon, shield } from '@wordpress/icons';
import { Badge } from '@ithemes/ui';

export function ActiveUpdatesBadge() {
	const { versionActive, versionSettings, installType } = useSelect( ( select ) => ( {
		versionActive: select( modulesStore ).isActive( 'version-management' ),
		versionSettings: select( modulesStore ).getSettings( 'version-management' ),
		installType: select( coreStore ).getInstallType(),
	} ), [] );

	const updateVulnerabilities = versionActive && versionSettings.update_if_vulnerable;
	const isFree = installType === 'free';

	const text = updateVulnerabilities
		? __( 'Real-Time Updates Active', 'better-wp-security' )
		: __( 'Real-Time Updates Inactive', 'better-wp-security' );

	const tooltip = isFree
		? __( 'Upgrade', 'better-wp-security' )
		: __( 'Enable “Auto Update If Fixes Vulnerability” in Version Management', 'better-wp-security' );

	const icon = updateVulnerabilities
		? <StyledCheck icon={ checkIcon } />
		: <StyledClose icon={ closeIcon } style={ { fill: '#8A2424' } } />;

	return (
		<Badge
			text={ text }
			icon={ icon }
			iconColor="#FFFFFF"
			tooltip={ tooltip }
		/>
	);
}

export function VirtualPatchingBadge() {
	const { hasPatchstack, installType } = useSelect( ( select ) => ( {
		hasPatchstack: select( coreStore ).hasPatchstack(),
		installType: select( coreStore ).getInstallType(),
	} ), [] );

	const isFree = installType === 'free';

	const text = hasPatchstack
		? __( 'Virtual Patching Active', 'better-wp-security' )
		: __( 'Virtual Patching Inactive', 'better-wp-security' );

	const tooltip = isFree
		? __( 'Upgrade', 'better-wp-security' )
		: null;

	const icon = hasPatchstack
		? shield
		: <StyledClose icon={ closeIcon } style={ { fill: '#8A2424' } } />;

	return (
		<Badge
			text={ text }
			icon={ icon }
			iconColor="#6817C5"
			tooltip={ tooltip }
		/>
	);
}