WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

Automattic\WooCommerce\Admin

PageController::get_current_screen_id() public WC 1.0

Returns the current screen ID.

This is slightly different from WP's get_current_screen, in that it attaches an action, so certain pages like 'add new' pages can have different breadcrumbs or handling. It also catches some more unique dynamic pages like taxonomy/attribute management.

Format:

  • {$current_screen->action}-{$current_screen->action}-tab-section
  • {$current_screen->action}-{$current_screen->action}-tab
  • {$current_screen->action}-{$current_screen->action} if no tab is present
  • {$current_screen->action} if no action or tab is present

{} Это метод класса: PageController{}

Возвращает

Строку. Current screen ID.

Использование

$PageController = new PageController();
$PageController->get_current_screen_id();

Код PageController::get_current_screen_id() WC 5.3.0

<?php
public function get_current_screen_id() {
	$current_screen = get_current_screen();
	if ( ! $current_screen ) {
		// Filter documentation below.
		return apply_filters( 'woocommerce_navigation_current_screen_id', false, $current_screen );
	}

	$screen_pieces = array( $current_screen->id );

	if ( $current_screen->action ) {
		$screen_pieces[] = $current_screen->action;
	}

	if (
		! empty( $current_screen->taxonomy ) &&
		isset( $current_screen->post_type ) &&
		'product' === $current_screen->post_type
	) {
		// Editing a product attribute.
		if ( 0 === strpos( $current_screen->taxonomy, 'pa_' ) ) {
			$screen_pieces = array( 'product_page_product_attribute-edit' );
		}

		// Editing a product taxonomy term.
		if ( ! empty( $_GET['tag_ID'] ) ) {
			$screen_pieces = array( $current_screen->taxonomy );
		}
	}

	// Pages with default tab values.
	$pages_with_tabs = apply_filters(
		'woocommerce_navigation_pages_with_tabs',
		array(
			'wc-reports'  => 'orders',
			'wc-settings' => 'general',
			'wc-status'   => 'status',
			'wc-addons'   => 'browse-extensions',
		)
	);

	// Tabs that have sections as well.
	$wc_emails    = \WC_Emails::instance();
	$wc_email_ids = array_map( 'sanitize_title', array_keys( $wc_emails->get_emails() ) );

	$tabs_with_sections = apply_filters(
		'woocommerce_navigation_page_tab_sections',
		array(
			'products'          => array( '', 'inventory', 'downloadable' ),
			'shipping'          => array( '', 'options', 'classes' ),
			'checkout'          => array( 'bacs', 'cheque', 'cod', 'paypal' ),
			'email'             => $wc_email_ids,
			'advanced'          => array(
				'',
				'keys',
				'webhooks',
				'legacy_api',
				'woocommerce_com',
			),
			'browse-extensions' => array( 'helper' ),
		)
	);

	if ( ! empty( $_GET['page'] ) ) {
		if ( in_array( $_GET['page'], array_keys( $pages_with_tabs ) ) ) { // WPCS: sanitization ok.
			if ( ! empty( $_GET['tab'] ) ) {
				$tab = wc_clean( wp_unslash( $_GET['tab'] ) );
			} else {
				$tab = $pages_with_tabs[ $_GET['page'] ]; // WPCS: sanitization ok.
			}

			$screen_pieces[] = $tab;

			if ( ! empty( $_GET['section'] ) ) {
				if (
					isset( $tabs_with_sections[ $tab ] ) &&
					in_array( $_GET['section'], array_keys( $tabs_with_sections[ $tab ] ) ) // WPCS: sanitization ok.
				) {
					$screen_pieces[] = wc_clean( wp_unslash( $_GET['section'] ) );
				}
			}

			// Editing a shipping zone.
			if ( ( 'shipping' === $tab ) && isset( $_GET['zone_id'] ) ) {
				$screen_pieces[] = 'edit_zone';
			}
		}
	}

	/**
	 * The current screen id.
	 *
	 * Used for identifying pages to render the WooCommerce Admin header.
	 *
	 * @param string|boolean $screen_id The screen id or false if not identified.
	 * @param WP_Screen      $current_screen The current WP_Screen.
	 */
	return apply_filters( 'woocommerce_navigation_current_screen_id', implode( '-', $screen_pieces ), $current_screen );
}