PluginProbe
Stream – Activity Log & Audit Trail / trunk
Stream – Activity Log & Audit Trail vtrunk
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
stream / classes / class-alert-trigger.php

class-alert-trigger.php in Stream – Activity Log & Audit Trail trunk, at classes/class-alert-trigger.php

96 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Alert Trigger abstract class.
4 *
5 * @package WP_Stream
6 */
7
8 namespace WP_Stream;
9
10 /**
11 * Class Alert_Trigger
12 *
13 * @package WP_Stream
14 */
15 abstract class Alert_Trigger {
16
17 /**
18 * Holds instance of plugin object
19 *
20 * @var Plugin
21 */
22 public $plugin;
23
24 /**
25 * Unique identifier
26 *
27 * @var string
28 */
29 public $slug;
30
31 /**
32 * Class constructor
33 *
34 * @param Plugin $plugin Instance of plugin object.
35 */
36 public function __construct( $plugin ) {
37 $this->plugin = $plugin;
38
39 add_action( 'wp_stream_alert_trigger_form_display', array( $this, 'add_fields' ), 10, 2 );
40 add_action( 'wp_stream_alert_trigger_form_save', array( $this, 'save_fields' ), 10, 1 );
41 add_filter( 'wp_stream_alert_trigger_check', array( $this, 'check_record' ), 10, 4 );
42 }
43
44 /**
45 * Checks if a record matches the criteria from the trigger.
46 *
47 * @filter wp_stream_alert_trigger_check
48 *
49 * @param bool $success Status of previous checks.
50 * @param int $record_id Record ID.
51 * @param array $recordarr Record data.
52 * @param Alert $alert The Alert being worked on.
53 * @return bool False on failure, otherwise should return original value of $success.
54 */
55 abstract public function check_record( $success, $record_id, $recordarr, $alert );
56
57 /**
58 * Adds fields to the trigger form.
59 *
60 * @action wp_stream_alert_trigger_form_display
61 *
62 * @param Form_Generator $form The Form Object to add to.
63 * @param Alert $alert The Alert being worked on.
64 * @return void
65 */
66 abstract public function add_fields( $form, $alert );
67
68 /**
69 * Validate and save Alert object
70 *
71 * @action wp_stream_alert_trigger_form_save
72 *
73 * @param Alert $alert The Alert being worked on.
74 * @return void
75 */
76 abstract public function save_fields( $alert );
77
78 /**
79 * Returns the trigger's value for the given alert.
80 *
81 * @param string $context The location this data will be displayed in.
82 * @param Alert|null $alert Alert being processed.
83 * @return string
84 */
85 abstract public function get_display_value( $context = 'normal', $alert = null );
86
87 /**
88 * Allow connectors to determine if their dependencies is satisfied or not
89 *
90 * @return bool
91 */
92 public function is_dependency_satisfied() {
93 return true;
94 }
95 }
96