Commit a7d4e1b9 authored by Eric Windham's avatar Eric Windham Committed by GitHub

Merge pull request #3562 from wpninjas/gdpr-optin

Gdpr optin
parents 8695ebbe 455672a3
......@@ -178,4 +178,43 @@ jQuery(document).ready(function($) {
$( "#delete_on_uninstall" ).attr( 'checked', true );
} );
// If we're allowed to track site data...
if ( '1' == nf_settings.allow_telemetry ) {
// Show the optout button.
$( '#nfTelOptin' ).addClass( 'hidden' );
$( '#nfTelOptout' ).removeClass( 'hidden' );
} // Otherwise...
else {
// Show the optin button.
$( '#nfTelOptout' ).addClass( 'hidden' );
$( '#nfTelOptin' ).removeClass( 'hidden' );
}
// If optin is clicked...
$( '#nfTelOptin' ).click( function( e ) {
// Hide the button.
$( '#nfTelOptin' ).addClass( 'hidden' );
$( '#nfTelSpinner' ).css( 'display', 'inline-block' );
// Hit AJAX endpoint and opt-in.
$.post( ajaxurl, { action: 'nf_optin', ninja_forms_opt_in: 1 },
function( response ) {
$( '#nfTelOptout' ).removeClass( 'hidden' );
$( '#nfTelSpinner' ).css( 'display', 'none' );
} );
} );
// If optout is clicked...
$( '#nfTelOptout' ).click( function( e ) {
// Hide the button.
$( '#nfTelOptout' ).addClass( 'hidden' );
$( '#nfTelSpinner' ).css( 'display', 'inline-block' );
// Hit AJAX endpoint and opt-out.
$.post( ajaxurl, { action: 'nf_optin', ninja_forms_opt_in: 0 },
function( response ) {
$( '#nfTelOptin' ).removeClass( 'hidden' );
$( '#nfTelSpinner' ).css( 'display', 'none' );
} );
} );
});
This diff is collapsed.
This diff is collapsed.
......@@ -84,7 +84,6 @@ define( [ 'views/sections/widgets.js', 'views/sections/apps.js', 'views/sections
// If form telemetry is defined...
// AND if we should run it...
if ( 'undefined' !== typeof nfAdmin.formTelemetry && 1 == nfAdmin.formTelemetry ) {
console.log( 'got here' );
// Make our AJAX call.
var data = {
action: 'nf_form_telemetry',
......@@ -93,6 +92,137 @@ define( [ 'views/sections/widgets.js', 'views/sections/apps.js', 'views/sections
// Make our AJAX call.
jQuery.post( ajaxurl, data );
}
// If the user has not seen the opt-in modal yet...
if ( '1' == nfAdmin.showOptin ) {
// Declare all of our opt-in code here.
var optinModal = new jBox( 'Modal', {
closeOnEsc: false,
closeOnClick: false,
width: 400
} );
// Define the modal title.
var title = document.createElement( 'div' );
title.id = 'optin-modal-title';
var titleStyling = document.createElement( 'h2' );
titleStyling.innerHTML = 'Help make Ninja Forms better!';
title.appendChild( titleStyling );
// Define the modal content.
var content = document.createElement( 'div' );
content.classList.add( 'message' );
content.style.padding = '0px 20px 20px 20px';
content.innerHTML = nfi18n.optinContent;
var p = document.createElement( 'p' );
p.style.paddingBottom = '10px';
var checkBox = document.createElement( 'input' );
checkBox.id = 'optin-send-email';
checkBox.setAttribute( 'type', 'checkbox' );
checkBox.style.margin = '7px';
var label = document.createElement( 'label' );
label.setAttribute( 'for', 'optin-send-email' );
label.innerHTML = nfi18n.optinYesplease;
p.appendChild( checkBox );
p.appendChild( label );
content.appendChild( p );
p = document.createElement( 'p' );
p.id = 'optin-block';
p.style.padding = '0px 5px 20px 5px';
p.style.display = 'none';
var email = document.createElement( 'input' );
email.id = 'optin-email-address';
email.setAttribute( 'type', 'text' );
email.setAttribute( 'value', nfAdmin.currentUserEmail );
email.style.width = '100%';
email.style.fontSize = '16px';
p.appendChild( email );
content.appendChild( p );
var spinner = document.createElement( 'span' );
spinner.id = 'optin-spinner';
spinner.classList.add( 'spinner' );
spinner.style.display = 'none';
content.appendChild( spinner );
var actions = document.createElement( 'div' );
actions.id = 'optin-buttons';
actions.classList.add( 'buttons' );
var cancel = document.createElement( 'div' );
cancel.id = 'optout';
cancel.classList.add( 'nf-button', 'secondary' );
cancel.innerHTML = nfi18n.optinSecondary;
actions.appendChild( cancel );
var confirm = document.createElement( 'button' );
confirm.id = 'optin';
confirm.classList.add( 'nf-button', 'primary', 'pull-right' );
confirm.innerHTML = nfi18n.optinPrimary;
actions.appendChild( confirm );
content.appendChild( actions );
// Define the success title.
var successTitle = document.createElement( 'h2' );
successTitle.innerHTML = nfi18n.optinAwesome;
// Define the success content.
var successContent = document.createElement( 'div' );
successContent.id = 'optin-thankyou';
successContent.classList.add( 'message' );
successContent.style.padding = '20px';
successContent.innerHTML = nfi18n.optinThanks;
// Set the options for the modal and open it.
optinModal.setContent( document.createElement( 'div' ).appendChild( content ).innerHTML );
optinModal.setTitle( document.createElement( 'div' ).appendChild( title ).innerHTML );
optinModal.open();
// Show/Hide email field, based on the opt-in checkbox.
jQuery( '#optin-send-email' ).click( function( e ) {
if( jQuery( this ).is( ':checked' ) ) {
jQuery( '#optin-block' ).show();
} else {
jQuery( '#optin-block' ).hide();
}
} );
// Setup the optin click event.
jQuery( '#optin' ).click( function( e ) {
var sendEmail;
if ( jQuery( '#optin-send-email' ).attr( 'checked' ) ) {
sendEmail = 1;
userEmail = jQuery( '#optin-email-address' ).val();
} else {
sendEmail = 0;
userEmail = '';
}
// Show spinner
jQuery( '#optin-spinner' ).css( 'visibility', 'visible' );
jQuery( '#optin-spinner' ).css( 'display', 'inline-block' );
jQuery( '#optin-buttons' ).css( 'visibility', 'hidden' );
// Hit AJAX endpoint and opt-in.
jQuery.post( ajaxurl, { action: 'nf_optin', ninja_forms_opt_in: 1, send_email: sendEmail, user_email: userEmail },
function( response ) {
jQuery( '#optin-spinner' ).css( 'visibility', 'hidden' );
jQuery( '#optin-spinner' ).css( 'display', 'none' );
optinModal.setTitle( document.createElement( 'div' ).appendChild( successTitle ).innerHTML );
optinModal.setContent( document.createElement( 'div' ).appendChild( successContent ).innerHTML );
/**
* When we get a response from our endpoint, show a thank you and set a timeout
* to close the modal.
*/
setTimeout (
function(){
optinModal.close();
},
2000
);
} );
} );
// Setup the optout click event.
jQuery( '#optout' ).click( function( e ) {
// Show spinner
jQuery( '#optin-spinner' ).css( 'visibility', 'visible' );
jQuery( '#optin-buttons' ).css( 'visibility', 'hidden' );
// Hit AJAX endpoint and opt-in.
jQuery.post( ajaxurl, { action: 'nf_optin', ninja_forms_opt_in: 0 }, function( response ) {
jQuery( '#optin-spinner' ).css( 'visibility', 'hidden' );
// When we get a response from our endpoint, close the modal.
optinModal.close();
} );
} );
}
},
templateContext: function() {
......
......@@ -61,8 +61,6 @@ class NF_THREE_Submenu
add_action( 'admin_menu', array( $this, 'register' ), $this->priority );
add_action( 'wp_ajax_ninja_forms_upgrade_check', array( $this, 'upgrade_check' ) );
add_action( 'wp_ajax_ninja_forms_optin', array( $this, 'optin' ) );
add_action( 'wp_ajax_ninja_forms_optout', array( $this, 'optout' ) );
add_filter( 'nf_general_settings_advanced', array( $this, 'settings_upgrade_button' ) );
}
......@@ -176,151 +174,6 @@ class NF_THREE_Submenu
{
include plugin_dir_path( __FILE__ ) . 'tmpl-settings-upgrade-button.html.php';
}
public function optin() {
if ( ! current_user_can( 'manage_options' ) ) return false;
$api_url = 'http://api.ninjaforms.com/';
/**
* Update our tracking option.
*/
update_option( 'ninja_forms_allow_tracking', true );
update_option( 'ninja_forms_do_not_allow_tracking', false );
/**
* Gather site data before we send.
*
* We send the following site data with our passed data:
* IP Address
* Email
* Site Url
*/
$ip_address = '';
if ( array_key_exists( 'SERVER_ADDR', $_SERVER ) ) {
$ip_address = $_SERVER[ 'SERVER_ADDR' ];
} else if ( array_key_exists( 'LOCAL_ADDR', $_SERVER ) ) {
$ip_address = $_SERVER[ 'LOCAL_ADDR' ];
}
/**
* Email address of the current user, defaulting to admin email if they do not have one.
*/
$current_user = wp_get_current_user();
if ( ! empty ( $current_user->user_email ) ) {
$email = $current_user->user_email;
} else {
$email = get_option( 'admin_email' );
}
$site_data = array(
'url' => site_url(),
'ip_address' => $ip_address,
'email' => $email,
);
/**
* Send our environment variables.
*/
global $wpdb;
// Plugins
$active_plugins = (array) get_option( 'active_plugins', array() );
//WP_DEBUG
if ( defined('WP_DEBUG') && WP_DEBUG ){
$debug = 1;
} else {
$debug = 0;
}
//WPLANG
if ( defined( 'WPLANG' ) && WPLANG ) {
$lang = WPLANG;
} else {
$lang = 'default';
}
$ip_address = '';
if ( array_key_exists( 'SERVER_ADDR', $_SERVER ) ) {
$ip_address = $_SERVER[ 'SERVER_ADDR' ];
} else if ( array_key_exists( 'LOCAL_ADDR', $_SERVER ) ) {
$ip_address = $_SERVER[ 'LOCAL_ADDR' ];
}
$host_name = gethostbyaddr( $ip_address );
if ( is_multisite() ) {
$multisite_enabled = 1;
} else {
$multisite_enabled = 0;
}
$tls = 'unknown';
$environment = array(
'nf_version' => NF_PLUGIN_VERSION,
'wp_version' => get_bloginfo('version'),
'multisite_enabled' => $multisite_enabled,
'server_type' => $_SERVER['SERVER_SOFTWARE'],
'tls_version' => $tls,
'php_version' => phpversion(),
'mysql_version' => $wpdb->db_version(),
'wp_memory_limit' => WP_MEMORY_LIMIT,
'wp_debug_mode' => $debug,
'wp_lang' => $lang,
'wp_max_upload_size' => size_format( wp_max_upload_size() ),
'php_max_post_size' => ini_get( 'post_max_size' ),
'hostname' => $host_name,
'smtp' => ini_get('SMTP'),
'smtp_port' => ini_get('smtp_port'),
'active_plugins' => $active_plugins,
);
/*
* Send our data using wp_remote_post.
*/
$response = wp_remote_post(
$api_url,
array(
'body' => array(
'slug' => 'update_environment_vars',
'data' => wp_json_encode( $environment ),
'site_data' => wp_json_encode( $site_data ),
),
)
);
$send_email = absint( $_REQUEST[ 'send_email' ] );
/*
* Send our opt-in event using wp_remote_post.
*/
$response = wp_remote_post(
$api_url,
array(
'body' => array(
'slug' => 'optin',
'data' => wp_json_encode( array( 'send_email' => $send_email ) ),
'site_data' => wp_json_encode( $site_data ),
),
)
);
die();
}
public function optout() {
if ( ! current_user_can( 'manage_options' ) ) return false;
/**
* Update our tracking option
*/
update_option( 'ninja_forms_do_not_allow_tracking', true );
die();
}
}
new NF_THREE_Submenu();
......@@ -157,6 +157,7 @@
</div>
<!--
<div id="optin-modal" style="display:none;">
<h2>Help make Ninja Forms better!</h2>
<p>
......@@ -170,7 +171,4 @@
<span id="optin-spinner" class="spinner"></span>
<button id="optin" class="button-primary" style="margin-bottom: 10px; font-size: 16px;">Yes, I want to make Ninja Forms better!</button> <button id="optout" class="button-secondary" style="margin-bottom: 10px;">No, please don't collect errors or other data.</button>
</div>
<div id="optin-thankyou" style="display:none;">
Thank you for opting in!
</div>
\ No newline at end of file
-->
\ No newline at end of file
jQuery(document).ready(function($) {
/**
* Show an opt-in modal if the user isn't currently opted in.
*/
if ( 0 == nfThreeUpgrade.optedIn ) {
var optinModal = new jBox( 'Modal', {
content: jQuery( '#optin-modal' ),
closeOnEsc: false,
closeOnClick: false
} );
optinModal.open();
jQuery( '#optin' ).click( function( e ) {
var sendEmail;
if ( jQuery( '#optin-send-email' ).attr( 'checked' ) ) {
sendEmail = 1;
} else {
sendEmail = 0;
}
// Show spinner
jQuery( '#optin-spinner' ).css( 'visibility', 'visible' );
// Hit AJAX endpoint and opt-in.
jQuery.post( ajaxurl, { action: 'ninja_forms_optin', send_email: sendEmail }, function( response ) {
jQuery( '#optin-spinner' ).css( 'visibility', 'hidden' );
optinModal.setContent( jQuery( '#optin-thankyou' ) );
/**
* When we get a response from our endpoint, show a thank you and set a timeout
* to close the modal.
*/
setTimeout (
function(){
optinModal.close();
},
2000
);
} );
} );
jQuery( '#optout' ).click( function( e ) {
// Show spinner
jQuery( '#optin-spinner' ).attr( 'visibility', 'visible' );
// Hit AJAX endpoint and opt-in.
jQuery.post( ajaxurl, { action: 'ninja_forms_optout' }, function( response ) {
jQuery( '#optin-spinner' ).attr( 'visibility', 'hidden' );
// When we get a response from our endpoint, close the modal.
optinModal.close();
} );
} );
}
/*
|--------------------------------------------------------------------------
| Ninja Forms THREE Upgrade App
......
......@@ -127,10 +127,14 @@ final class NF_Admin_Menus_Forms extends NF_Abstracts_Menu
wp_enqueue_script( 'nf-moment', Ninja_Forms::$url . 'assets/js/lib/moment-with-locales.min.js', array( 'jquery', 'nf-dashboard' ) );
wp_enqueue_script( 'nf-dashboard', Ninja_Forms::$url . 'assets/js/min/dashboard.min.js', array( 'backbone-radio', 'backbone-marionette-3' ) );
$current_user = wp_get_current_user();
wp_localize_script( 'nf-dashboard', 'nfi18n', Ninja_Forms::config( 'i18nDashboard' ) );
wp_localize_script( 'nf-dashboard', 'nfAdmin', array(
'ajaxNonce' => wp_create_nonce( 'ninja_forms_dashboard_nonce' ),
'formTelemetry' => ( get_option( 'nf_form_tel_sent' ) ) ? 0 : 1
'formTelemetry' => ( get_option( 'nf_form_tel_sent' ) ) ? 0 : 1,
'showOptin' => ( get_option( 'ninja_forms_do_not_allow_tracking' ) ||
get_option( 'ninja_forms_allow_tracking' ) ) ? 0 : 1,
'currentUserEmail' => $current_user->user_email
) );
wp_enqueue_style( 'nf-builder', Ninja_Forms::$url . 'assets/css/builder.css' );
......
......@@ -143,11 +143,18 @@ final class NF_Admin_Menus_Settings extends NF_Abstracts_Submenu
}
$form_options = apply_filters( 'ninja_forms_submission_filter_form_options', $form_options );
asort($form_options);
if ( get_option( 'ninja_forms_allow_tracking' ) && '1' == get_option( 'ninja_forms_allow_tracking' ) ) {
$allow_tel = 1;
} else {
$allow_tel = 0;
}
wp_enqueue_script( 'jBox', Ninja_Forms::$url . 'assets/js/lib/jBox.min.js', array( 'jquery' ) );
wp_enqueue_style( 'nf-combobox', Ninja_Forms::$url . 'assets/css/combobox.css' );
wp_enqueue_style( 'jBox', Ninja_Forms::$url . 'assets/css/jBox.css' );
wp_enqueue_style( 'nf-dashboard', Ninja_Forms::$url . 'assets/css/dashboard.min.css' );
wp_register_script( 'ninja_forms_admin_menu_settings', Ninja_Forms::$url . 'assets/js/admin-settings.js', array( 'jquery' ), FALSE, TRUE );
wp_localize_script( 'ninja_forms_admin_menu_settings', 'nf_settings', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
......@@ -156,7 +163,8 @@ final class NF_Admin_Menus_Settings extends NF_Abstracts_Submenu
'nonce' => wp_create_nonce( "ninja_forms_settings_nonce" ),
'i18n' => array(
'rollbackConfirm' => __( 'Are you sure you want to rollback?', 'ninja-forms' )
)
),
'allow_telemetry' => $allow_tel
));
......
......@@ -50,11 +50,19 @@ return apply_filters( 'ninja_forms_plugin_settings_advanced', array(
'allow_tracking' => array(
'id' => 'allow_tracking',
'type' => 'checkbox',
'label' => __( 'Allow Tracking', 'ninja-forms' ),
'desc' => __( 'If you opt-in, some data about your installation of Ninja Forms will be sent to NinjaForms.com (this does NOT include your submissions).', 'ninja-forms' )
'type' => 'html',
'html' => '<span id="nfTelOptin" class="button hidden">' . __( 'Opt-in', 'ninja-forms' ) . '</span><span id="nfTelOptout" class="button hidden">' . __( 'Opt-out', 'ninja-forms' ) . '</span><span id="nfTelSpinner" class="nf-loading-spinner" style="display:none;"></span>',
'label' => __( 'Allow Telemetry', 'ninja-forms' ),
'desc' => __( 'Opt-in to allow Ninja Forms to collect anonymous usage statistics from your site, such as PHP version, installed plugins, and other non-personally idetifiable informations.', 'ninja-forms' ),
),
// 'allow_tracking' => array(
// 'id' => 'allow_tracking',
// 'type' => 'checkbox',
// 'label' => __( 'Allow Tracking', 'ninja-forms' ),
// 'desc' => __( 'If you opt-in, some data about your installation of Ninja Forms will be sent to NinjaForms.com (this does NOT include your submissions).', 'ninja-forms' )
// ),
/*
|--------------------------------------------------------------------------
| Opinionated Styles
......
......@@ -68,6 +68,12 @@ return apply_filters( 'ninja_forms_i18n_dashboard', array(
'cancel' => __( 'Cancel', 'ninja-forms' ),
'deleteTitle' => __( 'Confirm Delete', 'ninja-forms' ),
'deleteXForm' => __( 'Export Form', 'ninja-forms' ),
'deleteXSubs' => __( 'Export Submissions', 'ninja-forms' )
'deleteXSubs' => __( 'Export Submissions', 'ninja-forms' ),
'optinContent' => sprintf( __( '%sWe would like to collect data about how Ninja Forms is used so that we can improve the experience for everyone. This data will not include ANY submission data or personally identifiable information.%sPlease check out our %sprivacy policy%s for additional clarification.%s', 'ninja-forms' ), '<p>', '</p><p>', '<a href="https://ninjaforms.com/privacy-policy/" target="_blank">', '</a>', '</p>' ),
'optinYesplease' => __( 'Yes, please send me occasional emails about Ninja Forms.', 'ninja-forms' ),
'optinSecondary' => __( 'Not Now', 'ninja-forms' ),
'optinPrimary' => __( 'Yes, I agree!', 'ninja-forms' ),
'optinAwesome' => __( 'Keep being awesome!', 'ninja-forms' ),
'optinThanks' => __( 'Thank you for opting in!', 'ninja-forms' )
));
......@@ -201,14 +201,10 @@ final class NF_Dispatcher
}
/**
* Email address of the current user, defaulting to admin email if they do not have one.
* Email address of the current user.
* (if one was provided)
*/
$current_user = wp_get_current_user();
if ( ! empty ( $current_user->user_email ) ) {
$email = $current_user->user_email;
} else {
$email = get_option( 'admin_email' );
}
$email = isset( $data[ 'user_email' ] ) ? $data[ 'user_email' ] : '';
$site_data = array(
'url' => site_url(),
......
......@@ -26,15 +26,11 @@ final class NF_Tracking
*/
public function __construct()
{
if( isset( $_GET[ self::FLAG ] ) ){
add_action( 'admin_init', array( $this, 'maybe_opt_in' ) );
}
// Temporary: Report previously opted-in users that were not already reported. @todo Remove after a couple of versions.
add_action( 'admin_init', array( $this, 'report_optin' ) );
add_filter( 'nf_admin_notices', array( $this, 'admin_notice' ) );
// add_action( 'admin_init', array( $this, 'report_optin' ) );
add_action( 'wp_ajax_nf_optin', array( $this, 'maybe_opt_in' ) );
add_filter( 'ninja_forms_check_setting_allow_tracking', array( $this, 'check_setting' ) );
add_filter( 'ninja_forms_update_setting_allow_tracking', array( $this, 'update_setting' ) );
}
......@@ -49,7 +45,7 @@ final class NF_Tracking
{
if( $this->can_opt_in() ) {
$opt_in_action = htmlspecialchars( $_GET[ self::FLAG ] );
$opt_in_action = htmlspecialchars( $_POST[ self::FLAG ] );
if( self::OPT_IN == $opt_in_action ){
$this->opt_in();
......@@ -59,7 +55,7 @@ final class NF_Tracking
$this->opt_out();
}
}
header( 'Location: ' . admin_url( 'admin.php?page=ninja-forms' ) );
die( 1 );
}
/**
......@@ -73,7 +69,8 @@ final class NF_Tracking
if( get_option( 'ninja_forms_optin_reported', 0 ) ) return;
$data = wp_parse_args( $data, array(
'send_email' => 1 // "Send Email" by default, if not specified (legacy).
'send_email' => 0, // Do not send email by default.
'user_email' => ''
) );
Ninja_Forms()->dispatcher()->send( 'optin', $data );
......@@ -83,61 +80,6 @@ final class NF_Tracking
update_option( 'ninja_forms_optin_reported', 1 );
}
/**
* Register the Admin Notice for asking users to opt in to tracking
*
* @access public
* @hook nf_admin_notices
* @param array $notices
* @return array $notices
*/
public function admin_notice( $notices )
{
// Check if the user is allowed to opt in.
if( ! $this->can_opt_in() ) return $notices;
// Check if the user is already opted in/out.
if( $this->is_opted_in() || $this->is_opted_out() ) return $notices;
$notices[ 'allow_tracking' ] = array(
'title' => __( 'Please help us improve Ninja Forms!', 'ninja-forms' ),
'msg' => '
If you agree, we will collect some server data and information about how you use Ninja Forms.
<em>No submission data will be collected.</em>
This data will help us troubleshoot errors and improve your Ninja Forms experience.
<p>
<input id="nf-optin-send-email" type="checkbox" checked="checked"> You can also occasionally send me an email about using Ninja Forms.
</p>',
'link' => implode( ' ', array(
sprintf( __( '%sYes, I want to make Ninja Forms better!%s', 'ninja-forms' ), '<a href="' . $this->get_opt_in_url( admin_url( 'admin.php?page=ninja-forms' ) ) . '" class="button-primary" id="ninja-forms-improve">', '</a>' ),
sprintf( __( '%sNo, please don\'t collect errors or other data.%s', 'ninja-forms' ), '<a href="' . $this->get_opt_out_url( admin_url( 'admin.php?page=ninja-forms' ) ) . '" class="button-secondary" id="ninja-forms-do-not-improve">', '</a>' ),
)),
'int' => 0, // No delay
'blacklist' => array(
'ninja-forms-three'
)
);
echo "<script type='text/javascript'>
jQuery( document ).ready( function( $ ) {
jQuery( '#ninja-forms-improve' ).click( function( e ) {
e.preventDefault();
var send_email, url;
if ( jQuery( '#nf-optin-send-email' ).attr( 'checked' ) ) {
send_email = 1;
} else {
send_email = 0;
}
url = jQuery( e.target ).attr( 'href' );
window.location.href = url + '&send_email=' + send_email;
} );
} );
</script>";
return $notices;
}
/**
* Check if the current user is allowed to opt in on behalf of a site
*
......@@ -195,23 +137,14 @@ final class NF_Tracking
*/
if ( isset ( $_REQUEST[ 'send_email' ] ) ) {
$send_email = absint( $_REQUEST[ 'send_email' ] );
$user_email = $_REQUEST[ 'user_email' ];
add_option( 'ninja_forms_optin_email', $user_email, '', 'no' );
} else {
$send_email = 1;
$send_email = 0;
$user_email = '';
}
$this->report_optin( array( 'send_email' => $send_email ) );
}
/**
* Get the Opt In URL
*
* @access private
* @param string $url
* @return string $url
*/
private function get_opt_in_url( $url )
{
return add_query_arg( 'ninja_forms_opt_in', self::OPT_IN, $url );
$this->report_optin( array( 'send_email' => $send_email, 'user_email' => $user_email ) );
}
/**
......@@ -244,6 +177,14 @@ final class NF_Tracking
private function opt_out()
{
if( $this->is_opted_out() ) return;
$data = array();
$user_email = get_option( 'ninja_forms_optin_email' );
if ( $user_email ) {
$data[ 'user_email' ] = $user_email;
}
Ninja_Forms()->dispatcher()->send( 'optout', $data );
delete_option( 'ninja_forms_optin_email' );
// Disable tracking.
update_option( 'ninja_forms_allow_tracking', false );
......@@ -253,18 +194,6 @@ final class NF_Tracking
update_option( 'ninja_forms_optin_reported', 0 );
}
/**
* Get the Opt Out URL
*
* @access private
* @param string $url
* @return string $url
*/
private function get_opt_out_url( $url )
{
return add_query_arg( 'ninja_forms_opt_in', self::OPT_OUT, $url );
}
public function check_setting( $setting )
{
if( $this->is_opted_in() && ! $this->is_opted_out() ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment