| 1 |
<?php |
| 2 |
/** |
| 3 |
* Alert Type abstract class. |
| 4 |
* |
| 5 |
* Used to register new Alert types. |
| 6 |
* |
| 7 |
* @package WP_Stream |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace WP_Stream; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class Alert_Type |
| 14 |
* |
| 15 |
* @package WP_Stream |
| 16 |
*/ |
| 17 |
abstract class Alert_Type { |
| 18 |
|
| 19 |
/** |
| 20 |
* Holds instance of plugin object |
| 21 |
* |
| 22 |
* @var Plugin |
| 23 |
*/ |
| 24 |
public $plugin; |
| 25 |
|
| 26 |
/** |
| 27 |
* Unique identifier. |
| 28 |
* |
| 29 |
* @var string |
| 30 |
*/ |
| 31 |
public $slug; |
| 32 |
|
| 33 |
/** |
| 34 |
* Class constructor. |
| 35 |
* |
| 36 |
* @param Plugin $plugin Plugin object. |
| 37 |
*/ |
| 38 |
public function __construct( $plugin ) { |
| 39 |
$this->plugin = $plugin; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Alert recipients about the new record |
| 44 |
* |
| 45 |
* @param int $record_id Record ID. |
| 46 |
* @param array $recordarr Record details. |
| 47 |
* @param array $options Alert options. |
| 48 |
*/ |
| 49 |
abstract public function alert( $record_id, $recordarr, $options ); |
| 50 |
|
| 51 |
/** |
| 52 |
* Display settings form for configuration of individual alerts |
| 53 |
* |
| 54 |
* @param Alert $alert Alert currently being worked on. |
| 55 |
*/ |
| 56 |
public function display_fields( $alert ) { |
| 57 |
// Implementation optional, but recommended. |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Process settings form for configuration of individual alerts |
| 62 |
* |
| 63 |
* @param Alert $alert Alert currently being worked on. |
| 64 |
*/ |
| 65 |
public function save_fields( $alert ) { |
| 66 |
// Implementation optional, but recommended. |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Allow connectors to determine if their dependencies are satisfied or not |
| 71 |
* |
| 72 |
* @return bool |
| 73 |
*/ |
| 74 |
public function is_dependency_satisfied() { |
| 75 |
// Implementation optional, but recommended. |
| 76 |
return true; |
| 77 |
} |
| 78 |
} |
| 79 |
|