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-network.php +31 -22 3.0.23.4.2 View file →
@@ -3,8 +3,9 @@
3 3
4 4 class Network {
5 5 /**
6 6 * Hold Plugin class
7 + *
7 8 * @var Plugin
8 9 */
9 10 public $plugin;
10 11
@@ -11,9 +12,9 @@
11 12 public $network_settings_page_slug = 'wp_stream_network_settings';
12 13
13 14 public $default_settings_page_slug = 'wp_stream_default_settings';
14 15
15 - function __construct( $plugin ) {
16 + public function __construct( $plugin ) {
16 17 $this->plugin = $plugin;
17 18
18 19 // Always add default site_id/blog_id params when multisite
19 20 if ( is_multisite() ) {
@@ -50,8 +51,10 @@
50 51
51 52 /**
52 53 * Workaround to get admin-ajax.php to know when the request is from the Network Admin
53 54 *
55 + * @return bool
56 + *
54 57 * @action init
55 58 *
56 59 * @see https://core.trac.wordpress.org/ticket/22589
57 60 */
@@ -63,9 +66,12 @@
63 66 &&
64 67 preg_match( '#^' . network_admin_url() . '#i', $_SERVER['HTTP_REFERER'] )
65 68 ) {
66 69 define( 'WP_NETWORK_ADMIN', true );
70 + return WP_NETWORK_ADMIN;
67 71 }
72 +
73 + return false;
68 74 }
69 75
70 76 /**
71 77 * Builds a stdClass object used when displaying actions done in network administration
@@ -72,9 +78,9 @@
72 78 *
73 79 * @return object
74 80 */
75 81 public function get_network_blog() {
76 - $blog = new \stdClass;
82 + $blog = new \stdClass();
77 83 $blog->blog_id = 0;
78 84 $blog->blogname = esc_html__( 'Network Admin', 'stream' );
79 85
80 86 return $blog;
@@ -85,13 +91,9 @@
85 91 *
86 92 * @return bool
87 93 */
88 94 public function is_network_activated() {
89 - if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
90 - require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
91 - }
92 -
93 - return is_plugin_active_for_network( $this->plugin->locations['plugin'] );
95 + return $this->plugin->is_network_activated();
94 96 }
95 97
96 98 /**
97 99 * Adds Stream to the admin bar under the "My Sites > Network Admin" menu
@@ -135,8 +137,9 @@
135 137 return;
136 138 }
137 139
138 140 remove_submenu_page( $this->plugin->admin->records_page_slug, 'wp_stream_settings' );
141 + remove_submenu_page( $this->plugin->admin->records_page_slug, 'edit.php?post_type=wp_stream_alerts' );
139 142
140 143 $this->plugin->admin->screen_id['network_settings'] = add_submenu_page(
141 144 $this->plugin->admin->records_page_slug,
142 145 __( 'Stream Network Settings', 'stream' ),
@@ -171,9 +174,14 @@
171 174 */
172 175 public function settings_form_action( $action ) {
173 176 if ( is_network_admin() ) {
174 177 $current_page = wp_stream_filter_input( INPUT_GET, 'page' );
175 - $action = add_query_arg( array( 'action' => $current_page ), 'edit.php' );
178 + $action = add_query_arg(
179 + array(
180 + 'action' => $current_page,
181 + ),
182 + 'edit.php'
183 + );
176 184 }
177 185
178 186 return $action;
179 187 }
@@ -192,12 +200,12 @@
192 200
193 201 $current_page = wp_stream_filter_input( INPUT_GET, 'page' );
194 202
195 203 switch ( $current_page ) {
196 - case $this->network_settings_page_slug :
204 + case $this->network_settings_page_slug:
197 205 $description = __( 'These settings apply to all sites on the network.', 'stream' );
198 206 break;
199 - case $this->default_settings_page_slug :
207 + case $this->default_settings_page_slug:
200 208 $description = __( 'These default settings will apply to new sites created on the network. These settings do not alter existing sites.', 'stream' );
201 209 break;
202 210 }
203 211
@@ -218,11 +226,13 @@
218 226
219 227 $stream_hidden_options = apply_filters(
220 228 'wp_stream_hidden_option_fields',
221 229 array(
222 - 'general' => array(
230 + 'general' => array(
231 + 'records_ttl',
232 + ),
233 + 'advanced' => array(
223 234 'delete_all_records',
224 - 'records_ttl',
225 235 ),
226 236 )
227 237 );
228 238
@@ -256,9 +266,9 @@
256 266 if ( ! isset( $hidden_options[ $section_key ] ) ) {
257 267 continue;
258 268 }
259 269
260 - if ( in_array( $field['name'], $hidden_options[ $section_key ] ) ) {
270 + if ( in_array( $field['name'], $hidden_options[ $section_key ], true ) ) {
261 271 unset( $fields[ $section_key ]['fields'][ $key ] );
262 272 }
263 273 }
264 274 }
@@ -318,15 +328,13 @@
318 328 $this->network_settings_page_slug,
319 329 $this->default_settings_page_slug,
320 330 );
321 331
322 - if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers ) ) {
332 + if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers, true ) ) { // CSRF okay
323 333 return;
324 334 }
325 335
326 - // @codingStandardsIgnoreStart
327 - $options = isset( $_POST['option_page'] ) ? explode( ',', stripslashes( $_POST['option_page'] ) ) : null;
328 - // @codingStandardsIgnoreEnd
336 + $options = isset( $_POST['option_page'] ) ? explode( ',', stripslashes( $_POST['option_page'] ) ) : null; // CSRF okay
329 337
330 338 if ( $options ) {
331 339
332 340 foreach ( $options as $option ) {
@@ -393,12 +401,12 @@
393 401 'disabled' => '',
394 402 );
395 403
396 404 // add all sites
397 - foreach ( wp_get_sites() as $blog ) {
398 - $blog_data = get_blog_details( $blog );
405 + foreach ( wp_stream_get_sites() as $blog ) {
406 + $blog_data = get_blog_details( $blog->blog_id );
399 407
400 - $blogs[ $blog['blog_id'] ] = array(
408 + $blogs[ $blog->blog_id ] = array(
401 409 'label' => $blog_data->blogname,
402 410 'disabled' => '',
403 411 );
404 412 }
@@ -478,9 +486,10 @@
478 486 * @return string
479 487 */
480 488 public function network_admin_page_title( $page_title ) {
481 489 if ( is_network_admin() ) {
482 - $site_count = sprintf( _n( '1 site', '%s sites', get_blog_count(), 'stream' ), number_format( get_blog_count() ) );
490 + // translators: Placeholder refers to a number of sites on the network (e.g. "42")
491 + $site_count = sprintf( _n( '%d site', '%d sites', get_blog_count(), 'stream' ), number_format( get_blog_count() ) );
483 492 $page_title = sprintf( '%s (%s)', $page_title, $site_count );
484 493 }
485 494
486 495 return $page_title;
@@ -493,9 +502,9 @@
493 502 *
494 503 * @return mixed
495 504 */
496 505 public function network_admin_columns( $columns ) {
497 - if ( is_network_admin() ) {
506 + if ( is_network_admin() || $this->ajax_network_admin() ) {
498 507 $columns = array_merge(
499 508 array_slice( $columns, 0, -1 ),
500 509 array(
501 510 'blog_id' => esc_html__( 'Site', 'stream' ),