Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. class MyPlugin {
  2.  
  3. function __construct() {
  4. add_shortcode('ShowMsg', [$this,'ShowMsg']);
  5.  
  6. //add_action( 'admin_menu', [$this,'load_starter_tab'] );
  7. add_action( 'admin_menu',
  8. function () {
  9. add_menu_page( 'Publications Upload', 'Publications Upload',
  10. 'manage_options', 'ha_pubs_load', [$this,'load_starter']);
  11. } );
  12. }
  13.  
  14. function ShowMsg($atts) {
  15. $data = shortcode_atts(array('phn' => '', 'msg' => ''), $atts);
  16. return 'You sent '.$data['msg'] .' from '.$data['phn'] ;
  17. }
  18.  
  19. /* not necessary see construct */
  20. function make_shortcode() {
  21. add_shortcode('ShowMsg', [$this,'ShowMsg']);
  22. }
  23.  
  24. /* not necessary see construct */
  25. function add_form() {
  26. add_action( 'admin_menu', [$this,'load_starter_tab'] );
  27. }
  28.  
  29.  
  30. /* see alternate usage with anonymous function*/
  31. function load_starter_tab() {
  32. add_menu_page( 'Publications Upload', 'Publications Upload', 'manage_options', 'ha_pubs_load', [$this,'load_starter']);
  33. }
  34.  
  35. function load_starter() {
  36. ?><h1>HERE YOU ARE!</h1>
  37. <?php
  38. }
  39.  
  40. }
  41.  
  42.  
  43. new MyPlugin;
Add Comment
Please, Sign In to add comment