<commit_before><?php
/**
 * Menu
 *
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
 *
 * Permission is hereby granted to use or copy this program
 * for any purpose, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 * @category  Wp
 * @package   Punction
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 W<NAME>polony, Kalisz
 * @license   MIT http://opensource.org/licenses/MIT
 * @version   1.0 $Format:%H$
 * @link      http://
 * @since     File available since Release 1.0.0
 * PHP Version 5
 */
namespace Hospitalplugin\WP;

/**
 * Menu
 *
 * @category  Wp
 * @package   Punction
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
 * @license   MIT http://opensource.org/licenses/MIT
 * @version   1.0  $Format:%H$
 * @link      http://
 * @since     File available since Release 1.0.0
 *
 */
class Menu
{

    private $menus;

    private $url;

    private $unregister;

    /**
     * init
     */
    public function init($menus, $url, $unregister = null)
    {
        $this->menus = $menus;
        $this->url = $url;
        $this->unregister = $unregister;
        add_action('admin_menu', array(
            $this,
            'registerPages'
        ));
    }

    /**
     * register menu pages
     */
    private function registerPages()
    {
        foreach ($this->menus as $menu) {
            $this->registerPage($menu['title'], $menu['cap'], $menu['link'], $menu['class'], $menu['callback'], $menu['type']);
        }
        $this->hideMenu();
    }

    /**
     * hide unused
     */
    public function hideMenu()
    {
        foreach ($this->unregister as $menu) {
            remove_submenu_page($menu['url'], $menu['page']);
        }
    }

    /**
     * register using add_submenu_page
     */
    function registerPage($title, $capabilities, $url_param, $class, $callback, $type)
    {
        if ($type == 'submenu') {
            add_submenu_page($this->url, $title, $title, $capabilities, $url_param, array(
                $class,
                $callback
            ));
        } else {
            add_menu_page($title, $title, $capabilities, $url_param, array(
                $class,
                $callback
            ));
        }
    }
}<commit_msg>fix the "Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method Hospitalplugin\WP\Menu::registerPages()"<commit_after><?php
/**
 * Menu
 *
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
 *
 * Permission is hereby granted to use or copy this program
 * for any purpose, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 * @category  Wp
 * @package   Punction
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 <NAME>, Kalisz
 * @license   MIT http://opensource.org/licenses/MIT
 * @version   1.0 $Format:%H$
 * @link      http://
 * @since     File available since Release 1.0.0
 * PHP Version 5
 */
namespace Hospitalplugin\WP;

/**
 * Menu
 *
 * @category  Wp
 * @package   Punction
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 <NAME>, Kalisz
 * @license   MIT http://opensource.org/licenses/MIT
 * @version   1.0  $Format:%H$
 * @link      http://
 * @since     File available since Release 1.0.0
 *
 */
class Menu
{

    private $menus;

    private $url;

    private $unregister;

    /**
     * init
     */
    public function init($menus, $url, $unregister = null)
    {
        $this->menus = $menus;
        $this->url = $url;
        $this->unregister = $unregister;
        add_action('admin_menu', array(
            $this,
            'registerPages'
        ));
    }

    /**
     * register menu pages
     */
    public function registerPages()
    {
        foreach ($this->menus as $menu) {
            $this->registerPage($menu['title'], $menu['cap'], $menu['link'], $menu['class'], $menu['callback'], $menu['type']);
        }
        $this->hideMenu();
    }

    /**
     * hide unused
     */
    public function hideMenu()
    {
        foreach ($this->unregister as $menu) {
            remove_submenu_page($menu['url'], $menu['page']);
        }
    }

    /**
     * register using add_submenu_page
     */
    private function registerPage($title, $capabilities, $url_param, $class, $callback, $type)
    {
        if ($type == 'submenu') {
            add_submenu_page($this->url, $title, $title, $capabilities, $url_param, array(
                $class,
                $callback
            ));
        } else {
            add_menu_page($title, $title, $capabilities, $url_param, array(
                $class,
                $callback
            ));
        }
    }
}
{'fraction_non_alphanumeric': 0.13371980676328502, 'fraction_numerical': 0.007536231884057971, 'mean_word_length': 2.2229140722291407, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5675249', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1528, 'n_words': 450}