我有一个自定义的职位类型“空缺”。我已成功在管理菜单“后台”中创建了一个子菜单项。我想显示一个文件上传表单,让管理员能够上传一个背景图像,然后将用于档案空缺。php模板。以下是我目前掌握的情况:
/** Step 1. */
function my_plugin_menu() {
// add_options_page( \'My Plugin Options\', \'My Plugin\', \'manage_options\', \'my-unique-identifier\', \'my_plugin_options\' );
add_submenu_page(\'edit.php?post_type=vacancies\', \'Background Image\', \'Background\', \'manage_options\', \'my-unique-identifier\', \'my_plugin_options\');
}
/** Step 2. */
add_action( \'admin_menu\', \'my_plugin_menu\' );
/** Step 3. */
function my_plugin_options() {
if ( !current_user_can( \'manage_options\' ) ) {
wp_die( __( \'You do not have sufficient permissions to access this page.\' ) );
}
wp_enqueue_media();
?>
<h3>Background Image</h3>
<table class="form-table">
<tr>
<th>
<label for="coverimage">Background Image</label>
</th>
<td>
<img class="user-cover-image" id="user-cover-image-preview" src="<?php //echo esc_attr( get_the_author_meta( \'coverimage\', $user->ID ) ); ?>" style="width:150px;"><br />
<input type="text" name="coverimage" id="coverimage" value="" class="regular-text" />
<input type=\'button\' class="user-cover-image button-primary" value="Upload Image" id="uploadimage"/><br />
<span class="description">Please upload a background image for the Vancancies Archive page.</span>
</td>
</tr>
</table>
<?php }