1

默认Yourls不允许在 http 或 https 以外的其他方案中缩短 url。但我也希望它接受它们。我将通过添加自定义插件来实现。

有一个函数评估用户输入的 url,如下所示。

包括\functions.php

function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
    // Allow plugins to short-circuit the whole function
    $pre = yourls_apply_filter( 'shunt_add_new_link', false, $url, $keyword, $title );
    if ( false !== $pre )
        return $pre;

    $url = yourls_encodeURI( $url );
    $url = yourls_sanitize_url( $url );
    if ( !$url || $url == 'http://' || $url == 'https://' ) {
        $return['status']    = 'fail';
        $return['code']      = 'error:nourl';
        $return['message']   = yourls__( 'Missing or malformed URL' );
        $return['errorCode'] = '400';
        return yourls_apply_filter( 'add_new_link_fail_nourl', $return, $url, $keyword, $title );
    }

我只是不知道是否可以通过添加插件来允许其他 url 方案。你有什么主意吗?

4

0 回答 0