AnsPress_Admin::fix_active_admin_menu( string $parent_file )

Description #

Fix active menu css class in wp-admin.

Parameters #

  • $parent_file
    string (Required) Parent file.

Changelog #

VersionDescription
unknownIntroduced.

Source #

File: admin/anspress-admin.php

	public static function fix_active_admin_menu( $parent_file ) {
		global $submenu_file, $current_screen;

		// Set correct active/current menu and submenu in the WordPress Admin menu for the "example_cpt" Add-New/Edit/List.
		if ( in_array( $current_screen->post_type, array( 'question', 'answer' ), true ) ) {
			$submenu_file = 'edit.php?post_type=' . $current_screen->post_type; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

			if ( 'add' === $current_screen->action ) {
				$submenu_file = 'post-new.php?post_type=' . $current_screen->post_type; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
			}

			$parent_file = 'anspress';
		}

		return $parent_file;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment