Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

Products::possibly_add_load_sample_return_notice_script()publicWC 1.0

Adds a return to task list notice when completing the loading sample products action.

Метод класса: Products{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$Products = new Products();
$Products->possibly_add_load_sample_return_notice_script( $hook );
$hook(строка) (обязательный)
Page hook.

Код Products::possibly_add_load_sample_return_notice_script() WC 8.7.0

public function possibly_add_load_sample_return_notice_script( $hook ) {
	if ( $hook !== 'edit.php' || get_query_var( 'post_type' ) !== 'product' ) {
		return;
	}

	$referer = wp_get_referer();
	if ( ! $referer || strpos( $referer, wc_admin_url() ) !== 0 ) {
		return;
	}

	if ( ! isset( $_GET[ Task::ACTIVE_TASK_TRANSIENT ] ) ) {
		return;
	}

	$task_id = sanitize_title_with_dashes( wp_unslash( $_GET[ Task::ACTIVE_TASK_TRANSIENT ] ) );
	if ( $task_id !== $this->get_id() || ! $this->is_complete() ) {
		return;
	}

	WCAdminAssets::register_script( 'wp-admin-scripts', 'onboarding-load-sample-products-notice', true );
}