UM_Admin_Enqueue

The Ultimate Member UM Admin Enqueue class.

Defined (1)

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

/admin/core/um-admin-enqueue.php  
  1. class UM_Admin_Enqueue { 
  2.  
  3. function __construct() { 
  4.  
  5. $this->slug = 'ultimatemember'; 
  6.  
  7. add_action('admin_head', array(&$this, 'admin_head'), 9); 
  8.  
  9. add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'), 9); 
  10.  
  11. add_filter('admin_body_class', array(&$this, 'admin_body_class'), 999 ); 
  12.  
  13. add_filter('enter_title_here', array(&$this, 'enter_title_here') ); 
  14.  
  15.  
  16. /*** 
  17. *** @enter title placeholder 
  18. ***/ 
  19. function enter_title_here( $title ) { 
  20. $screen = get_current_screen(); 
  21. if ( 'um_directory' == $screen->post_type ) { 
  22. $title = 'e.g. Member Directory'; 
  23. if ( 'um_role' == $screen->post_type ) { 
  24. $title = 'e.g. Community Member'; 
  25. if ( 'um_form' == $screen->post_type ) { 
  26. $title = 'e.g. New Registration Form'; 
  27. return $title; 
  28.  
  29. /*** 
  30. *** @Runs on admin head 
  31. ***/ 
  32. function admin_head() { 
  33. global $current_screen, $post; 
  34. $screen_id = $current_screen->id; 
  35.  
  36. if ( $this->is_plugin_post_type() ) { 
  37.  
  38. ?> 
  39.  
  40. <style type="text/css"> 
  41. .um-admin.post-type-<?php echo get_post_type(); ?> div#slugdiv,  
  42. .um-admin.post-type-<?php echo get_post_type(); ?> div#minor-publishing,  
  43. .um-admin.post-type-<?php echo get_post_type(); ?> div#screen-meta-links 
  44. {display:none} 
  45. </style> 
  46.  
  47. <?php 
  48.  
  49.  
  50. /*** 
  51. *** @check that we're on a custom post type supported by UM 
  52. ***/ 
  53. function is_plugin_post_type() { 
  54. if (isset($_REQUEST['post_type'])) { 
  55. $post_type = $_REQUEST['post_type']; 
  56. if ( in_array($post_type, array('um_form', 'um_role', 'um_directory'))) { 
  57. return true; 
  58. } else if ( isset($_REQUEST['action'] ) && $_REQUEST['action'] == 'edit') { 
  59. $post_type = get_post_type(); 
  60. if ( in_array($post_type, array('um_form', 'um_role', 'um_directory'))) { 
  61. return true; 
  62. return false; 
  63.  
  64. /*** 
  65. *** @Load Form 
  66. ***/ 
  67. function load_form() { 
  68.  
  69. wp_register_style('um_admin_form', um_url . 'admin/assets/css/um-admin-form.css' ); 
  70. wp_enqueue_style('um_admin_form'); 
  71.  
  72. wp_register_script('um_admin_form', um_url . 'admin/assets/js/um-admin-form.js', '', '', true ); 
  73. wp_enqueue_script('um_admin_form'); 
  74.  
  75.  
  76. /*** 
  77. *** @Load dashboard 
  78. ***/ 
  79. function load_dashboard() { 
  80.  
  81. wp_register_style('um_admin_dashboard', um_url . 'admin/assets/css/um-admin-dashboard.css' ); 
  82. wp_enqueue_style('um_admin_dashboard'); 
  83.  
  84. wp_register_script('um_admin_dashboard', um_url . 'admin/assets/js/um-admin-dashboard.js', '', '', true ); 
  85. wp_enqueue_script('um_admin_dashboard'); 
  86.  
  87.  
  88. /*** 
  89. *** @Load modal 
  90. ***/ 
  91. function load_modal() { 
  92.  
  93. wp_register_style('um_admin_modal', um_url . 'admin/assets/css/um-admin-modal.css' ); 
  94. wp_enqueue_style('um_admin_modal'); 
  95.  
  96. wp_register_script('um_admin_modal', um_url . 'admin/assets/js/um-admin-modal.js', '', '', true ); 
  97. wp_enqueue_script('um_admin_modal'); 
  98.  
  99.  
  100. /*** 
  101. *** @Field Processing 
  102. ***/ 
  103. function load_field() { 
  104.  
  105. wp_register_script('um_admin_field', um_url . 'admin/assets/js/um-admin-field.js', '', '', true ); 
  106. wp_enqueue_script('um_admin_field'); 
  107.  
  108.  
  109. /*** 
  110. *** @Users table 
  111. ***/ 
  112. function load_users_js() { 
  113.  
  114. wp_register_script('um_admin_users', um_url . 'admin/assets/js/um-admin-users.js', '', '', true ); 
  115. wp_enqueue_script('um_admin_users'); 
  116.  
  117.  
  118. /*** 
  119. *** @Load Builder 
  120. ***/ 
  121. function load_builder() { 
  122.  
  123. wp_register_script('um_admin_builder', um_url . 'admin/assets/js/um-admin-builder.js', '', '', true ); 
  124. wp_enqueue_script('um_admin_builder'); 
  125.  
  126. wp_register_script('um_admin_dragdrop', um_url . 'admin/assets/js/um-admin-dragdrop.js', '', '', true ); 
  127. wp_enqueue_script('um_admin_dragdrop'); 
  128.  
  129. wp_register_style('um_admin_builder', um_url . 'admin/assets/css/um-admin-builder.css' ); 
  130. wp_enqueue_style('um_admin_builder'); 
  131.  
  132.  
  133. /*** 
  134. *** @Load core WP styles/scripts 
  135. ***/ 
  136. function load_core_wp() { 
  137.  
  138. wp_enqueue_style( 'wp-color-picker' ); 
  139. wp_enqueue_script( 'wp-color-picker' ); 
  140.  
  141. wp_enqueue_script('jquery-ui-draggable'); 
  142. wp_enqueue_script('jquery-ui-sortable'); 
  143.  
  144.  
  145. /*** 
  146. *** @Load Admin Styles 
  147. ***/ 
  148. function load_css() { 
  149.  
  150. wp_register_style('um_admin_menu', um_url . 'admin/assets/css/um-admin-menu.css' ); 
  151. wp_enqueue_style('um_admin_menu'); 
  152.  
  153. wp_register_style('um_admin_columns', um_url . 'admin/assets/css/um-admin-columns.css' ); 
  154. wp_enqueue_style('um_admin_columns'); 
  155.  
  156. wp_register_style('um_admin_misc', um_url . 'admin/assets/css/um-admin-misc.css' ); 
  157. wp_enqueue_style('um_admin_misc'); 
  158.  
  159. if ( get_post_type() != 'shop_order' ) { 
  160. wp_register_style('um_admin_select2', um_url . 'admin/assets/css/um-admin-select2.css' ); 
  161. wp_enqueue_style('um_admin_select2'); 
  162.  
  163.  
  164. /*** 
  165. *** @Load global css 
  166. ***/ 
  167. function load_global_css() { 
  168.  
  169. wp_register_style('um_admin_global', um_url . 'admin/assets/css/um-admin-global.css' ); 
  170. wp_enqueue_style('um_admin_global'); 
  171.  
  172.  
  173. /*** 
  174. *** @Load jQuery custom code 
  175. ***/ 
  176. function load_custom_scripts() { 
  177.  
  178. wp_register_script('um_admin_scripts', um_url . 'admin/assets/js/um-admin-scripts.js', '', '', true ); 
  179. wp_enqueue_script('um_admin_scripts'); 
  180.  
  181.  
  182. /*** 
  183. *** @Load AJAX 
  184. ***/ 
  185. function load_ajax_js() { 
  186.  
  187. wp_register_script('um_admin_ajax', um_url . 'admin/assets/js/um-admin-ajax.js', '', '', true ); 
  188. wp_enqueue_script('um_admin_ajax'); 
  189.  
  190.  
  191. /*** 
  192. *** @Load Redux css 
  193. ***/ 
  194. function load_redux_css() { 
  195.  
  196. wp_register_style('um_admin_redux', um_url . 'admin/assets/css/um-admin-redux.css' ); 
  197. wp_enqueue_style('um_admin_redux'); 
  198.  
  199.  
  200. /*** 
  201. *** @Boolean check if we're viewing UM backend 
  202. ***/ 
  203. function is_UM_admin() { 
  204.  
  205. global $current_screen, $post; 
  206.  
  207. $screen_id = $current_screen->id; 
  208.  
  209. if ( !is_admin() ) return false; 
  210.  
  211. if ( strstr( $screen_id, 'ultimatemember') || strstr( $screen_id, 'um_') || strstr($screen_id, 'user') || strstr($screen_id, 'profile') )return true; 
  212.  
  213. if ( $screen_id == 'nav-menus' ) return true; 
  214.  
  215. if ( isset( $post->post_type ) ) return true; 
  216.  
  217. return false; 
  218.  
  219.  
  220. /*** 
  221. *** @Adds class to our admin pages 
  222. ***/ 
  223. function admin_body_class($classes) { 
  224. if ( $this->is_UM_admin() ) { 
  225. return "$classes um-admin"; 
  226. return $classes;  
  227.  
  228. /*** 
  229. *** @Enqueue scripts and styles 
  230. ***/ 
  231. function admin_enqueue_scripts() { 
  232. global $ultimatemember, $post; 
  233.  
  234. if ( $this->is_UM_admin() ) { 
  235.  
  236. if ( get_post_type() != 'shop_order' ) { 
  237. $ultimatemember->styles->wp_enqueue_scripts(); 
  238.  
  239. $this->load_global_css(); 
  240. $this->load_form(); 
  241. $this->load_modal(); 
  242. $this->load_dashboard(); 
  243. $this->load_field(); 
  244. $this->load_users_js(); 
  245. $this->load_builder(); 
  246. $this->load_redux_css(); 
  247. $this->load_css(); 
  248. $this->load_core_wp(); 
  249. $this->load_ajax_js(); 
  250. $this->load_custom_scripts(); 
  251.  
  252. if ( is_rtl() ) { 
  253. wp_register_style('um_admin_rtl', um_url . 'admin/assets/css/um-admin-rtl.css' ); 
  254. wp_enqueue_style('um_admin_rtl'); 
  255.  
  256. } else { 
  257.  
  258. $this->load_global_css(); 
  259.  
  260.  
  261.