0

I found this question here but I'm a bit confused on how to proceed. I need to register or enqueue the bootstrap css for my plugin admin menu page. I've understand that when an admin menu page is created is identified by an hook suffix. I want to understand how to correctly enqueue my script only on that page. All the examples I've found are writed in procedural style and I need to achive this inside my plugin class.

Here is my code.

/**
   * [initOptionsMenu description]
   * @return [type] [description]
   */

  public function initOptionsMenu()
  {
    $page_title = 'Boot Settings';
    $menu_title = 'Boot';
    $capability = 'edit_posts';
    $menu_slug = 'boo_s';
    $function = array( $this, 'renderMenu' );
    $icon_url = '';
    $position = 24;

    $hook_suffix = add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
  }

  /**
   * [renderMenu description]
   * @return [type] [description]
   */

  public function renderMenu( $hook_suffix )
  {
    // here i want to do the scripts loading
    require_once 'bs-options.php';
  }
  • Have you tried get_current_screen()? – Max Yudin Oct 3 at 10:17
  • no, I've read a lot of posts about the hook argument to load the scripts only on certain pages, but they are only created more doubt on how to proceed. This function is not clear to me, bou with the $hook_suffix I think that it's achivable? – userone2 Oct 3 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.