用html回声的PHP代码

时间:2015-11-28 07:35:22

标签: php wordpress shortcode

我一直在努力将内容储存器放到我的模板中的表单中,但是我成功了,但是表单正在获取一些php值,所以我的echo中包含PHP代码。不知道我该怎么做。

有人可以帮忙吗?我10个小时都在挣扎,无法找到解决方案。

 <?
    $locker='[ihc-hide-content ihc_mb_type="block" ihc_mb_who="all" ihc_mb_template="1"]
                <form id="contact" type="post" action="" >  
                    <span class="contact-name">
                        <input type="text"  name="contactName" id="contactName" value="" class="input-textarea" placeholder="<?php _e("Name*", "themesdojo"); ?>" />
                    </span>

                    <span class="contact-email">
                        <input type="text" name="email" id="email" value="" class="input-textarea" placeholder="<?php _e("Email*", "themesdojo"); ?>" />
                    </span>

                    <span class="contact-message">
                        <textarea name="message" id="message" cols="8" rows="8" ></textarea>
                    </span>

                    <span class="contact-test">
                        <p style="margin-top: 20px;"><?php _e("Human test. Please input the result of 5+3=?", "themesdojo"); ?></p>
                        <input type="text" onfocus="if(this.value=='')this.value='';" onblur="if(this.value=='')this.value='';" name="answer" id="humanTest" value="" class="input-textarea" />
                    </span>

                    <input type="text" name="receiverEmail" id="receiverEmail" value="<?php echo $wpjobus_job_email; ?>" class="input-textarea" style="display: none;"/>

                    <input type="hidden" name="action" value="wpjobContactForm" />
                    <?php wp_nonce_field( 'scf_html', 'scf_nonce' ); ?>

                    <input style="margin-bottom: 0;" name="submit" type="submit" value="<?php _e( 'Send Message', 'themesdojo' ); ?>" class="input-submit">  

                    <span class="submit-loading"><i class="fa fa-refresh fa-spin"></i></span>

                </form>
            [/ihc-hide-content]'; 
    echo do_shortcode( $locker );
?>

2 个答案:

答案 0 :(得分:0)

只需汇总您的php变量

        $locker='[ihc-hide-content ihc_mb_type="block" ihc_mb_who="all" ihc_mb_template="1"]                            
        <form id="contact" type="post" action="" >  

                        <span class="contact-name">
                            <input type="text"  name="contactName" id="contactName" value="" class="input-textarea" placeholder="'._e("Name*", "themesdojo").'" />
                        </span>

                        <span class="contact-email">
                            <input type="text" name="email" id="email" value="" class="input-textarea" placeholder="'._e("Email*", "themesdojo").'" />
                        </span>

                        <span class="contact-message">
                            <textarea name="message" id="message" cols="8" rows="8" ></textarea>
                        </span>

                        <span class="contact-test">
                            <p style="margin-top: 20px;">'._e("Human test. Please input the result of 5+3=?", "themesdojo").'</p>
                            <input type="text" onfocus="if(this.value=="")this.value="";" onblur="if(this.value=="")this.value="";" name="answer" id="humanTest" value="" class="input-textarea" />
                        </span>

                        <input type="text" name="receiverEmail" id="receiverEmail" value="'.$wpjobus_job_email.'" class="input-textarea" style="display: none;"/>

                        <input type="hidden" name="action" value="wpjobContactForm" />
                        '.wp_nonce_field( 'scf_html', 'scf_nonce' ).'

                        <input style="margin-bottom: 0;" name="submit" type="submit" value="'._e( 'Send Message', 'themesdojo' ).'" class="input-submit">  

                        <span class="submit-loading"><i class="fa fa-refresh fa-spin"></i></span>

                    </form> [/ihc-hide-content]'; 
                    echo do_shortcode( $locker );

答案 1 :(得分:0)

第25行包含PHP,它被解释为$ locker变量的一部分。

<?php wp_nonce_field( 'scf_html', 'scf_nonce' ); ?>