# extendify/1.17.1/src/Library/library.js

Extendify, version 1.17.1. 34 lines.

- Page: https://pluginprobe.com/plugins/extendify/1.17.1/code/src/Library/library.js
- Raw: https://pluginprobe.com/plugins/extendify/1.17.1/raw/src/Library/library.js
- Modified: 2023-11-14T03:13:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/1.17.1/code/src/Library/library.js#L10-L20`.

```javascript
import { createRoot } from '@wordpress/element';
import { registerPlugin } from '@wordpress/plugins';
import { MainButton } from '@library/components/MainButton';
import { Modal } from '@library/components/Modal';
import './library.css';

registerPlugin('extendify-library', {
	render: () => {
		if (typeof createRoot !== 'function') return;
		const id = 'extendify-library-btn';
		const className = 'extendify-library';
		const page = '.edit-post-header-toolbar';
		const fse = '.edit-site-header-edit-mode__start';
		if (!document.querySelector(page) && !document.querySelector(fse)) {
			return;
		}
		requestAnimationFrame(() => {
			if (document.getElementById(id)) return;
			const btnWrap = document.createElement('div');
			const btn = Object.assign(btnWrap, { id, className });
			document.querySelector(page)?.append(btn);
			document.querySelector(fse)?.append(btn);
			createRoot(btn).render(<MainButton />);

			const mdl = 'extendify-library-modal';
			if (document.getElementById(mdl)) return;
			const modalWrap = document.createElement('div');
			const modal = Object.assign(modalWrap, { id: mdl, className });
			document.body.append(modal);
			createRoot(modal).render(<Modal />);
		});
	},
});

```
