PluginProbe
Stream – Activity Log & Audit Trail / 3.8.2
Stream – Activity Log & Audit Trail v3.8.2
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
← All changes | classes/class-alert.php +16 -8 3.2.33.8.2 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Single Alert handler.
3 + * Manages a single alert, acting as a model.
4 4 *
5 5 * @package WP_Stream
6 6 */
7 7
@@ -56,9 +56,9 @@
56 56 */
57 57 public $alert_meta;
58 58
59 59 /**
60 - * Hold Plugin class
60 + * Holds instance of plugin object
61 61 *
62 62 * @var Plugin
63 63 */
64 64 public $plugin;
@@ -66,9 +66,9 @@
66 66 /**
67 67 * Class constructor
68 68 *
69 69 * @param object $item Alert data.
70 - * @param Plugin $plugin Plugin class.
70 + * @param Plugin $plugin Instance of plugin object.
71 71 * @return void
72 72 */
73 73 public function __construct( $item, $plugin ) {
74 74 $this->plugin = $plugin;
@@ -82,10 +82,11 @@
82 82 $this->alert_meta = isset( $item->alert_meta ) ? $item->alert_meta : array();
83 83 }
84 84
85 85 /**
86 - * Save state of the Alert to database
86 + * Saves alert state.
87 87 *
88 + * @todo Clean up/Remove unnecessary conditional statements.
88 89 * @return int The Post ID of the alert.
89 90 */
90 91 public function save() {
91 92
@@ -98,17 +99,20 @@
98 99 'post_author' => $this->author,
99 100 'post_type' => Alerts::POST_TYPE,
100 101 );
101 102
103 + // Remove empty "ID" field, if new post.
102 104 if ( empty( $args['ID'] ) ) {
103 105 unset( $args['ID'] );
104 106 }
105 107
108 + // Create or update alert and assign the ID.
106 109 $post_id = wp_insert_post( $args );
107 110 if ( empty( $args['ID'] ) ) {
108 111 $this->ID = $post_id;
109 112 }
110 113
114 + // Save alert type and meta.
111 115 $meta = array(
112 116 'alert_type' => $this->alert_type,
113 117 'alert_meta' => $this->alert_meta,
114 118 );
@@ -122,8 +126,10 @@
122 126
123 127 /**
124 128 * Process settings form data
125 129 *
130 + * @todo Confirm if the function is necessary, it's currently unreference
131 + * anywhere else in the plugin.
126 132 * @param array $data Processed post object data.
127 133 * @return array New post object data.
128 134 */
129 135 public function process_settings_form( $data ) {
@@ -200,9 +206,9 @@
200 206 return $title;
201 207 }
202 208
203 209 /**
204 - * Retrive current alert type object
210 + * Retreive current alert type object
205 211 *
206 212 * @return Alert_Type
207 213 */
208 214 public function get_alert_type_obj() {
@@ -229,9 +235,8 @@
229 235 * Trigger alert for a specific record.
230 236 *
231 237 * @param int $record_id Record ID.
232 238 * @param int $recordarr Record Data.
233 - * @return void
234 239 */
235 240 public function send_alert( $record_id, $recordarr ) {
236 241 $this->get_alert_type_obj()->alert( $record_id, $recordarr, $this );
237 242 }
@@ -318,10 +323,13 @@
318 323 if ( empty( $values ) ) {
319 324 return false;
320 325 }
321 326
322 - // Grab an Alert post ID.
323 - // @todo determine which Alert post takes priority.
327 + /**
328 + * Grab an Alert post ID.
329 + *
330 + * @todo Determine which Alert post takes priority.
331 + */
324 332 if ( is_array( $values ) ) {
325 333 $post_id = $values[0];
326 334 } else {
327 335 $post_id = $values;