Problem with shortcodes in external file

Shortcodes and Tags

At first, please keep in mind that your understanding of tags is actually a shortcode.

A Tag is used to add meta information to content, while a shortcode is used for adding functionality, usually to be called from inside the content.

To your Problem

As @s_ha_dum pointed out, you should implement your WorkWithTags-function as a Shortcode, so you do not have to add an extra filter to your content, searching for your shortcode.

To get it to work like you implemented it, you have @s_ha_dum’s method, or you could alter your shortcode and function like this:

[xx]http://harrix.org/1.txt[/xx] //note that the second xx closes with the / before the shortcode-identifier.

Next, you add this function as a shortcode.

Keep in mind, there is already a filter on the_content looking for all the shortcodes, so you do not have to implement this yourself.

function WorkWithTags( $atts, $content ){
    $yourfile = esc_url( $content ); // clean the input
    $contents = file_get_contents( $yourfile ); // get the file
    return do_shortcode( $contents ); // search the content of your file for all registered shortcodes
}
add_shortcode('xx','WorkWithTags');

This should set you up nicely, although the preferable method is to implement your shortcode like [xx url="yoururl" /]. In this case, the url will not be in your $content of the function WorkWithTags, but in the $atts.

All registered Shortcodes will be executed on the contents of $yourfile. If they are not, make sure they are registered.

One last thing, if you use an external file to be included and “executed”, make sure that you do not call an infinite look by placing another [xx] shortcode in your external file.