2

I'm using 2 plugins in my wordpress blog - WP-Members and Dropbox Folder Share. I want to do something like this:

[dropbox-foldershare-hyno link="[wp-members field="some_link"]" ver_como='lista']

Is this possible?

  • 1
    Plenty of good material here, +1 for everybody! – brasofilo Oct 17 '13 at 14:26
3

You cannot use shortcodes like this. The parser would not read that like you want.

But there is a workaround: Hijack the shortcode dropbox-foldershare-hyno, run the callback function for the wp-members on the link and pass the result to the original dropbox-foldershare-hyno callback.

Sample code, not tested:

// wait until the other plugins are loaded
add_action( 'wp_loaded', 'wpse_100100_shortcode_magic' );

function wpse_100100_shortcode_magic()
{
    add_shortcode(
        'dropbox-foldershare-hyno',  
        'wpse_100100_shortcode_replacement' 
    );
}

function wpse_100100_shortcode_replacement( $atts )
{
    global $bvwidget;

    if ( isset ( $atts['link'] ) )
        $atts['link'] = wpmem_shortcode( array( 'field' => $atts['link'] ) );

    return $bvwidget->replace_shortcode( $atts );
}

Now you can use the shortcode [dropbox-foldershare-hyno] and pass a value for the link attribute that should be converted from WP-Members before Dropbox Folder Share gets its hands on it.

  • Thanks for the explanation. I'm still a bit confused. Please clarify: Do I still have to declare the attribute of link in the shortcode [dropbox-foldershare-hyno link=""]? Also, field I assume is referring to the custom option_value some_link? – input May 20 '13 at 18:14
  • @input See my update, I added an explanation. – fuxia May 20 '13 at 18:18
3

How we can do it in the near future ;-)

When the dropbox-foldershare-hyno plugin becomes WordPress 3.6 ready, we can do this:

add_filter('shortcode_atts_dfh','overwrite_dfh_atts',10,3);
function overwrite_dfh_atts($out, $pairs, $atts){
    if($atts['link'])
        $out['link'] = do_shortcode( sprintf( '[wp-members field="%s"]', esc_attr( $atts['link'] ) ) ); 

    return $out;
}

to overwrite the link attribute of shortcode:

[dropbox-foldershare-hyno link="some value for the wp-member field attribute"] 

shortcode, if the corresponding shortcode_atts_{$shortcode} filter is shortcode_atts_dfh.

You can read more about it here.

2

Nested shortcodes only work in certain specific circumstances:

  • Only enclosed shortcodes can be nested. In other words, the style of [shortcode] content [/shortcode]. Self-enclosing shortcodes like [shortcode attribute="foo"] cannot be nested.
  • Even in that case, the outer shortcode must be set up properly by calling do_shortcodes() on the content that's being returned. (ref: Shortcodes API: Nested Shortcodes)

So, in your example, the answer is probably no, due to the first point above. But to be sure, you'd have to check the documentation for your specific plugins to see if the author gives any other options for how to use their particular shortcodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.