Skip to content

Commit

Permalink
Update 4.2.2
Browse files Browse the repository at this point in the history
Vari fix e update inserimento informativa privacy
  • Loading branch information
Alessandro Morloi Grazioli committed May 24, 2018
1 parent 8fc0e4a commit 298a6fd
Show file tree
Hide file tree
Showing 21 changed files with 1,095 additions and 953 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changelog
=========

#### 4.2.2 - May 22, 2018

**Fixes**

- Events Manager integration was not working with logged-in users.
- Form preview URL should respect admin HTTP(S) scheme.
- Removed use of PHP 5.4 function.

**Improvements**

- Add "agree to terms" checkbox to field helper.

**Additions**

- Add filter `nl4wp_http_request_args`.


#### 4.2.1 - April 11, 2018

**Fixes**
Expand Down
48 changes: 45 additions & 3 deletions assets/js/forms-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ var rows = function rows(m, i18n) {
return html;
};

r.linkToTerms = function (config) {
// label row
return m("div", [m("label", i18n.agreeToTermsLink), m("input.widefat", {
type: "text",
value: config.link,
onchange: m.withAttr('value', config.link),
placeholder: 'https://...'
})]);
};
return r;
};

Expand Down Expand Up @@ -197,6 +206,10 @@ var forms = function forms(m, i18n) {
return [rows.value(config), rows.useParagraphs(config)];
};

forms['terms-checkbox'] = function (config) {
return [rows.label(config), rows.linkToTerms(config), rows.isRequired(config), rows.useParagraphs(config)];
};

forms.number = function (config) {
return [forms.text(config), rows.numberMinMax(config)];
};
Expand Down Expand Up @@ -266,6 +279,23 @@ var g = function g(m) {
return m('select', attributes, options);
};

generators['terms-checkbox'] = function (config) {
var checkbox = [m('input', {
name: config.name(),
type: 'checkbox',
value: config.value(),
required: config.required()
}), ' ', config.label()];

var content = checkbox;

if (config.link().length > 0) {
content = m('a', { href: config.link(), target: "_blank" }, checkbox);
}

return m('label', content);
};

/**
* Generates a checkbox or radio type input field.
*
Expand Down Expand Up @@ -343,7 +373,7 @@ var g = function g(m) {
html = void 0,
vdom = document.createElement('div');

label = config.label().length > 0 ? m("label", {}, config.label()) : '';
label = config.label().length > 0 && config.showLabel() ? m("label", {}, config.label()) : '';
field = typeof generators[config.type()] === "function" ? generators[config.type()](config) : generators['default'](config);
htmlTemplate = config.wrap() ? m('p', [label, field]) : [label, field];

Expand Down Expand Up @@ -686,6 +716,16 @@ var FieldFactory = function FieldFactory(fields, i18n) {
value: 'subscribe',
help: i18n.formActionDescription
}, true);

register(category, {
name: '_nl4wp_agree_to_terms',
value: 1,
type: "terms-checkbox",
label: i18n.agreeToTerms,
title: i18n.agreeToTermsShort,
showLabel: false,
required: true
}, true);
}

/**
Expand Down Expand Up @@ -722,18 +762,20 @@ module.exports = function (m, events) {
this.title = prop(data.title || data.name);
this.type = prop(data.type);
this.newsletterType = prop(data.newsletterType || '');
this.label = prop(data.title || '');
this.label = prop(data.label || data.title || '');
this.showLabel = prop(data.showLabel !== undefined ? data.showLabel : true);
this.value = prop(data.value || '');
this.placeholder = prop(data.placeholder || '');
this.required = prop(data.required || false);
this.forceRequired = prop(data.forceRequired || false);
this.wrap = prop(data.wrap || true);
this.wrap = prop(data.wrap !== undefined ? data.wrap : true);
this.min = prop(data.min || null);
this.max = prop(data.max || null);
this.help = prop(data.help || '');
this.choices = prop(data.choices || []);
this.inFormContent = prop(null);
this.acceptsMultipleValues = data.acceptsMultipleValues;
this.link = prop(data.link || '');

this.selectChoice = function (value) {
var field = this;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/forms-admin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/forms-admin.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/api/class-api-v3-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private function request( $method, $resource, array $data = array() ) {
{
$status=$result['mail_disable']==0?'subscribed':'';
// gestione gruppi
$interests=split(',',$result['audiences']);
$interests=explode(',',$result['audiences']);
foreach ($interests as $value) $inter[$value]=1;
$data= (object) array('id' => $result['uid'], 'email_address' => $result['mail'], 'unique_email_id' => $result['uid'], 'status' => $status, 'interests' => (object) $inter);
}
Expand Down
26 changes: 26 additions & 0 deletions includes/class-newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public function list_subscribe( $list_id, $email_address, array $args = array(),
}

/**
* Changes the subscriber status to "unsubscribed"
*
* @param string $list_id
* @param string $email_address
Expand All @@ -126,6 +127,31 @@ public function list_unsubscribe( $list_id, $email_address ) {
return true;
}

/**
* Deletes the subscriber from the given list.
*
* @param string $list_id
* @param string $email_address
*
* @return boolean
*/
public function list_unsubscribe_delete( $list_id, $email_address ) {
$this->reset_error();

try {
$this->get_api()->delete_list_member( $list_id, $email_address );
} catch( NL4WP_API_Resource_Not_Found_Exception $e ) {
// if email wasn't even on the list: great.
return true;
} catch( NL4WP_API_Exception $e ) {
$this->error_code = $e->getCode();
$this->error_message = $e;
return false;
}

return true;
}

