Saturday, 24 August 2013

do_shortcode doesnt extract WORKING shortcode

do_shortcode doesnt extract WORKING shortcode

I've got strange problem. I'm making page via Ajax and I need Form plugin
there. It uses shortcodes and it work well in default templates (twenty
thirteen), but it's not installed.
Array ( [embed] => __return_false
[wp_caption] => img_caption_shortcode
[caption] => img_caption_shortcode
[gallery] => gallery_shortcode
[audio] => wp_audio_shortcode
[video] => wp_video_shortcode )
it's list of installed shortcodes and [Form] isnt there, but it works via
the_post(); My Ajax script looks like this:
echo "<div id=\"aside\">";
$post = get_page_by_title('right');
$code = "Form";
echo extracted_shortcode();
echo $post->post_content;
echo "</div>";
function extracted_shortcode() looks like this:
global $post, $code;
$pattern = get_shortcode_regex();
preg_match("/".$pattern."/s", $post->post_content, $matches);
if (is_array($matches) && $matches[2] == $code) {
$shortcode = $matches[0];
echo do_shortcode($shortcode);
Can someone tell me where is problem? I'm doing this second day and
shortcode from gallery plugin at one of mine sites works well since 2
months.

No comments:

Post a Comment