Ninja Tables – WP Data Table Plugin for WordPress - Version 4.3.2

Version Description

Download this release

Release Info

Developer adreastrian
Plugin Icon 128x128 Ninja Tables – WP Data Table Plugin for WordPress
Version 4.3.2
Comparing to
See all releases

Code changes from version 4.3.1 to 4.3.2

admin/NinjaTablesAdmin.php CHANGED
@@ -1078,7 +1078,7 @@ class NinjaTablesAdmin
1078
  if (is_array($value)) {
1079
  $value = implode(', ', $value);
1080
  }
1081
- $temp[] = $value;
1082
  }
1083
  array_push($exportData, $temp);
1084
  }
@@ -1155,7 +1155,7 @@ class NinjaTablesAdmin
1155
 
1156
  header('Content-type: application/json');
1157
 
1158
- echo json_encode($data);
1159
 
1160
  die();
1161
  }
@@ -1188,8 +1188,8 @@ class NinjaTablesAdmin
1188
  title: '<?php _e('Insert Ninja Tables Shortcode', 'ninja-tables') ?>',
1189
  select_error: '<?php _e('Please select a table'); ?>',
1190
  insert_text: '<?php _e('Insert Shortcode', 'ninja-tables'); ?>',
1191
- tables: <?php echo json_encode($tables);?>,
1192
- logo: '<?php echo NINJA_TABLES_DIR_URL . 'assets/img/ninja-table-editor-button-2x.png'; ?>'
1193
  }
1194
  </script>
1195
  <?php
@@ -1219,9 +1219,9 @@ class NinjaTablesAdmin
1219
 
1220
  foreach ($tables as $table) {
1221
  $formatted[] = array(
1222
- 'text' => $table->post_title,
1223
  'value' => $table->ID,
1224
- 'data_source' => ninja_table_get_data_provider($table->ID)
1225
  );
1226
  }
1227
 
@@ -1374,22 +1374,12 @@ class NinjaTablesAdmin
1374
  $formatted_data = array_slice($formatted_data, 0, 25);
1375
  }
1376
 
1377
- echo self::loadView('public/views/table_inner_html', array(
1378
  'table_columns' => $formattedColumns,
1379
  'table_rows' => $formatted_data
1380
  ));
1381
  }
1382
 
1383
- private static function loadView($file, $data)
1384
- {
1385
- $file = NINJA_TABLES_DIR_PATH . $file . '.php';
1386
- ob_start();
1387
- extract($data);
1388
- include $file;
1389
-
1390
- return ob_get_clean();
1391
- }
1392
-
1393
  public function checkDBMigrations()
1394
  {
1395
  $this->migrateIdAndTableIdColumn();
1078
  if (is_array($value)) {
1079
  $value = implode(', ', $value);
1080
  }
1081
+ $temp[] = ninjaTablesSanitizeForCSV($value);
1082
  }
1083
  array_push($exportData, $temp);
1084
  }
1155
 
1156
  header('Content-type: application/json');
1157
 
1158
+ echo json_encode($data); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1159
 
1160
  die();
1161
  }
1188
  title: '<?php _e('Insert Ninja Tables Shortcode', 'ninja-tables') ?>',
1189
  select_error: '<?php _e('Please select a table'); ?>',
1190
  insert_text: '<?php _e('Insert Shortcode', 'ninja-tables'); ?>',
1191
+ tables: <?php echo json_encode($tables); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $tables is already escaped before being passed in. ?>,
1192
+ logo: '<?php echo esc_url(NINJA_TABLES_DIR_URL . 'assets/img/ninja-table-editor-button-2x.png'); ?>'
1193
  }
1194
  </script>
1195
  <?php
1219
 
1220
  foreach ($tables as $table) {
1221
  $formatted[] = array(
1222
+ 'text' => esc_attr($table->post_title),
1223
  'value' => $table->ID,
1224
+ 'data_source' => esc_attr(ninja_table_get_data_provider($table->ID))
1225
  );
1226
  }
1227
 
1374
  $formatted_data = array_slice($formatted_data, 0, 25);
