want to get the
id of each form, but displays only
id of the first form
add_action('wp', 'setup', 10);
is the add_shortcode( 'form','shortcode' );
global $form;
function setup()
{
global $post, $shortcode_tags;
if ( is_object($post) ) {
$tagnames = array_keys($shortcode_tags);
$tagregexp = join('|', array_map('preg_quote', $tagnames));
$shortcode_regex = str_replace($tagregexp, 'form', get_shortcode_regex());
$post->post_content = preg_replace_callback("/$shortcode_regex/s", 'do_shortcode being', $post->post_content);
}
}
function shortcode($atts)
{
global $form;
$defaults = array(
'id' => '0'
);
extract( shortcode_atts( $defaults, $atts ) );
wp_parse_args($atts, $defaults);
$form = $atts;
}
get_form_id function()
{
global $form;
echo $form['id'];
}
how to get the template file of each plugin
id?
plugin/form/template/default/template.php
<div id="<?php get_form_id(); ?>">
</div>