$item ) { if ( isset( $item[2] ) && $item[2] === 'edit-tags.php?taxonomy=adqs_tags' ) { $tags_position = $position; break; } } if ( $tags_position !== null ) { // Add separator right after tags array_splice( $submenu['adirectory'], $tags_position + 1, 0, [ [ '', 'read', 'javascript:void(0);', '', 'wp-menu-separator', ], ] ); ksort( $submenu['adirectory'] ); } } public function highlight_taxonomy_menu( $parent_file ) { global $current_screen, $submenu_file, $pagenow; if ( in_array( $current_screen->taxonomy, [ 'adqs_category', 'adqs_location', 'adqs_tags' ], true ) ) { $parent_file = 'adirectory'; } if ( isset( $current_screen->post_type ) && adqs_is_directory_post_type( $current_screen->post_type ) ) { $parent_file = 'adirectory'; if ( $pagenow === 'post.php' || $pagenow === 'post-new.php' ) { $submenu_file = 'edit.php?post_type=' . $current_screen->post_type; } } return $parent_file; } public function highlight_taxonomy_submenu( $submenu_file ) { global $current_screen; if ( in_array( $current_screen->taxonomy, [ 'adqs_category', 'adqs_location', 'adqs_tags' ], true ) ) { $submenu_file = 'edit-tags.php?taxonomy=' . $current_screen->taxonomy; // Your submenu item } return $submenu_file; } public function post_type_tabs() { if ( ! current_user_can( 'edit_posts' ) ) { return; } $current_screen = get_current_screen(); if ( ! $current_screen ) { return; } // Check if this is a dynamic post type $post_type = $current_screen->post_type; if ( ! adqs_is_directory_post_type( $post_type ) ) { return; } // Get directory-specific taxonomies for this post type $directory_taxonomies = adqs_get_directory_taxonomies( $post_type, 'object' ); if ( empty( $directory_taxonomies ) ) { return; } $tab_items = [ [ 'link' => 'edit.php?post_type=' . $post_type, 'name' => get_post_type_object( $post_type )->labels->name, 'id' => 'edit-' . $post_type, ], ]; foreach ( $directory_taxonomies as $directory_taxonomy ) { $tab_items[] = [ 'link' => 'edit-tags.php?taxonomy=' . $directory_taxonomy->name . '&post_type=' . $post_type, 'name' => $directory_taxonomy->labels->name, 'id' => 'edit-' . $directory_taxonomy->name, ]; } $tab_items = apply_filters( 'adqs_directory_typs_tab_menus', $tab_items ); // Display tabs if ( ! empty( $tab_items ) ) { echo ''; } } /** * All Sub Menu Here */ public function register_sub_menu() { add_menu_page( esc_html__( 'aDirectory Dashboard', 'adirectory' ), esc_html__( 'aDirectory', 'adirectory' ), 'edit_others_posts', 'adirectory', [ $this, 'render_main_menu_page' ], // Redirect to first submenu ADQS_DIRECTORY_ASSETS_URL . '/admin/img/menu-icon.svg', 10 ); $post_types = adqs_get_directory_post_types(); if ( ! empty( $post_types ) ) { $this->add_directory_post_type_menus( $post_types ); $this->add_directory_taxonomy_menus(); } // Add other submenus do_action( 'adqs_admin_submenu_before' ); add_submenu_page( 'adirectory', esc_html__( 'aDirectory Builder Page', 'adirectory' ), esc_html__( 'Settings & Builder', 'adirectory' ), 'manage_options', 'adqs_directory_builder', [ $this, 'directory_builder_content' ] ); if ( ! empty( AD()->Helper->get_setting( 'enable_review' ) ) ) { add_submenu_page( 'adirectory', esc_html__( 'aDirectory Review Page', 'adirectory' ), esc_html__( 'Reviews', 'adirectory' ), 'manage_options', 'adqs_directory_review', function () { ?> labels->name ) ), $post_type_object->labels->name, 'edit_others_posts', 'edit.php?post_type=' . $post_type ); } } private function add_directory_taxonomy_menus() { $directory_taxonomies = adqs_get_directory_taxonomies( '', 'object' ); foreach ( $directory_taxonomies as $directory_taxonomy ) { add_submenu_page( 'adirectory', $directory_taxonomy->labels->name, $directory_taxonomy->labels->name, 'edit_others_posts', 'edit-tags.php?taxonomy=' . $directory_taxonomy->name ); } } /** * directory shortcodes * * @return string */ public function directory_shortcodes() { ?>