1375
  }
1376
 
1377
+ echo ninjaTablesLoadView('public/views/table_inner_html', array(
1378
  'table_columns' => $formattedColumns,
1379
  'table_rows' => $formatted_data
1380
  ));
1381
  }
1382
 
 
 
 
 
 
 
 
 
 
 
1383
  public function checkDBMigrations()
1384
  {
1385
  $this->migrateIdAndTableIdColumn();
admin/partials/deactive_form.php CHANGED
@@ -10,7 +10,7 @@
10
  <li class="reason">
11
  <label>
12
  <span>
13
- <input class="<?php echo esc_attr(($reason['has_custom']) ? 'has_custom' : ''); ?>" type="radio" name="selected-reason" value="<?php echo esc_attr($reason_key); ?>">
14
  </span>
15
  <span><?php echo esc_attr($reason['label']); ?></span>
16
  </label>
10
  <li class="reason">
11
  <label>
12
  <span>
13
+ <input class="<?php echo $reason['has_custom'] ? 'has_custom' : ''; ?>" type="radio" name="selected-reason" value="<?php echo esc_attr($reason_key); ?>">
14
  </span>
15
  <span><?php echo esc_attr($reason['label']); ?></span>
16
  </label>
admin/table-builder/ImportExport.php CHANGED
@@ -8,14 +8,13 @@ class ImportExport
8
  $tableTitle = get_the_title($tableId);
9
  $fileName = sanitize_title($tableTitle, 'Export-Table-' . date('Y-m-d-H-i-s'), 'preview');
10
  $tableData = get_post_meta($tableId, '_ninja_table_builder_table_data', true);
11
- $format = esc_attr($_REQUEST['format']);
12
 
13
  if ($format === 'csv') {
14
  static::exportCSV($tableData, $fileName);
15
  } elseif ($format === 'json') {
16
  static::exportJSON($tableId, $fileName);
17
  }
18
-
19
  }
20
 
21
  public static function import()
@@ -99,9 +98,14 @@ class ImportExport
99
  $values = '';
100
  foreach ($columns['columns'] as $key => $item) {
101
  if (is_array($item['data']['value'])) {
102
- $values .= implode(",", $item['data']['value']);
 
 
 
 
 
103
  } else {
104
- $values .= " " . $item['data']['value'];
105
  }
106
  }
107
  $cols[] = $values;
@@ -163,4 +167,4 @@ class ImportExport
163
 
164
  return static::import();
165
  }
166
- }
8
  $tableTitle = get_the_title($tableId);
9
  $fileName = sanitize_title($tableTitle, 'Export-Table-' . date('Y-m-d-H-i-s'), 'preview');
10
  $tableData = get_post_meta($tableId, '_ninja_table_builder_table_data', true);
11
+ $format = sanitize_text_field($_REQUEST['format']);
12
 
13
  if ($format === 'csv') {
14
  static::exportCSV($tableData, $fileName);
15
  } elseif ($format === 'json') {
16
  static::exportJSON($tableId, $fileName);
17
  }
 
18
  }
19
 
20
  public static function import()
98
  $values = '';
99
  foreach ($columns['columns'] as $key => $item) {
100
  if (is_array($item['data']['value'])) {
101
+ $tmp = [];
102
+ foreach ($item['data']['value'] as $value) {
103
+ $tmp[] = ninjaTablesSanitizeForCSV($value);
104
+ }
105
+
106
+ $values .= implode(",", $tmp);
107
  } else {
108
+ $values .= " " . ninjaTablesSanitizeForCSV($item['data']['value']);
109
  }
110
  }
111
  $cols[] = $values;
167
 
168
  return static::import();
169
  }
170
+ }
admin/table-builder/NinjaTableBuilder.php CHANGED
@@ -89,8 +89,8 @@ class NinjaTableBuilder
89
  public function update()
