diff --git a/assets/js/src/form_editor/form_editor.js b/assets/js/src/form_editor/form_editor.js index 9733b70cbe..26335b0682 100644 --- a/assets/js/src/form_editor/form_editor.js +++ b/assets/js/src/form_editor/form_editor.js @@ -296,7 +296,7 @@ var WysijaForm = { var settings_elements = $('mailpoet_form_settings').getElements(); settings_elements.each(function(setting) { // skip lists - if(setting.name === 'lists') { + if(setting.name === 'segments') { return true; } else if(setting.name === 'on_success') { // if the input value is equal to the one stored in the settings @@ -402,7 +402,7 @@ var WysijaForm = { }); // hide list selection if a list widget has been dragged into the editor - $('mailpoet_settings_list_selection')[(($$('#' + WysijaForm.options.editor + ' [wysija_field="list"]').length > 0) === true) ? 'hide' : 'show'](); + $('mailpoet_settings_segment_selection')[(($$('#' + WysijaForm.options.editor + ' [wysija_field="segment"]').length > 0) === true) ? 'hide' : 'show'](); }, setBlockPositions: function(event, target) { // release dragging lock @@ -862,6 +862,18 @@ WysijaForm.Block.create = function(block, target) { template = Handlebars.compile($('form_template_' + block.type).innerHTML), output = ''; + if(block.type === 'segment') { + if(block.params.values === undefined) { + var settings_segments = jQuery('#mailpoet_form_segments').val(); + if(settings_segments.length > 0){ + mailpoet_segments.filter(function(segment) { + return (settings_segments.indexOf(segment.id) !== -1); + }); + block.params.values = mailpoet_segments; + } + } + } + // set block template (depending on the block type) block.template = template(block); output = block_template(block); @@ -873,13 +885,14 @@ WysijaForm.Block.create = function(block, target) { } // if the drop target was the bottom placeholder + var element = null; if(target.identify() === 'block_placeholder') { // insert block at the bottom - body.insert(output); + element = body.insert(output); //block = body.childElements().last(); } else { // insert block before the drop target - target.insert({ + element = target.insert({ before: output }); //block = target.previous('.mailpoet_form_block'); diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index d5ab576bf8..055fd454ed 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -67,7 +67,7 @@ class Migrator { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'name varchar(20) NOT NULL,', - 'value varchar(255) NOT NULL,', + 'value longtext,', 'created_at TIMESTAMP NOT NULL DEFAULT 0,', 'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,', 'PRIMARY KEY (id),', diff --git a/lib/Config/Widget.php b/lib/Config/Widget.php index bf3f191ac5..a9a2608641 100644 --- a/lib/Config/Widget.php +++ b/lib/Config/Widget.php @@ -13,7 +13,7 @@ class Widget { add_action('widgets_init', array($this, 'registerWidget')); if(!is_admin()) { - add_action('widgets_init', array($this, 'setupActions')); + //$this->setupActions(); add_action('widgets_init', array($this, 'setupDependencies')); } else { add_action('widgets_init', array($this, 'setupAdminDependencies')); @@ -85,9 +85,9 @@ class Widget { 'admin_post_mailpoet_form_subscribe', 'mailpoet_form_subscribe' ); - /*add_action( + add_action( 'init', 'mailpoet_form_subscribe' - );*/ + ); } -} +} \ No newline at end of file diff --git a/lib/Form/Block/Segment.php b/lib/Form/Block/Segment.php index c285a894d0..e5a1683d3f 100644 --- a/lib/Form/Block/Segment.php +++ b/lib/Form/Block/Segment.php @@ -22,8 +22,8 @@ class Segment extends Base { $html .= '