Ejemplo n.º 1
0
/**
 * Checks enqueued URL hostname and extension against whitelists.
 *
 * @since   0.4.0
 *
 * @param  string   $url        URL to be checked.
 * @param  array   $extensions  Whitelist of filename extensions.
 * @return bool                 True if extension is in whitelist, false if not.
 */
function postscript_check_url($url, $extensions = array())
{
    if (!empty($url) && postscript_check_url_extension($url, $extensions) && postscript_check_url_hostname($url)) {
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 2
0
/**
 * Checks enqueued URL hostname and extension against whitelists.
 *
 * @since   0.4.0
 *
 * @param  string   $url        URL to be checked.
 * @param  array    $extensions Whitelist of filename extensions.
 * @return string   $url_error  Error message if true, else empty string if not.
 */
function postscript_url_error($url, $extensions = array())
{
    $screen = get_current_screen();
    $url_error = '';
    if ('postscript' != $screen->id && !empty($url)) {
        // Do not display on settings screen.
        if (!postscript_check_url_extension($url, $extensions)) {
            $url_error = '<br /><span class="wp-ui-notification">' . __('Error: Wrong file <strong>extension</strong>:', 'postscript') . '</span>';
        } elseif (!postscript_check_url_hostname($url)) {
            $url_error = '<br /><span class="wp-ui-notification">' . __('Error: URL <strong>hostname</strong> not on whitelist:', 'postscript') . '</span>';
        } else {
            $url_error = '';
        }
    }
    return $url_error;
}