90
  {
91
  $table_id = intval($_REQUEST['table_id']);
92
- $table_html = sanitize_post_field('table_html', $_REQUEST['table_html'], $table_id, 'db');
93
- $json = sanitize_post_field('data', $_REQUEST['data'], $table_id, 'db');
94
  $data = json_decode(stripcslashes($json), true);
95
 
96
  $table_name = ArrayHelper::get($data, 'table_data.table_name');
89
  public function update()
90
  {
91
  $table_id = intval($_REQUEST['table_id']);
92
+ $table_html = ninjaTablesEscapeScript($_REQUEST['table_html']);
93
+ $json = ninjaTablesEscapeScript($_REQUEST['data']);
94
  $data = json_decode(stripcslashes($json), true);
95
 
96
  $table_name = ArrayHelper::get($data, 'table_data.table_name');
includes/ProcessDemoPage.php CHANGED
@@ -47,7 +47,7 @@ class ProcessDemoPage
47
  $table = get_post($table_id);
48
 
49
  if ($table) {
50
- echo ninjaTableLoadView('public/views/frameless/show_ntb_preview', [
51
  'table_id' => $table_id
52
  ]);
53
  exit;
@@ -55,4 +55,4 @@ class ProcessDemoPage
55
  }
56
  }
57
  }
58
- }
47
  $table = get_post($table_id);
48
 
49
  if ($table) {
50
+ echo ninjaTablesLoadView('public/views/frameless/show_ntb_preview', [
51
  'table_id' => $table_id
52
  ]);
53
  exit;
55
  }
56
  }
57
  }
58
+ }
includes/libs/TableDrivers/views/ninja_foo_table.php CHANGED
@@ -1,9 +1,9 @@
1
  <div id="footable_parent_<?php echo esc_attr($table_id); ?>"
2
  <?php
3
- $loader = esc_attr($tableArray['settings']['frontend_loader']);
4
  $loader_class = $loader === 'no' ? 'ninja-footable-loader' : '';
5
  ?>
6
- class="<?php echo $loader_class;?> footable_parent ninja_table_wrapper loading_ninja_table wp_table_data_press_parent <?php echo esc_attr($settings['css_lib']); ?> <?php echo esc_attr($tableHasColor); ?>">
7
  <?php if (isset($settings['show_title']) && $settings['show_title']) : ?>
8
  <?php do_action('ninja_tables_before_table_title', $table); ?>
9
  <h3 class="table_title footable_title"><?php echo esc_attr($table->post_title); ?></h3>
@@ -40,7 +40,7 @@
40
  <?php endif; ?>
41
 
42
  <?php if (is_user_logged_in() && ninja_table_admin_role()): ?>
43
- <a class="nt_edit_link" href="<?php echo esc_url_raw(admin_url('admin.php?page=ninja_tables#/tables/' . $table->ID)); ?>">
44
  <?php _e('Edit Table', 'ninja-tables') ?>
45
  </a>
46
  <?php endif; ?>
1
  <div id="footable_parent_<?php echo esc_attr($table_id); ?>"
2
  <?php
3
+ $loader = \NinjaTables\Classes\ArrayHelper::get($settings, 'frontend_loader', 'yes');
4
  $loader_class = $loader === 'no' ? 'ninja-footable-loader' : '';
5
  ?>
6
+ class="<?php echo esc_attr($loader_class);?> footable_parent ninja_table_wrapper loading_ninja_table wp_table_data_press_parent <?php echo esc_attr($settings['css_lib']); ?> <?php echo esc_attr($tableHasColor); ?>">
7
  <?php if (isset($settings['show_title']) && $settings['show_title']) : ?>
8
  <?php do_action('ninja_tables_before_table_title', $table); ?>
9
  <h3 class="table_title footable_title"><?php echo esc_attr($table->post_title); ?></h3>
40
  <?php endif; ?>
41
 
42
  <?php if (is_user_logged_in() && ninja_table_admin_role()): ?>
43
+ <a class="nt_edit_link" href="<?php echo esc_url(admin_url('admin.php?page=ninja_tables#/tables/' . $table->ID)); ?>">
44
  <?php _e('Edit Table', 'ninja-tables') ?>
45
  </a>
46
  <?php endif; ?>
