@@ -268,7 +268,7 @@ public function shortcode_metabox_display( $post ) {
268
268
269
269
270
270
/**
271
- * Save meta box for cbxchangelog
271
+ * Save meta box
272
272
*
273
273
* @param $post_id
274
274
* @param $post
@@ -321,7 +321,8 @@ public function metabox_save( $post_id, $post, $update ) {
321
321
322
322
$ meta_data = CBXChangelogHelper::get_changelog_data ( $ post_id );
323
323
$ used_keys = $ meta_data ->getUsedKeys ();
324
-
324
+ //let's reset as we need to honor the index order to display
325
+ $ meta_data ->resetRows ();
325
326
326
327
foreach ( $ submitted_values as $ value ) {
327
328
$ valid_change_log = [];
@@ -333,11 +334,6 @@ public function metabox_save( $post_id, $post, $update ) {
333
334
$ valid_change_log ['date ' ] = isset ( $ value ['date ' ] ) ? sanitize_text_field ( wp_unslash ( $ value ['date ' ] ) ) : '' ;
334
335
$ valid_change_log ['note ' ] = isset ( $ value ['note ' ] ) ? sanitize_textarea_field ( wp_unslash ( $ value ['note ' ] ) ) : '' ;
335
336
336
- //$valid_change_log['version'] = $version;
337
- //$valid_change_log['url'] = $url;
338
- //$valid_change_log['date'] = $date;
339
- //$valid_change_log['note'] = $note;
340
-
341
337
//labels
342
338
if ( isset ( $ value ['label ' ] ) && is_array ( $ value ['label ' ] ) ) {
343
339
$ value ['label ' ] = array_filter ( $ value ['label ' ] );
@@ -378,15 +374,23 @@ public function metabox_save( $post_id, $post, $update ) {
378
374
//end features
379
375
380
376
//if ( $id > 0 && in_array( $id, $used_keys ) ) {
381
- if ( $ id > 0 ) {
377
+ /* if ( $id > 0 ) {
382
378
//update
383
379
$meta_data->update( $id, $valid_change_log );
384
380
} else {
385
381
//add
386
382
$meta_data->insert( $valid_change_log );
387
383
//$used_keys = $meta_data->getUsedKeys();
384
+ }*/
385
+
386
+
387
+ if ($ id > 0 ){
388
+ $ valid_change_log ['id ' ] = $ id ;
388
389
}
389
390
391
+ $ meta_data ->insert ( $ valid_change_log );
392
+
393
+
390
394
unset( $ valid_change_log );
391
395
//$valid_change_logs[] = $valid_change_log;
392
396
}//end for each
@@ -406,9 +410,17 @@ public function metabox_save( $post_id, $post, $update ) {
406
410
$ extras ['show_label ' ] = isset ( $ extras ['show_label ' ] ) ? intval ( $ extras ['show_label ' ] ) : 1 ;
407
411
$ extras ['show_date ' ] = isset ( $ extras ['show_date ' ] ) ? intval ( $ extras ['show_date ' ] ) : 1 ;
408
412
$ extras ['relative_date ' ] = isset ( $ extras ['relative_date ' ] ) ? intval ( $ extras ['relative_date ' ] ) : 0 ;
409
- $ extras ['layout ' ] = isset ( $ extras ['layout ' ] ) ? esc_attr ( wp_unslash ( $ extras ['layout ' ] ) ) : 'prepros ' ;
410
- $ extras ['order ' ] = isset ( $ extras ['order ' ] ) ? esc_attr ( wp_unslash ( $ extras ['order ' ] ) ) : 'desc ' ;
411
- $ extras ['orderby ' ] = isset ( $ extras ['orderby ' ] ) ? esc_attr ( wp_unslash ( $ extras ['orderby ' ] ) ) : 'order ' ;
413
+ $ extras ['layout ' ] = isset ( $ extras ['layout ' ] ) ? sanitize_text_field ( wp_unslash ( $ extras ['layout ' ] ) ) : 'prepros ' ;
414
+ $ extras ['order ' ] = isset ( $ extras ['order ' ] ) ? sanitize_text_field ( wp_unslash ( $ extras ['order ' ] ) ) : 'desc ' ;
415
+ $ extras ['orderby ' ] = isset ( $ extras ['orderby ' ] ) ? sanitize_text_field ( wp_unslash ( $ extras ['orderby ' ] ) ) : 'order ' ; //'order' == 'default'
416
+
417
+ if (!in_array ($ extras ['orderby ' ], ['order ' , 'id ' , 'date ' ])){
418
+ $ extras ['orderby ' ] = 'order ' ;
419
+ }
420
+
421
+ if (!in_array ($ extras ['order ' ], ['desc ' , 'asc ' ])){
422
+ $ extras ['order ' ] = 'desc ' ;
423
+ }
412
424
413
425
//now update post meta
414
426
update_post_meta ( $ post_id , '_cbxchangelog_extra ' , $ extras );
@@ -420,7 +432,6 @@ public function metabox_save( $post_id, $post, $update ) {
420
432
421
433
422
434
do_action ( 'cbxchangelog_meta_save ' , $ post_id , $ post , $ update );
423
-
424
435
}//end metabox_save
425
436
426
437
/**
@@ -961,15 +972,16 @@ public function custom_message_after_plugin_row_proaddon( $plugin_file, $plugin_
961
972
}
962
973
963
974
$ pro_addon_version = CBXChangelogHelper::get_any_plugin_version ( 'cbxchangelogpro/cbxchangelogpro.php ' );
975
+ $ pro_latest_version = '1.1.6 ' ;
964
976
965
977
966
- if ( $ pro_addon_version != '' && version_compare ( $ pro_addon_version , ' 1.1.6 ' , '< ' ) ) {
978
+ if ( $ pro_addon_version != '' && version_compare ( $ pro_addon_version , $ pro_latest_version , '< ' ) ) {
967
979
// Custom message to display
968
980
$ plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/ ' ;
969
981
970
982
/* translators:translators: %s: plugin setting url for licence */
971
- $ custom_message = wp_kses ( sprintf ( __ ( '<strong>Note:</strong> CBX Changelog Pro Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin \'s current version is older than 1.1.6 . To get the latest pro addon features, this plugin needs to upgrade to 1.1.6 or later.</strong> ' , 'cbxchangelog ' ),
972
- esc_url ( $ plugin_manual_update ) ), [ 'strong ' => [ 'style ' => [] ], 'a ' => [ 'href ' => [], 'target ' => [] ] ] );
983
+ $ custom_message = wp_kses ( sprintf ( __ ( '<strong>Note:</strong> CBX Changelog Pro Addon is custom plugin. This plugin can not be auto update from dashboard/plugin manager. For manual update please check <a target="_blank" href="%1$s">documentation</a>. <strong style="color: red;">It seems this plugin \'s current version is older than %2$s . To get the latest pro addon features, this plugin needs to upgrade to %2$s or later.</strong> ' , 'cbxchangelog ' ),
984
+ esc_url ( $ plugin_manual_update ), $ pro_latest_version ), [ 'strong ' => [ 'style ' => [] ], 'a ' => [ 'href ' => [], 'target ' => [] ] ] );
973
985
974
986
// Output a row with custom content
975
987
echo '<tr class="plugin-update-tr">
@@ -1165,6 +1177,11 @@ public function init_changelog_shortcode_block() {
1165
1177
'value ' => 'order ' ,
1166
1178
];
1167
1179
1180
+ $ orderby_options [] = [
1181
+ 'label ' => esc_html__ ( 'Release No/ID ' , 'cbxchangelog ' ),
1182
+ 'value ' => 'id ' ,
1183
+ ];
1184
+
1168
1185
$ orderby_options [] = [
1169
1186
'label ' => esc_html__ ( 'Date ' , 'cbxchangelog ' ),
1170
1187
'value ' => 'date ' ,
@@ -1301,9 +1318,14 @@ public function cbxchangelog_block_render( $attr ) {
1301
1318
$ params ['relative_date ' ] = ( $ params ['relative_date ' ] == 'true ' ) ? 1 : 0 ;
1302
1319
1303
1320
1304
- $ params ['layout ' ] = isset ( $ attr ['layout ' ] ) ? sanitize_text_field ( $ attr ['layout ' ] ) : 'prepros ' ;
1305
- $ params ['order ' ] = isset ( $ attr ['order ' ] ) ? sanitize_text_field ( $ attr ['order ' ] ) : 'desc ' ;
1306
- $ params ['orderby ' ] = isset ( $ attr ['orderby ' ] ) ? sanitize_text_field ( $ attr ['orderby ' ] ) : 'default ' ;
1321
+ $ params ['layout ' ] = isset ( $ attr ['layout ' ] ) ? sanitize_text_field ( wp_unslash ($ attr ['layout ' ]) ) : 'prepros ' ;
1322
+ $ params ['order ' ] = isset ( $ attr ['order ' ] ) ? sanitize_text_field ( wp_unslash ($ attr ['order ' ]) ) : 'desc ' ;
1323
+ $ params ['orderby ' ] = isset ( $ attr ['orderby ' ] ) ? sanitize_text_field ( wp_unslash ($ attr ['orderby ' ]) ) : 'default ' ;
1324
+
1325
+ if ($ params ['orderby ' ] === 'order ' ){
1326
+ $ params ['orderby ' ] = 'default ' ;
1327
+ }
1328
+
1307
1329
1308
1330
$ params = apply_filters ( 'cbxchangelog_shortcode_builder_block_attr ' , $ params , $ attr );
1309
1331
0 commit comments