@@ -621,14 +621,13 @@ public function shortcode_list_handler(): string
621
621
622
622
// Call the function to update the link
623
623
$ shorten_result = ShortURL::shorten ($ aParams );
624
+ $ bUpdated = true ;
624
625
625
626
if ($ shorten_result ['error ' ]) {
626
- // $bUpdated = true;
627
627
self ::$ update_message ['error ' ] = true ;
628
628
self ::$ update_message ['class ' ] = 'notice-error ' ;
629
629
self ::$ update_message ['txt ' ] = $ shorten_result ['message ' ];
630
630
} else {
631
- // $bUpdated = true;
632
631
self ::$ update_message ['error ' ] = false ;
633
632
self ::$ update_message ['class ' ] = 'notice-success ' ;
634
633
self ::$ update_message ['txt ' ] = __ ('Link updated ' , 'rrze-shorturl ' );
@@ -692,7 +691,11 @@ public function shortcode_list_handler(): string
692
691
// $category_filter_form .= ' ' . $checkbox;
693
692
$ category_filter_form .= '</form> ' ;
694
693
695
- // Generate table
694
+ // Display success notice
695
+ if ($ bUpdated && !self ::$ update_message ['error ' ]){
696
+ $ table .= '<div class="notice ' . self ::$ update_message ['class ' ] . ' is-dismissible"><p> ' . self ::$ update_message ['txt ' ] . '</p></div> ' ;
697
+ }
698
+
696
699
$ table .= $ category_filter_form ;
697
700
$ table .= '<table class="shorturl-wp-list-table widefat striped"> ' ;
698
701
$ table .= '<thead><tr> ' ;
@@ -736,14 +739,16 @@ public function shortcode_list_handler(): string
736
739
// $table .= '<td>' . esc_html($uri) . '</td>';
737
740
$ table .= '<td> ' . (!empty ($ valid_until ) ? esc_html ($ valid_until ) : esc_html__ ('indefinite ' , 'rrze-shorturl ' )) . '</td> ' ;
738
741
$ table .= '<td> ' . esc_html ($ category_names_str ) . '</td> ' ;
739
- $ table .= '<td> ' . (self ::$ rights ['idm ' ] == get_post_meta ($ link_id , 'idm ' , true ) || is_user_logged_in () ? '<a href="#" class="edit-link" data-link-id=" ' . esc_attr ($ link_id ) . '"> ' . esc_html__ ('Edit ' , 'rrze-shorturl ' ) . '</a> | <a href="#" data-link-id=" ' . esc_attr ($ link_id ) . '" class="delete-link"> ' . esc_html__ ('Delete ' , 'rrze-shorturl ' ) . '</a> ' : '' ) . '</td> ' ;
742
+ // 2.1.24 : Admins now edit links in backend
743
+ // $table .= '<td>' . (self::$rights['idm'] == get_post_meta($link_id, 'idm', true) || is_user_logged_in() ? '<a href="#" class="edit-link" data-link-id="' . esc_attr($link_id) . '">' . esc_html__('Edit', 'rrze-shorturl') . '</a> | <a href="#" data-link-id="' . esc_attr($link_id) . '" class="delete-link">' . esc_html__('Delete', 'rrze-shorturl') . '</a>' : '') . '</td>';
744
+ $ table .= '<td><a href="#" class="edit-link" data-link-id=" ' . esc_attr ($ link_id ) . '"> ' . esc_html__ ('Edit ' , 'rrze-shorturl ' ) . '</a> | <a href="#" data-link-id=" ' . esc_attr ($ link_id ) . '" class="delete-link"> ' . esc_html__ ('Delete ' , 'rrze-shorturl ' ) . '</a></td> ' ;
740
745
$ table .= '</tr> ' ;
741
746
}
742
747
}
743
748
744
749
$ table .= '</tbody></table> ' ;
745
750
746
- if (!$ bUpdated && !empty ($ results )) {
751
+ if (( !$ bUpdated && !empty ($ results )) || self :: $ update_message [ ' error ' ] ) {
747
752
$ table .= $ this ->display_edit_link_form ();
748
753
}
749
754
@@ -752,7 +757,7 @@ public function shortcode_list_handler(): string
752
757
753
758
private function display_edit_link_form ()
754
759
{
755
- $ link_id = !empty ($ _GET ['link_id ' ]) ? (int ) $ _GET ['link_id ' ] : 0 ;
760
+ $ link_id = ( !empty ($ _GET ['link_id ' ]) ? (int ) $ _GET ['link_id ' ] : (! empty ( $ _POST [ ' link_id ' ]) ? ( int ) $ _POST [ ' link_id ' ] : 0 )) ;
756
761
757
762
if ($ link_id <= 0 ) {
758
763
return '' ;
0 commit comments