includes/ninja_tables-global-functions.php CHANGED
@@ -1081,8 +1081,7 @@ if (!function_exists('ninjaTablesEscCss')) {
1081
  }
1082
  }
1083
 
1084
- if (!function_exists('ninjaTableLoadView')) {
1085
- function ninjaTableLoadView( $file, $data = [] )
1086
  {
1087
  $file = NINJA_TABLES_DIR_PATH . $file . '.php';
1088
  ob_start();
@@ -1095,5 +1094,55 @@ if (!function_exists('ninjaTableLoadView')) {
1095
 
1096
  return ob_get_clean();
1097
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1098
  }
1099
 
1081
  }
1082
  }
1083
 
1084
+ function ninjaTablesLoadView( $file, $data = [] )
 
1085
  {
1086
  $file = NINJA_TABLES_DIR_PATH . $file . '.php';
1087
  ob_start();
1094
 
1095
  return ob_get_clean();
1096
  }
1097
+
1098
+ /**
1099
+ * Checks if a string starts with something
1100
+ *
1101
+ * @param string $haystack
1102
+ * @param array $needles
1103
+ *
1104
+ * @return bool
1105
+ */
1106
+ function ninjaTablesStartsWith($haystack, $needles)
1107
+ {
1108
+ if (is_array($haystack)) {
1109
+ $haystack = implode(' ', $haystack);
1110
+ }
1111
+
1112
+ foreach ((array) $needles as $needle) {
1113
+ if ('' != $needle && substr($haystack, 0, strlen($needle)) === (string) $needle) {
1114
+ return true;
1115
+ }
1116
+ }
1117
+
1118
+ return false;
1119
+ }
1120
+
1121
+ /**
1122
+ * Sanitizes CSV value
1123
+ *
1124
+ * @param string $content
1125
+ *
1126
+ * @return string $content
1127
+ */
1128
+ function ninjaTablesSanitizeForCSV($content)
1129
+ {
1130
+ $formulas = ['=', '-', '+', '@', "\t", "\r"];
1131
+
1132
+ if (ninjaTablesStartsWith($content, $formulas)) {
1133
+ $content = "'" . $content;
1134
+ }
1135
+
1136
+ return $content;
1137
+ }
1138
+
1139
+ /**
1140
+ * @param string $data
1141
+ *
1142
+ * @return mixed $data
1143
+ */
1144
+ function ninjaTablesEscapeScript($data)
1145
+ {
1146
+ return preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', '', $data);
1147
  }
1148
 
ninja-tables.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Ninja Tables
17
  * Plugin URI: https://wpmanageninja.com/downloads/ninja-tables-pro-add-on/
18
  * Description: The Easiest & Fastest Responsive Table Plugin on WordPress. Multiple templates, drag-&-drop live table builder, multiple color scheme, and styles.
19
- * Version: 4.3.1
20
  * Author: WPManageNinja LLC
21
  * Author URI: https://wpmanageninja.com/
22
  * License: GPL-2.0+
@@ -34,7 +34,7 @@ define('NINJA_TABLES_BASENAME', plugin_basename(__FILE__));
34
  define('NINJA_TABLES_DIR_URL', plugin_dir_url(__FILE__));
35
  define('NINJA_TABLES_DIR_PATH', plugin_dir_path(__FILE__));
36
  define('NINJA_TABLES_PUBLIC_DIR_URL', NINJA_TABLES_DIR_URL . 'public/');
37
- define('NINJA_TABLES_VERSION', '4.3.1');
38
  define('NINJA_TABLES_ASSET_VERSION', '3.1.0');
39
  define('NINJA_TABLES_PRELOAD_FONT_VERSION', "1a82860cb5286f7833a2c33fbdd1d76c");
40
 
16
  * Plugin Name: Ninja Tables
17
  * Plugin URI: https://wpmanageninja.com/downloads/ninja-tables-pro-add-on/
18
  * Description: The Easiest & Fastest Responsive Table Plugin on WordPress. Multiple templates, drag-&-drop live table builder, multiple color scheme, and styles.
19
+ * Version: 4.3.2
20
  * Author: WPManageNinja LLC
