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/delta/wp-content/plugins/better-wp-security/core/packages/data/src/resolvers.js
/**
 * External dependencies
 */
import { get } from 'lodash';

/**
 * WordPress dependencies
 */
import { controls } from '@wordpress/data';

/**
 * Internal dependencies
 */
import { apiFetch } from './controls';
import {
	receiveActors,
	receiveActorTypes,
	receiveBatchMaxItems,
	receiveCurrentUserId,
	receiveIndex,
	receiveSiteInfo,
	receiveUser,
} from './actions';

export function* getIndex() {
	const index = yield apiFetch( {
		path: '/ithemes-security/v1?context=help',
	} );
	yield receiveIndex( index );
}

export const getSchema = () => ( { resolveSelect } ) =>
	resolveSelect.getIndex();

export const getRoles = () => ( { resolveSelect } ) =>
	resolveSelect.getIndex();

export const getRequirementsInfo = () => ( { resolveSelect } ) =>
	resolveSelect.getIndex();

export const getServerType = () => ( { resolveSelect } ) =>
	resolveSelect.getIndex();

export const getInstallType = () => ( { resolveSelect } ) =>
	resolveSelect.getIndex();

export const hasPatchstack = () => ( { resolveSelect } ) =>
	resolveSelect.getIndex();

export const isLiquidWebCustomer = () => ( { resolveSelect } ) => resolveSelect.getIndex();

export const getUser = {
	*fulfill( id ) {
		const currentUserId = yield controls.select( 'ithemes-security/core', 'getCurrentUserId' );
		const user = yield apiFetch( {
			path: `/wp/v2/users/${ id === currentUserId ? 'me' : id }?context=edit`,
		} );

		yield receiveUser( user );
	},
	isFulfilled( state, userId ) {
		return !! state.users.byId[ userId ];
	},
};

export const getCurrentUser = {
	*fulfill() {
		const user = yield apiFetch( {
			path: '/wp/v2/users/me?context=edit',
		} );

		yield receiveUser( user );
		yield receiveCurrentUserId( user.id );
	},
	isFulfilled( state ) {
		return (
			state.users.currentId && state.users.byId[ state.users.currentId ]
		);
	},
};

export const getActorTypes = {
	*fulfill() {
		const response = yield apiFetch( {
			path: '/ithemes-security/v1/actors?_embed=1',
		} );

		const types = [];

		for ( const type of response ) {
			const actors = get( type, [ '_embedded', 'wp:items', 0 ], [] );

			yield receiveActors( type.slug, actors );
			types.push( { slug: type.slug, label: type.label } );
		}

		yield receiveActorTypes( types );
	},

	isFulfilled( state ) {
		return state.actors.types.length > 0;
	},
};

export const getActors = {
	*fulfill() {
		yield controls.select( 'ithemes-security/core', 'getActorTypes' );
	},
	isFulfilled( state, type ) {
		return !! state.actors.byType[ type ];
	},
};

export const getSiteInfo = {
	*fulfill() {
		const response = yield apiFetch( {
			path: '/?_fields=name,description,url,home,multisite',
		} );
		yield receiveSiteInfo( response );
	},
	isFulfilled( state ) {
		return !! state.siteInfo;
	},
};

export function* getBatchMaxItems() {
	const response = yield apiFetch( {
		path: '/batch/v1',
		method: 'OPTIONS',
	} );
	yield receiveBatchMaxItems(
		response.endpoints[ 0 ].args.requests.maxItems
	);
}