GFPDFModelModel_Welcome_Screen

Model_Welcome_Screen.

Defined (1)

The class is defined in the following location(s).

/src/model/Model_Welcome_Screen.php  
  1. class Model_Welcome_Screen extends Helper_Abstract_Model { 
  2.  
  3. /** 
  4. * @var string The capability users should have to view the page 
  5. * @since 4.0 
  6. */ 
  7. public $minimum_capability = 'read'; 
  8.  
  9. /** 
  10. * @var string The welcome page title 
  11. * @since 4.0 
  12. */ 
  13. public $welcome_title; 
  14.  
  15. /** 
  16. * @var string The updated page title 
  17. * @since 4.0 
  18. */ 
  19. public $updated_title; 
  20.  
  21. /** 
  22. * Holds our log class 
  23. * @var LoggerInterface 
  24. * @since 4.0 
  25. */ 
  26. protected $log; 
  27.  
  28. /** 
  29. * Setup our view with the needed data and classes 
  30. * @param LoggerInterface $log Our logger class 
  31. * @since 4.0 
  32. */ 
  33. public function __construct( LoggerInterface $log ) { 
  34.  
  35. /** Assign our internal variables */ 
  36. $this->log = $log; 
  37.  
  38. $this->welcome_title = esc_html__( 'Welcome to Gravity PDF', 'gravity-forms-pdf-extended' ); 
  39. $this->updated_title = esc_html__( "What's new in Gravity PDF?", 'gravity-forms-pdf-extended' ); 
  40.  
  41. /** 
  42. * Register the Dashboard Welcome pages and then hide them so they aren't displayed in the navigation 
  43. * @since 4.0 
  44. * @return void 
  45. */ 
  46. public function admin_menus() { 
  47. $controller = $this->getController(); 
  48.  
  49. add_dashboard_page( 
  50. $this->welcome_title,  
  51. $this->welcome_title,  
  52. $this->minimum_capability,  
  53. 'gfpdf-getting-started',  
  54. [ $controller, 'getting_started_screen' ] 
  55. ); 
  56.  
  57. add_dashboard_page( 
  58. $this->updated_title,  
  59. $this->updated_title,  
  60. $this->minimum_capability,  
  61. 'gfpdf-update',  
  62. [ $controller, 'update_screen' ] 
  63. ); 
  64.  
  65. /** 
  66. * Hide the new dashboard pages we registered in self::admin_menus() 
  67. * We had to move this to the "admin_head" action instead of all in one place 
  68. * because it was causing authentication problems for some users. 
  69. * @since 4.0 
  70. * @return void 
  71. */ 
  72. public function hide_admin_menus() { 
  73. remove_submenu_page( 'index.php', 'gfpdf-getting-started' ); 
  74. remove_submenu_page( 'index.php', 'gfpdf-update' ); 
  75.  
  76. /** 
  77. * Because we want to hide our welcome pages (using remove_submenu_page) our page titles no longer work 
  78. * This method will fix that 
  79. * @param string $title The page title 
  80. * @return string 
  81. */ 
  82. public function add_page_title( $title ) { 
  83.  
  84. switch ( rgget( 'page' ) ) { 
  85. case 'gfpdf-getting-started': 
  86. $this->log->addNotice( 'Display Welcome Screen' ); 
  87.  
  88. return $this->welcome_title; 
  89. break; 
  90.  
  91. case 'gfpdf-update': 
  92. $this->log->addNotice( 'Display Update Screen' ); 
  93.  
  94. return $this->updated_title; 
  95. break; 
  96.  
  97. return $title;