21
  * Author URI: https://wpmanageninja.com/
22
  * License: GPL-2.0+
34
  define('NINJA_TABLES_DIR_URL', plugin_dir_url(__FILE__));
35
  define('NINJA_TABLES_DIR_PATH', plugin_dir_path(__FILE__));
36
  define('NINJA_TABLES_PUBLIC_DIR_URL', NINJA_TABLES_DIR_URL . 'public/');
37
+ define('NINJA_TABLES_VERSION', '4.3.2');
38
  define('NINJA_TABLES_ASSET_VERSION', '3.1.0');
39
  define('NINJA_TABLES_PRELOAD_FONT_VERSION', "1a82860cb5286f7833a2c33fbdd1d76c");
40
 
public/NinjaTablePublic.php CHANGED
@@ -499,7 +499,7 @@ class NinjaTablePublic
499
 
500
  do_action('ninja_table_builder_before_render', $table_id);
501
 
502
- return ninjaTableLoadView('public/views/table_builder_html', [
503
  'ninja_table_builder_html' => $html,
504
  'table_data' => $ninja_table_builder_table_data,
505
  'setting' => $ninja_table_builder_setting,
499
 
500
  do_action('ninja_table_builder_before_render', $table_id);
501
 
502
+ return ninjaTablesLoadView('public/views/table_builder_html', [
503
  'ninja_table_builder_html' => $html,
504
  'table_data' => $ninja_table_builder_table_data,
505
  'setting' => $ninja_table_builder_setting,
public/views/frameless/show_ntb_preview.php CHANGED
@@ -23,29 +23,29 @@
23
  <div class="nt_preview_header_title">
24
  <ul>
25
  <li>
26
- [ninja_table_builder id="<?php echo $table_id; ?>"]
27
  </li>
28
  </ul>
29
  </div>
30
  <div class="nt_preview_header_action">
31
- <a href="<?php echo admin_url('admin.php?page=ninja_tables#/table_builder_edit_table/' . $table_id) ?>">Edit</a>
32
  </div>
33
  </div>
34
 
35
  <div class="nt_preview_body">
36
  <div class="nt_preview_body_wrapper">
37
- <?php echo do_shortcode('[ninja_table_builder id="' . $table_id . '"]'); ?>
38
  </div>
39
  </div>
40
  <div class="nt_preview_fotter">
41
  <p class="nt_preview_fotter_text">You are seeing preview version of Ninja Tables. This table is only accessible
42
  for Admin users. Other users
43
  may not access this page. To use this for in a page please use the following shortcode: [ninja_table_builder
44
- id='<?php echo $table_id ?>']</p>
45
  </div>
46
  </div>
47
  <?php
48
  wp_footer();
49
  ?>
50
  </body>
51
- </html>
23
  <div class="nt_preview_header_title">
24
  <ul>
25
  <li>
26
+ [ninja_table_builder id="<?php echo esc_attr($table_id); ?>"]
27
  </li>
28
  </ul>
29
  </div>
30
  <div class="nt_preview_header_action">
31
+ <a href="<?php echo esc_url(admin_url('admin.php?page=ninja_tables#/table_builder_edit_table/' . $table_id)) ?>">Edit</a>
32
  </div>
33
  </div>
34
 
35
  <div class="nt_preview_body">
36
  <div class="nt_preview_body_wrapper">
37
+ <?php echo do_shortcode('[ninja_table_builder id="' . esc_attr($table_id) . '"]'); ?>
38
  </div>
39
  </div>
40
  <div class="nt_preview_fotter">
41
  <p class="nt_preview_fotter_text">You are seeing preview version of Ninja Tables. This table is only accessible
42
  for Admin users. Other users
43
  may not access this page. To use this for in a page please use the following shortcode: [ninja_table_builder
44
+ id='<?php echo esc_attr($table_id) ?>']</p>
45
  </div>
46
  </div>
47
  <?php
48
  wp_footer();
49
  ?>
50
  </body>
51
+ </html>
public/views/frameless/show_preview.php CHANGED
@@ -33,7 +33,7 @@
33
  <div class="nt_preview_body">
34
  <div class="nt_preview_body_wrapper">
35
  <?php // The shortcode HTML is already escaped line by line at table_inner_html.php ?>
36
- <?php echo do_shortcode('[ninja_tables id="' . $table_id . '"]'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
37
  </div>
38
  </div>
39
  <div class="nt_preview_fotter">
33
  <div class="nt_preview_body">
34
  <div class="nt_preview_body_wrapper">
35
  <?php // The shortcode HTML is already escaped line by line at table_inner_html.php ?>
36
+ <?php echo do_shortcode('[ninja_tables id="' . esc_attr($table_id) . '"]'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
37
  </div>
38
  </div>
39
  <div class="nt_preview_fotter">
public/views/table_builder_html.php CHANGED
@@ -22,12 +22,12 @@ if (isset($setting['general']['options']['container_max_height']['value'])) {
22
  }
23
  ?>
24
 
25
- <div class="ntb_table_wrapper" data-responsive='<?php echo json_encode($responsive) ?>'
26
- id='ninja_table_builder_<?php echo $table_id; ?>'
27
  style="
28
- <?php echo "max-height:$max_height" . "px" ?>;
29
- <?php echo $max_width != '' ? "max-width: $max_width" . "px;" . $alignment : 'max-width: 1160px'; ?>;">
30
  <?php
31
- echo $ninja_table_builder_html;
32
  ?>
33
- </div>
22
  }
23
  ?>
24
 
25
+ <div class="ntb_table_wrapper" data-responsive='<?php esc_attr_e(json_encode($responsive)); ?>'
26
+ id='ninja_table_builder_<?php esc_attr_e($table_id); ?>'
27
  style="
28
+ <?php esc_attr_e("max-height:$max_height" . "px"); ?>;
29
+ <?php esc_attr_e($max_width != '' ? "max-width: $max_width" . "px;" . $alignment : 'max-width: 1160px'); ?>;">
30
  <?php
31
+ ninjaTablesPrintSafeVar($ninja_table_builder_html);
32
  ?>
33
+ </div>
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://wpmanageninja.com/downloads/ninja-tables-pro-add-on/
4
  Tags: table builder, table plugin, wpdatatables, wordpress tables, table grid, charts, wp table, datatables plugin, csv, tablepress migration, footable plugin, tabular data, stackable table, spreadsheet data, WooCommerce product table, Amazon affiliate table, bootstrap table, drag-and-drop
5
  Requires at least: 4.5
6
  Requires PHP: 5.6
7
- Tested up to: 6.0
8
- Stable tag: 4.3.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -260,6 +260,11 @@ You can connect your Google spreadsheets to your WordPress table plugin by using
260
  Over the past two years of development, we released several updates for Ninja Tables. These include improvements to the existing features and some wonderful additions to help you design tables more effectively.
261
  ### What's New on 4.3.1?
262
 
 
 
 
 
 
263
  = 4.3.1 (Date: October 13, 2022) =
264
  * Fixes responsive issue for drag & drop table
265
  * Added global importer for drag & drop table
4
  Tags: table builder, table plugin, wpdatatables, wordpress tables, table grid, charts, wp table, datatables plugin, csv, tablepress migration, footable plugin, tabular data, stackable table, spreadsheet data, WooCommerce product table, Amazon affiliate table, bootstrap table, drag-and-drop
5
  Requires at least: 4.5
6
  Requires PHP: 5.6
7
+ Tested up to: 6.1
8
+ Stable tag: 4.3.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
260
  Over the past two years of development, we released several updates for Ninja Tables. These include improvements to the existing features and some wonderful additions to help you design tables more effectively.
261
  ### What's New on 4.3.1?
262
 
263
+ = 4.3.1 (Date: October 19, 2022) =
264
+ * Fixes frontend loader notice issue
265
+ * Added phpcs
266
+ * Improves data sanitization
267
+
268
  = 4.3.1 (Date: October 13, 2022) =
269
  * Fixes responsive issue for drag & drop table
270
  * Added global importer for drag & drop table