<?php

if (!function_exists('\sanitize_text_field')) {
    function sanitize_text_field($ret)
    {
        return $ret;
    }
}

if (! function_exists('\esc_html')) {
    function esc_html($ret)
    {
        if (null === $ret) {
            $ret = '';
        }
        $ret = htmlspecialchars($ret, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, null, false);
        return $ret;
    }
}

if (!function_exists('\esc_attr')) {
    function esc_attr($ret)
    {
        if (null === $ret) {
            $ret = '';
        }
        $ret = htmlspecialchars($ret, ENT_QUOTES);
        return $ret;
    }
}

if (!function_exists('\esc_textarea')) {
    function esc_textarea($ret)
    {
        return $ret;
    }
}

if (!function_exists('\_print_r')) {
    function _print_r($thing)
    {
        $wpAdmin = defined('WPINC') && is_admin();
        if ($wpAdmin) {
            echo '<div style="margin-left: 15em;">';
        }

        echo '<pre>';
        ob_start();
        // if (is_array($thing)) ksort($thing);
        print_r($thing);
        $ret = ob_get_clean();
        echo esc_html($ret);
        echo '</pre>';

        if ($wpAdmin) {
            echo '</div>';
        }
    }
}
