<?php
/*
 * This file is part of WPCore project.
 *
 * (c) Louis-Michel Raynauld <louismichel@pweb.ca>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WPCore;

/**
 * WP script admin
 *
 * @author Louis-Michel Raynauld <louismichel@pweb.ca>
 */
class WPscriptAdmin extends WPscript
{
  protected $admin_page = array();


  public function __construct($admin_page, $handle, $src = false, $deps = array(),$ver = false, $in_footer = true)
  {
    parent::__construct($handle, $src, $deps, $ver, $in_footer);

    if(!is_array($admin_page))
    {
      $admin_page[] = $admin_page;
    }
    $this->admin_page = $admin_page;

  }

  public function is_needed($page)
  {
    if(empty($this->admin_page)) return true;

    return in_array($page, $this->admin_page);
  }

  public function enqueue($page)
  {
    if($this->is_needed($page))
    {
      parent::enqueue();
    }
  }
}
<?php
/*
 * This file is part of WPCore project.
 *
 * (c) Louis-Michel Raynauld <louismichel@pweb.ca>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace WPCore;

/**
 * WP script admin
 *
 * @author Louis-Michel Raynauld <louismichel@pweb.ca>
 */
class WPscriptAdmin extends WPscript
{
  protected $admin_page = array();


  public function __construct($admin_page, $handle, $src = false, $deps = array(),$ver = false, $in_footer = true)
  {
    parent::__construct($handle, $src, $deps, $ver, $in_footer);

    if(!is_array($admin_page))
    {
      $admin_page[] = $admin_page;
    }
    $this->admin_page = $admin_page;

  }

  public function is_needed($page)
  {
    if(empty($this->admin_page)) return true;


    if(in_array($page, $this->admin_page))
    {
      return true;
    }
    elseif(isset($this->admin_page[$page]))
    {
      if(empty($this->admin_page[$page]))
      {
        return true;
      }
      elseif(isset($this->admin_page[$page]['post_type']))
      {

        global $post;
        if($post->post_type === $this->admin_page[$page]['post_type'])
        {
          return true;
        }
      }
    }
    return false;
  }

  public function enqueue()
  {
    $page = func_get_arg(0);
    if($this->is_needed($page))
    {
      parent::enqueue();
    }
  }
}
Remove bad argument to enqueue to prevent strict error. Added support of custom post type check to script loading conditions.
Remove bad argument to enqueue to prevent strict error. Added support of custom post type check to script loading conditions.
