Commit 7dc0e660 authored by Kevin Stover's avatar Kevin Stover

Merge branch 'release/v2.8.6'

parents 8e0453ed eb17b262
......@@ -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: 3.8
Tested up to: 4.0
Stable tag: 2.8.5
Stable tag: 2.8.6
License: GPLv2 or later
Forms created with a simple drag and drop interface. Contact forms, Email collection forms, or any other form you want on your WordPress site.
......
......@@ -14,7 +14,7 @@ jQuery(document).ready(function($) {
var n_id = $( this ).data( 'n_id' );
console.log( n_id );
if(answer){
$.post( ajaxurl, { n_id: n_id, action: 'nf_delete_notification' }, function( response ) {
$.post( ajaxurl, { n_id: n_id, action: 'nf_delete_notification', nf_ajax_nonce:ninja_forms_settings.nf_ajax_nonce }, function( response ) {
$( tr ).css( 'background-color', '#FF0000' ).fadeOut( 'slow', function() {
$(this).remove();
} );
......@@ -28,7 +28,7 @@ jQuery(document).ready(function($) {
var activate_action = $( this ).data( 'action' );
var n_id = $( this ).data( 'n_id' );
var that = this;
$.post( ajaxurl, { n_id: n_id, activate_action: activate_action, action: 'nf_' + activate_action + '_notification' }, function( response ) {
$.post( ajaxurl, { n_id: n_id, activate_action: activate_action, action: 'nf_' + activate_action + '_notification', nf_ajax_nonce:ninja_forms_settings.nf_ajax_nonce }, function( response ) {
$( tr ).removeClass( 'nf-notification-active' );
$( tr ).removeClass( 'nf-notification-inactive' );
......
jQuery(document).ready(function(e){e("#settings-type").change(function(){var t=this.value;e(".notification-type").hide();e("#notification-"+t).show()});e(document).on("click",".notification-delete",function(t){t.preventDefault();var n=confirm(commonL10n.warnDelete);var r=e(this).parent().parent().parent().parent();var i=e(this).data("n_id");console.log(i);if(n){e.post(ajaxurl,{n_id:i,action:"nf_delete_notification"},function(t){e(r).css("background-color","#FF0000").fadeOut("slow",function(){e(this).remove()})})}});e(document).on("click",".notification-activate",function(t){t.preventDefault();var n=e(this).parent().parent().parent().parent();var r=e(this).data("action");var i=e(this).data("n_id");var s=this;e.post(ajaxurl,{n_id:i,activate_action:r,action:"nf_"+r+"_notification"},function(t){e(n).removeClass("nf-notification-active");e(n).removeClass("nf-notification-inactive");if(r=="activate"){e(n).addClass("nf-notification-active");e(s).html(nf_notifications.deactivate);e(s).data("action","deactivate")}else{e(n).addClass("nf-notification-inactive");e(s).html(nf_notifications.activate);e(s).data("action","activate")}})});e(".nf-tokenize").each(function(){var t=e(this).data("token-limit");var n=e(this).data("key");var r=e(this).data("type");e(this).tokenfield({autocomplete:{source:nf_notifications.search_fields[r],delay:100},tokens:nf_notifications.tokens[n],delimiter:["`"],showAutocompleteOnFocus:true,beautify:false,limit:t,createTokensOnBlur:true})});e(document).on("click",".nf-insert-field",function(t){t.preventDefault();var n=e(this).prev().prev(".nf-fields-combobox").val();if(n!=""&&n!=null){var r="[ninja_forms_field id="+n+"]";window.parent.send_to_editor(r)}});e(document).on("click",".nf-insert-all-fields",function(e){e.preventDefault();var t="[ninja_forms_all_fields]";window.parent.send_to_editor(t)});e(".nf-fields-combobox").combobox();e(".ui-combobox-input").focus(function(t){var n=e(this).parent().prev(".nf-fields-combobox").val();if(n==""||n==null){this.value=""}else{e(this).select()}});e(".ui-combobox-input").mouseup(function(e){e.preventDefault()});e(".ui-combobox-input").blur(function(t){if(this.value==""){this.value=e(this).parent().prev(".nf-fields-combobox").data("first-option")}});e("#filter-type").change(function(t){if(this.value==""){var n=nf_notifications.filter_type}else{var n=nf_notifications.filter_type+"&type="+this.value}e(".spinner").show();document.location.href=n});e("#toggle_email_advanced").click(function(t){t.preventDefault();e("#email_advanced").toggle()})})
\ No newline at end of file
jQuery(document).ready(function(e){e("#settings-type").change(function(){var t=this.value;e(".notification-type").hide();e("#notification-"+t).show()});e(document).on("click",".notification-delete",function(t){t.preventDefault();var n=confirm(commonL10n.warnDelete);var r=e(this).parent().parent().parent().parent();var i=e(this).data("n_id");console.log(i);if(n){e.post(ajaxurl,{n_id:i,action:"nf_delete_notification",nf_ajax_nonce:ninja_forms_settings.nf_ajax_nonce},function(t){e(r).css("background-color","#FF0000").fadeOut("slow",function(){e(this).remove()})})}});e(document).on("click",".notification-activate",function(t){t.preventDefault();var n=e(this).parent().parent().parent().parent();var r=e(this).data("action");var i=e(this).data("n_id");var s=this;e.post(ajaxurl,{n_id:i,activate_action:r,action:"nf_"+r+"_notification",nf_ajax_nonce:ninja_forms_settings.nf_ajax_nonce},function(t){e(n).removeClass("nf-notification-active");e(n).removeClass("nf-notification-inactive");if(r=="activate"){e(n).addClass("nf-notification-active");e(s).html(nf_notifications.deactivate);e(s).data("action","deactivate")}else{e(n).addClass("nf-notification-inactive");e(s).html(nf_notifications.activate);e(s).data("action","activate")}})});e(".nf-tokenize").each(function(){var t=e(this).data("token-limit");var n=e(this).data("key");var r=e(this).data("type");e(this).tokenfield({autocomplete:{source:nf_notifications.search_fields[r],delay:100},tokens:nf_notifications.tokens[n],delimiter:["`"],showAutocompleteOnFocus:true,beautify:false,limit:t,createTokensOnBlur:true})});e(document).on("click",".nf-insert-field",function(t){t.preventDefault();var n=e(this).prev().prev(".nf-fields-combobox").val();if(n!=""&&n!=null){var r="[ninja_forms_field id="+n+"]";window.parent.send_to_editor(r)}});e(document).on("click",".nf-insert-all-fields",function(e){e.preventDefault();var t="[ninja_forms_all_fields]";window.parent.send_to_editor(t)});e(".nf-fields-combobox").combobox();e(".ui-combobox-input").focus(function(t){var n=e(this).parent().prev(".nf-fields-combobox").val();if(n==""||n==null){this.value=""}else{e(this).select()}});e(".ui-combobox-input").mouseup(function(e){e.preventDefault()});e(".ui-combobox-input").blur(function(t){if(this.value==""){this.value=e(this).parent().prev(".nf-fields-combobox").data("first-option")}});e("#filter-type").change(function(t){if(this.value==""){var n=nf_notifications.filter_type}else{var n=nf_notifications.filter_type+"&type="+this.value}e(".spinner").show();document.location.href=n});e("#toggle_email_advanced").click(function(t){t.preventDefault();e("#email_advanced").toggle()})})
\ No newline at end of file
<?php
/**
* Class for notification types.
* Class for notification types.
* This is the parent class. it should be extended by specific notification types
*
* @package Ninja Forms
......@@ -10,7 +10,7 @@
* @since 2.8
*/
class NF_Notification_Base_Type
abstract class NF_Notification_Base_Type
{
/**
......@@ -24,7 +24,7 @@ class NF_Notification_Base_Type
/**
* Processing function
*
*
* @access public
* @since 2.8
* @return false
......@@ -35,7 +35,7 @@ class NF_Notification_Base_Type
/**
* Output admin edit screen
*
*
* @access public
* @since 2.8
* @return false
......@@ -46,7 +46,7 @@ class NF_Notification_Base_Type
/**
* Save admin edit screen
*
*
* @access public
* @since 2.8
* @return void
......@@ -55,4 +55,37 @@ class NF_Notification_Base_Type
// This space left intentionally blank
return $data;
}
}
\ No newline at end of file
/**
* Explode our settings by ` and extract each value.
* Check to see if the setting is a field; if it is, assign the value.
* Run shortcodes and return the result.
*
* @access public
* @since 2.8
* @return array $setting
*/
public function process_setting( $id, $setting, $html = 1 ) {
global $ninja_forms_processing;
$setting_name = $setting;
$setting = explode( '`', Ninja_Forms()->notification( $id )->get_setting( $setting ) );
for ( $x = 0; $x <= count ( $setting ) - 1; $x++ ) {
if ( strpos( $setting[ $x ], 'field_' ) !== false ) {
if ( $ninja_forms_processing->get_field_value( str_replace( 'field_', '', $setting[ $x ] ) ) ) {
$setting[ $x ] = $ninja_forms_processing->get_field_value( str_replace( 'field_', '', $setting[ $x ] ) );
} else {
$setting[ $x ] = '';
}
}
$setting[ $x ] = str_replace( '[ninja_forms_all_fields]', '[ninja_forms_all_fields html=' . $html . ']', $setting[ $x ] );
$setting[ $x ] = do_shortcode( $setting[ $x ] );
$setting[ $x ] = nf_parse_fields_shortcode( $setting[ $x ] );
}
return apply_filters( 'nf_notification_process_setting', $setting, $setting_name, $id );
}
}
......@@ -16,12 +16,12 @@ class NF_Notification_Email extends NF_Notification_Base_Type
* Get things rolling
*/
function __construct() {
$this->name = __( 'Email', 'ninja-forms' );
}
/**
* Output our edit screen
*
*
* @access public
* @since 2.8
* @return void
......@@ -48,19 +48,10 @@ class NF_Notification_Email extends NF_Notification_Base_Type
$cc = Ninja_Forms()->notification( $id )->get_setting( 'cc' );
$bcc = Ninja_Forms()->notification( $id )->get_setting( 'bcc' );
$email_subject = Ninja_Forms()->notification( $id )->get_setting( 'email_subject' );
$email_message = Ninja_Forms()->notification( $id )->get_setting( 'email_message' );
$email_message = Ninja_Forms()->notification( $id )->get_setting( 'email_message' );
}
?>
<tr>
<th scope="row"><label for="settings-email_format"><?php _e( 'Format', 'ninja-forms' ); ?></label></th>
<td>
<select name="settings[email_format]" id="settings-email_format" data-key="email_format"/>
<option value="html" <?php selected( $email_format, 'html' ); ?>><?php _e( 'HTML', 'ninja-forms' ); ?></option>
<option value="plain" <?php selected( $email_format, 'plain' ); ?>><?php _e( 'Plain Text', 'ninja-forms' ); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="settings-from_name"><?php _e( 'From Name', 'ninja-forms' ); ?></label></th>
<td>
......@@ -68,8 +59,6 @@ class NF_Notification_Email extends NF_Notification_Base_Type
<span class="howto"><?php _e( 'Email will appear to be from this name.', 'ninja-forms' ) ?></span>
</td>
</tr>
<tr>
<th scope="row"><label for="settings-from_address"><?php _e( 'From Address', 'ninja-forms' ); ?></label></th>
<td>
......@@ -90,7 +79,7 @@ class NF_Notification_Email extends NF_Notification_Base_Type
<input name="settings[email_subject]" type="text" id="settings-email_subject" value="<?php echo $email_subject; ?>" class="nf-tokenize" placeholder="Subject Text or search for a field" data-token-limit="0" data-key="email_subject" data-type="all" />
<span class="howto"><?php _e( 'This will be the subject of the email.', 'ninja-forms' ) ?></span>
</td>
</tr>
</tr>
<tr>
<th scope="row"><label for="settings-email_message"><?php _e( 'Email Message', 'ninja-forms' ); ?></label></th>
<td>
......@@ -98,7 +87,7 @@ class NF_Notification_Email extends NF_Notification_Base_Type
$settings = array(
'textarea_name' => 'settings[email_message]',
);
wp_editor( $email_message, 'email_message', $settings );
wp_editor( $email_message, 'email_message', $settings );
?>
</td>
</tr>
......@@ -112,14 +101,14 @@ class NF_Notification_Email extends NF_Notification_Base_Type
'attach_csv' => 'Submission CSV',
)
);
foreach ( $attachment_types as $slug => $nicename ) {
if ( '' == $id ) {
$current_setting = 0;
} else {
$current_setting = Ninja_Forms()->notification( $id )->get_setting( $slug );
}
?>
<li>
<input name="settings[<?php echo $slug; ?>]" type="hidden" value="0">
......@@ -137,6 +126,15 @@ class NF_Notification_Email extends NF_Notification_Base_Type
<th scope="row"><a href="#" id="toggle_email_advanced"><?php _e( 'Advanced Settings', 'ninja-forms' ); ?></a></th>
</tr>
<tbody id="email_advanced" style="display:none;">
<tr>
<th scope="row"><label for="settings-email_format"><?php _e( 'Format', 'ninja-forms' ); ?></label></th>
<td>
<select name="settings[email_format]" id="settings-email_format" data-key="email_format"/>
<option value="html" <?php selected( $email_format, 'html' ); ?>><?php _e( 'HTML', 'ninja-forms' ); ?></option>
<option value="plain" <?php selected( $email_format, 'plain' ); ?>><?php _e( 'Plain Text', 'ninja-forms' ); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="settings-reply_to"><?php _e( 'Reply To', 'ninja-forms' ); ?></label></th>
<td>
......@@ -148,7 +146,7 @@ class NF_Notification_Email extends NF_Notification_Base_Type
<td>
<input name="settings[cc]" type="text" id="settings-cc" value="<?php echo $cc; ?>" class="nf-tokenize" placeholder="Email addresses or search for a field" data-token-limit="0" data-key="cc" data-type="all" />
</td>
</tr>
</tr>
<tr>
<th scope="row"><label for="settings-bcc"><?php _e( 'Bcc', 'ninja-forms' ); ?></label></th>
<td>
......@@ -166,8 +164,8 @@ class NF_Notification_Email extends NF_Notification_Base_Type
$reply_to = $this->get_value( $id, 'reply_to', $form_id );
$to = $this->get_value( $id, 'to', $form_id );
$cc = $this->get_value( $id, 'cc', $form_id );
$bcc = $this->get_value( $id, 'bcc', $form_id );
$email_subject = $this->get_value( $id, 'email_subject', $form_id );
$bcc = $this->get_value( $id, 'bcc', $form_id );
$email_subject = $this->get_value( $id, 'email_subject', $form_id );
} else {
$from_name = get_bloginfo( 'name' );
$from_address = get_bloginfo( 'admin_email' );
......@@ -195,7 +193,7 @@ class NF_Notification_Email extends NF_Notification_Base_Type
/**
* Get our input value labels
*
*
* @access public
* @since 2.8
* @return string $label
......@@ -224,7 +222,7 @@ class NF_Notification_Email extends NF_Notification_Base_Type
/**
* Process our Email notification
*
*
* @access public
* @since 2.8
* @return void
......@@ -245,10 +243,12 @@ class NF_Notification_Email extends NF_Notification_Base_Type
$from_address = $from_address[0];
$reply_to = $this->process_setting( $id, 'reply_to' );
$reply_to = $reply_to[0];
$reply_to = $reply_to[0];
$to = $this->process_setting( $id, 'to' );
$cc = $this->process_setting( $id, 'cc' );
$cc = $cc[0];
$bcc = $this->process_setting( $id, 'bcc' );
$bcc = $bcc[0];
if ( empty ( $from_name ) )
$from_name = 'WordPress';
......@@ -286,15 +286,11 @@ class NF_Notification_Email extends NF_Notification_Base_Type
$headers[] = 'charset=utf-8';
if ( ! empty( $cc ) ) {
foreach ( $cc as $address ) {
$headers[] = 'Cc: ' . $address;
}
$headers[] = 'Cc: ' . $address;
}
if ( ! empty( $bcc ) ) {
foreach ( $bcc as $address ) {
$headers[] = 'Bcc: ' . $address;
}
$headers[] = 'Bcc: ' . $address;
}
$csv_attachment = '';
......@@ -309,31 +305,31 @@ class NF_Notification_Email extends NF_Notification_Base_Type
// create CSV content
$csv_content = Ninja_Forms()->sub( $sub_id )->export( true );
$upload_dir = wp_upload_dir();
$path = trailingslashit( $upload_dir['path'] );
// create temporary file
$path = tempnam( $path, 'Sub' );
$temp_file = fopen( $path, 'r+' );
// write to temp file
fwrite( $temp_file, $csv_content );
fclose( $temp_file );
// find the directory we will be using for the final file
$path = pathinfo( $path );
$dir = $path['dirname'];
$basename = $path['basename'];
// create name for file
$new_name = apply_filters( 'ninja_forms_submission_csv_name', 'ninja-forms-submission' );
// remove a file if it already exists
if( file_exists( $dir.'/'.$new_name.'.csv' ) ) {
unlink( $dir.'/'.$new_name.'.csv' );
}
// move file
rename( $dir.'/'.$basename, $dir.'/'.$new_name.'.csv' );
$csv_attachment = $dir.'/'.$new_name.'.csv';
......@@ -342,9 +338,7 @@ class NF_Notification_Email extends NF_Notification_Base_Type
}
if ( is_array( $to ) AND !empty( $to ) ){
foreach( $to as $to ) {
wp_mail( $to, $subject, $message, $headers, $attachments );
}
wp_mail( $to, $subject, $message, $headers, $attachments );
}
// Delete our admin CSV if one is present.
......@@ -357,27 +351,27 @@ class NF_Notification_Email extends NF_Notification_Base_Type
* Explode our settings by ` and extract each value.
* Check to see if the setting is a field; if it is, assign the value.
* Run shortcodes and return the result.
*
*
* @access public
* @since 2.8
* @return array $setting
*/
public function process_setting( $id, $setting ) {
global $ninja_forms_processing;
$setting_name = $setting;
public function process_setting( $id, $setting, $html = 0 ) {
$setting = explode( '`', Ninja_Forms()->notification( $id )->get_setting( $setting ) );
// save the setting name
$setting_name = $setting;
for ( $x = 0; $x <= count ( $setting ) - 1; $x++ ) {
if ( $ninja_forms_processing->get_field_value( str_replace( 'field_', '', $setting[ $x ] ) ) ) {
$setting[ $x ] = $ninja_forms_processing->get_field_value( str_replace( 'field_', '', $setting[ $x ] ) );
}
$setting[ $x ] = do_shortcode( $setting[ $x ] );
$setting[ $x ] = nf_parse_fields_shortcode( $setting[ $x ] );
}
$format = Ninja_Forms()->notification( $id )->get_setting( 'email_format' );
if ( 'html' == $format )
$html = 1;
// call parent process setting method
$setting = parent::process_setting( $id, $setting, $html );
// gotta keep the old filter in case anyone was using it.
return apply_filters( 'nf_email_notification_process_setting', $setting, $setting_name, $id );
}
}
\ No newline at end of file
}
return new NF_Notification_Email();
......@@ -16,7 +16,7 @@ class NF_Notification_Redirect extends NF_Notification_Base_Type
* Get things rolling
*/
function __construct() {
$this->name = __( 'Redirect', 'ninja-forms' );
}
/**
......@@ -51,3 +51,5 @@ class NF_Notification_Redirect extends NF_Notification_Base_Type
}
}
return new NF_Notification_Redirect();
\ No newline at end of file
......@@ -16,7 +16,7 @@ class NF_Notification_Success_Message extends NF_Notification_Base_Type
* Get things rolling
*/
function __construct() {
$this->name = __( 'Success Message', 'ninja-forms' );
}
/**
......@@ -71,10 +71,17 @@ class NF_Notification_Success_Message extends NF_Notification_Base_Type
public function process( $id ) {
global $ninja_forms_processing;
// We need to get our name setting so that we can use it to create a unique success message ID.
$name = Ninja_Forms()->notification( $id )->get_setting( 'name' );
// If our name is empty, we need to generate a random string.
if ( empty ( $name ) ) {
$name = ninja_forms_random_string( 4 );
}
$success_msg = apply_filters( 'nf_success_msg', Ninja_Forms()->notification( $id )->get_setting( 'success_msg' ), $id );
$success_msg = do_shortcode( wpautop( $success_msg ) );
$success_msg = nf_parse_fields_shortcode( $success_msg );
$ninja_forms_processing->add_success_msg( 'success_msg', $success_msg );
$ninja_forms_processing->add_success_msg( 'success_msg-' . $name, $success_msg );
}
}
}
\ No newline at end of file
return new NF_Notification_Success_Message();
\ No newline at end of file
<?php
/**
* Notification Types Class.
* This class instantiates all of our registered notification types.
*
* @package Ninja Forms
* @subpackage Classes/Nofitications
* @copyright Copyright (c) 2014, WPNINJAS
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.8
*/
class NF_Notification_Types
{
/**
* Get things rolling by instantiating our notification type classes.
*/
function __construct() {
foreach( Ninja_Forms()->registered_notification_types as $slug => $type ) {
$classname = $type['classname'];
if ( class_exists( $classname ) )
$this->$slug = new $classname();
}
}
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ class NF_Notification
public function edit_screen() {
$type = $this->type;
// Call our type edit screen.
Ninja_Forms()->notification_types->$type->edit_screen( $this->id );
Ninja_Forms()->notification_types[ $type ]->edit_screen( $this->id );
}
/**
......@@ -126,7 +126,7 @@ class NF_Notification
*/
public function process() {
$type = $this->type;
Ninja_Forms()->notification_types->$type->process( $this->id );
Ninja_Forms()->notification_types[ $type ]->process( $this->id );
}
/**
......
......@@ -27,6 +27,13 @@ class NF_Notifications
function __construct() {
global $pagenow;
// Register our notification types
Ninja_Forms()->notification_types['email'] = require_once( NF_PLUGIN_DIR . 'classes/notification-email.php' );
Ninja_Forms()->notification_types['redirect'] = require_once( NF_PLUGIN_DIR . 'classes/notification-redirect.php' );
Ninja_Forms()->notification_types['success_message'] = require_once( NF_PLUGIN_DIR . 'classes/notification-success-message.php' );
Ninja_Forms()->notification_types = apply_filters( 'nf_notification_types', Ninja_Forms()->notification_types );
// Register our notification tab
add_action( 'admin_init', array( $this, 'register_tab' ) );
......@@ -43,6 +50,8 @@ class NF_Notifications
add_action( 'wp_ajax_nf_activate_notification', array( $this, 'activate_notification' ) );
add_action( 'wp_ajax_nf_deactivate_notification', array( $this, 'deactivate_notification' ) );
// Add our hook to add notification types processors.
add_action( 'ninja_forms_post_process', array( $this, 'notification_processing' ), 999 );
}
......@@ -212,9 +221,9 @@ class NF_Notifications
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
<form id="forms-filter" method="get">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>" />
<input type="hidden" name="tab" value="<?php echo $_REQUEST['tab']; ?>" />
<input type="hidden" name="form_id" value="<?php echo $_REQUEST['form_id']; ?>" />
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
<input type="hidden" name="tab" value="<?php echo esc_attr( $_REQUEST['tab'] ); ?>" />
<input type="hidden" name="form_id" value="<?php echo esc_attr( $_REQUEST['form_id'] ); ?>" />
<?php
//Create an instance of our package class...
$nf_all_forms = new NF_Notifications_List_Table();
......@@ -273,7 +282,7 @@ class NF_Notifications
<tbody id="notification-<?php echo $slug; ?>" class="notification-type" style="<?php echo $display;?>">
<?php
// Call our type edit screen.
Ninja_Forms()->notification_types->$slug->edit_screen( $id );
Ninja_Forms()->notification_types[ $slug ]->edit_screen( $id );
?>
</tbody>
<?php
......@@ -311,12 +320,14 @@ class NF_Notifications
$new = false;
}
$data = Ninja_Forms()->notification_types->$type->save_admin( $n_id, $data );
$data = Ninja_Forms()->notification_types[ $type ]->save_admin( $n_id, $data );
foreach ( $settings as $meta_key => $meta_value ) {
nf_update_object_meta( $n_id, $meta_key, $meta_value );
}
do_action( 'nf_save_notification', $n_id, $data, $new );
if ( $new ) {
$redirect = remove_query_arg( array( 'notification-action' ) );
$redirect = add_query_arg( array( 'id' => $n_id, 'notification-action' => 'edit' ), $redirect );
......@@ -336,8 +347,8 @@ class NF_Notifications
*/
public function get_types() {
$types = array();
foreach ( Ninja_Forms()->registered_notification_types as $slug => $type ) {
$types[ $slug ] = $type['nicename'];
foreach ( Ninja_Forms()->notification_types as $slug => $object ) {
$types[ $slug ] = $object->name;
}
return $types;
}
......@@ -351,6 +362,9 @@ class NF_Notifications
* @return void
*/
public function delete_notification() {
// Bail if our nonce doesn't verify.
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
$n_id = $_REQUEST['n_id'];
Ninja_Forms()->notification( $n_id )->delete();
}
......@@ -364,6 +378,9 @@ class NF_Notifications
* @return void
*/
public function activate_notification() {
// Bail if our nonce doesn't verify.
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
$n_id = $_REQUEST['n_id'];
Ninja_Forms()->notification( $n_id )->activate();
}
......@@ -377,6 +394,9 @@ class NF_Notifications
* @return void
*/
public function deactivate_notification() {
// Bail if our nonce doesn't verify.
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
$n_id = $_REQUEST['n_id'];
Ninja_Forms()->notification( $n_id )->deactivate();
}
......@@ -508,6 +528,7 @@ class NF_Notifications
$notifications = nf_get_notifications_by_form_id( $form_id, false );
if ( is_array( $notifications ) ) {
foreach ( $notifications as $id ) {
do_action( 'nf_notification_before_process', $id );
if ( Ninja_Forms()->notification( $id )->active ) {
Ninja_Forms()->notification( $id )->process();
}
......
......@@ -121,7 +121,7 @@ class NF_Subs_CPT {
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => true,
'publicly_queryable' => false,
'show_ui' => true,
'_builtin' => false, // It's a custom post type, not built in!
'query_var' => true,
......
......@@ -117,46 +117,6 @@ margin: 0;
padding: 0;
}
.description label,
#ninja-forms-conditionals .label {
border-radius: 4px;
padding: 5px;
overflow: hidden;
}
#ninja-forms-conditionals {
border: 1px solid #ccc;
border-radius: 5px;
clear: both;
float: none;
overflow: hidden;
}
#ninja-forms-conditionals .label {
background: #ccc;
display: block;
}
.ninja-forms-condition {
border: 1px solid #ddd;
margin: 10px;
}
.ninja-forms-condition-title {
background: #ddd;
padding: 10px;
}
.ninja-forms-criteria {
background: #fff;
overflow: hidden;
}
.single-criteria {
border-bottom: 1px solid #ddd;
padding: 5px 0 5px 20px;
}
.ninja-forms-field-list-options {
margin-bottom: 10px;
}
......
......@@ -108,6 +108,8 @@ function ninja_forms_serialize_form( $form_id ){
$notifications = nf_get_notifications_by_form_id( $form_id );
$form_row['notifications'] = $notifications;
$form_row = apply_filters( 'nf_export_form_row', $form_row );
$form_row = serialize($form_row);
return $form_row;
......
......@@ -81,6 +81,12 @@ function ninja_forms_register_label_settings_metabox(){
'label' => __( 'Processing Submission Label', 'ninja-forms' ),
'desc' => __( 'This message is shown inside the submit button whenever a user clicks "submit" to let them know it is processing.', 'ninja-forms' ),
),
array(
'name' => 'password_mismatch',
'type' => 'text',
'label' => __( 'Password Mismatch Label', 'ninja-forms' ),
'desc' => __( 'This message is shown to a user when non-matching values are placed in the password field.', 'ninja-forms' ),
),
),
);
ninja_forms_register_tab_metabox( $args );
......
......@@ -268,7 +268,7 @@ class NF_Convert_Notifications extends NF_Step_Processing {
nf_update_object_meta( $n_id, 'name', __( 'Success Message', 'ninja-forms' ) );
nf_update_object_meta( $n_id, 'type', 'success_message' );
nf_update_object_meta( $n_id, 'active', 1 );
nf_update_object_meta( $n_id, 'success_message', $form_settings['success_msg'] );
nf_update_object_meta( $n_id, 'success_msg', $form_settings['success_msg'] );
}
if ( isset ( $form_settings['landing_page'] ) && ! empty( $form_settings['landing_page'] ) ) {
......
......@@ -423,16 +423,22 @@ function ninja_forms_delete_transient(){
* @return int $count
*/
function nf_get_sub_count( $form_id, $post_status = 'publish' ) {
$args = array(
'meta_key' => '_form_id',
'meta_value' => $form_id,
'post_type' => 'nf_sub',
'posts_per_page' => -1,
'post_status' => $post_status,
);
$posts = get_posts( $args );
return count( $posts );
global $wpdb;
$meta_key = '_form_id';
$meta_value = $form_id;
$sql = "SELECT count(DISTINCT pm.post_id)
FROM $wpdb->postmeta pm
JOIN $wpdb->posts p ON (p.ID = pm.post_id)
WHERE pm.meta_key = '$meta_key'
AND pm.meta_value = '$meta_value'
AND p.post_type = 'nf_sub'
AND p.post_status = '$post_status'";
$count = $wpdb->get_var($sql);
return $count;
}
/**
......
......@@ -790,4 +790,29 @@ function nf_deprecate_success_message_filter( $message, $n_id ) {
return apply_filters( 'ninja_forms_success_msg', $message );
}
add_filter( 'nf_success_msg', 'nf_deprecate_success_message_filter', 10, 2 );
\ No newline at end of file