[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/ -> MP_WP_Admin_Menu.class.php (source)

   1  <?php
   2  class MP_WP_Admin_Menu
   3  {
   4  	function __construct()
   5      {
   6          $menus = array();
   7  
   8          foreach ( MailPress::capabilities() as $capability => $datas )
   9          {
  10              if ( isset( $datas['menu'] ) && $datas['menu'] && current_user_can( $capability ) )
  11              {
  12                  $datas['capability']     = $capability;
  13                  $menus[]            = $datas;
  14              }
  15          }
  16          if ( empty( $menus ) ) return;
  17  
  18          uasort( $menus, array( 'self', 'sort_menus' ) );
  19  
  20          $first = true;
  21          foreach ( $menus as $menu )
  22          {
  23              if ( !$menu['parent'] )
  24              {
  25                  if ( $first )
  26                  {
  27                      $toplevel = $menu['page'];
  28                      add_menu_page( '', __( 'Mails', 'MailPress' ), $menu['capability'], $menu['page'], $menu['func'], 'dashicons-admin-mailpress' );
  29                  }
  30                  $first = false;
  31              }
  32  
  33              $parent = ( $menu['parent'] ) ? $menu['parent'] : $toplevel;
  34              add_submenu_page( $parent, $menu['page_title'], $menu['menu_title'], $menu['capability'], $menu['page'], $menu['func'] );
  35  
  36              if ( $menu['page'] == MailPress_page_mails )
  37              {
  38                  add_submenu_page( $toplevel, __( 'Add New Mail', 'MailPress' ), '&#160;' . __( 'Add New' ), 'MailPress_edit_mails', MailPress_page_write, array( 'MP_AdminPage', 'body' ) );
  39              }
  40          }
  41      }
  42  
  43  	public static function sort_menus( $a, $b ) 
  44      {
  45          return strcmp( $a['menu'], $b['menu'] );
  46      }
  47  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1