Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../classes
File: notifications.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
/**
[1] Fix | Delete
* Main Notifications Class
[2] Fix | Delete
*
[3] Fix | Delete
* Adds our notifications to the form edit page.
[4] Fix | Delete
* Gets notification types
[5] Fix | Delete
* Listens for ajax commands to delete/activate/deactivate notifications
[6] Fix | Delete
* Listens for bulk actions from the notifications admin page
[7] Fix | Delete
* Adds notification types processing to the appropriate action hook
[8] Fix | Delete
*
[9] Fix | Delete
* @package Ninja Forms
[10] Fix | Delete
* @subpackage Classes/Notifications
[11] Fix | Delete
* @copyright Copyright (c) 2014, WPNINJAS
[12] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[13] Fix | Delete
* @since 2.8
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
class NF_Notifications
[17] Fix | Delete
{
[18] Fix | Delete
/**
[19] Fix | Delete
* Get things rolling
[20] Fix | Delete
*
[21] Fix | Delete
* @access public
[22] Fix | Delete
*
[23] Fix | Delete
* @since 2.8
[24] Fix | Delete
*/
[25] Fix | Delete
function __construct() {
[26] Fix | Delete
global $pagenow;
[27] Fix | Delete
[28] Fix | Delete
// Register our notification types
[29] Fix | Delete
Ninja_Forms()->notification_types['email'] = require_once( NF_PLUGIN_DIR . 'classes/notification-email.php' );
[30] Fix | Delete
Ninja_Forms()->notification_types['redirect'] = require_once( NF_PLUGIN_DIR . 'classes/notification-redirect.php' );
[31] Fix | Delete
Ninja_Forms()->notification_types['success_message'] = require_once( NF_PLUGIN_DIR . 'classes/notification-success-message.php' );
[32] Fix | Delete
[33] Fix | Delete
Ninja_Forms()->notification_types = apply_filters( 'nf_notification_types', Ninja_Forms()->notification_types );
[34] Fix | Delete
[35] Fix | Delete
// Register our notification tab
[36] Fix | Delete
add_action( 'admin_init', array( $this, 'register_tab' ) );
[37] Fix | Delete
[38] Fix | Delete
// Only add these actions if we are actually on the notification tab.
[39] Fix | Delete
if ( 'admin.php' == $pagenow && isset ( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ninja-forms' && isset ( $_REQUEST['tab'] ) && $_REQUEST['tab'] == 'notifications' ) {
[40] Fix | Delete
add_action( 'admin_init', array( $this, 'add_js' ) );
[41] Fix | Delete
add_action( 'admin_init', array( $this, 'add_css' ) );
[42] Fix | Delete
add_action( 'admin_init', array( $this, 'bulk_actions' ) );
[43] Fix | Delete
add_action( 'admin_init', array( $this, 'duplicate_notification' ) );
[44] Fix | Delete
add_filter( 'media_buttons_context', array( $this, 'tinymce_buttons' ) );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
add_action( 'wp_ajax_nf_delete_notification', array( $this, 'delete_notification' ) );
[48] Fix | Delete
add_action( 'wp_ajax_nf_activate_notification', array( $this, 'activate_notification' ) );
[49] Fix | Delete
add_action( 'wp_ajax_nf_deactivate_notification', array( $this, 'deactivate_notification' ) );
[50] Fix | Delete
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
// Add our hook to add notification types processors.
[54] Fix | Delete
add_action( 'ninja_forms_post_process', array( $this, 'notification_processing' ), 999 );
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Register our setting tab.
[59] Fix | Delete
*
[60] Fix | Delete
* @access public
[61] Fix | Delete
*
[62] Fix | Delete
* @since 2.8
[63] Fix | Delete
* @return void
[64] Fix | Delete
*/
[65] Fix | Delete
public function register_tab() {
[66] Fix | Delete
$form_id = isset ( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : '';
[67] Fix | Delete
$action = isset ( $_REQUEST['notification-action'] ) ? esc_html( $_REQUEST['notification-action'] ) : '';
[68] Fix | Delete
$output_form = false;
[69] Fix | Delete
$show_save = false;
[70] Fix | Delete
if ( 'edit' == $action || 'new' == $action ) {
[71] Fix | Delete
$output_form = true;
[72] Fix | Delete
$show_save = true;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
$args = array(
[76] Fix | Delete
'name' => __( 'Email & Actions', 'ninja-forms' ),
[77] Fix | Delete
'page' => 'ninja-forms',
[78] Fix | Delete
'display_function' => array( $this, 'output_admin' ),
[79] Fix | Delete
'save_function' => array( $this, 'save_admin' ),
[80] Fix | Delete
'disable_no_form_id' => true,
[81] Fix | Delete
'show_save' => $show_save,
[82] Fix | Delete
'tab_reload' => true,
[83] Fix | Delete
'output_form' => $output_form,
[84] Fix | Delete
);
[85] Fix | Delete
[86] Fix | Delete
ninja_forms_register_tab( 'notifications', $args );
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Enqueue JS
[91] Fix | Delete
*
[92] Fix | Delete
* @access public
[93] Fix | Delete
* @since 2.8
[94] Fix | Delete
* @return void
[95] Fix | Delete
*/
[96] Fix | Delete
public function add_js() {
[97] Fix | Delete
global $ninja_forms_fields;
[98] Fix | Delete
[99] Fix | Delete
$form_id = isset ( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : '';
[100] Fix | Delete
if ( empty ( $form_id ) )
[101] Fix | Delete
return false;
[102] Fix | Delete
[103] Fix | Delete
if ( defined( 'NINJA_FORMS_JS_DEBUG' ) && NINJA_FORMS_JS_DEBUG ) {
[104] Fix | Delete
$suffix = '';
[105] Fix | Delete
$src = 'dev';
[106] Fix | Delete
} else {
[107] Fix | Delete
$suffix = '.min';
[108] Fix | Delete
$src = 'min';
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
wp_enqueue_script( 'nf-notifications',
[112] Fix | Delete
NF_PLUGIN_URL . 'assets/js/' . $src .'/notifications' . $suffix . '.js',
[113] Fix | Delete
array( 'jquery', 'jquery-ui-autocomplete' ) );
[114] Fix | Delete
[115] Fix | Delete
wp_enqueue_script( 'nf-tokenize',
[116] Fix | Delete
NF_PLUGIN_URL . 'assets/js/' . $src .'/bootstrap-tokenfield' . $suffix . '.js',
[117] Fix | Delete
array( 'jquery', 'jquery-ui-autocomplete' ) );
[118] Fix | Delete
[119] Fix | Delete
wp_enqueue_script( 'nf-combobox',
[120] Fix | Delete
NF_PLUGIN_URL . 'assets/js/' . $src .'/combobox' . $suffix . '.js',
[121] Fix | Delete
array( 'jquery', 'jquery-ui-core', 'jquery-ui-button', 'jquery-ui-autocomplete' ) );
[122] Fix | Delete
[123] Fix | Delete
$all_fields = Ninja_Forms()->form( $form_id )->fields;
[124] Fix | Delete
$process_fields = array();
[125] Fix | Delete
$search_fields = array();
[126] Fix | Delete
$search_fields['email'] = array();
[127] Fix | Delete
$search_fields['name'] = array();
[128] Fix | Delete
$fields = array();
[129] Fix | Delete
// Generate our search fields JS var.
[130] Fix | Delete
foreach( $all_fields as $field_id => $field ) {
[131] Fix | Delete
$label = esc_attr( nf_get_field_admin_label( $field_id ) );
[132] Fix | Delete
[133] Fix | Delete
$fields[ $field_id ] = array( 'field_id' => $field_id, 'label' => $label );
[134] Fix | Delete
[135] Fix | Delete
if ( strlen( $label ) > 30 ) {
[136] Fix | Delete
$tmp_label = substr( $label, 0, 30 );
[137] Fix | Delete
} else {
[138] Fix | Delete
$tmp_label = $label;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
$tmp_array = array( 'value' => 'field_' . $field_id, 'label' => $tmp_label . ' - ID: ' . $field_id );
[142] Fix | Delete
[143] Fix | Delete
$admin_label = $label;
[144] Fix | Delete
[145] Fix | Delete
$label = isset( $field['data']['label'] ) ? $field['data']['label'] : '';
[146] Fix | Delete
[147] Fix | Delete
// Check to see if this field is supposed to be "processed"
[148] Fix | Delete
$type = $field['type'];
[149] Fix | Delete
if ( isset ( $ninja_forms_fields[ $type ]['process_field'] ) && $ninja_forms_fields[ $type ]['process_field'] ) {
[150] Fix | Delete
$process_fields[ $field_id ] = array( 'field_id' => $field_id, 'label' => $label, 'admin_label' => $admin_label );
[151] Fix | Delete
$search_fields['all'][] = $tmp_array;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
if ( $field['type'] == '_text' && isset ( $field['data']['email'] ) && $field['data']['email'] == 1 ) {
[155] Fix | Delete
$search_fields['email'][] = $tmp_array;
[156] Fix | Delete
} else if ( $field['type'] == '_text' && isset ( $field['data']['first_name'] ) && $field['data']['first_name'] == 1 ) {
[157] Fix | Delete
$search_fields['name'][] = $tmp_array;
[158] Fix | Delete
} else if ( $field['type'] == '_text' && isset ( $field['data']['last_name'] ) && $field['data']['last_name'] == 1 ) {
[159] Fix | Delete
$search_fields['name'][] = $tmp_array;
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
// Add our "process_fields" to our form global
[164] Fix | Delete
Ninja_Forms()->form( $form_id )->process_fields = $process_fields;
[165] Fix | Delete
[166] Fix | Delete
$js_vars = apply_filters( 'nf_notification_admin_js_vars', array(
[167] Fix | Delete
'activate' => __( 'Activate', 'ninja-forms' ),
[168] Fix | Delete
'deactivate' => __( 'Deactivate', 'ninja-forms' ),
[169] Fix | Delete
'search_fields' => $search_fields,
[170] Fix | Delete
'tokens' => array(),
[171] Fix | Delete
'all_fields' => $fields,
[172] Fix | Delete
'process_fields' => $process_fields,
[173] Fix | Delete
'filter_type' => esc_url_raw( remove_query_arg( array( 'type' ) ) ),
[174] Fix | Delete
) );
[175] Fix | Delete
[176] Fix | Delete
wp_localize_script( 'nf-notifications', 'nf_notifications', $js_vars );
[177] Fix | Delete
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Enqueue CSS
[182] Fix | Delete
*
[183] Fix | Delete
* @access public
[184] Fix | Delete
* @since 2.8
[185] Fix | Delete
* @return void
[186] Fix | Delete
*/
[187] Fix | Delete
public function add_css() {
[188] Fix | Delete
wp_enqueue_style( 'nf-notifications',
[189] Fix | Delete
NF_PLUGIN_URL . 'assets/css/notifications.css' );
[190] Fix | Delete
[191] Fix | Delete
wp_enqueue_style( 'nf-tokenize',
[192] Fix | Delete
NF_PLUGIN_URL . 'assets/css/bootstrap-tokenfield.css' );
[193] Fix | Delete
[194] Fix | Delete
wp_enqueue_style( 'nf-combobox',
[195] Fix | Delete
NF_PLUGIN_URL . 'assets/css/combobox.css' );
[196] Fix | Delete
[197] Fix | Delete
// wp_enqueue_style( 'nf-bootstrap',
[198] Fix | Delete
// 'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css' );
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Output our notifications admin.
[203] Fix | Delete
*
[204] Fix | Delete
* @access public
[205] Fix | Delete
*
[206] Fix | Delete
* @since 2.8
[207] Fix | Delete
* @return void
[208] Fix | Delete
*/
[209] Fix | Delete
public function output_admin() {
[210] Fix | Delete
$action = isset ( $_REQUEST['notification-action'] ) ? esc_html( $_REQUEST['notification-action'] ) : '';
[211] Fix | Delete
[212] Fix | Delete
?>
[213] Fix | Delete
<div class="wrap">
[214] Fix | Delete
<?php
[215] Fix | Delete
if ( '' == $action ) {
[216] Fix | Delete
?>
[217] Fix | Delete
<h2><?php _e( 'Email & Actions', 'ninja-forms' ); ?> <a href="<?php echo esc_url( add_query_arg( array( 'notification-action' => 'new' ) ) ); ?>" class="add-new-h2"><?php _e( 'Add New', 'ninja-forms' );?></a></h2>
[218] Fix | Delete
[219] Fix | Delete
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
[220] Fix | Delete
<form id="forms-filter" method="get">
[221] Fix | Delete
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
[222] Fix | Delete
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
[223] Fix | Delete
<input type="hidden" name="tab" value="<?php echo esc_attr( $_REQUEST['tab'] ); ?>" />
[224] Fix | Delete
<input type="hidden" name="form_id" value="<?php echo esc_attr( $_REQUEST['form_id'] ); ?>" />
[225] Fix | Delete
<?php
[226] Fix | Delete
//Create an instance of our package class...
[227] Fix | Delete
$nf_all_forms = new NF_Notifications_List_Table();
[228] Fix | Delete
//Fetch, prepare, sort, and filter our data...
[229] Fix | Delete
$nf_all_forms->prepare_items();
[230] Fix | Delete
// Now we can render the completed list table
[231] Fix | Delete
$nf_all_forms->display();
[232] Fix | Delete
?>
[233] Fix | Delete
</form>
[234] Fix | Delete
<?php
[235] Fix | Delete
} else {
[236] Fix | Delete
$id = isset ( $_REQUEST['id'] ) ? absint( $_REQUEST['id'] ) : '';
[237] Fix | Delete
if ( $id == '' ) {
[238] Fix | Delete
$id = 'new';
[239] Fix | Delete
$this_type = 'email';
[240] Fix | Delete
$title = __( 'New Action', 'ninja-forms' );
[241] Fix | Delete
} else {
[242] Fix | Delete
$this_type = Ninja_Forms()->notification( $id )->type;
[243] Fix | Delete
$title = __( 'Edit Action', 'ninja-forms' ) . ' - ID ' . $id;
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
?>
[247] Fix | Delete
<h2><?php echo $title; ?> <a href="<?php echo esc_url( remove_query_arg( array( 'notification-action', 'id', 'update_message' ) ) );?>" class="button-secondary"><?php _e( 'Back To List', 'ninja-forms' );?></a></h2>
[248] Fix | Delete
[249] Fix | Delete
<input type="hidden" id="notification_id" name="notification_id" value="<?php echo $id; ?>" />
[250] Fix | Delete
<table class="form-table">
[251] Fix | Delete
<tbody id="notification-main">
[252] Fix | Delete
<tr>
[253] Fix | Delete
<th scope="row"><label for="setting-name"><?php _e( 'Action Name', 'ninja-forms' ); ?></label></th>
[254] Fix | Delete
<td><input name="settings[name]" type="text" id="settings-name" value="<?php echo nf_get_object_meta_value( $id, 'name' ); ?>" class="regular-text"></td>
[255] Fix | Delete
</tr>
[256] Fix | Delete
<tr>
[257] Fix | Delete
<th scope="row"><label for="type"><?php _e( 'Type', 'ninja-forms' ); ?></label></th>
[258] Fix | Delete
<td>
[259] Fix | Delete
<select name="settings[type]" id="settings-type">
[260] Fix | Delete
<?php
[261] Fix | Delete
foreach ( $this->get_types() as $slug => $nicename ) {
[262] Fix | Delete
?>
[263] Fix | Delete
<option value="<?php echo $slug; ?>" <?php selected ( $this_type, $slug ); ?>><?php echo $nicename; ?></option>
[264] Fix | Delete
<?php
[265] Fix | Delete
}
[266] Fix | Delete
?>
[267] Fix | Delete
</select>
[268] Fix | Delete
<span class="nf-more-actions"><a href="<?php echo nf_aff_link( 'https://ninjaforms.com/extensions/?display=actions&utm_medium=plugin&utm_source=action-single&utm_campaign=Ninja+Forms+Upsell&utm_content=Ninja+Forms+Actions' ); ?>" target="_blank"><?php _e( 'Get More Actions', 'ninja-forms' ); ?> <span class="dashicons dashicons-external"></span></a></span>
[269] Fix | Delete
</td>
[270] Fix | Delete
</tr>
[271] Fix | Delete
</tbody>
[272] Fix | Delete
<?php
[273] Fix | Delete
do_action( 'nf_edit_notification_settings', $id );
[274] Fix | Delete
foreach ( $this->get_types() as $slug => $nicename ) {
[275] Fix | Delete
if ( $this_type == $slug ) {
[276] Fix | Delete
$display = '';
[277] Fix | Delete
} else {
[278] Fix | Delete
$display = 'display:none;';
[279] Fix | Delete
}
[280] Fix | Delete
?>
[281] Fix | Delete
<tbody id="notification-<?php echo $slug; ?>" class="notification-type" style="<?php echo $display;?>">
[282] Fix | Delete
<?php
[283] Fix | Delete
// Call our type edit screen.
[284] Fix | Delete
Ninja_Forms()->notification_types[ $slug ]->edit_screen( $id );
[285] Fix | Delete
?>
[286] Fix | Delete
</tbody>
[287] Fix | Delete
<?php
[288] Fix | Delete
}
[289] Fix | Delete
?>
[290] Fix | Delete
</table>
[291] Fix | Delete
<?php
[292] Fix | Delete
} ?>
[293] Fix | Delete
[294] Fix | Delete
</div>
[295] Fix | Delete
<?php
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Save our notifications admin.
[300] Fix | Delete
*
[301] Fix | Delete
* @access public
[302] Fix | Delete
*
[303] Fix | Delete
* @since 2.8
[304] Fix | Delete
* @return void
[305] Fix | Delete
*/
[306] Fix | Delete
public function save_admin( $form_id, $data ) {
[307] Fix | Delete
if ( ! isset ( $data['notification_id'] ) || empty ( $data['notification_id'] ) )
[308] Fix | Delete
return false;
[309] Fix | Delete
[310] Fix | Delete
$n_id = $data['notification_id'];
[311] Fix | Delete
$settings = $data['settings'];
[312] Fix | Delete
[313] Fix | Delete
if ( 'new' == $n_id ) {
[314] Fix | Delete
$type = $settings['type'];
[315] Fix | Delete
$n_id = $this->create( $form_id );
[316] Fix | Delete
$new = true;
[317] Fix | Delete
} else {
[318] Fix | Delete
$type = Ninja_Forms()->notification( $n_id )->type;
[319] Fix | Delete
$new = false;
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
$data = Ninja_Forms()->notification_types[ $type ]->save_admin( $n_id, $data );
[323] Fix | Delete
[324] Fix | Delete
foreach ( $settings as $meta_key => $meta_value ) {
[325] Fix | Delete
nf_update_object_meta( $n_id, $meta_key, nf_wp_kses_post_deep( $meta_value ) );
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
do_action( 'nf_save_notification', $n_id, $data, $new );
[329] Fix | Delete
[330] Fix | Delete
if ( $new ) {
[331] Fix | Delete
$redirect = esc_url_raw( remove_query_arg( array( 'notification-action' ) ) );
[332] Fix | Delete
$redirect = esc_url_raw( add_query_arg( array( 'id' => $n_id, 'notification-action' => 'edit', 'update_message' => urlencode( __( 'Action Updated', 'ninja-forms' ) ) ), $redirect ) );
[333] Fix | Delete
wp_redirect( $redirect );
[334] Fix | Delete
die();
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
return __( 'Action Updated', 'ninja-forms' );
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
/**
[341] Fix | Delete
* Get our registered notification types
[342] Fix | Delete
*
[343] Fix | Delete
* @access public
[344] Fix | Delete
* @since 2.8
[345] Fix | Delete
* @return array $types
[346] Fix | Delete
*/
[347] Fix | Delete
public function get_types() {
[348] Fix | Delete
$types = array();
[349] Fix | Delete
foreach ( Ninja_Forms()->notification_types as $slug => $object ) {
[350] Fix | Delete
$types[ $slug ] = $object->name;
[351] Fix | Delete
}
[352] Fix | Delete
return $types;
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
/**
[356] Fix | Delete
* Delete a notification.
[357] Fix | Delete
* Hooked into the ajax action for nf_delete_notification
[358] Fix | Delete
*
[359] Fix | Delete
* @access public
[360] Fix | Delete
* @since 2.8
[361] Fix | Delete
* @return void
[362] Fix | Delete
*/
[363] Fix | Delete
public function delete_notification() {
[364] Fix | Delete
// Bail if our nonce doesn't verify.
[365] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[366] Fix | Delete
[367] Fix | Delete
$n_id = absint( $_REQUEST['n_id'] );
[368] Fix | Delete
Ninja_Forms()->notification( $n_id )->delete();
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Activate a notification.
[373] Fix | Delete
* Hooked into the ajax action for nf_activate_notification
[374] Fix | Delete
*
[375] Fix | Delete
* @access public
[376] Fix | Delete
* @since 2.8
[377] Fix | Delete
* @return void
[378] Fix | Delete
*/
[379] Fix | Delete
public function activate_notification() {
[380] Fix | Delete
// Bail if our nonce doesn't verify.
[381] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[382] Fix | Delete
[383] Fix | Delete
$n_id = absint( $_REQUEST['n_id'] );
[384] Fix | Delete
Ninja_Forms()->notification( $n_id )->activate();
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Deactivate a notification.
[389] Fix | Delete
* Hooked into the ajax action for nf_deactivate_notification
[390] Fix | Delete
*
[391] Fix | Delete
* @access public
[392] Fix | Delete
* @since 2.8
[393] Fix | Delete
* @return void
[394] Fix | Delete
*/
[395] Fix | Delete
public function deactivate_notification() {
[396] Fix | Delete
// Bail if our nonce doesn't verify.
[397] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[398] Fix | Delete
[399] Fix | Delete
$n_id = absint( $_REQUEST['n_id'] );
[400] Fix | Delete
Ninja_Forms()->notification( $n_id )->deactivate();
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
/**
[404] Fix | Delete
* Duplicate our notification
[405] Fix | Delete
*
[406] Fix | Delete
* @access public
[407] Fix | Delete
* @since 2.8
[408] Fix | Delete
* @return void
[409] Fix | Delete
*/
[410] Fix | Delete
public function duplicate_notification() {
[411] Fix | Delete
if ( ! isset ( $_REQUEST['notification-action'] ) || $_REQUEST['notification-action'] != 'duplicate' )
[412] Fix | Delete
return false;
[413] Fix | Delete
[414] Fix | Delete
$n_id = isset ( $_REQUEST['id'] ) ? absint( $_REQUEST['id'] ) : '';
[415] Fix | Delete
[416] Fix | Delete
// Bail if we don't have an ID.
[417] Fix | Delete
if ( '' === $n_id )
[418] Fix | Delete
return false;
[419] Fix | Delete
[420] Fix | Delete
Ninja_Forms()->notification( $n_id )->duplicate();
[421] Fix | Delete
[422] Fix | Delete
wp_redirect( esc_url_raw( remove_query_arg( array( 'notification-action' ) ) ) );
[423] Fix | Delete
die();
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
/**
[427] Fix | Delete
* Create a new notification
[428] Fix | Delete
*
[429] Fix | Delete
* @access public
[430] Fix | Delete
* @since 2.8
[431] Fix | Delete
* @return int $n_id
[432] Fix | Delete
*/
[433] Fix | Delete
public function create( $form_id = '' ) {
[434] Fix | Delete
// Bail if we don't have a form_id
[435] Fix | Delete
if ( '' == $form_id )
[436] Fix | Delete
return false;
[437] Fix | Delete
[438] Fix | Delete
$n_id = nf_insert_notification( $form_id );
[439] Fix | Delete
[440] Fix | Delete
// Activate our new notification
[441] Fix | Delete
Ninja_Forms()->notification( $n_id )->activate();
[442] Fix | Delete
[443] Fix | Delete
return $n_id;
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
/**
[447] Fix | Delete
* Handle bulk actions
[448] Fix | Delete
*
[449] Fix | Delete
* @access public
[450] Fix | Delete
* @since 2.8
[451] Fix | Delete
* @return void
[452] Fix | Delete
*/
[453] Fix | Delete
public function bulk_actions() {
[454] Fix | Delete
$action = '';
[455] Fix | Delete
[456] Fix | Delete
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
[457] Fix | Delete
$action = esc_html( $_REQUEST['action2'] );
[458] Fix | Delete
[459] Fix | Delete
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
[460] Fix | Delete
$action = esc_html( $_REQUEST['action'] );
[461] Fix | Delete
[462] Fix | Delete
$n_ids = isset ( $_REQUEST['notification'] ) ? esc_html( $_REQUEST['notification'] ) : '';
[463] Fix | Delete
[464] Fix | Delete
if ( ! is_array( $n_ids ) || empty( $n_ids ) )
[465] Fix | Delete
return false;
[466] Fix | Delete
[467] Fix | Delete
if( 'delete' === $action ) {
[468] Fix | Delete
foreach ( $n_ids as $n_id ) {
[469] Fix | Delete
Ninja_Forms()->notification( $n_id )->delete();
[470] Fix | Delete
}
[471] Fix | Delete
} else if ( 'activate' === $action ) {
[472] Fix | Delete
foreach ( $n_ids as $n_id ) {
[473] Fix | Delete
Ninja_Forms()->notification( $n_id )->activate();
[474] Fix | Delete
}
[475] Fix | Delete
} else if ( 'deactivate' === $action ) {
[476] Fix | Delete
foreach ( $n_ids as $n_id ) {
[477] Fix | Delete
Ninja_Forms()->notification( $n_id )->deactivate();
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
wp_redirect( esc_url_raw( remove_query_arg( array( 'notification', '_wpnonce', '_wp_http_referer', 'action', 'action2' ) ) ) );
[482] Fix | Delete
die();
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
/**
[486] Fix | Delete
* Output our tinyMCE field buttons
[487] Fix | Delete
*
[488] Fix | Delete
* @access public
[489] Fix | Delete
* @since 2.8
[490] Fix | Delete
* @return void
[491] Fix | Delete
*/
[492] Fix | Delete
public function tinymce_buttons( $context ) {
[493] Fix | Delete
$form_id = isset ( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : '';
[494] Fix | Delete
if ( empty ( $form_id ) )
[495] Fix | Delete
return $context;
[496] Fix | Delete
[497] Fix | Delete
$all_fields = Ninja_Forms()->form( $form_id )->process_fields;
[498] Fix | Delete
$first_option = __( 'Select a field or type to search', 'ninja-forms' );
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function