最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Registerenqueue scripts only on certain admin pages

programmeradmin0浏览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';
  }
发布评论

评论列表(0)

  1. 暂无评论