<?php

/**
 * Renders debug for wp-hooks.
 *
 * @package northmill-online-shared
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Checkout;

/**
 * View parameters.
 *
 * @var array $params
 */
\defined('ABSPATH') || exit;
if (!\is_null($params['hooks'])) {
    if (!empty($params['hooks'])) {
        foreach ($params['hooks'] as $priority => $hooked) {
            foreach ($hooked as $hook) {
                if (\is_string($hook['function'])) {
                    \printf('<p>%s: %s - %s: %s</p>', \esc_html__('Priority', 'northmill-online-shared'), \esc_html($priority), \esc_html__('Function', 'northmill-online-shared'), \esc_html($hook['function']));
                } elseif (\is_array($hook['function'])) {
                    if (\is_object($hook['function'][0])) {
                        \printf('<p>%s: %s - %s: %s</p>', \esc_html__('Priority', 'northmill-online-shared'), \esc_html($priority), \esc_html__('Method', 'northmill-online-shared'), \esc_html(\get_class($hook['function'][0]) . '::' . $hook['function'][1]));
                    } else {
                        \printf('<p>%s: %s - %s: %s</p>', \esc_html__('Priority', 'northmill-online-shared'), \esc_html($priority), \esc_html__('Function', 'northmill-online-shared'), \esc_html($hook['function'][0] . '::' . $hook['function'][1]));
                    }
                } elseif ($hook['function'] instanceof \Closure) {
                    \printf('<p>%s: %s - %s</p>', \esc_html__('Priority', 'northmill-online-shared'), \esc_html($priority), \esc_html__('Function: Closure', 'northmill-online-shared'));
                }
            }
        }
    } else {
        \printf('<p>%s</p>', \wp_kses_post(\sprintf(
            // translators: %s: hook name.
            \__('No hooks found for %s.', 'northmill-online-shared'),
            '<i>' . $params['hook_name'] . '</i>'
        )));
    }
} else {
    \printf('<p>%s</p>', \wp_kses_post(\sprintf(
        // translators: %s: hook name.
        \__('No hooks registered for %s.', 'northmill-online-shared'),
        '<i>' . $params['hook_name'] . '</i>'
    )));
}
