PluginProbe
Stream – Activity Log & Audit Trail / 3.6.1
Stream – Activity Log & Audit Trail v3.6.1
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-db.php +32 -22 3.2.33.6.1 View file →
@@ -1,10 +1,19 @@
1 1 <?php
2 +/**
3 + * Manage DB connections using a provided DB driver.
4 + *
5 + * @package WP_Stream
6 + */
7 +
2 8 namespace WP_Stream;
3 9
10 +/**
11 + * Class - DB
12 + */
4 13 class DB {
5 14 /**
6 - * Hold the Driver class
15 + * Holds the driver instance
7 16 *
8 17 * @var DB_Driver
9 18 */
10 19 public $driver;
@@ -27,9 +36,9 @@
27 36
28 37 /**
29 38 * Insert a record
30 39 *
31 - * @param array $record
40 + * @param array $record New record.
32 41 *
33 42 * @return int
34 43 */
35 44 public function insert( $record ) {
@@ -46,11 +55,12 @@
46 55 */
47 56 $record = apply_filters( 'wp_stream_record_array', $record );
48 57
49 58 array_walk(
50 - $record, function( &$value, &$key ) {
59 + $record,
60 + function( &$value, &$key ) {
51 61 if ( ! is_array( $value ) ) {
52 - $value = strip_tags( $value );
62 + $value = wp_strip_all_tags( $value );
53 63 }
54 64 }
55 65 );
56 66
@@ -95,14 +105,14 @@
95 105 *
96 106 * @see assemble_records
97 107 * @since 1.0.4
98 108 *
99 - * @param string $column
109 + * @param string $column Table column to pull data from.
100 110 *
101 111 * @return array
102 112 */
103 113 public function existing_records( $column ) {
104 - // Sanitize column
114 + // Sanitize column.
105 115 $allowed_columns = array( 'ID', 'site_id', 'blog_id', 'object_id', 'user_id', 'user_role', 'created', 'summary', 'connector', 'context', 'action', 'ip' );
106 116 if ( ! in_array( $column, $allowed_columns, true ) ) {
107 117 return array();
108 118 }
@@ -129,39 +139,39 @@
129 139
130 140 /**
131 141 * Get stream records
132 142 *
133 - * @param array Query args
143 + * @param array $args Arguments to filter result by.
134 144 *
135 145 * @return array Stream Records
136 146 */
137 147 public function get_records( $args ) {
138 148 $defaults = array(
139 - // Search param
149 + // Search param.
140 150 'search' => null,
141 151 'search_field' => 'summary',
142 152 'record_after' => null, // Deprecated, use date_after instead
143 - // Date-based filters
144 - 'date' => null, // Ex: 2015-07-01
145 - 'date_from' => null, // Ex: 2015-07-01
146 - 'date_to' => null, // Ex: 2015-07-01
147 - 'date_after' => null, // Ex: 2015-07-01T15:19:21+00:00
148 - 'date_before' => null, // Ex: 2015-07-01T15:19:21+00:00
149 - // Record ID filters
153 + // Date-based filters.
154 + 'date' => null, // Ex: 2015-07-01.
155 + 'date_from' => null, // Ex: 2015-07-01.
156 + 'date_to' => null, // Ex: 2015-07-01.
157 + 'date_after' => null, // Ex: 2015-07-01T15:19:21+00:00.
158 + 'date_before' => null, // Ex: 2015-07-01T15:19:21+00:00.
159 + // Record ID filters.
150 160 'record' => null,
151 161 'record__in' => array(),
152 162 'record__not_in' => array(),
153 - // Pagination params
163 + // Pagination params.
154 164 'records_per_page' => get_option( 'posts_per_page', 20 ),
155 165 'paged' => 1,
156 - // Order
166 + // Order.
157 167 'order' => 'desc',
158 168 'orderby' => 'date',
159 - // Fields selection
169 + // Fields selection.
160 170 'fields' => array(),
161 171 );
162 172
163 - // Additional property fields
173 + // Additional property fields.
164 174 $properties = array(
165 175 'user_id' => null,
166 176 'user_role' => null,
167 177 'ip' => null,
@@ -179,9 +189,9 @@
179 189 * @return array Array of query properties
180 190 */
181 191 $properties = apply_filters( 'wp_stream_query_properties', $properties );
182 192
183 - // Add property fields to defaults, including their __in/__not_in variations
193 + // Add property fields to defaults, including their __in/__not_in variations.
184 194 foreach ( $properties as $property => $default ) {
185 195 if ( ! isset( $defaults[ $property ] ) ) {
186 196 $defaults[ $property ] = $default;
187 197 }
@@ -207,9 +217,9 @@
207 217
208 218 /**
209 219 * Helper function, backwards compatibility
210 220 *
211 - * @param array $args Query args
221 + * @param array $args Argument to filter result by.
212 222 *
213 223 * @return array Stream Records
214 224 */
215 225 public function query( $args ) {
@@ -218,9 +228,9 @@
218 228
219 229 /**
220 230 * Return the number of records found in last request
221 231 *
222 - * return int
232 + * @return int
223 233 */
224 234 public function get_found_records_count() {
225 235 return $this->found_records_count;
226 236 }