balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

index.js (599B)


      1 const {compose} = wp.compose;
      2 const {withSelect} = wp.data;
      3 import {useEffect} from '@wordpress/element';
      4 
      5 function TemplateChange (props) {
      6 	const {template} = props;
      7 	useEffect(() => {
      8 		if ( template.includes('redux-templates_') ) {
      9 			document.body.className += ' redux-template';
     10 		} else {
     11 			document.querySelector('body').classList.remove('redux-template');
     12 		}
     13 	}, [template])
     14 	return ( <div /> )
     15 }
     16 
     17 export default compose([
     18 	withSelect((select) => {
     19 		const {getEditedPostAttribute} = select('core/editor');
     20 		return {template: getEditedPostAttribute('template')};
     21 	})
     22 ])(TemplateChange);