Support » Fixing WordPress » Short code – inside of short code – need help please

  • My knowledge level is very low when it comes to php, codex, functions etc.
    I “fumble” my way through things so please forgive my incorrect lingo at times.

    What I need help with is how to be able to use a short code inside of a short code and get the contents to “parse”? (not sure what else to call it).

    For example on a post I might have a Gallery inserted through a plugin that I want to password protect with another plugin…like this.


    [nggallery id=1]


    If I do this now I get the outter short code to work but what’s inside it just gets printed as text instead of actually inserting / doing whatever it should…in this case displaying an embedded gallery.

    I have read enough to know I need to edit the php itself but when I read this page:

    I have no clue what to edit..and how to edit it, may as well be written in Latin…lol.

    Your help (hopefully in newbie terms) would be greatly appreciated.
    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Michael


    Forum Moderator

    you need to edit the plugin which provided this shortcode [password-protect] (please post a link to that plugin).

    and find where it returns the output; then add the do_shortcode() there.

    example only (will be different in your actual plugin):

    at the end of the actual function in the plugin:

    return $protected;

    turn that into:

    return do_shortcode($protected);

    please post a (download) link to the ‘protect’ plugin.

    This is the “WRAPPER” plugin shortcode [password-protect]…
    Exclusive Content Password Protect


    And this is what will go inside the wrapper..
    NextGen Gallery


    Ok..I just opened the plugin file for the Exclusive Content Password plugin…here is ALL the code on the bottom of the page.

    Hopefully this will post right since there is no preview button and it’s my first attempt at posting code.

    add_shortcode("password-protect", "ecpp_handler");
    function ecpp_handler($atts, $content = null) {
    	global $cpp_html, $ecpp_global_password;
    				"password" => $ecpp_global_password
    	 // This stores a session PASSWORD for each item..wether its individual or global..this is what will unlock it
    	$perm_hash = md5(get_permalink()) . md5($content);
    	$_SESSION[$perm_hash]['password'] = $password;
    	// this sets the global password in a session variable
    	$_SESSION['global_password'] = $ecpp_global_password;
    		$content = str_replace('{TPLCPP_PERMHASH}', $perm_hash, parse_template($cpp_html));
    	return $content;


    Forum Moderator

    right at the end of content-password-protect.php in the plugin’s folder, change:

    return $content;


    return do_shortcode($content);

    or follow the solution in this topic:

    (not tested with ngg)

    YES!…that did the trick 🙂

    Thank you very much.

    Since I am here though and this really didn’t tell me why it worked…can you tell me what “the_content” is referring to etc.

    From the topic you posted above:

    already found the solution: just add this line BEFORE the final ‘return $content;’ of the main plugin file ‘content-password-protect.php’:

    $content = apply_filters(‘the_content’, $content);

    I get that $content is the output…a filter gets added to do something to it differently and then it gets displayed again…but what does “the_content” do?

    Sorry if it’s a dumb question…lol



    Forum Moderator

    kind of difficult to explain;

    all post and page content gets by default filtered with the ‘the_content’ filter, which for instance takes care of the ‘more tag’, turning shortcodes into output, etc.

    Hmm…it sounds like it may be a place holder for the script to use in order to do the filtering?? $content to the_content then do all the stuff…then rename it to $content with the filters done?

    Does that sound right?

    Probably not but that’s what I am seeing…lol

    And how about this question…
    Using the above example:
    $content = apply_filters('the_content', $content);

    What (and where) are the filters that are getting applied?
    I would expect to see something like apply_filter(UPPERCASE) or something…and yes that’s a bad example but I don’t know any filters

    Man I think I need sleep…I am confusing myself as I am typing this 🙂



    Forum Moderator

    the default filter are set in /wp-includes/default-filters.php; example:

    add_filter( 'the_content', 'wptexturize'        );
    add_filter( 'the_content', 'convert_smilies'    );
    add_filter( 'the_content', 'convert_chars'      );
    add_filter( 'the_content', 'wpautop'            );
    add_filter( 'the_content', 'shortcode_unautop'  );
    add_filter( 'the_content', 'prepend_attachment' );

    each of the names are referring to some functions which might be in any of the /wp-includes templates (or other folders);

    to find the code of functions, check for instance:

    where you get an alphabetical functions list

    click on a function name …

    this opens a new page, where you could click on the link below ‘Defined at:’ (this already shows the folder and template file name)

    this then opens the corresponding template file, and moves to the correct position in the file to show the full function (this is somtimes quite slow and might take a while …)

    to find the code of functions, check for instance:

    Wow that is a lot of functions…doh!

    That page isn’t a standard wordpress install is it?
    Meaning my site wouldn’t look like that with that many would it?

    Also…you showed the list of filters and where to find them (which is great) but I am still confused as to what filter is being applied when using the mentioned code:
    $content = apply_filters('the_content', $content);

    Thanks for all your help so far.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Short code – inside of short code – need help please’ is closed to new replies.