Yoast\WP\SEO\Task_List\Domain\Tasks
Abstract_Task{} │ abstract │ Yoast 1.0└─ Task_Interface
Abstract class for a task.
Хуков нет.
Использование
$Abstract_Task = new Abstract_Task();
// use class methods
Методы
- public get_badge()
- public get_duration()
- public get_enhanced_call_to_action()
- public get_id()
- public get_priority()
- public is_valid()
- public set_enhanced_call_to_action( ?Call_To_Action_Entry $enhanced_call_to_action )
- public to_array()
Код Abstract_Task{} Abstract Task{}
Yoast 27.8
abstract class Abstract_Task implements Task_Interface {
/**
* The ID of the task.
*
* @var string
*/
protected $id;
/**
* The priority of the task.
*
* @var string
*/
protected $priority;
/**
* The duration of the task.
*
* @var int
*/
protected $duration;
/**
* Whether the task is completed. Can be used for caching the completed status if the calculation is expensive.
*
* @var bool|null
*/
protected $is_completed = null;
/**
* The enhanced call to action.
*
* @var Call_To_Action_Entry
*/
private $enhanced_call_to_action;
/**
* Returns the task ID.
*
* @return string
*/
public function get_id(): string {
return $this->id;
}
/**
* Returns the task's priority.
*
* @return string
*/
public function get_priority(): string {
return $this->priority;
}
/**
* Returns the task's duration.
*
* @return int
*/
public function get_duration(): int {
return $this->duration;
}
/**
* Returns the task's badge.
*
* @return string|null
*/
public function get_badge(): ?string {
return null;
}
/**
* Sets the enhanced call to action.
*
* @param Call_To_Action_Entry $enhanced_call_to_action The enhanced call to action.
*
* @return void
*/
public function set_enhanced_call_to_action( ?Call_To_Action_Entry $enhanced_call_to_action ): void {
$this->enhanced_call_to_action = $enhanced_call_to_action;
}
/**
* Returns the enhanced call to action.
*
* @return Call_To_Action_Entry|null
*/
public function get_enhanced_call_to_action(): ?Call_To_Action_Entry {
return $this->enhanced_call_to_action;
}
/**
* Returns an array representation of the task data.
*
* @return array<string, string|bool> Returns in an array format.
*/
public function to_array(): array {
$data = [
'id' => $this->get_id(),
'duration' => $this->get_duration(),
'priority' => $this->get_priority(),
'badge' => $this->get_badge(),
'isCompleted' => $this->get_is_completed(),
'callToAction' => ( $this->get_enhanced_call_to_action() !== null ) ? $this->get_enhanced_call_to_action()->to_array() : null,
];
return \array_merge( $data, $this->get_copy_set()->to_array() );
}
/**
* Returns whether the task is valid.
*
* @return bool
*/
public function is_valid(): bool {
return true;
}
}