PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/api-rest/wp-content/plugins/material-admin/lib/mtrl-topbar.php

https://gitlab.com/neyberbz/suelos-ualm
PHP | 243 lines | 133 code | 66 blank | 44 comment | 104 complexity | 864c71dee4f715191a29cbab36fbaafe MD5 | raw file
  1. <?php
  2. /**
  3. * @Package: WordPress Plugin
  4. * @Subpackage: Material - White Label WordPress Admin Theme Theme
  5. * @Since: Mtrl 1.0
  6. * @WordPress Version: 4.0 or above
  7. * This file is part of Material - White Label WordPress Admin Theme Theme Plugin.
  8. */
  9. ?>
  10. <?php
  11. function mtrl_admintopbar(){
  12. global $mtrladmin;
  13. $mtrladmin = mtrladmin_network($mtrladmin);
  14. if(isset($mtrladmin['enable-topbar']) && $mtrladmin['enable-topbar'] != "1" && $mtrladmin['enable-topbar'] == "0" && !$mtrladmin['enable-topbar']){
  15. echo "<style type='text/css'>#wpadminbar{display: none !important;} html.wp-toolbar{padding-top:0px !important;} #wpcontent{padding-top: 0px !important;} #wpcontent:before{height: 70px !important;position:absolute !important;}</style>";
  16. }
  17. }
  18. function mtrl_wptopbar(){
  19. global $mtrladmin;
  20. $mtrladmin = mtrladmin_network($mtrladmin);
  21. if(isset($mtrladmin['enable-topbar-wp']) && $mtrladmin['enable-topbar-wp'] != "1" && $mtrladmin['enable-topbar-wp'] == "0" && !$mtrladmin['enable-topbar-wp']){
  22. remove_action('wp_footer', 'wp_admin_bar_render', 9);
  23. add_filter('show_admin_bar', '__return_false');
  24. }
  25. }
  26. /*function mtrl_admintopbar_style(){
  27. global $mtrladmin;
  28. $mtrladmin = mtrladmin_network($mtrladmin);
  29. $logomargintop = "-40px";
  30. if(isset($mtrladmin['enable-topbar']) && $mtrladmin['enable-topbar'] != "1" && $mtrladmin['enable-topbar'] == "0" && !$mtrladmin['enable-topbar']){
  31. $logomargintop = "0px";
  32. }
  33. if(isset($mtrladmin['topbar-style']) && $mtrladmin['topbar-style'] != "style1"){
  34. return " #adminmenuback{z-index: 99998 !important;}
  35. #adminmenuwrap{margin-top: ".$logomargintop." !important;z-index: 99999 !important;}
  36. .folded #wpadminbar{padding-left: 46px !important;}
  37. #wpadminbar{padding-left: 230px !important;z-index: 9999 !important;}
  38. .menu-hidden #wpadminbar{padding-left: 0px !important;}
  39. .menu-expanded #wpadminbar{padding-left: 230px !important;}
  40. .menu-collapsed #wpadminbar{padding-left: 46px !important;}
  41. .rtl #adminmenuback{z-index: 99998 !important;}
  42. .rtl #adminmenuwrap{margin-top: ".$logomargintop." !important;z-index: 99999 !important;}
  43. .rtl.folded #wpadminbar{padding-right: 46px !important;padding-left: 0px!important;}
  44. .rtl #wpadminbar{padding-right: 230px !important;padding-left: 0px !important;z-index: 9999 !important;}
  45. .rtl.menu-hidden #wpadminbar{padding-left: 0px !important;padding-right: 0px !important;}
  46. .rtl.menu-expanded #wpadminbar{padding-right: 230px !important;padding-left: 0px !important;}
  47. .rtl.menu-collapsed #wpadminbar{padding-right: 46px !important;padding-left: 0px !important;}
  48. ";
  49. }
  50. }*/
  51. function mtrl_admintopbar_links(){
  52. global $mtrladmin;
  53. $mtrladmin = mtrladmin_network($mtrladmin);
  54. //print_r($mtrladmin);
  55. $str = "";
  56. $element = 'enable-topbar-links-wp';
  57. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  58. $str .= "#wp-admin-bar-wp-logo{display:none;}";
  59. }
  60. $element = 'enable-topbar-links-site';
  61. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  62. $str .= "#wp-admin-bar-site-name{display:none;}";
  63. }
  64. $element = 'enable-topbar-links-comments';
  65. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  66. $str .= "#wp-admin-bar-comments{display:none;}";
  67. }
  68. $element = 'enable-topbar-links-new';
  69. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  70. $str .= "#wp-admin-bar-new-content{display:none;}";
  71. }
  72. $element = 'enable-topbar-links-mtrladmin';
  73. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  74. $str .= "#wp-admin-bar-_mtrloptions{display:none;}";
  75. }
  76. /*$element = 'user-profile-style';
  77. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "style2"){
  78. $str .= "#wp-admin-bar-my-account{display:none;}";
  79. }*/
  80. $element = 'enable-topbar-links-updates';
  81. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  82. $str .= "#wp-admin-bar-updates{display:none;}";
  83. }
  84. echo "<style type='text/css'>".$str."</style>";
  85. }
  86. function mtrl_topbar_logout_link() {
  87. global $mtrladmin;
  88. $mtrladmin = mtrladmin_network($mtrladmin);
  89. $element = 'user-profile-style';
  90. if(isset($mtrladmin[$element]) && trim($mtrladmin[$element]) == "style3"){
  91. global $wp_admin_bar;
  92. $wp_admin_bar->add_menu( array(
  93. 'id' => 'wp-custom-logout',
  94. 'title' => 'Logout',
  95. 'parent'=> 'top-secondary',
  96. 'href' => wp_logout_url()
  97. ) );
  98. }
  99. }
  100. function mtrl_topbar_menuids(){
  101. global $wp_admin_bar;
  102. global $mtrladmin;
  103. $mtrladmin = mtrladmin_network($mtrladmin);
  104. $element = 'enable-topbar-links-wp';
  105. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  106. $wp_admin_bar->remove_menu('wp-logo');
  107. }
  108. $element = 'enable-topbar-links-site';
  109. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  110. $wp_admin_bar->remove_menu('site-name');
  111. }
  112. $element = 'enable-topbar-links-comments';
  113. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  114. $wp_admin_bar->remove_menu('comments');
  115. }
  116. $element = 'enable-topbar-links-updates';
  117. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  118. $wp_admin_bar->remove_menu('updates');
  119. }
  120. $element = 'enable-topbar-links-new';
  121. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  122. $wp_admin_bar->remove_menu('new-content');
  123. }
  124. $element = 'enable-topbar-links-mtrladmin';
  125. if(isset($mtrladmin[$element]) && $mtrladmin[$element] != "1" && $mtrladmin[$element] == "0" && !$mtrladmin[$element]){
  126. $wp_admin_bar->remove_menu('_mtrloptions');
  127. }
  128. $element = 'user-profile-style';
  129. if(isset($mtrladmin[$element]) && ($mtrladmin[$element] != "style1" && $mtrladmin[$element] != "style2") ){
  130. $wp_admin_bar->remove_menu('my-account');
  131. }
  132. $element = 'topbar-removeids';
  133. if(isset($mtrladmin[$element]) && trim($mtrladmin[$element]) != ""){
  134. $exp = explode(",",$mtrladmin[$element]);
  135. $exp = array_unique(array_filter($exp));
  136. foreach($exp as $nodeid){
  137. if(trim($nodeid) != ""){
  138. $wp_admin_bar->remove_menu($nodeid);
  139. }
  140. }
  141. }
  142. }
  143. function mtrl_topbar_account_menu( $wp_admin_bar ) {
  144. global $mtrladmin;
  145. $mtrladmin = mtrladmin_network($mtrladmin);
  146. $greet = 'Howdy';
  147. $element = 'myaccount_greet';
  148. if(isset($mtrladmin[$element]) && trim($mtrladmin[$element]) != "Howdy"){
  149. $greet = $mtrladmin[$element];
  150. if($greet != ""){ $greet .= ', '; }
  151. $user_id = get_current_user_id();
  152. $current_user = wp_get_current_user();
  153. $profile_url = get_edit_profile_url( $user_id );
  154. if ( 0 != $user_id ) {
  155. /* Add the "My Account" menu */
  156. $avatar = get_avatar( $user_id, 28 );
  157. $howdy = $greet.''.sprintf( __('%1$s','mtrl_framework'), $current_user->display_name );
  158. $class = empty( $avatar ) ? '' : 'with-avatar';
  159. $wp_admin_bar->add_menu( array(
  160. 'id' => 'my-account',
  161. 'parent' => 'top-secondary',
  162. 'title' => $howdy . $avatar,
  163. 'href' => $profile_url,
  164. 'meta' => array(
  165. 'class' => $class,
  166. ),
  167. ) );
  168. }
  169. }
  170. }
  171. ?>