Dynamic data :text value filters from function

So there’s a dynamic data filters that are MAGICAL. f.e

What I’m trying to do is to set 10 as variable that can be reached from a wpcodebox or functions.php.

So lets say I will create a snippet:

$customExcerpt = 5;
update_option( 'custom_excerpt_length', $customExcerpt, '', 'yes');

Is there a way to utilise it to work with filters. Documentation says about text value filters

  • :text value – Depending on the context it could mean the following:
    • User or term custom field meta key
    • The URL parameter key
    • Post terms separator
    • Date format
    • Image size slug (e.g. thumbnail, or full)
    • The echo tag function name

I can use
to render “5” and that’s works alright.

Is there a way to create smth like: