pagehook = add_menu_page(__('All In One Metadata Settings', 'all-in-one-metadata'), "Metadata", 'manage_options', 'pressbooks_metadata_settings', array($this, 'render_options_page'), 'dashicons-search'); //small fix to have different menu name of first tab add_submenu_page('pressbooks_metadata_settings',__('General Settings', 'all-in-one-metadata'), __('General Settings', 'all-in-one-metadata'), 'manage_options', 'pressbooks_metadata_settings'); if(!site_cpt::pressbooks_identify()){ //Used to remove the default menu for the cpt we created remove_menu_page( 'edit.php?post_type=site-meta' ); remove_meta_box( 'submitdiv', 'site-meta', 'side' ); add_meta_box( 'metadata-save', __('Save Site Metadata Information', 'all-in-one-metadata'), array( $this, 'metadata_save_box' ), 'site-meta', 'side', 'high' ); $meta = site_cpt::get_site_meta_post(); if ( ! empty( $meta ) ) { $site_meta_url = 'post.php?post=' . absint( $meta->ID ) . '&action=edit'; } else { $site_meta_url = 'post-new.php?post_type=site-meta'; } //adding Site-Meta page under main plugin page add_submenu_page('pressbooks_metadata_settings','Site-Meta', 'Site-Meta', 'edit_posts', $site_meta_url); } //getting active locations for metadata $this->locations = get_option('schema_locations') ?: []; //Creating subpages for all active post types foreach ($this->locations as $location => $enabled) { if ( $enabled && ! ( $location == 'site-meta' || $location == 'metadata' ) ) { add_submenu_page( 'pressbooks_metadata_settings', ucfirst( $location ) . __(' Metadata Settings', 'all-in-one-metadata'), ucfirst( $location ) .' Metadata', 'manage_options', $location . '_meta_settings' , function () use ($location){ wp_enqueue_script('common'); wp_enqueue_script('wp-lists'); wp_enqueue_script('postbox'); //adding metabox to post options page add_meta_box('activated-schema-types', __('Active Schema Types', 'all-in-one-metadata'), array($this, 'render_metabox_active_schemas'), $location.'_meta_settings', 'normal', 'core'); ?>