Tasks
1 month ago
DeprecatedExtendedTask.php
2 years ago
DeprecatedOptions.php
3 months ago
Init.php
3 years ago
Task.php
11 months ago
TaskList.php
4 weeks ago
TaskListSection.php
3 years ago
TaskLists.php
4 months ago
TaskTraits.php
4 years ago
TaskTraits.php
48 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Task and TaskList Traits |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Admin\Features\OnboardingTasks; |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * TaskTraits class. |
| 12 | */ |
| 13 | trait TaskTraits { |
| 14 | /** |
| 15 | * Record a tracks event with the prefixed event name. |
| 16 | * |
| 17 | * @param string $event_name Event name. |
| 18 | * @param array $args Array of tracks arguments. |
| 19 | * @return string Prefixed event name. |
| 20 | */ |
| 21 | public function record_tracks_event( $event_name, $args = array() ) { |
| 22 | if ( ! $this->get_list_id() ) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | $prefixed_event_name = $this->prefix_event( $event_name ); |
| 27 | |
| 28 | wc_admin_record_tracks_event( |
| 29 | $prefixed_event_name, |
| 30 | $args |
| 31 | ); |
| 32 | |
| 33 | return $prefixed_event_name; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get the task list ID. |
| 38 | * |
| 39 | * @return string |
| 40 | */ |
| 41 | public function get_list_id() { |
| 42 | $namespaced_class = get_class( $this ); |
| 43 | return is_subclass_of( $namespaced_class, 'Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task' ) |
| 44 | ? $this->get_parent_id() |
| 45 | : $this->id; |
| 46 | } |
| 47 | } |
| 48 |