我在下面的函数中添加了两个额外的字段,工作正常(名称和数字字段),但是我想在提交按钮之前添加一个额外的字段,但无论我在哪里添加它都会出错。
你能告诉我我添加的代码有什么问题:
<input type="text" placeholder="'.__('Questions or comments: (required)','dt_themes').'" name="quescomms" required>';
对于此功能以及如何正确添加它,并添加&#34;添加到订阅者列表?勾选&#34;在提交按钮之前?
这是我的代码(请参阅给出错误的输入部分):
function dt_sc_subscription_form( $atts, $content = null ) {
extract(shortcode_atts(array(
'image_url' => '',
'slider' => '',
'slider_id' => '',
'title' => __('Plan a Visit', 'dt_themse'),
'submit_text' => __('Submit', 'dt_themes'),
'success_msg' => __('Thanks for subscribing, we will contact you soon.', 'dt_themes'),
'error_msg' => __('Mail not sent, please try again Later.', 'dt_themes'),
'subject' => __('Subscription', 'dt_themes'),
'admin_email' => get_bloginfo('admin_email'),
'enable_planavisit' => 'true',
'contact_label' => __('Inquiries', 'dt_themes'),
'contact_number' => ''
), $atts));
if($admin_email == '') $admin_email = get_bloginfo('admin_email');
$out = '';
$out .= '<div class="column dt-sc-two-third no-space">
<div class="dt-sc-subscription-frm-image">';
if($image_url != '') {
$out .= '<img src="'.$image_url.'" alt="'.$title.'" title="'.$title.'">';
} else if($slider != '' && $slider_id != '') {
if($slider == 'LayerSlider') {
$out .= do_shortcode("[layerslider id='{$slider_id}']");
} elseif($slider == 'RevolutionSlider') {
$out .= do_shortcode("[rev_slider $slider_id]");
}
}
$out .= '</div>
</div>
<div class="column dt-sc-one-third no-space">
<div class="dt-sc-subscription-frm-container">
<h2> <i class="fa fa-clock-o"> </i> '.$title.' </h2>
<div class="dt-sc-clear"></div>
<form name="frmsubscription" action="'.get_template_directory_uri().'/framework/subscribe_mail.php" class="dt-sc-subscription-frm" method="post">
<input type="text" placeholder="'.__('Full Name (required)', 'dt_themes').'" name="dtfullname" required>
<input type="email" placeholder="'.__('Email (required)', 'dt_themes').'" name="dtemail" required>
<input type="text" placeholder="'.__('Tel No (required)', 'dt_themes').'" name="dttelno" required>';
$course_args = array('post_type' => 'dt_courses', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'DESC');
$course_array = get_posts( $course_args );
$out .= '<select id="dtcourse" name="dtcourse" required>';
$out .= '<option value="">' . __( 'Choose class, date, time, location? ', 'dt_themes' ) . '</option>';
<input type="text" placeholder="'.__('Questions or comments: (required)', 'dt_themes').'" name="quescomms" required>';
if ( count( $course_array ) > 0 ) {
foreach ($course_array as $course_item){
$out .= '<option value="' . esc_attr( $course_item->post_title ) . '" >' . esc_html( $course_item->post_title ) . '</option>';
}
}
$out .= '</select>';
if($enable_planavisit == 'true') {
$out .= '<div class="dt-sc-check-box">
<input type="checkbox" id="dtplanavisit" name="dtplanavisit"> <label class="checkbox-label"> <span> </span>'.__('Plan a Visit', 'dt_themes').' </label>
</div>
<input type="text" style="display: none;" id="dtdatetimepicker" name="dtdatetimepicker" placeholder="'.__('Date Time', 'dt_themes').'" >';
}
$out .= '<div id="ajax_subscribe_msg"></div>
<input type="submit" class="dt-sc-button" value="'.$submit_text.'" name="btnsubscribe" id="btnsubscribe">
<input type="hidden" value="'.$admin_email.'" name="hid_adminemail">
<input type="hidden" value="'.$subject.'" name="hid_subject">
<input type="hidden" value="'.$success_msg.'" name="hid_successmsg">
<input type="hidden" value="'.$error_msg.'" name="hid_errormsg">
</form>';
if($contact_number != '') {
$out .= '<div class="dt-sc-subscription-enquiry"> <i class="fa fa-phone"> </i> <span> '.$contact_label.' </span> '.$contact_number.' </div>';
}
$out .= '</div>
</div>';
答案 0 :(得分:0)
您不能只将原始HTML写入PHP代码。也许你打算做这样的事情:
$out .= '<input type="text" placeholder="'.__('Questions or comments: (required)', 'dt_themes').'" name="quescomms" required>';