Beispiel #1
0
  public static function admin_menu() {
    
    global $wf;

    // we need to hide built-in types
    
    foreach (MasterPress::$post_types as $post_type) {
      
      if ($post_type->name == "post" && ($post_type->disabled || !$post_type->in_current_site())) {
        remove_menu_page('edit.php');
      } else if ($post_type->name == "page" && ($post_type->disabled || !$post_type->in_current_site())) {
        remove_menu_page('edit.php?post_type=page');
      } else if ($post_type->name == "attachment" && ($post_type->disabled || !$post_type->in_current_site())) {
        remove_menu_page('upload.php');
      }
      
    }

    $caps = array(
      "manage_masterplan" => MasterPress::get_cap_key("manage_masterplan"),
      "manage_post_types" => MasterPress::get_cap_key("manage_post_types"),
      "manage_taxonomies" => MasterPress::get_cap_key("manage_taxonomies"),
      "manage_templates" => MasterPress::get_cap_key("manage_templates"),
      "manage_user_roles" => MasterPress::get_cap_key("manage_user_roles"),
      "manage_site_field_sets" => MasterPress::get_cap_key("manage_site_field_sets"),
      "manage_shared_field_sets" => MasterPress::get_cap_key("manage_shared_field_sets"),
      "manage_mp_settings" => MasterPress::get_cap_key("manage_mp_settings"),
      "manage_mp_tools" => MasterPress::get_cap_key("manage_mp_tools")
    );
    
    
    if ($wf->the_user->is_an("Administrator")) {
      // ensure that user roles can be accessed by admins!
      $caps["manage_user_roles"] = "manage_options";
      $caps["edit_user_roles"] = "manage_options";
      $caps["manage_mp_settings"] = "manage_options";
    }


    // main menu

    $page = add_menu_page( 
      __( 'Masterplan', "masterpress" ), 
      __( 'Masterplan', "masterpress" ), 
      $caps['manage_masterplan'], 
      'masterpress', 
      array('MasterPress', 'render'),
      self::menu_icon( "masterpress", MPU::plugin_image("menu-icon-masterpress.sprite.png"), "", true ),
      "85.5"
    );



    add_action("load-$page", array("MasterPress", "add_help_tabs"));
    
    
    // sub menus
  
    $sm = add_submenu_page( 
      'masterpress', 
      __('Post Types', MASTERPRESS_DOMAIN), 
      MPU::options_menu('post-types', __( 'Post Types', MASTERPRESS_DOMAIN )), 
      $caps['manage_post_types'],
      'masterpress-post-types', 
      array('MasterPress', 'render')
    );

    add_action("load-$sm", array("MasterPress", "add_help_tabs"));

    $sm = add_submenu_page( 
      'masterpress', 
      __('Taxonomies', MASTERPRESS_DOMAIN), 
      MPU::options_menu('taxonomies', __( 'Taxonomies', MASTERPRESS_DOMAIN )), 
      $caps['manage_taxonomies'],
      'masterpress-taxonomies', 
      array('MasterPress', 'render')
    );

    add_action("load-$sm", array("MasterPress", "add_help_tabs"));

    $sm = add_submenu_page( 
      'masterpress', 
      __('Templates', MASTERPRESS_DOMAIN), 
      MPU::options_menu('page-templates', __( 'Templates', MASTERPRESS_DOMAIN )), 
      $caps['manage_templates'],
      'masterpress-templates', 
      array('MasterPress', 'render')
    );

    add_action("load-$sm", array("MasterPress", "add_help_tabs"));
  
    $sm = add_submenu_page( 
      'masterpress', 
      __('User Roles' ), 
      MPU::options_menu('roles', __( 'User Roles', MASTERPRESS_DOMAIN )), 
      $caps['manage_user_roles'],
      'masterpress-roles', 
      array('MasterPress', 'render')
    );

    add_action("load-$sm", array("MasterPress", "add_help_tabs"));

    $sm = add_submenu_page( 
      'masterpress', 
      __('Site Field Sets', MASTERPRESS_DOMAIN), 
      MPU::options_menu('site-field-sets', __( 'Site Field Sets', MASTERPRESS_DOMAIN )), 
      $caps['manage_site_field_sets'],
      'masterpress-site-field-sets', 
      array('MasterPress', 'render')
    );

    add_action("load-$sm", array("MasterPress", "add_help_tabs"));
    
    $sm = add_submenu_page( 
      'masterpress', 
      __('Shared Field Sets', MASTERPRESS_DOMAIN), 
      MPU::options_menu('shared-field-sets', __( 'Shared Field Sets', MASTERPRESS_DOMAIN )), 
      $caps['manage_shared_field_sets'],
      'masterpress-shared-field-sets', 
      array('MasterPress', 'render')
    );

    add_action("load-$sm", array("MasterPress", "add_help_tabs"));

    // add settings page for MasterPress
    
    add_options_page( __('MasterPress', MASTERPRESS_DOMAIN), __('MasterPress', MASTERPRESS_DOMAIN), 'manage_options', 'masterpress-settings', array("MasterPress", "render"));
    
    add_action("load-$sm", array("MasterPress", "add_help_tabs"));

    $sfs = MPM_SiteFieldSet::find();
    
    if (count($sfs)) {


      $page = add_menu_page(
        __("Site Content", MASTERPRESS_DOMAIN),
        __("Site Content", MASTERPRESS_DOMAIN),
        'publish_posts',
        'masterpress-site-content',
        array('MasterPress', 'render'),
        self::menu_icon( "masterpress-site-content", MPU::plugin_image("menu-icon-site-content.png") ),
        "3"
      );
      
      add_action("load-$page", array("MasterPress", "add_help_tabs"));

    }
    
       
    
  } // create_menu