: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
window.wp.domReady(() => {
const el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
RawHTML = wp.element.RawHTML,
aaGut = window.advadsGutenberg,
textFlow = aaGut.textFlow,
safeHTML = wp.dom.safeHTML,
* could move to a separated file if we need it in other places, too
* <source> https://gist.github.com/zgordon/e837e29f77c343d29ebb7290a1a75eea
viewBox: '1.396 3276 24 24',
xmlns: 'http://www.w3.org/2000/svg',
d: 'M18.602,3286.2v8.53H6.677v-11.925h8.53c-0.355-0.804-0.545-1.684-0.545-2.625s0.205-1.82,0.545-2.625 h-2.57H1.406v18.266l0.6,0.6l-0.6-0.6c0,2.304,1.875,4.179,4.18,4.179l0,0h7.05h11.216v-13.821 c-0.805,0.355-1.705,0.566-2.645,0.566C20.286,3286.745,19.406,3286.541,18.602,3286.2z',
* Register the single ad block type
registerBlockType('advads/gblock', {
// todo: make the keywords translatable
keywords: ['advert', 'adsense', 'banner'],
const itemID = props.attributes.itemID;
* @param {Event} event change event on the select input.
itemID: event.target.querySelector('option:checked')
* @param {Event} event change event on the number input.
function setWidth(event) {
props.setAttributes({ width: event.target.value });
* @param {Event} event change event on the number input.
function setHeight(event) {
props.setAttributes({ height: event.target.value });
* Request hints related to the item.
* @param {string} ID Item ID.
function requestHints(ID) {
if (!ID || 0 !== ID.indexOf('group_')) {
const data = new FormData();
data.append('action', 'advads-get-block-hints');
data.append('nonce', window.advadsglobal.ajax_nonce);
data.append('itemID', itemID);
credentials: 'same-origin',
.then((response) => response.json())
// eslint-disable-next-line no-console -- Might help experienced users
function createSizeInputs(label, name, onchange) {
(Math.random() + 1).toString(36).substring(1);
{ className: 'size-group' },
el('span', { className: 'head' }, label)
{ className: 'size-input' },
value: props.attributes[name],
el('span', { className: 'suffix' }, 'px')
const [hints, setHints] = window.wp.element.useState([]);
window.wp.element.useEffect(() => {
// the form children elements
// argument list (in array form) for the children creation
value: props.attributes.itemID,
args.push(el('option', { key: 'empty' }, i18n['--empty--']));
for (const adID in aaGut.ads) {
if (typeof aaGut.ads[adID].id === 'undefined') {
value: 'ad_' + aaGut.ads[adID].id,
for (const GID in aaGut.groups) {
if ('undefined' === typeof aaGut.groups[GID].id) {
value: 'group_' + aaGut.groups[GID].id,
for (const pid in aaGut.placements) {
if ('undefined' === typeof aaGut.placements[pid].id) {
value: 'place_' + aaGut.placements[pid].id,
aaGut.placements[pid].name
args.push(el('optgroup', { label: i18n.ads, key: 'ads' }, ads));
// add a <label /> first and style it.
className: 'components-placeholder__label',
key: 'components-placeholder__label',
{ style: { display: 'block' } },
if (itemID && i18n['--empty--'] !== itemID) {
if (0 === itemID.indexOf('place_')) {
url = aaGut.editLinks.placement;
} else if (0 === itemID.indexOf('group_')) {
url = aaGut.editLinks.group;
} else if (0 === itemID.indexOf('ad_')) {
url = aaGut.editLinks.ad.replace(
className: 'components-placeholder__fieldset',
key: 'components-placeholder__fieldset',
// then add the <select /> input with its own children
className: 'dashicons dashicons-external',
hints.forEach(function (item, index) {
'advads-block-hint advads-notice-inline advads-error',
children.push(el.apply(null, args));
className: 'components-placeholder__label',
key: 'components-placeholder__label',
href: window.advadsglobal.create_ad_url,
window.advadsglobal.create_your_first_ad
{ id: 'advanced-ads-size-wrap' },
createSizeInputs(i18n.width, 'width', setWidth),
createSizeInputs(i18n.height, 'height', setHeight)
editor.InspectorControls,
{ key: 'advads-sidebar' },
const alignmentItems = [];
for (const slug in textFlow) {
const isSelected = props.attributes.align === slug;
label: textFlow[slug].label,
props.setAttributes({ align: slug }),
(isSelected ? ' current' : ''),
className: 'text-flow-icon',
src: `${aaGut.imagesUrl}${slug}.png`,
title: textFlow[slug].label,
src: `${aaGut.imagesUrl}${slug}-alt.png`,
title: textFlow[slug].label,
className: 'text-flow-label',
title: textFlow[slug].description,
el('span', {}, textFlow[slug].label)
el(comp.ToolbarDropdownMenu, {
icon: 'editor-alignleft',
label: 'Choose an alignment',
{ className: 'advads-align-dropdown' },
// return the complete form
className: 'components-placeholder is-large',