I’ve created a category so as to add customized meta bins for my web site, and it really works completely nice after I add it to pages, however nothing is exhibiting up after I go to the nav-menus web page.
//provides choice to edit nav menu
operate register_my_menu() {
register_nav_menus(['nav-menu' => "Navigation Menu"]);
}
add_action('init', 'register_my_menu');
//class that provides customized inputs to pages
class reflection_page_edit {
non-public $htmlcontent;
non-public $ID;
non-public $metaid;
non-public $page_location;
public operate __construct($title, $htmlcontent, $page_location) {
$this->htmlcontent = $htmlcontent;
$this->page_location = $page_location;
$this->ID = str_replace(' ', '_', $title);
$this->metaid = "wp".$this->ID;
world $submit;
add_action( 'admin_init', [$this, 'addmetabox']);
add_action( 'save_post', [$this, 'savethispost']);
}
public operate addmetabox() {
add_action( 'add_meta_boxes', [$this, 'create_meta_box']);
}
public operate create_meta_box() {
add_meta_box($this->ID, str_replace('_',' ',$this->ID), [$this, $this->htmlcontent], $this->page_location, 'facet');
}
public operate image_uploader() {
world $submit;
$post_id = $post->ID;
$input_id = "custom_img_id".$this->ID;
$picture = get_post_meta( $post_id, $this->metaid, true);
$image_source = wp_get_attachment_image_src( $picture, 'full');
?>
<div class="custom-img-container">
<img class=<?php echo "thumbnail".$input_id;?> src=<?php echo $picture; ?> alt="" model="max-width:100%;" />
<p class="error_message" model="font-size: 1.5rem; font-weight: bold; <?php if ($image): ?> visibility: hidden; <?php endif ?>">No Picture Chosen.</p>
</div>
<a href="#" class="reflection_image_uploader" data_title=<?php echo $this->ID;?>>Select Picture</a>
<enter id=<?php echo $input_id;?> title=<?php echo $input_id;?> kind="hidden" worth="<?php echo esc_attr($image); ?>"/>
<?php
}
public operate savethispost() {
world $submit;
$post_id = $post->ID;
$input_id = "custom_img_id".$this->ID;
update_post_meta( $post_id, $this->metaid, $_POST[$input_id]);
}
}
new reflection_page_edit('Hero Picture', 'image_uploader', ['page']);
new reflection_page_edit('New Factor', 'image_uploader', ['page']);
new reflection_page_edit('Model Picture', 'image_uploader', ['nav-menus']);
Right here is the nav-menus web page with no customized field