我在wordpress上有一个表单,我试图在插件上创建,我试图发布它,但是当我提交表单页面重新加载。
if (isset( $_POST['plugin-guide-info-form-submitted'] ) ) {
$hidden_field = esc_html ( $_POST['plugin-guide-info-form-submitted'] ) ;
if( $hidden_field == 'Y' ) {
$guide_name = esc_html( $_POST['wpt_guide_name'] );
$guide_description = esc_html( $_POST['wpt_guide_description'] );
echo $guide_name;
echo $guide_description;
}
}
}
我的表格是
$html .= '<form name = "plugin-guide-info" method="post" action="" enctype="multipart/form-data">' . "\n";
ob_start();
settings_fields( $this->parent->_token . '_settings' );
do_settings_sections( $this->parent->_token . '_settings' );
$html .= ob_get_clean();
$html .= '<input type ="hidden" name="plugin-guide-info-form-submitted" value="Y" />' . "\n";
$html .= '<p class="submit">' . "\n";
$html .= '<input name="plugin-guide-info-Submit" type="submit" class="button-primary" value="' . esc_attr( __( 'Save' , 'assist' ) ) . '" />' . "\n";
$html .= '</p>' . "\n";
$html .= '</form>' . "\n";
设置
private function settings_fields () {
$settings['standard'] = array(
'title' => __( '', 'assist' ),
'description' => __( '', 'assist' ),
'fields' => array(
array(
'id' => 'guide_name',
'name' => 'guide_name',
'label' => __( 'Guide Name' , 'assist' ),
'description' => __( '', 'assist' ),
'type' => 'text',
'default' => '',
'placeholder' => __( 'Guide Name', 'assist' )
),
array(
'id' => 'guide_description',
'name' => 'guide_description',
'label' => __( 'Guide Description' , 'assist' ),
'description' => __( '', 'assist' ),
'type' => 'textarea',
'default' => '',
'placeholder' => __( 'Plug in Description and links to tutoials', 'assist' )
)
)
);
$settings = apply_filters( $this->parent->_token . '_settings_fields', $settings );
return $settings;
}
我知道指南说明和指南名称的名称与settings_fields函数和html不同,因为当我在开发人员工具上查看它时,它已将wpt_添加到name-value。
我开始在github上使用wordpress插件模板
所以我的问题是,为什么我无法让它发布并返回?