403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.217.33
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/self/cwd/wp-content/plugins/generateblocks/src/pattern-library/components/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/cwd/wp-content/plugins/generateblocks/src/pattern-library/components/library-cache.js
import { useState, useEffect } from '@wordpress/element';
import { useLibrary } from './library-provider';
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import { isEmpty } from 'lodash';
import { Button, Icon, Spinner } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { backup } from '@wordpress/icons';

export default function LibraryCache( { setCacheIsClearing, cacheIsClearing } ) {
	const { activeLibrary, setLibraryCategories, setLibraryPatterns, isLocal } = useLibrary();
	const [ cacheData, setCacheData ] = useState( false );

	async function checkCacheData() {
		if ( isLocal ) {
			setCacheData( {} );
			return;
		}

		const cacheDataResponse = await apiFetch( {
			path: addQueryArgs( `/generateblocks/v1/pattern-library/get-cache-data`, {
				id: activeLibrary.id,
			} ),
			method: 'GET',
		} );

		if ( cacheDataResponse.success ) {
			setCacheData( cacheDataResponse?.response?.data ?? {} );
		} else {
			setCacheData( {} );
		}
	}

	useEffect( () => {
		( async function() {
			if ( ! activeLibrary?.id ) {
				return;
			}

			checkCacheData();
		}() );
	}, [ activeLibrary?.id ] );

	if ( isEmpty( cacheData ) ) {
		return null;
	}

	return (
		<Button
			className="has-icon"
			variant="tertiary"
			size="compact"
			disabled={ ! cacheData.can_clear || cacheIsClearing }
			label={ __( 'Refresh patterns', 'generateblocks' ) }
			showTooltip
			onClick={ async() => {
				setCacheIsClearing( true );
				const response = await apiFetch( {
					path: '/generateblocks/v1/pattern-library/clear-cache',
					data: {
						id: activeLibrary?.id,
					},
					method: 'POST',
				} );

				if ( response.success ) {
					await setLibraryCategories();
					await setLibraryPatterns();
					await checkCacheData();
				}

				setCacheIsClearing( false );
			} }
		>
			{ !! cacheIsClearing ? <Spinner /> : <Icon icon={ backup } /> }
		</Button>
	);
}

Youez - 2016 - github.com/yon3zu
LinuXploit