PluginProbe
Stream – Activity Log & Audit Trail / 3.4.2
Stream – Activity Log & Audit Trail v3.4.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-connector.php +27 -13 3.0.13.4.2 View file →
@@ -30,13 +30,27 @@
30 30 */
31 31 public $prev_stream = null;
32 32
33 33 /**
34 + * Register connector in the WP Admin
35 + *
36 + * @var bool
37 + */
38 + public $register_admin = true;
39 +
40 + /**
41 + * Register connector in the WP Frontend
42 + *
43 + * @var bool
44 + */
45 + public $register_frontend = true;
46 +
47 + /**
34 48 * Register all context hooks
35 49 */
36 50 public function register() {
37 51 foreach ( $this->actions as $action ) {
38 - add_action( $action, array( $this, 'callback' ), 10, 5 );
52 + add_action( $action, array( $this, 'callback' ), 10, 99 );
39 53 }
40 54
41 55 add_filter( 'wp_stream_action_links_' . $this->name, array( $this, 'action_links' ), 10, 2 );
42 56 }
@@ -67,9 +81,9 @@
67 81
68 82 /**
69 83 * Add action links to Stream drop row in admin list screen
70 84 *
71 - * @param array $links Previous links registered
85 + * @param array $links Previous links registered
72 86 * @param object $record Stream record
73 87 *
74 88 * @filter wp_stream_action_links_{connector}
75 89 *
@@ -83,19 +97,18 @@
83 97 /**
84 98 * Log handler
85 99 *
86 100 * @param string $message sprintf-ready error message string
87 - * @param array $args sprintf (and extra) arguments to use
88 - * @param int $object_id Target object id
101 + * @param array $args sprintf (and extra) arguments to use
102 + * @param int $object_id Target object id
89 103 * @param string $context Context of the event
90 104 * @param string $action Action of the event
91 - * @param int $user_id User responsible for the event
105 + * @param int $user_id User responsible for the event
92 106 *
93 107 * @return bool
94 108 */
95 109 public function log( $message, $args, $object_id, $context, $action, $user_id = null ) {
96 - $class = get_called_class();
97 - $connector = str_replace( array( 'WP_Stream\\', 'Connector_' ), array( '', '' ), $class );
110 + $connector = $this->name;
98 111
99 112 $data = apply_filters(
100 113 'wp_stream_log_data',
101 114 compact( 'connector', 'message', 'args', 'object_id', 'context', 'action', 'user_id' )
@@ -144,10 +157,10 @@
144 157
145 158 /**
146 159 * Compare two values and return changed keys if they are arrays
147 160 *
148 - * @param mixed $old_value Value before change
149 - * @param mixed $new_value Value after change
161 + * @param mixed $old_value Value before change
162 + * @param mixed $new_value Value after change
150 163 * @param bool|int $deep Get array children changes keys as well, not just parents
151 164 *
152 165 * @return array
153 166 */
@@ -167,9 +180,10 @@
167 180 $diff = array_udiff_assoc(
168 181 $old_value,
169 182 $new_value,
170 183 function( $value1, $value2 ) {
171 - return maybe_serialize( $value1 ) !== maybe_serialize( $value2 );
184 + // Compare potentially complex nested arrays
185 + return wp_json_encode( $value1 ) !== wp_json_encode( $value2 );
172 186 }
173 187 );
174 188
175 189 $result = array_keys( $diff );
@@ -200,11 +214,11 @@
200 214
201 215 $result = array_fill_keys( $result, null );
202 216
203 217 foreach ( $result as $key => $val ) {
204 - if ( in_array( $key, $unique_keys_old ) ) {
218 + if ( in_array( $key, $unique_keys_old, true ) ) {
205 219 $result[ $key ] = false; // Removed
206 - } elseif ( in_array( $key, $unique_keys_new ) ) {
220 + } elseif ( in_array( $key, $unique_keys_new, true ) ) {
207 221 $result[ $key ] = true; // Added
208 222 } elseif ( $deep ) { // Changed, find what changed, only if we're allowed to explore a new level
209 223 if ( is_array( $old_value[ $key ] ) && is_array( $new_value[ $key ] ) ) {
210 224 $inner = array();
@@ -214,9 +228,9 @@
214 228 foreach ( $changed as $child => $change ) {
215 229 $inner[ $parent . '::' . $child ] = $change;
216 230 }
217 231 $result[ $key ] = 0; // Changed parent which has a changed children
218 - $result = array_merge( $result, $inner );
232 + $result = array_merge( $result, $inner );
219 233 }
220 234 }
221 235 }
222 236