calderawpmetaplateadminpage

Class page.

Defined (1)

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

/vendor/calderawp/metaplate-admin/src/page.php  
  1. class page extends init { 
  2.  
  3. /** 
  4. * Start up 
  5. */ 
  6. public function __construct() { 
  7.  
  8. // add admin page 
  9. add_action( 'admin_menu', array( $this, 'add_settings_pages' ), 25 ); 
  10. // Load admin style sheet and JavaScript. 
  11. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_stylescripts' ) 
  12. ); 
  13.  
  14. add_action( 'admin_init', array( $this, 'define_admin_template_path' ) ); 
  15.  
  16.  
  17.  
  18. /** 
  19. * Add options page 
  20. */ 
  21. public function add_settings_pages() { 
  22. // This page will be under "Settings" 
  23.  
  24.  
  25. $this->plugin_screen_hook_suffix['metaplate'] = add_submenu_page( 'themes.php', __( 'Metaplate', $this->plugin_slug ), __( 'Metaplate', $this->plugin_slug ), 'manage_options', 'metaplate', array( $this, 'create_admin_page' ) ); 
  26. add_action( 'admin_print_styles-' . $this->plugin_screen_hook_suffix['metaplate'], array( $this, 'enqueue_admin_stylescripts' ) ); 
  27.  
  28.  
  29.  
  30. /** 
  31. * Options page callback 
  32. */ 
  33. public function create_admin_page() { 
  34. // Set class property 
  35. $screen = get_current_screen(); 
  36. $base = array_search($screen->id, $this->plugin_screen_hook_suffix); 
  37.  
  38. $path = dirname( __FILE__ ) .'/includes/'; 
  39.  
  40. // include main template 
  41. if( empty( $_GET['edit'] ) ) { 
  42. include $path .'/admin.php'; 
  43. }else{ 
  44. include $path .'/edit.php'; 
  45.  
  46.  
  47. // php based script include 
  48. if( file_exists( $path .'assets/js/inline-scripts.php' ) ) { 
  49. echo "<script type=\"text/javascript\">\r\n"; 
  50. include $path .'assets/js/inline-scripts.php'; 
  51. echo "</script>\r\n"; 
  52.  
  53.  
  54. /** 
  55. * Register and enqueue admin-specific style sheet. 
  56. * @return null 
  57. */ 
  58. public function enqueue_admin_stylescripts() { 
  59.  
  60. $screen = get_current_screen(); 
  61. $path = MTPT_URL . '/vendor/calderawp/metaplate-admin-assets/src/assets/'; 
  62.  
  63. if( false !== strpos( $screen->base, 'metaplate' ) ) { 
  64.  
  65. wp_enqueue_style( 'metaplate-core-style', $path . 'css/styles.css' ); 
  66. wp_enqueue_style( 'metaplate-baldrick-modals', $path . 'css/modals.css' ); 
  67. wp_enqueue_script( 'metaplate-wp-baldrick', $path . 'js/wp-baldrick-full.min.js', array( 'jquery' ) , false, true ); 
  68. wp_enqueue_script( 'jquery-ui-autocomplete' ); 
  69. wp_enqueue_style( 'wp-color-picker' ); 
  70. wp_enqueue_script( 'wp-color-picker' ); 
  71.  
  72. if( !empty( $_GET['edit'] ) ) { 
  73. wp_enqueue_style( 'metaplate-codemirror-style', $path . 'css/codemirror.css' ); 
  74. wp_enqueue_script( 'metaplate-codemirror-script', $path . 'js/codemirror.js', array( 'jquery' ) , false ); 
  75.  
  76. wp_enqueue_script( 'metaplate-core-script', $path . 'js/scripts.min.js', array( 'metaplate-wp-baldrick' ) , false ); 
  77.  
  78.  
  79.  
  80.  
  81.  
  82. public function define_admin_template_path() { 
  83. if ( ! defined( 'MTPT_ADMIN_TEMPLATE_PATH' ) ) { 
  84. $path = $this->template_package_path(); 
  85. $path = $path . 'templates/'; 
  86.  
  87. define( 'MTPT_ADMIN_TEMPLATE_PATH', $path ); 
  88.  
  89.  
  90. public function template_package_path() { 
  91. return MTPT_CALDERAWP_PATH . 'metaplate-admin-templates/src/'; 
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.