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 +23 -16 3.13.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,9 +226,9 @@
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(
223 231 'records_ttl',
224 232 ),
225 233 'advanced' => array(
226 234 'delete_all_records',
@@ -320,15 +328,13 @@
320 328 $this->network_settings_page_slug,
321 329 $this->default_settings_page_slug,
322 330 );
323 331
324 - if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers, true ) ) {
332 + if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers, true ) ) { // CSRF okay
325 333 return;
326 334 }
327 335
328 - // @codingStandardsIgnoreStart
329 - $options = isset( $_POST['option_page'] ) ? explode( ',', stripslashes( $_POST['option_page'] ) ) : null;
330 - // @codingStandardsIgnoreEnd
336 + $options = isset( $_POST['option_page'] ) ? explode( ',', stripslashes( $_POST['option_page'] ) ) : null; // CSRF okay
331 337
332 338 if ( $options ) {
333 339
334 340 foreach ( $options as $option ) {
@@ -480,8 +486,9 @@
480 486 * @return string
481 487 */
482 488 public function network_admin_page_title( $page_title ) {
483 489 if ( is_network_admin() ) {
490 + // translators: Placeholder refers to a number of sites on the network (e.g. "42")
484 491 $site_count = sprintf( _n( '%d site', '%d sites', get_blog_count(), 'stream' ), number_format( get_blog_count() ) );
485 492 $page_title = sprintf( '%s (%s)', $page_title, $site_count );
486 493 }
487 494
@@ -495,9 +502,9 @@
495 502 *
496 503 * @return mixed
497 504 */
498 505 public function network_admin_columns( $columns ) {
499 - if ( is_network_admin() ) {
506 + if ( is_network_admin() || $this->ajax_network_admin() ) {
500 507 $columns = array_merge(
501 508 array_slice( $columns, 0, -1 ),
502 509 array(
503 510 'blog_id' => esc_html__( 'Site', 'stream' ),