Advertisement
Guest User

Untitled

a guest
May 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2.  
  3. // Avoid losing drafted changes by alerting other users with editing roles
  4. // that the current page has a draft.
  5.  
  6. // Place the code below in a plugin file or in functions.php
  7.  
  8. // NOTES:
  9. // The alert will only display for users with `edit_posts` capability
  10. // when the builder is open. Triggered by the 'fl_body_open' hook, which is part
  11. // of the Beaver Builder Theme.
  12.  
  13. add_action( 'fl_body_open', function(){
  14.  
  15. // if current user can edit posts
  16. if ( current_user_can('edit_posts') ) :
  17. if (
  18. // if in Edit mode
  19. isset($_GET['fl_builder'])
  20. // and the page has drafted changes
  21. && FLBuilderModel::layout_has_drafted_changes() ) :
  22.  
  23. $style = '<style type="text/css">
  24. .bb-draft-warning {
  25. background-color: #ff6961;
  26. padding: 5px;
  27. color: #fff;
  28. text-align: center;
  29. }
  30. </style>';
  31.  
  32. // Throw alert on the page
  33. echo $style . '<div class="bb-draft-warning">This page has drafted changes.</div>';
  34. endif;
  35. endif;
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement