0

I'm working on a site for a client that runs a social ransom style blog. This is where the user has to click one of the social media buttons to get access to the content.

However, she is now going to use the OnePress Social Locker Plugin for wordpress which works by wrapping the content in specific tags, like so:

[sociallocker] Content Here will Be Locked [/sociallocker]

At the moment she already has her own custom shortcode in place which works like this:

[socialLock url="http://example.com" text="Click here to view content"] Content here will be locked [/socialLock]

The problem is that she has over 2,300 pages on her blog and to change every single one indv. through the dashboard will take ages and this is not a by the hour pay contract.

I thought that I would be able to pass the current shortcode into the new one like so:

function parseShortcode_func( $atts ) {
  $atts = shortcode_atts( array(
      'link' => '',
      'text' => 'default text'
  ), $atts );

  return "[sociallocker] <a href=\"{$atts['link']}\">{$atts['text']}</a> [/sociallocker]";
}
add_shortcode( 'socialLock', 'parseShortcode_func' );

However that just outputs

 [sociallocker] Click here to view content [/sociallocker]

Has anyone got any ideas how to parse this second shortcode within a shortcode?

1 Answer 1

1

The do_shortcode() function will reparse your output string.

return do_shortcode("[sociallocker] <a href=\"{$atts['link']}\">{$atts['text']}</a> [/sociallocker]");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.