Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../includes/admin
File: admin.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
function ninja_forms_add_menu(){
[2] Fix | Delete
$page = add_menu_page("Ninja Forms" , __( 'Forms', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_parent_menu_capabilities', 'manage_options' ), "ninja-forms", "ninja_forms_admin", "dashicons-feedback", "35.1337" );
[3] Fix | Delete
$all_forms = add_submenu_page("ninja-forms", __( 'Forms', 'ninja-forms' ), __( 'All Forms', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_all_forms_capabilities', 'manage_options' ), "ninja-forms", "ninja_forms_admin");
[4] Fix | Delete
$new_form = add_submenu_page("ninja-forms", __( 'Add New', 'ninja-forms' ), __( 'Add New', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_add_new_capabilities', 'manage_options' ), "ninja-forms&tab=builder&form_id=new", "ninja_forms_admin");
[5] Fix | Delete
[6] Fix | Delete
$upgrade = add_submenu_page( null, __( 'Ninja Forms Upgrades', 'ninja-forms' ), __( 'Upgrades', 'ninja-forms' ), 'install_plugins', 'nf-upgrades', 'nf_upgrades_screen' );
[7] Fix | Delete
[8] Fix | Delete
add_action('admin_print_styles-' . $page, 'ninja_forms_admin_css');
[9] Fix | Delete
add_action('admin_print_styles-' . $page, 'ninja_forms_admin_js');
[10] Fix | Delete
[11] Fix | Delete
add_action('admin_print_styles-' . $new_form, 'ninja_forms_admin_css');
[12] Fix | Delete
add_action('admin_print_styles-' . $new_form, 'ninja_forms_admin_js');
[13] Fix | Delete
[14] Fix | Delete
add_action( 'load-' . $page, 'ninja_forms_load_screen_options_tab' );
[15] Fix | Delete
add_action( 'load-' . $all_forms, 'ninja_forms_load_screen_options_tab' );
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
add_action( 'admin_menu', 'ninja_forms_add_menu' );
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Add our submenu pages
[22] Fix | Delete
*
[23] Fix | Delete
* @since 2.7
[24] Fix | Delete
* @return void
[25] Fix | Delete
*/
[26] Fix | Delete
function nf_add_submenus() {
[27] Fix | Delete
$import = add_submenu_page("ninja-forms", __( 'Import/Export', 'ninja-forms' ), __( 'Import / Export', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_import_export_capabilities', 'manage_options' ), "ninja-forms-impexp", "ninja_forms_admin");
[28] Fix | Delete
$settings = add_submenu_page("ninja-forms", __( 'Ninja Form Settings', 'ninja-forms' ), __( 'Settings', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_settings_capabilities', 'manage_options' ), "ninja-forms-settings", "ninja_forms_admin");
[29] Fix | Delete
$system_status = add_submenu_page("ninja-forms", __( 'System Status', 'ninja-forms' ), __( 'System Status', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_status_capabilities', 'manage_options' ), "ninja-forms-system-status", "ninja_forms_admin");
[30] Fix | Delete
$extend = add_submenu_page("ninja-forms", __( 'Add-Ons', 'ninja-forms' ), __( 'Add-Ons', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_extend_capabilities', 'manage_options' ), "ninja-forms-extend", "ninja_forms_admin");
[31] Fix | Delete
[32] Fix | Delete
add_action('admin_print_styles-' . $settings, 'ninja_forms_admin_js');
[33] Fix | Delete
add_action('admin_print_styles-' . $settings, 'ninja_forms_admin_css');
[34] Fix | Delete
[35] Fix | Delete
add_action('admin_print_styles-' . $import, 'ninja_forms_admin_js');
[36] Fix | Delete
add_action('admin_print_styles-' . $import, 'ninja_forms_admin_css');
[37] Fix | Delete
[38] Fix | Delete
add_action('admin_print_styles-' . $system_status, 'ninja_forms_admin_js');
[39] Fix | Delete
add_action('admin_print_styles-' . $system_status, 'ninja_forms_admin_css');
[40] Fix | Delete
[41] Fix | Delete
add_action('admin_print_styles-' . $extend, 'ninja_forms_admin_js');
[42] Fix | Delete
add_action('admin_print_styles-' . $extend, 'ninja_forms_admin_css');
[43] Fix | Delete
[44] Fix | Delete
add_action( 'load-' . $settings, 'ninja_forms_load_screen_options_tab' );
[45] Fix | Delete
add_action( 'load-' . $import, 'ninja_forms_load_screen_options_tab' );
[46] Fix | Delete
add_action( 'load-' . $system_status, 'ninja_forms_load_screen_options_tab' );
[47] Fix | Delete
add_action( 'load-' . $extend, 'ninja_forms_load_screen_options_tab' );
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
add_action( 'admin_menu', 'nf_add_submenus', 15 );
[51] Fix | Delete
[52] Fix | Delete
function ninja_forms_admin(){
[53] Fix | Delete
global $wpdb, $ninja_forms_tabs, $ninja_forms_sidebars, $current_tab, $ninja_forms_tabs_metaboxes, $ninja_forms_admin_update_message;
[54] Fix | Delete
[55] Fix | Delete
$current_tab = ninja_forms_get_current_tab();
[56] Fix | Delete
$current_page = esc_html( $_REQUEST['page'] );
[57] Fix | Delete
[58] Fix | Delete
if( isset ( $_REQUEST['form_id'] ) ) {
[59] Fix | Delete
$form_id = absint( $_REQUEST['form_id'] );
[60] Fix | Delete
$data = Ninja_Forms()->form( $form_id )->get_all_settings();
[61] Fix | Delete
$form_title = isset ( $data['form_title'] ) ? $data['form_title'] : '';
[62] Fix | Delete
}else{
[63] Fix | Delete
$form_id = '';
[64] Fix | Delete
$data = '';
[65] Fix | Delete
$form_title = '';
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
if( !isset( $ninja_forms_admin_update_message ) AND isset( $_REQUEST['update_message'] ) ){
[69] Fix | Delete
$ninja_forms_admin_update_message = esc_html( $_REQUEST['update_message'] );
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
$output_form = isset ( $ninja_forms_tabs[$current_page][$current_tab]['output_form'] ) ? $ninja_forms_tabs[$current_page][$current_tab]['output_form'] : true;
[73] Fix | Delete
[74] Fix | Delete
$form_method = isset ( $ninja_forms_tabs[$current_page][$current_tab]['form_method'] ) ? $ninja_forms_tabs[$current_page][$current_tab]['form_method'] : 'post';
[75] Fix | Delete
[76] Fix | Delete
$hidden_fields = isset ( $ninja_forms_tabs[$current_page][$current_tab]['hidden_fields'] ) ? $ninja_forms_tabs[$current_page][$current_tab]['hidden_fields'] : true;
[77] Fix | Delete
[78] Fix | Delete
if ( $output_form ) {
[79] Fix | Delete
?>
[80] Fix | Delete
<form id="ninja_forms_admin" enctype="multipart/form-data" method="<?php echo $form_method; ?>">
[81] Fix | Delete
<input type="hidden" name="_page" id="_page" value="<?php echo $current_page;?>">
[82] Fix | Delete
<input type="hidden" name="_tab" id="_tab" value="<?php echo $current_tab;?>">
[83] Fix | Delete
<input type="hidden" name="_form_id" id="_form_id" value="<?php echo $form_id;?>">
[84] Fix | Delete
<input type="hidden" name="_fields_order" id="_fields_order" value="same">
[85] Fix | Delete
<?php
[86] Fix | Delete
wp_nonce_field('_ninja_forms_save','_ninja_forms_admin_submit');
[87] Fix | Delete
}
[88] Fix | Delete
?>
[89] Fix | Delete
<div class="wrap">
[90] Fix | Delete
<?php
[91] Fix | Delete
screen_icon( 'ninja-custom-forms' );
[92] Fix | Delete
if(isset($ninja_forms_tabs[$current_page][$current_tab]['title'])){
[93] Fix | Delete
echo $ninja_forms_tabs[$current_page][$current_tab]['title'];
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
if ( 'form_list' == $current_tab ) {
[97] Fix | Delete
$builder_url = esc_url( add_query_arg( array( 'form_id' => 'new', 'tab' => 'builder' ) ) );
[98] Fix | Delete
?>
[99] Fix | Delete
<h2><?php _e( 'Forms', 'ninja-forms' ); ?> <a href="<?php echo $builder_url; ?>" class="add-new-h2"><?php _e( 'Add New', 'ninja-forms'); ?></a></h2>
[100] Fix | Delete
<?php
[101] Fix | Delete
} else {
[102] Fix | Delete
[103] Fix | Delete
?>
[104] Fix | Delete
<h2 id="nf-display-form-title"><?php echo $form_title; ?></h2>
[105] Fix | Delete
<?php
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
if($ninja_forms_tabs[$current_page][$current_tab]['show_tab_links']){
[109] Fix | Delete
?>
[110] Fix | Delete
<h2 class="nav-tab-wrapper">
[111] Fix | Delete
<?php
[112] Fix | Delete
ninja_forms_display_tabs();
[113] Fix | Delete
if ( ! empty ( $form_id ) ) {
[114] Fix | Delete
$preview_link = ninja_forms_preview_link( $form_id, false );
[115] Fix | Delete
$subs_link = admin_url( 'edit.php?post_status=all&post_type=nf_sub&action=-1&m=0&form_id=' . $form_id . '&begin_date&end_date&paged=1&mode=list&action2=-1' );
[116] Fix | Delete
?>
[117] Fix | Delete
<a href="<?php echo $preview_link; ?>" target="_blank" class="nf-preview button-secondary"><span class="dashicons dashicons-welcome-view-site"></span><?php _e( 'Preview', 'ninja-forms' ); ?></a>
[118] Fix | Delete
<a href="<?php echo $subs_link; ?>" target="_blank" class="nf-subs button-secondary"><span class="dashicons dashicons-email-alt"></span><?php _e( 'Submissions', 'ninja-forms' ); ?></a>
[119] Fix | Delete
<?php } ?>
[120] Fix | Delete
</h2>
[121] Fix | Delete
<?php
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
if( isset( $ninja_forms_admin_update_message ) AND $ninja_forms_admin_update_message != '' ){
[125] Fix | Delete
?>
[126] Fix | Delete
<div id="message" class="updated below-h2">
[127] Fix | Delete
<p>
[128] Fix | Delete
<?php echo $ninja_forms_admin_update_message;?>
[129] Fix | Delete
</p>
[130] Fix | Delete
</div>
[131] Fix | Delete
<?php
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
if(isset($ninja_forms_sidebars[$current_page][$current_tab]) AND is_array($ninja_forms_sidebars[$current_page][$current_tab])){
[135] Fix | Delete
[136] Fix | Delete
?>
[137] Fix | Delete
<div id="nav-menus-frame">
[138] Fix | Delete
<?php ninja_forms_display_sidebars($data); ?>
[139] Fix | Delete
[140] Fix | Delete
</div><!-- /#menu-settings-column -->
[141] Fix | Delete
<?php
[142] Fix | Delete
[143] Fix | Delete
}
[144] Fix | Delete
?>
[145] Fix | Delete
[146] Fix | Delete
<div id="poststuff">
[147] Fix | Delete
<div id="post-body">
[148] Fix | Delete
<div id="post-body-content">
[149] Fix | Delete
<?php
[150] Fix | Delete
[151] Fix | Delete
//Check to see if the registered tab has an metaboxes registered to it.
[152] Fix | Delete
if(isset($ninja_forms_tabs_metaboxes[$current_page][$current_tab]) AND !empty($ninja_forms_tabs_metaboxes[$current_page][$current_tab])){
[153] Fix | Delete
?>
[154] Fix | Delete
<div id="ninja_forms_admin_metaboxes">
[155] Fix | Delete
<?php
[156] Fix | Delete
foreach($ninja_forms_tabs_metaboxes[$current_page][$current_tab] as $slug => $metabox){
[157] Fix | Delete
ninja_forms_output_tab_metabox($form_id, $slug, $metabox);
[158] Fix | Delete
}
[159] Fix | Delete
?>
[160] Fix | Delete
</div>
[161] Fix | Delete
<?php
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
//Check to see if the registered tab has a display function registered.
[165] Fix | Delete
if(isset($ninja_forms_tabs[$current_page][$current_tab]['display_function']) AND $ninja_forms_tabs[$current_page][$current_tab]['display_function'] != ''){
[166] Fix | Delete
$tab_callback = $ninja_forms_tabs[$current_page][$current_tab]['display_function'];
[167] Fix | Delete
$arguments = func_get_args();
[168] Fix | Delete
array_shift($arguments); // We need to remove the first arg ($function_name)
[169] Fix | Delete
$arguments['form_id'] = $form_id;
[170] Fix | Delete
$arguments['data'] = $data;
[171] Fix | Delete
call_user_func_array($tab_callback, $arguments);
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
if(isset($ninja_forms_tabs[$current_page][$current_tab]['show_save']) AND $ninja_forms_tabs[$current_page][$current_tab]['show_save'] === true){ ?>
[175] Fix | Delete
<br />
[176] Fix | Delete
<input class="button-primary menu-save ninja-forms-save-data" id="ninja_forms_save_data_top" type="submit" value="<?php _e( 'Save', 'ninja-forms' ); ?>" />
[177] Fix | Delete
<?php
[178] Fix | Delete
}
[179] Fix | Delete
?>
[180] Fix | Delete
[181] Fix | Delete
</div><!-- /#post-body-content -->
[182] Fix | Delete
</div><!-- /#post-body -->
[183] Fix | Delete
</div>
[184] Fix | Delete
</div>
[185] Fix | Delete
<!-- </div>/.wrap-->
[186] Fix | Delete
<?php
[187] Fix | Delete
if ( $output_form ) {
[188] Fix | Delete
?>
[189] Fix | Delete
</form>
[190] Fix | Delete
<?php
[191] Fix | Delete
}
[192] Fix | Delete
?>
[193] Fix | Delete
[194] Fix | Delete
[195] Fix | Delete
<?php
[196] Fix | Delete
} //End ninja_edit_forms function
[197] Fix | Delete
[198] Fix | Delete
if(is_admin()){
[199] Fix | Delete
require_once(ABSPATH . 'wp-admin/includes/post.php');
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
function ninja_forms_get_current_tab(){
[203] Fix | Delete
global $ninja_forms_tabs;
[204] Fix | Delete
if(isset($_REQUEST['page'])){
[205] Fix | Delete
$current_page = esc_html( $_REQUEST['page'] );
[206] Fix | Delete
[207] Fix | Delete
[208] Fix | Delete
if(isset($_REQUEST['tab'])){
[209] Fix | Delete
$current_tab = esc_html( $_REQUEST['tab'] );
[210] Fix | Delete
}else{
[211] Fix | Delete
if(isset($ninja_forms_tabs[$current_page]) AND is_array($ninja_forms_tabs[$current_page])){
[212] Fix | Delete
$first_tab = array_slice($ninja_forms_tabs[$current_page], 0, 1);
[213] Fix | Delete
foreach($first_tab as $key => $val){
[214] Fix | Delete
$current_tab = $key;
[215] Fix | Delete
}
[216] Fix | Delete
}else{
[217] Fix | Delete
$current_tab = '';
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
return $current_tab;
[221] Fix | Delete
}else{
[222] Fix | Delete
return false;
[223] Fix | Delete
}
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
function ninja_forms_date_to_datepicker($date){
[227] Fix | Delete
$pattern = array(
[228] Fix | Delete
[229] Fix | Delete
//day
[230] Fix | Delete
'd', //day of the month
[231] Fix | Delete
'j', //3 letter name of the day
[232] Fix | Delete
'l', //full name of the day
[233] Fix | Delete
'z', //day of the year
[234] Fix | Delete
[235] Fix | Delete
//month
[236] Fix | Delete
'F', //Month name full
[237] Fix | Delete
'M', //Month name short
[238] Fix | Delete
'n', //numeric month no leading zeros
[239] Fix | Delete
'm', //numeric month leading zeros
[240] Fix | Delete
[241] Fix | Delete
//year
[242] Fix | Delete
'Y', //full numeric year
[243] Fix | Delete
'y' //numeric year: 2 digit
[244] Fix | Delete
);
[245] Fix | Delete
$replace = array(
[246] Fix | Delete
'dd','d','DD','o',
[247] Fix | Delete
'MM','M','m','mm',
[248] Fix | Delete
'yy','y'
[249] Fix | Delete
);
[250] Fix | Delete
foreach($pattern as &$p) {
[251] Fix | Delete
$p = '/'.$p.'/';
[252] Fix | Delete
}
[253] Fix | Delete
return preg_replace($pattern,$replace,$date);
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
function str_putcsv( $array, $delimiter = ',', $enclosure = '"', $terminator = "\n" ) {
[257] Fix | Delete
// First convert associative array to numeric indexed array
[258] Fix | Delete
$workArray = array();
[259] Fix | Delete
foreach ($array as $key => $value) {
[260] Fix | Delete
$workArray[] = $value;
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
$returnString = ''; # Initialize return string
[264] Fix | Delete
$arraySize = count( $workArray ); # Get size of array
[265] Fix | Delete
[266] Fix | Delete
for ( $i=0; $i<$arraySize; $i++ ) {
[267] Fix | Delete
// Nested array, process nest item
[268] Fix | Delete
if ( is_array( $workArray[$i] ) ) {
[269] Fix | Delete
$returnString .= str_putcsv( $workArray[$i], $delimiter, $enclosure, $terminator );
[270] Fix | Delete
} else {
[271] Fix | Delete
switch ( gettype( $workArray[$i] ) ) {
[272] Fix | Delete
// Manually set some strings
[273] Fix | Delete
case "NULL": $_spFormat = ''; break;
[274] Fix | Delete
case "boolean": $_spFormat = ($workArray[$i] == true) ? 'true': 'false'; break;
[275] Fix | Delete
// Make sure sprintf has a good datatype to work with
[276] Fix | Delete
case "integer": $_spFormat = '%i'; break;
[277] Fix | Delete
case "double": $_spFormat = '%0.2f'; break;
[278] Fix | Delete
case "string": $_spFormat = '%s'; $workArray[$i] = str_replace("$enclosure", "$enclosure$enclosure", $workArray[$i]); break;
[279] Fix | Delete
// Unknown or invalid items for a csv - note: the datatype of array is already handled above, assuming the data is nested
[280] Fix | Delete
case "object":
[281] Fix | Delete
case "resource":
[282] Fix | Delete
default: $_spFormat = ''; break;
[283] Fix | Delete
}
[284] Fix | Delete
$returnString .= sprintf('%2$s'.$_spFormat.'%2$s', $workArray[$i], $enclosure);
[285] Fix | Delete
$returnString .= ($i < ($arraySize-1)) ? $delimiter : $terminator;
[286] Fix | Delete
}
[287] Fix | Delete
}
[288] Fix | Delete
// Done the workload, return the output information
[289] Fix | Delete
return $returnString;
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function