: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
add: function( editor, cookie ) {
var $editor = $( editor ),
cookie.index !== null && cookie.index >= 0
'table.list-table tbody tr'
name: $editor.data( 'field_name' ),
settings: cookie.settings || {},
$row = $editor.find( 'tbody tr' ).eq( data.index ),
$new_row = PUM_Admin.templates.render(
$row.replaceWith( $new_row );
$editor.find( 'tbody' ).append( $new_row );
$editor.addClass( 'has-list-items' );
cookies.refreshDescriptions();
* Remove a cookie editor table row.
remove: function( $cookie ) {
var $editor = $cookie.parents( '.pum-popup-cookie-editor' );
$editor.find( 'table.list-table tbody tr' ).length === 0
$editor.removeClass( 'has-list-items' );
* Renumber all rows for all editors.
'.pum-popup-cookie-editor table.list-table tbody tr'
.attr( 'data-index', index )
$this.find( ':input, [name]' ).each( function() {
if ( this.name && this.name !== '' ) {
this.name = this.name.replace(
window.PUM_Admin = window.PUM_Admin || {};
window.PUM_Admin.cookies = cookies;
.on( 'pum_init', function() {
cookies.refreshDescriptions();
'select2:select pumselect2:select',
$editor = $this.parents( '.pum-popup-cookie-editor' ),
indes: $editor.find( 'table.list-table tbody tr' )
name: 'pum-' + $( '#post_ID' ).val(),
$this.val( null ).trigger( 'change' );
cookies.template.form( event, values, function( e ) {
event = $form.find( 'input#event' ).val(),
index = $form.find( 'input#index' ).val(),
values = $form.pumSerializeObject();
if ( ! index || index < 0 ) {
index = $editor.find( 'tbody tr' ).length;
cookies.rows.add( $editor, {
settings: values.cookie_settings,
PUM_Admin.modals.closeAll();
.on( 'click', '.pum-popup-cookie-editor .pum-add-new', function() {
current_editor = $( this ).parents( '.pum-popup-cookie-editor' );
var template = wp.template( 'pum-cookie-add-event' );
'#pum_cookie_add_event_modal',
template( { I10n: I10n } )
.on( 'click', '.pum-popup-cookie-editor .edit', function( e ) {
$editor = $this.parents( '.pum-popup-cookie-editor' ),
$row = $this.parents( 'tr:first' ),
event = $row.find( '.popup_cookies_field_event' ).val(),
$row.find( '.popup_cookies_field_settings:first' ).val()
cookies.template.form( event, values, function( e ) {
event = $form.find( 'input#event' ).val(),
index = $form.find( 'input#index' ).val(),
values = $form.pumSerializeObject();
if ( index === false || index < 0 ) {
index = $editor.find( 'tbody tr' ).length;
cookies.rows.add( $editor, {
settings: values.cookie_settings,
PUM_Admin.modals.closeAll();
.on( 'click', '.pum-popup-cookie-editor .remove', function( e ) {
$row = $this.parents( 'tr:first' );
if ( window.confirm( I10n.confirm_delete_cookie ) ) {
cookies.rows.remove( $row );
.on( 'click', '.pum-field-cookie_key button.reset', function( e ) {
newKey = new Date().getTime().toString( 16 );
$this.siblings( 'input[type="text"]:first' ).val( newKey );
.on( 'submit', '#pum_cookie_add_event_modal .pum-form', function( e ) {
var $editor = current_editor,
event = $( '#popup_cookie_add_event' ).val(),
index: $editor.find( 'table.list-table tbody tr' ).length,
name: 'pum-' + $( '#post_ID' ).val(),
cookies.template.form( event, values, function( e ) {
event = $form.find( 'input#event' ).val(),
index = $form.find( 'input#index' ).val(),
values = $form.pumSerializeObject();
if ( index === false || index < 0 ) {
index = $editor.find( 'tbody tr' ).length;
cookies.rows.add( $editor, {
settings: values.cookie_settings,
PUM_Admin.modals.closeAll();
typeof PUM_Admin.triggers !== 'undefined' &&
PUM_Admin.triggers.new_cookie !== false &&
PUM_Admin.triggers.new_cookie >= 0
var $trigger = PUM_Admin.triggers.current_editor
.eq( PUM_Admin.triggers.new_cookie )
.find( '.popup_triggers_field_settings:first' ),
trigger_settings = JSON.parse( $trigger.val() );
if ( typeof trigger_settings.cookie_name === 'string' ) {
trigger_settings.cookie_name = trigger_settings.cookie_name.replace(
values.cookie_settings.name
trigger_settings.cookie_name[
trigger_settings.cookie_name.indexOf( 'add_new' )
] = values.cookie_settings.name;
trigger_settings.cookie_name = trigger_settings.cookie_name.filter(
function( element, index, array ) {
: ( this[ element ] = true );
$trigger.val( JSON.stringify( trigger_settings ) );
PUM_Admin.triggers.new_cookie = false;
PUM_Admin.triggers.refreshDescriptions();
( function( $, document, undefined ) {
var I10n = pum_admin_vars.I10n;
get_triggers: function() {
return window.pum_popup_settings_editor.triggers;
get_trigger: function( type ) {
var triggers = this.get_triggers(),
triggers[ type ] !== 'undefined' ? triggers[ type ] : false;
typeof trigger === 'object' &&
typeof trigger.fields === 'object' &&
Object.keys( trigger.fields ).length
trigger = this.parseFields( trigger );
parseFields: function( trigger ) {
_.each( trigger.fields, function( fields, tabID ) {
_.each( fields, function( field, fieldID ) {
trigger.fields[ tabID ][ fieldID ].name =
'trigger_settings[' + fieldID + ']';
if ( trigger.fields[ tabID ][ fieldID ].id === '' ) {
trigger.fields[ tabID ][ fieldID ].id =
'trigger_settings_' + fieldID;
parseValues: function( values, type ) {
for ( var key in values ) {
if ( ! values.hasOwnProperty( key ) ) {
// Clean measurement fields.
if ( values.hasOwnProperty( key + '_unit' ) ) {
values[ key ] += values[ key + '_unit' ];
delete values[ key + '_unit' ];
select_list: function() {
_triggers = PUM_Admin.utils.object_to_array(
for ( i = 0; i < _triggers.length; i++ ) {
options[ _triggers[ i ].id ] = _triggers[ i ].name;
add: function( editor, trigger ) {
var $editor = $( editor ),
trigger.index !== null && trigger.index >= 0
: $editor.find( 'table.list-table tbody tr' )
name: $editor.data( 'field_name' ),
settings: trigger.settings || {},
$row = $editor.find( 'tbody tr' ).eq( data.index ),
$new_row = PUM_Admin.templates.render(
$row.replaceWith( $new_row );
$editor.find( 'tbody' ).append( $new_row );
$editor.addClass( 'has-list-items' );
triggers.refreshDescriptions();
remove: function( $trigger ) {
var $editor = $trigger.parents( '.pum-popup-trigger-editor' );
$editor.find( 'table.list-table tbody tr' ).length === 0
$editor.removeClass( 'has-list-items' );
$( '#pum-first-trigger' )
form: function( type, values, callback ) {
var trigger = triggers.get_trigger( type ),
modalID = 'pum_trigger_settings',
firstTab = Object.keys( trigger.fields )[ 0 ],
$cookies = $( '.pum-field-cookies .list-table tbody tr' );
values.index = values.index >= 0 ? values.index : null;
// Add hidden index & type fields.
trigger.fields[ firstTab ] = $.extend(
trigger.fields[ firstTab ],
$cookies.each( function() {
var settings = JSON.parse(
.find( '.popup_cookies_field_settings:first' )
typeof trigger.fields[ firstTab ].cookie_name.options[
trigger.fields[ firstTab ].cookie_name.options[
PUM_Admin.templates.modal( {
title: trigger.modal_title || trigger.name,
classes: 'tabbed-content',
values.index !== null ? I10n.update : I10n.add,
content: PUM_Admin.forms.render(
id: 'pum_trigger_settings_form',
tabs: trigger.tabs || {},
fields: trigger.fields || {},
$( '#' + modalID + ' form' ).on(
PUM_Admin.modals.closeAll();
editor: function( args ) {
data.triggers = PUM_Admin.utils.object_to_array(
return PUM_Admin.templates.render( 'pum-trigger-editor', data );
return PUM_Admin.templates.render( 'pum-trigger-row', data );
selectbox: function( args ) {