--- a/ninja-tables/app/Models/Post.php
+++ b/ninja-tables/app/Models/Post.php
@@ -25,7 +25,10 @@
}
});
$total = $posts->count();
- $posts = $posts->orderBy($orderBy, $args['order'])
+ $orderByType = Arr::get($args, 'order');
+ $orderByType = in_array(strtoupper($orderByType), ['ASC', 'DESC']) ? $orderByType : 'DESC';
+
+ $posts = $posts->orderBy($orderBy, $orderByType)
->skip($args['offset'])
->take($args['posts_per_page'])
->get();
@@ -129,7 +132,7 @@
update_post_meta($tableId, '_ninja_table_columns', $tableColumns);
if ($provider === 'default') {
NinjaTableItem::where('table_id', $tableId)->delete();
- }
+ }
} elseif (is_array($rawColumns) && ! empty($rawColumns)) {
foreach ($rawColumns as $column) {
foreach ($column as $column_index => $column_value) {
--- a/ninja-tables/app/Modules/DataProviders/DefaultProvider.php
+++ b/ninja-tables/app/Modules/DataProviders/DefaultProvider.php
@@ -104,14 +104,15 @@
$columns = ninja_table_get_table_columns($tableId);
$sortingColumn = Arr::get($settings, 'sorting_column');
$sortingColumnBy = Arr::get($settings, 'sorting_column_by', 'asc');
+ $sortingColumnBy = in_array(strtoupper($sortingColumnBy), ['ASC', 'DESC']) ? $sortingColumnBy : 'DESC';
$column = Arr::first($columns, function ($column) use ($sortingColumn) {
return Arr::get($column, 'key') === $sortingColumn;
});
- $dataType = Arr::get($column, 'data_type');
-
- $dateFormat = Arr::get($column, 'dateFormat');
+ $dataType = Arr::get($column, 'data_type');
+ $dateFormat = Arr::get($column, 'dateFormat');
+ $sortingColumn = Arr::get($column, 'key');
if ($dataType === 'number') {
$query->orderByRaw("CAST(JSON_UNQUOTE(JSON_EXTRACT(value, '$.$sortingColumn')) AS SIGNED) " . $sortingColumnBy);
--- a/ninja-tables/app/Modules/FluentCart/Traits/FluentCartTrait.php
+++ b/ninja-tables/app/Modules/FluentCart/Traits/FluentCartTrait.php
@@ -49,6 +49,7 @@
$orderBy = Arr::get($queryConditions, 'order_by');
$orderByType = Arr::get($queryConditions, 'order_by_type');
+ $orderByType = in_array(strtoupper($orderByType), ["ASC", "DESC"]) ? $orderByType : 'DESC';
$categories = Arr::get($querySelection, 'product-categories');
//TODO: rename product-types to product-brands
$brands = Arr::get($querySelection, 'product-types');
--- a/ninja-tables/app/Modules/Gutenberg/GutenbergModule.php
+++ b/ninja-tables/app/Modules/Gutenberg/GutenbergModule.php
@@ -37,7 +37,7 @@
'preview_required_scripts' => array(
$assets . "css/ninjatables-public.css",
$assets . "css/ninja-table-builder-public.css",
- includes_url( '/js/dist/vendor/moment.min.js' ),
+ includes_url('/js/dist/vendor/moment.min.js'),
$assets . "libs/footable/js/footable.min.js",
$assets . "js/ninja-tables-footable.js",
// $assets . "js/ninja-table-builder-public.js",
@@ -128,6 +128,19 @@
$tablePreference = ninja_tables_sanitize_array($tableSettings);
}
- Post::updatedSettings($tableId, $rawColumns, $tablePreference);
+ if (!empty($tablePreference['sorting_column_by'])) {
+ $direction = strtoupper($tablePreference['sorting_column_by']);
+ if (!in_array($direction, ['ASC', 'DESC'], true)) {
+ $tablePreference['sorting_column_by'] = 'DESC';
+ }
+ }
+
+ if (!empty($tablePreference['sorting_column'])) {
+ $tablePreference['sorting_column'] = sanitize_key($tablePreference['sorting_column']);
+ }
+
+ $mergedSettings = wp_parse_args($tablePreference, ninjaTablesGetDefaultSettings());
+
+ Post::updatedSettings($tableId, $rawColumns, $mergedSettings);
}
}
--- a/ninja-tables/assets/blocks/index.php
+++ b/ninja-tables/assets/blocks/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/blocks/table-block/index.php
+++ b/ninja-tables/assets/blocks/table-block/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/css/index.php
+++ b/ninja-tables/assets/css/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/icons/index.php
+++ b/ninja-tables/assets/icons/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/images/index.php
+++ b/ninja-tables/assets/images/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/img/index.php
+++ b/ninja-tables/assets/img/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/js/fluent-cart/index.php
+++ b/ninja-tables/assets/js/fluent-cart/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/js/index.php
+++ b/ninja-tables/assets/js/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/libs/ace/index.php
+++ b/ninja-tables/assets/libs/ace/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/libs/footable/css/index.php
+++ b/ninja-tables/assets/libs/footable/css/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/libs/footable/index.php
+++ b/ninja-tables/assets/libs/footable/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/libs/footable/js/index.php
+++ b/ninja-tables/assets/libs/footable/js/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/libs/icons/index.php
+++ b/ninja-tables/assets/libs/icons/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/assets/libs/index.php
+++ b/ninja-tables/assets/libs/index.php
@@ -1,3 +0,0 @@
-<?php
-
-// Silence is golden
No newline at end of file
--- a/ninja-tables/ninja-tables.php
+++ b/ninja-tables/ninja-tables.php
@@ -5,7 +5,7 @@
/**
Plugin Name: Ninja Tables – Easy Data Table Builder
Description: The Easiest & Fastest Responsive Table Plugin on WordPress. Multiple templates, drag-&-drop live table builder, multiple color scheme, and styles.
-Version: 5.2.4
+Version: 5.2.5
Author: WPManageNinja LLC
Author URI: https://ninjatables.com/
Plugin URI: https://wpmanageninja.com/downloads/ninja-tables-pro-add-on/
@@ -18,7 +18,7 @@
define('NINJA_TABLES_DIR_URL', plugin_dir_url(__FILE__));
define('NINJA_TABLES_DIR_PATH', plugin_dir_path(__FILE__));
-define('NINJA_TABLES_VERSION', '5.2.4');
+define('NINJA_TABLES_VERSION', '5.2.5');
define('NINJA_TABLES_BASENAME', plugin_basename(__FILE__));
call_user_func(function ($bootstrap) {