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-settings.php +51 -30 3.2.33.4.2 View file →
@@ -9,8 +9,9 @@
9 9 class Settings {
10 10
11 11 /**
12 12 * Hold Plugin class
13 + *
13 14 * @var Plugin
14 15 */
15 16 public $plugin;
16 17
@@ -57,17 +58,21 @@
57 58 add_action( 'admin_init', array( $this, 'register_settings' ) );
58 59
59 60 // Remove records when records TTL is shortened
60 61 add_action(
61 - 'update_option_' . $this->option_key, array(
62 + 'update_option_' . $this->option_key,
63 + array(
62 64 $this,
63 65 'updated_option_ttl_remove_records',
64 - ), 10, 2
66 + ),
67 + 10,
68 + 2
65 69 );
66 70
67 71 // Apply label translations for settings
68 72 add_filter(
69 - 'wp_stream_serialized_labels', array(
73 + 'wp_stream_serialized_labels',
74 + array(
70 75 $this,
71 76 'get_settings_translations',
72 77 )
73 78 );
@@ -107,12 +112,15 @@
107 112 'find' => $search,
108 113 );
109 114
110 115 add_filter(
111 - 'user_search_columns', array(
116 + 'user_search_columns',
117 + array(
112 118 $this,
113 119 'add_display_name_search_columns',
114 - ), 10, 3
120 + ),
121 + 10,
122 + 3
115 123 );
116 124
117 125 $users = new WP_User_Query(
118 126 array(
@@ -128,12 +136,14 @@
128 136 )
129 137 );
130 138
131 139 remove_filter(
132 - 'user_search_columns', array(
140 + 'user_search_columns',
141 + array(
133 142 $this,
134 143 'add_display_name_search_columns',
135 - ), 10
144 + ),
145 + 10
136 146 );
137 147
138 148 if ( 0 === $users->get_total() ) {
139 149 wp_send_json_error( $response );
@@ -370,21 +380,18 @@
370 380
371 381 array_push( $fields['advanced']['fields'], $akismet_tracking );
372 382 }
373 383
374 - // If WP Cron is enabled, allow Admins to opt-in to WP Cron tracking
375 - if ( wp_stream_is_cron_enabled() ) {
376 - $wp_cron_tracking = array(
377 - 'name' => 'wp_cron_tracking',
378 - 'title' => esc_html__( 'WP Cron Tracking', 'stream' ),
379 - 'type' => 'checkbox',
380 - 'desc' => esc_html__( 'By default, Stream does not track activity performed by WordPress cron events unless you opt-in here. Enabling this is not necessary or recommended for most sites.', 'stream' ),
381 - 'after_field' => esc_html__( 'Enabled', 'stream' ),
382 - 'default' => 0,
383 - );
384 + $wp_cron_tracking = array(
385 + 'name' => 'wp_cron_tracking',
386 + 'title' => esc_html__( 'WP Cron Tracking', 'stream' ),
387 + 'type' => 'checkbox',
388 + 'desc' => esc_html__( 'By default, Stream does not track activity performed by WordPress cron events unless you opt-in here. Enabling this is not necessary or recommended for most sites.', 'stream' ),
389 + 'after_field' => esc_html__( 'Enabled', 'stream' ),
390 + 'default' => 0,
391 + );
384 392
385 - array_push( $fields['advanced']['fields'], $wp_cron_tracking );
386 - }
393 + array_push( $fields['advanced']['fields'], $wp_cron_tracking );
387 394
388 395 /**
389 396 * Filter allows for modification of options fields
390 397 *
@@ -464,9 +471,11 @@
464 471 public function register_settings() {
465 472 $sections = $this->get_fields();
466 473
467 474 register_setting(
468 - $this->option_key, $this->option_key, array(
475 + $this->option_key,
476 + $this->option_key,
477 + array(
469 478 $this,
470 479 'sanitize_settings',
471 480 )
472 481 );
@@ -540,14 +549,15 @@
540 549 $output[ $name ] = $input[ $name ];
541 550
542 551 // Support all values in multidimentional arrays too.
543 552 array_walk_recursive(
544 - $output[ $name ], function ( &$v, $k ) {
545 - $v = trim( $v );
553 + $output[ $name ],
554 + function ( &$v ) {
555 + $v = sanitize_text_field( trim( $v ) );
546 556 }
547 557 );
548 558 } else {
549 - $output[ $name ] = trim( $input[ $name ] );
559 + $output[ $name ] = sanitize_text_field( trim( $input[ $name ] ) );
550 560 }
551 561 }
552 562 }
553 563 }
@@ -831,10 +841,15 @@
831 841 );
832 842
833 843 $exclude_rows = array();
834 844
845 + // Account for when no rules have been added yet.
846 + if ( ! is_array( $current_value ) ) {
847 + $current_value = array();
848 + }
849 +
835 850 // Prepend an empty row.
836 - $current_value['exclude_row'] = array( 'helper' => '' ) + ( isset( $current_value['exclude_row'] ) ? $current_value['exclude_row'] : array() );
851 + $current_value['exclude_row'] = ( isset( $current_value['exclude_row'] ) ? $current_value['exclude_row'] : array() ) + array( 'helper' => '' );
837 852
838 853 foreach ( $current_value['exclude_row'] as $key => $value ) {
839 854 // Prepare values.
840 855 $author_or_role = isset( $current_value['author_or_role'][ $key ] ) ? $current_value['author_or_role'][ $key ] : '';
@@ -877,9 +892,10 @@
877 892 $author_or_role_values[] = $author_or_role_selected;
878 893 }
879 894
880 895 $author_or_role_input = $form->render_field(
881 - 'select2', array(
896 + 'select2',
897 + array(
882 898 'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'author_or_role' ) ),
883 899 'options' => $author_or_role_values,
884 900 'classes' => 'author_or_role',
885 901 'data' => array(
@@ -922,9 +938,10 @@
922 938 }
923 939 }
924 940
925 941 $connector_or_context_input = $form->render_field(
926 - 'select2', array(
942 + 'select2',
943 + array(
927 944 'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector_or_context' ) ),
928 945 'options' => $context_values,
929 946 'classes' => 'connector_or_context',
930 947 'data' => array(
@@ -934,9 +951,10 @@
934 951 )
935 952 );
936 953
937 954 $connector_input = $form->render_field(
938 - 'hidden', array(
955 + 'hidden',
956 + array(
939 957 'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector' ) ),
940 958 'value' => $connector,
941 959 'classes' => 'connector',
942 960 )
@@ -942,9 +960,10 @@
942 960 )
943 961 );
944 962
945 963 $context_input = $form->render_field(
946 - 'hidden', array(
964 + 'hidden',
965 + array(
947 966 'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'context' ) ),
948 967 'value' => $context,
949 968 'classes' => 'context',
950 969 )
@@ -960,9 +979,10 @@
960 979 );
961 980 }
962 981
963 982 $action_input = $form->render_field(
964 - 'select2', array(
983 + 'select2',
984 + array(
965 985 'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'action' ) ),
966 986 'value' => $action,
967 987 'options' => $action_values,
968 988 'classes' => 'action',
@@ -973,9 +993,10 @@
973 993 );
974 994
975 995 // IP Address input
976 996 $ip_address_input = $form->render_field(
977 - 'select2', array(
997 + 'select2',
998 + array(
978 999 'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'ip_address' ) ),
979 1000 'value' => $ip_address,
980 1001 'classes' => 'ip_address',
981 1002 'data' => array(