Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class My_Plugin {
  2.  
  3. private $error;
  4.  
  5. public function __construct()
  6. {
  7. add_shortcode('my_plugin_form', array($this, 'form_shortcode'));
  8. }
  9.  
  10. public function setError($value)
  11. {
  12. $this->error = $value;
  13. }
  14.  
  15. public function getError()
  16. {
  17. return $this->error;
  18. }
  19.  
  20. public function form_validation()
  21. {
  22. // Validation has failed
  23. $this->setError('Please complete all of the fields.');
  24. }
  25.  
  26. public function form_shortcode()
  27. {
  28. $err = $this->getError();
  29.  
  30. ob_start();
  31.  
  32. // Some HTML
  33.  
  34. $this->getError();
  35.  
  36. // Some more HTML
  37.  
  38. $html = ob_get_contents();
  39. ob_end_clean();
  40. return $html;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement