Advertisement
Guest User

wordpress post update filter

a guest
Sep 9th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement