@@ -268,7 +268,7 @@ public function shortcode_metabox_display( $post ) {
268268
269269
270270 /**
271- * Save meta box for cbxchangelog
271+ * Save meta box
272272 *
273273 * @param $post_id
274274 * @param $post
@@ -321,7 +321,8 @@ public function metabox_save( $post_id, $post, $update ) {
321321
322322 $ meta_data = CBXChangelogHelper::get_changelog_data ( $ post_id );
323323 $ used_keys = $ meta_data ->getUsedKeys ();
324-
324+ //let's reset as we need to honor the index order to display
325+ $ meta_data ->resetRows ();
325326
326327 foreach ( $ submitted_values as $ value ) {
327328 $ valid_change_log = [];
@@ -333,11 +334,6 @@ public function metabox_save( $post_id, $post, $update ) {
333334 $ valid_change_log ['date ' ] = isset ( $ value ['date ' ] ) ? sanitize_text_field ( wp_unslash ( $ value ['date ' ] ) ) : '' ;
334335 $ valid_change_log ['note ' ] = isset ( $ value ['note ' ] ) ? sanitize_textarea_field ( wp_unslash ( $ value ['note ' ] ) ) : '' ;
335336
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-
341337 //labels
342338 if ( isset ( $ value ['label ' ] ) && is_array ( $ value ['label ' ] ) ) {
343339 $ value ['label ' ] = array_filter ( $ value ['label ' ] );
@@ -378,15 +374,23 @@ public function metabox_save( $post_id, $post, $update ) {
378374 //end features
379375
380376 //if ( $id > 0 && in_array( $id, $used_keys ) ) {
381- if ( $ id > 0 ) {
377+ /* if ( $id > 0 ) {
382378 //update
383379 $meta_data->update( $id, $valid_change_log );
384380 } else {
385381 //add
386382 $meta_data->insert( $valid_change_log );
387383 //$used_keys = $meta_data->getUsedKeys();
384+ }*/
385+
386+
387+ if ($ id > 0 ){
388+ $ valid_change_log ['id ' ] = $ id ;
388389 }
389390
391+ $ meta_data ->insert ( $ valid_change_log );
392+
393+
390394 unset( $ valid_change_log );
391395 //$valid_change_logs[] = $valid_change_log;
392396 }//end for each
@@ -406,9 +410,17 @@ public function metabox_save( $post_id, $post, $update ) {
406410 $ extras ['show_label ' ] = isset ( $ extras ['show_label ' ] ) ? intval ( $ extras ['show_label ' ] ) : 1 ;
407411 $ extras ['show_date ' ] = isset ( $ extras ['show_date ' ] ) ? intval ( $ extras ['show_date ' ] ) : 1 ;
408412 $ 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+ }
412424
413425 //now update post meta
414426 update_post_meta ( $ post_id , '_cbxchangelog_extra ' , $ extras );
@@ -420,7 +432,6 @@ public function metabox_save( $post_id, $post, $update ) {
420432
421433
422434 do_action ( 'cbxchangelog_meta_save ' , $ post_id , $ post , $ update );
423-
424435 }//end metabox_save
425436
426437 /**
@@ -961,15 +972,16 @@ public function custom_message_after_plugin_row_proaddon( $plugin_file, $plugin_
961972 }
962973
963974 $ pro_addon_version = CBXChangelogHelper::get_any_plugin_version ( 'cbxchangelogpro/cbxchangelogpro.php ' );
975+ $ pro_latest_version = '1.1.6 ' ;
964976
965977
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 , '< ' ) ) {
967979 // Custom message to display
968980 $ plugin_manual_update = 'https://codeboxr.com/manual-update-pro-addon/ ' ;
969981
970982 /* 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 ' => [] ] ] );
973985
974986 // Output a row with custom content
975987 echo '<tr class="plugin-update-tr">
@@ -1165,6 +1177,11 @@ public function init_changelog_shortcode_block() {
11651177 'value ' => 'order ' ,
11661178 ];
11671179
1180+ $ orderby_options [] = [
1181+ 'label ' => esc_html__ ( 'Release No/ID ' , 'cbxchangelog ' ),
1182+ 'value ' => 'id ' ,
1183+ ];
1184+
11681185 $ orderby_options [] = [
11691186 'label ' => esc_html__ ( 'Date ' , 'cbxchangelog ' ),
11701187 'value ' => 'date ' ,
@@ -1301,9 +1318,14 @@ public function cbxchangelog_block_render( $attr ) {
13011318 $ params ['relative_date ' ] = ( $ params ['relative_date ' ] == 'true ' ) ? 1 : 0 ;
13021319
13031320
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+
13071329
13081330 $ params = apply_filters ( 'cbxchangelog_shortcode_builder_block_attr ' , $ params , $ attr );
13091331
0 commit comments