Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks
Products::possibly_add_load_sample_return_notice_script
Adds a return to task list notice when completing the loading sample products action.
Method of the class: Products{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Products = new Products(); $Products->possibly_add_load_sample_return_notice_script( $hook );
- $hook(string) (required)
- Page hook.
Products::possibly_add_load_sample_return_notice_script() Products::possibly add load sample return notice script code WC 10.9.4
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 );
}