| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Features\TaskManagement\Tasks; |
| 6 |
|
| 7 |
// todo - add listener |
| 8 |
class UnableToTrackTrafficTask extends AbstractTask |
| 9 |
{ |
| 10 |
public const IDENTIFIER = 'unable_to_track_traffic'; |
| 11 |
|
| 12 |
/** |
| 13 |
* This task is hidden by default as a user should have a working Metricool |
| 14 |
* script by default. Only show the task if it has an active state, never |
| 15 |
* in a completed state. That looks weird while filtering. |
| 16 |
*/ |
| 17 |
public function __construct() |
| 18 |
{ |
| 19 |
$this->hide(); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @inheritDoc |
| 24 |
*/ |
| 25 |
public function getText(): string |
| 26 |
{ |
| 27 |
return __('Unable to track traffic on your site', 'metricool'); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* @inheritDoc |
| 32 |
*/ |
| 33 |
public function getAction(): array |
| 34 |
{ |
| 35 |
// todo - fetch from settings |
| 36 |
$queryArgs = array_filter([ |
| 37 |
'blogId' => (defined('METRICOOL_BLOG_ID') ? METRICOOL_BLOG_ID : ''), |
| 38 |
'userId' => (defined('METRICOOL_USER_ID') ? METRICOOL_USER_ID : ''), |
| 39 |
]); |
| 40 |
|
| 41 |
$link = add_query_arg($queryArgs, 'https://app.metricool.com/evolution/web'); |
| 42 |
|
| 43 |
return [ |
| 44 |
'text' => __('Validate connection', 'metricool'), |
| 45 |
'link' => $link, |
| 46 |
'target' => '_blank', |
| 47 |
]; |
| 48 |
} |
| 49 |
} |
| 50 |
|