Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Plenty of good material here, +1 for everybody! –  brasofilo Oct 17 '13 at 14:26
add comment

3 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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. –  toscho May 20 '13 at 18:18
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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