Commit bc64f262 authored by KR Moorhouse's avatar KR Moorhouse

Resolved merge conflicts.

parents b32c23d7 3b893311
This diff is collapsed.
......@@ -4,7 +4,7 @@
Tags: form, forms, contact form, custom form, form builder, form creator, form manager, form creation, contact forms, custom forms, forms builder, forms creator, forms manager, forms creation, form administration,
Requires at least: 4.7
Tested up to: 4.9
Stable tag: 3.2.27
Stable tag: 3.3.0
License: GPLv2 or later
With a simple drag and drop interface you can create contact forms, email subscription forms, order forms, payment forms, and any other type of form for your WordPress site.
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -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' );
} );
} );
});
/**
* Handles actions related to our toggle field.
* When we change the toggle, the setting value will be 'on' or ''.
* We need to change this to 1 or 0.
*
* @package Ninja Forms builder
* @subpackage Fields - Edit Field Drawer
* @copyright (c) 2015 WP Ninjas
* @since 3.0
*/
define( [], function() {
var controller = Marionette.Object.extend( {
initialize: function() {
// We don't want the RTE setting to re-render when the value changes.
nfRadio.channel( 'setting-type-button-toggle' ).reply( 'renderOnChange', function(){ return false; } );
// Respond to requests for field setting filtering.
nfRadio.channel( 'button-toggle' ).reply( 'before:updateSetting', this.updateSetting, this );
},
/**
* Return either 1 or 0, depending upon the toggle position.
*
* @since 3.0
* @param Object e event
* @param backbone.model fieldModel field model
* @param string name setting name
* @param backbone.model settingTypeModel field type model
* @return int 1 or 0
*/
updateSetting: function( e, fieldModel, name, settingTypeModel ) {
return e.target.value;
}
});
return controller;
} );
\ No newline at end of file
define( [], function() {
var controller = Marionette.Object.extend({
initialize: function () {
// Respond to requests for field setting filtering.
console.log( nfRadio.channel( 'radio' ) );
nfRadio.channel('radio').reply( 'before:updateSetting', this.updateSetting, this);
},
updateSetting: function( e, fieldModel, name, settingTypeModel ) {
console.log( 'test' );
}
});
return controller;
} );
\ No newline at end of file
......@@ -34,6 +34,8 @@ define(
'controllers/app/changeSettingDefault',
'controllers/app/fieldset',
'controllers/app/toggleSetting',
'controllers/app/buttonToggleSetting',
'controllers/app/radioSetting',
'controllers/app/itemControls',
'controllers/app/mergeTags',
'controllers/app/mergeTagBox',
......@@ -137,6 +139,8 @@ define(
ChangeSettingDefault,
Fieldset,
ToggleSetting,
ButtonToggleSetting,
RadioSetting,
ItemControls,
MergeTags,
MergeTagsBox,
......@@ -271,6 +275,8 @@ define(
new MainContentFieldsSortable();
new ChangeSettingDefault();
new ToggleSetting();
new ButtonToggleSetting();
new RadioSetting();
new DrawerSettingChildView();
new FieldsEditActive();
new FieldSettings();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -237,6 +237,33 @@
}
}
}
.button-toggle {
text-align: left;
border: #ccc 1px solid;
border-radius: 5px;
background: #f1f1f1;
margin-top: 35px;
padding: 9px 0px;
width: 100%;
label {
width: 48%;
display: inline-block;
margin-left: 1%;
span {
width: 100%;
display: inline-block;
cursor: pointer;
}
input:checked + span {
background-color: #1ea9ea;
border-color: #1ea9ea;
}
input + span {
background-color: #ccc;
border-color: #ccc;
}
}
}
}
.nf-drawer-buttons {
display: none;
......
......@@ -102,10 +102,13 @@ th {
flex-wrap: wrap;
& > div {
display: flex;
width: 50%;
}
.template {
display: grid;
width: 100%;
a {
color: #424242;
display: block;
......
......@@ -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() {
......
......@@ -265,7 +265,7 @@ class Ninja_Forms {
// Plugin version
if ( ! defined( 'NF_PLUGIN_VERSION' ) )
define( 'NF_PLUGIN_VERSION', '3.2.27' );
define( 'NF_PLUGIN_VERSION', '3.3.0' );
// Plugin Folder Path
if ( ! defined( 'NF_PLUGIN_DIR' ) )
......
......@@ -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
......
......@@ -24,7 +24,16 @@ abstract class NF_Abstracts_Migration
public function charset_collate()
{
global $wpdb;
return $wpdb->get_charset_collate();
// If our mysql version is 5.5.3 or higher...
if ( version_compare( $wpdb->db_version(), '5.5.3', '>=' ) ) {
// We can use mb4.
return 'DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci';
} // Otherwise...
else {
// We use standard utf8.
return 'DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci';
}
}
public function _run()
......
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class NF_Actions_DataRemoval
*/
final class NF_Actions_DeleteDataRequest extends NF_Abstracts_Action
{
/**
* @var string
*/
protected $_name = 'deletedatarequest';
/**
* @var array
*/
protected $_tags = array();
/**
* @var string
*/
protected $_timing = 'late';
/**
* @var int
*/
protected $_priority = 10;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->_nicename = __( 'Delete Data Request', 'ninja-forms' );
$settings = Ninja_Forms::config( 'ActionDeleteDataRequestSettings' );
$this->_settings = array_merge( $this->_settings, $settings );
}
/*
* PUBLIC METHODS
*/
public function save( $action_settings )
{
}
/**
* Creates a Erase Personal Data request for the user with the email
* provided
*
* @param $action_settings
* @param $form_id
* @param $data
*
* @return array
*/
public function process( $action_settings, $form_id, $data )
{
$data = array();
if( isset( $data['settings']['is_preview'] ) && $data['settings']['is_preview'] ){
return $data;
}
// get the email setting
$email = $action_settings[ 'email' ];
// create request for user
$request_id = wp_create_user_request( $email,
'remove_personal_data' );
/**
* Basically ignore if we get a user error as it will be one of two
* things.
*
* 1) The email in question is already in the erase data request queue