/**
* Checks if an email address is on a given list with status "subscribed"
*
Expand Down
34 changes: 22 additions & 12 deletions includes/forms/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function enqueue_assets( $suffix, $page = '' ) {
wp_enqueue_script( 'nl4wp-forms-admin');
wp_localize_script( 'nl4wp-forms-admin', 'nl4wp_forms_i18n', array(
'addToForm' => __( "Add to form", 'newsletter-for-wp' ),
'agreeToTerms' => __( "I have read and agree to the terms & conditions", 'newsletter-for-wp' ),
'agreeToTermsShort' => __( "Agree to terms", 'newsletter-for-wp' ),
'agreeToTermsLink' => __( 'Link to your terms & conditions page', 'newsletter-for-wp' ),
'city' => __( 'City', 'newsletter-for-wp' ),
'checkboxes' => __( 'Checkboxes', 'newsletter-for-wp' ),
'choices' => __( 'Choices', 'newsletter-for-wp' ),
Expand Down Expand Up @@ -314,18 +317,24 @@ public function redirect_to_form_action() {
return;
}

// query first available form and go there
$forms = nl4wp_get_forms( array( 'numberposts' => 1 ) );

if( $forms ) {
// if we have a post, go to the "edit form" screen
$form = array_pop( $forms );
$redirect_url = nl4wp_get_edit_form_url( $form->ID );
} else {
// we don't have a form yet, go to "add new" screen
$redirect_url = nl4wp_get_add_form_url();
try{
// try default form first
$default_form = nl4wp_get_form();
$redirect_url = nl4wp_get_edit_form_url( $default_form->ID );
} catch(Exception $e) {
// no default form, query first available form and go there
$forms = nl4wp_get_forms( array( 'numberposts' => 1 ) );

if( $forms ) {
// if we have a post, go to the "edit form" screen
$form = array_pop( $forms );
$redirect_url = nl4wp_get_edit_form_url( $form->ID );
} else {
// we don't have a form yet, go to "add new" screen
$redirect_url = nl4wp_get_add_form_url();
}
}

wp_redirect( $redirect_url );
exit;
}
Expand Down Expand Up @@ -371,9 +380,10 @@ public function show_edit_page() {
$opts = $form->settings;
$active_tab = ( isset( $_GET['tab'] ) ) ? $_GET['tab'] : 'fields';


$form_preview_url = add_query_arg( array(
'nl4wp_preview_form' => $form_id,
), get_option( 'home' ) );
), site_url( '/', 'admin' ) );

require dirname( __FILE__ ) . '/views/edit-form.php';
}
Expand Down
2 changes: 1 addition & 1 deletion includes/forms/class-form-previewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function load_preview() {
}

$form_id = (int) $_GET['nl4wp_preview_form'];
http_response_code(200);
status_header(200);
require dirname( __FILE__ ) . '/views/preview.php';
exit;
}
Expand Down
9 changes: 9 additions & 0 deletions integrations/events-manager/class-events-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public function subscribe_from_events_manager( $args ) {
}

$em_data = $this->get_data();

// logged-in users do not have these form fields, so grab from user object instead
if( empty( $em_data['user_email'] ) && is_user_logged_in() ) {
$user = wp_get_current_user();
$em_data['user_email'] = $user->user_email;
$em_data['user_name'] = sprintf("%s %s", $user->first_name, $user->last_name );
}

if( empty( $em_data['user_email'] ) ) {
return false;
}
Expand All @@ -69,4 +77,5 @@ public function is_installed() {
return defined( 'EM_VERSION' );
}


}
Binary file modified languages/newsletter-for-wp-it_IT.mo
100755 → 100644
Binary file not shown.
13 changes: 11 additions & 2 deletions languages/newsletter-for-wp-it_IT.po
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ msgid ""
msgstr ""
"Project-Id-Version: Newsletter for WordPress\n"
"POT-Creation-Date: 2018-04-16 18:02+0200\n"
"PO-Revision-Date: 2018-04-18 18:29+0200\n"
"PO-Revision-Date: 2018-05-24 15:48+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: it_IT\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"X-Generator: Poedit 2.0.7\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
Expand Down Expand Up @@ -1668,3 +1668,12 @@ msgstr "Usa Gravity Forms per iscrivere nuovi utenti."

msgid "Subscribes people from your AffiliateWP registration form."
msgstr "Usa AffiliateWP per iscrivere nuovi utenti."

msgid "I have read and agree to the terms & conditions"
msgstr "Ho letto e accettato l'informativa privacy"

msgid "Link to your terms & conditions page"
msgstr "Link alla pagina dell'informativa privacy"

msgid "Agree to terms"
msgstr "Informativa privacy"
Binary file modified languages/newsletter-for-wp-ja_JP.mo
Binary file not shown.
Loading

0 comments on commit 298a6fd

Please sign in to comment.