Jetpack_Admin_Page

The Jetpack by WordPress.com Jetpack Admin Page class.

Defined (1)

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

/_inc/lib/admin-pages/class.jetpack-admin-page.php  
  1. abstract class Jetpack_Admin_Page { 
  2. // Add page specific actions given the page hook 
  3. abstract function add_page_actions( $hook ); 
  4.  
  5. // Create a menu item for the page and returns the hook 
  6. abstract function get_page_hook(); 
  7.  
  8. // Enqueue and localize page specific scripts 
  9. abstract function page_admin_scripts(); 
  10.  
  11. // Render page specific HTML 
  12. abstract function page_render(); 
  13.  
  14. function __construct() { 
  15. $this->jetpack = Jetpack::init(); 
  16.  
  17. function add_actions() { 
  18. /** 
  19. * Don't add in the modules page unless modules are available! 
  20. */ 
  21. if ( $this->dont_show_if_not_active && ! Jetpack::is_active() && ! Jetpack::is_development_mode() ) { 
  22. return; 
  23.  
  24. // Initialize menu item for the page in the admin 
  25. $hook = $this->get_page_hook(); 
  26.  
  27. // Attach hooks common to all Jetpack admin pages based on the created 
  28. // hook 
  29. add_action( "load-$hook", array( $this, 'admin_help' ) ); 
  30. add_action( "load-$hook", array( $this, 'admin_page_load' ) ); 
  31. add_action( "admin_head-$hook", array( $this, 'admin_head' ) ); 
  32.  
  33. add_action( "admin_footer-$hook", array( $this, 'module_modal_js_template' ) ); 
  34.  
  35. add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) ); 
  36. add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) ); 
  37.  
  38. // Attach page specific actions in addition to the above 
  39. $this->add_page_actions( $hook ); 
  40.  
  41. function admin_head() { 
  42. if ( isset( $_GET['configure'] ) && Jetpack::is_module( $_GET['configure'] ) && current_user_can( 'manage_options' ) ) { 
  43. /** 
  44. * Fires in the <head> of a particular Jetpack configuation page. 
  45. * The dynamic portion of the hook name, `$_GET['configure']`,  
  46. * refers to the slug of module, such as 'stats', 'sso', etc. 
  47. * A complete hook for the latter would be 
  48. * 'jetpack_module_configuation_head_sso'. 
  49. * @since 3.0.0 
  50. */ 
  51. do_action( 'jetpack_module_configuration_head_' . $_GET['configure'] ); 
  52.  
  53. // Render the page with a common top and bottom part, and page specific 
  54. // content 
  55. function render() { 
  56. $this->admin_page_top(); 
  57. $this->page_render(); 
  58. $this->admin_page_bottom(); 
  59.  
  60. function admin_help() { 
  61. $this->jetpack->admin_help(); 
  62.  
  63. function admin_page_load() { 
  64. // This is big. For the moment, just call the existing one. 
  65. $this->jetpack->admin_page_load(); 
  66.  
  67. // Load underscore template for the landing page and settings page modal 
  68. function module_modal_js_template() { 
  69. Jetpack::init()->load_view( 'admin/module-modal-template.php' ); 
  70.  
  71. function admin_page_top() { 
  72. include_once( JETPACK__PLUGIN_DIR . '_inc/header.php' ); 
  73.  
  74. function admin_page_bottom() { 
  75. include_once( JETPACK__PLUGIN_DIR . '_inc/footer.php' ); 
  76.  
  77. // Add page specific scripts and jetpack stats for all menu pages 
  78. function admin_scripts() { 
  79. $this->page_admin_scripts(); // Delegate to inheriting class 
  80. add_action( 'admin_footer', array( $this->jetpack, 'do_stats' ) ); 
  81.  
  82. // Enqueue the Jetpack admin stylesheet 
  83. function admin_styles() { 
  84. $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 
  85.  
  86. wp_enqueue_style( 'jetpack-google-fonts', '//fonts.googleapis.com/css?family=Open+Sans:400italic, 400, 700, 600, 800' ); 
  87.  
  88. wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons' ), JETPACK__VERSION . '-20121016' ); 
  89. wp_style_add_data( 'jetpack-admin', 'rtl', 'replace' ); 
  90. wp_style_add_data( 'jetpack-admin', 'suffix', $min );