Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • in reply to: .kleo-main-header #207772
     mudandroutes
    Participant

    Thanks for looking into this @radu – the code now looks like this:

    COPY CODE
    // turn any link to a gpx file to a shortcode
    function osmap_gpx_link_filter( $content ) {
    $content = preg_replace( '/\\<a href="(.*?\\.gpx).*?a\\>/','[toolset_access role="Guest"][su_note note_color="#f7332a"]<a href="/wp-login.php">Log in</a> or <a href="https://www.mudandroutes.com/register-with-mud-and-routes/">register</a> to see the Ordnance Survey map[/su_note][/toolset_access][toolset_access role="Guest" operator="deny"][osmap gpx="$1"][/toolset_access]', $content );
    return $content;
    }
    function sqr_late_trigger_rand89() {
    add_filter( 'the_content', 'osmap_gpx_link_filter' );
    add_shortcode( 'map', 'osmap_generator' );
    }
    
    //add_action('after_setup_theme','sqr_late_trigger_rand89');
    //add_action('wp_loaded','sqr_late_trigger_rand89');
    add_action('init','sqr_late_trigger_rand89');
    

    Which is hopefully correct (someone else actually did the code – i added the extra shortcodes – i’m able to modify and add snippets but that’s about the limit of my PHP).

    Unfortunately, this still brings the same error. I tried each add_action in turn uncommented, cleared the site cache completely and opened a few posts to see if this solved it.

    in reply to: .kleo-main-header #207730
     mudandroutes
    Participant

    Hi @radu – I’m getting a slightly different issue – it’s a different file that’s causing the issue – see the screen grab.

    Indeed – it is an issue in my child theme – and unfortunately it’s from one of the most essential pieces of code from functions.php for my entire site! Specifically we have a preg_replace that’s causing the problem.

    COPY CODE
    // turn any link to a gpx file to a shortcode
    function osmap_gpx_link_filter( $content ) {
    $content = preg_replace( '/\<a href="(.*?\.gpx).*?a\>/','[toolset_access role="Guest"][su_note note_color="#f7332a"]<a href="/wp-login.php">Log in</a> or <a href="https://www.mudandroutes.com/register-with-mud-and-routes/">register</a> to see the Ordnance Survey map[/su_note][/toolset_access][toolset_access role="Guest" operator="deny"][osmap gpx="$1"][/toolset_access]', $content );
    return $content;
    }
    add_filter( 'the_content', 'osmap_gpx_link_filter' );
    add_shortcode( 'map', 'osmap_generator' );
    

    This turns any link to a file ending in .gpx into a specific shortcode – not sure why this is misbehaving with the theme all of a sudden. If i comment this out, then everything works – except that this then breaks a load of my posts as this is what converts the gpx files over into a map for our readers. It’s a workaround in order to support legacy posts where different shortcodes were used to embed the files, with the direct link style the one that works best as it’s easiest.

    Any idea why the above is causing a problem?
    The remainder of my functions.php has only adsense code, a couple of custom widgets and

    Also – happy to open a new thread on this if needed as I realise I’ve jumped into this thread with my issue !

    Attachments:
    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)

Log in with your credentials

Forgot your details?