Want more features on Pastebin? Sign Up, it's FREE!
Guest

wordpress post update filter

By: a guest on Sep 9th, 2011  |  syntax: PHP  |  size: 0.80 KB  |  views: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. add_filter('wp_insert_post_data', 'initiate_sectionize', 99);
  2. function initiate_sectionize($data) {
  3.     $processed_content = sectionize($data['post_content']);
  4.     if(is_array($processed_content)) {
  5.     $data['post_content'] = $processed_content[1];
  6.     add_filter('redirect_post_location', 'sectionize_location_filter', 99);
  7.         }
  8.     else {
  9.     $data['post_content'] = $processed_content;
  10.     }
  11.   return $data;  
  12. }
  13.  
  14. function sectionize_location_filter($location) {
  15.   remove_filter('redirect_post_location', __FUNCTION__, 99);
  16.   $location = add_query_arg('message', 99, $location);
  17.   return $location;
  18. }
  19.  
  20. add_filter('post_updated_messages', 'sectionize_messages_filter');
  21. function sectionize_messages_filter($messages) {
  22.   $messages['post'][99] = 'Something went wrong';
  23.   return $messages;
  24. }
clone this paste RAW Paste Data