@@ -56,28 +56,27 @@ public function makeFaqSortable( $wp_query ) {
56
56
}
57
57
}
58
58
59
- // public function saveSort( $post_id ){
60
59
public function savePostMeta ( $ postID ){
61
60
if ( ! current_user_can ( 'edit_post ' , $ postID ) || ! isset ( $ _POST ['sortfield ' ] ) || ( defined ( 'DOING_AUTOSAVE ' ) && DOING_AUTOSAVE ) ){
62
61
return $ postID ;
63
62
}
64
- update_post_meta ( $ postID , 'source ' , 'website ' );
65
- $ lang = substr ( get_locale (), 0 , 2 );
66
- update_post_meta ( $ postID , 'lang ' , $ lang );
63
+ $ source = ( empty ( $ _POST [ 'source ' ]) ? 'website ' : sanitize_text_field ( $ _POST [ ' source ' ] ) );
64
+ update_post_meta ( $ postID , ' source ' , $ source );
65
+ update_post_meta ( $ postID , 'lang ' , substr ( get_locale (), 0 , 2 ) );
67
66
update_post_meta ( $ postID , 'remoteID ' , $ postID );
68
- $ remoteChanged = get_post_timestamp ( $ postID , 'modified ' );
69
- update_post_meta ( $ postID , 'remoteChanged ' , $ remoteChanged );
67
+ update_post_meta ( $ postID , 'remoteChanged ' , get_post_timestamp ( $ postID , 'modified ' ) );
70
68
update_post_meta ( $ postID , 'sortfield ' , sanitize_text_field ( $ _POST ['sortfield ' ] ) );
71
69
}
72
70
73
71
public function sortboxCallback ( $ meta_id ) {
74
- $ output = '<input type="text" name="sortfield" id="sortfield" class="sortfield" value=" ' . esc_attr (get_post_meta ( $ meta_id ->ID , 'sortfield ' , TRUE )) .'"> ' ;
72
+ $ output = '<input type="hidden" name="source" id="source" value=" ' . esc_attr (get_post_meta ( $ meta_id ->ID , 'source ' , TRUE )) .'"> ' ;
73
+ $ output .= '<input type="text" name="sortfield" id="sortfield" class="sortfield" value=" ' . esc_attr (get_post_meta ( $ meta_id ->ID , 'sortfield ' , TRUE )) .'"> ' ;
75
74
$ output .= '<p class="description"> ' . __ ( 'Criterion for sorting the output of the shortcode ' , 'rrze-faq ' ) . '</p> ' ;
76
75
echo $ output ;
77
76
}
78
77
79
78
public function langboxCallback ( $ meta_id ) {
80
- $ output = '<input type="text" name="sortfield " id="sortfield " class="sortfield " value=" ' . esc_attr (get_post_meta ( $ meta_id ->ID , 'lang ' , TRUE )) .'"> ' ;
79
+ $ output = '<input type="text" name="lang " id="lang " class="lang " value=" ' . esc_attr (get_post_meta ( $ meta_id ->ID , 'lang ' , TRUE )) .'"> ' ;
81
80
$ output .= '<p class="description"> ' . __ ( 'Language of this FAQ ' , 'rrze-faq ' ) . '</p> ' ;
82
81
echo $ output ;
83
82
}
0 commit comments