Skip to content

Commit 2dc736e

Browse files
authored
Tweak: Remove notifications legacy code (#231)
1 parent 1cded0e commit 2dc736e

15 files changed

Lines changed: 96 additions & 866 deletions

‎.github/workflows/php-coding-standards.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ jobs:
4848
run: |
4949
export PATH=$HOME/.composer/vendor/bin:$PATH
5050
composer run lint -- --report=checkstyle
51-
# Also show warnings as PR annotations (non-blocking)
51+
# Errors (including EscapeOutput) fail the job; remaining Security sniffs stay warnings
5252
vendor/bin/phpcs --standard=./ruleset.xml --extensions=php --error-severity=0 . --report=checkstyle || true

‎.github/workflows/phpunit.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@ jobs:
6868
cp -r /tmp/wordpress-develop/tests/phpunit/* /tmp/wordpress-tests-lib/
6969
7070
if [ "${{ matrix.wp-version }}" = "latest" ]; then
71-
wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
71+
WP_URL="https://wordpress.org/latest.tar.gz"
7272
else
73-
wget -O /tmp/wordpress.tar.gz https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
73+
WP_URL="https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz"
7474
fi
75+
for i in 1 2 3 4 5; do
76+
wget -nv -O /tmp/wordpress.tar.gz "$WP_URL" && break
77+
echo "Download attempt $i failed, retrying in $((i * 15))s..."
78+
sleep $((i * 15))
79+
done
7580
tar -xzf /tmp/wordpress.tar.gz -C /tmp/
7681
}
7782

‎aryo-activity-log.php‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
include( 'classes/class-aal-settings.php' );
3636
include( 'classes/class-aal-api.php' );
3737
include( 'classes/class-aal-hooks.php' );
38-
include( 'classes/class-aal-notifications.php' );
3938
include( 'classes/class-aal-export.php' );
4039
include( 'classes/class-aal-privacy.php' );
4140
include( 'classes/abstract-class-aal-exporter.php' );
@@ -76,11 +75,6 @@ final class AAL_Main {
7675
*/
7776
public $api;
7877

79-
/**
80-
* @var \AAL_Notifications
81-
*/
82-
public $notifications;
83-
8478
/**
8579
* Construct
8680
*/
@@ -91,7 +85,6 @@ protected function __construct() {
9185
$this->hooks = new AAL_Hooks();
9286
$this->settings = new AAL_Settings();
9387
$this->api = new AAL_API();
94-
$this->notifications = new AAL_Notifications();
9588

9689
new AAL_Export();
9790
new AAL_Privacy();
@@ -112,10 +105,12 @@ protected function __construct() {
112105
public function __clone() {
113106
_doing_it_wrong(
114107
__FUNCTION__,
115-
sprintf(
116-
/* translators: %s: Class name. */
117-
__( 'Cloning instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ),
118-
get_class( $this )
108+
esc_html(
109+
sprintf(
110+
/* translators: %s: Class name. */
111+
__( 'Cloning instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ),
112+
get_class( $this )
113+
)
119114
),
120115
'2.0.7'
121116
);
@@ -130,10 +125,12 @@ public function __clone() {
130125
public function __wakeup() {
131126
_doing_it_wrong(
132127
__FUNCTION__,
133-
sprintf(
134-
/* translators: %s: Class name. */
135-
__( 'Unserializing instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ),
136-
get_class( $this )
128+
esc_html(
129+
sprintf(
130+
/* translators: %s: Class name. */
131+
__( 'Unserializing instances of the singleton "%s" class is forbidden.', 'aryo-activity-log' ),
132+
get_class( $this )
133+
)
137134
),
138135
'2.0.7'
139136
);

‎assets/js/settings.js‎

Lines changed: 0 additions & 123 deletions
This file was deleted.

‎bin/install-wp-tests.sh‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@ WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
1818
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress}
1919

2020
download() {
21-
if [ `which curl` ]; then
22-
curl -s "$1" > "$2";
23-
elif [ `which wget` ]; then
24-
wget -nv -O "$2" "$1"
25-
fi
21+
local max_retries=5
22+
for i in $(seq 1 $max_retries); do
23+
if [ `which curl` ]; then
24+
curl -sSf --retry 3 --retry-delay 10 "$1" > "$2" && return 0
25+
elif [ `which wget` ]; then
26+
wget -nv --tries=3 --waitretry=10 -O "$2" "$1" && return 0
27+
fi
28+
echo "Download attempt $i/$max_retries failed for $1, retrying in $((i * 15))s..."
29+
sleep $((i * 15))
30+
done
31+
echo "All download attempts failed for $1"
32+
return 1
2633
}
2734

2835
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then

‎classes/class-aal-activity-log-list-table.php‎

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ private function maybe_promotion_row( $object_type ) {
222222
printf(
223223
'<tr class="aal-table-promotion-row" data-promotion-id="%s" data-nonce="%s"><td colspan="' . count( $this->get_columns() ) . '"><div class="aal-table-promotion-inner">%s%s</div></td></tr>',
224224
esc_attr( $object_type ),
225-
wp_create_nonce( 'aal_promotion' ),
226-
$promotion_html,
227-
$dismiss_button
225+
esc_attr( wp_create_nonce( 'aal_promotion' ) ),
226+
$promotion_html, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in get_promotion_html_by_object_type().
227+
$dismiss_button // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- label escaped with esc_html__().
228228
);
229229
}
230230

@@ -558,9 +558,21 @@ public function extra_tablenav_footer() {
558558
<?php
559559
// Is result filtering enabled?
560560
if ( array_key_exists( 'aal-filter', $_GET ) ) {
561-
echo sprintf( esc_html__( 'Export filtered records as %s', 'aryo-activity-log' ), $action_title );
561+
echo esc_html(
562+
sprintf(
563+
/* translators: %s: export format title. */
564+
__( 'Export filtered records as %s', 'aryo-activity-log' ),
565+
$action_title
566+
)
567+
);
562568
} else {
563-
echo sprintf( esc_html__( 'Export as %s', 'aryo-activity-log' ), $action_title );
569+
echo esc_html(
570+
sprintf(
571+
/* translators: %s: export format title. */
572+
__( 'Export as %s', 'aryo-activity-log' ),
573+
$action_title
574+
)
575+
);
564576
}
565577
?>
566578
</button>
@@ -614,7 +626,7 @@ public function extra_tablenav( $which ) {
614626
);
615627
echo '<select name="dateshow" id="hs-filter-date">';
616628
foreach ( $date_options as $key => $value )
617-
printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['dateshow'], $key, false ), $value );
629+
printf( '<option value="%s"%s>%s</option>', esc_attr( $key ), selected( $_REQUEST['dateshow'], $key, false ), esc_html( $value ) );
618630
echo '</select>';
619631

620632
submit_button( __( 'Filter', 'aryo-activity-log' ), 'button', 'aal-filter', false, array( 'id' => 'activity-query-submit' ) );
@@ -631,9 +643,9 @@ public function extra_tablenav( $which ) {
631643

632644
if ( ! empty( $output ) ) {
633645
echo '<select name="capshow" id="hs-filter-capshow">';
634-
printf( '<option value="">%s</option>', __( 'All Roles', 'aryo-activity-log' ) );
646+
printf( '<option value="">%s</option>', esc_html__( 'All Roles', 'aryo-activity-log' ) );
635647
foreach ( $output as $key => $value ) {
636-
printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['capshow'], $key, false ), $value );
648+
printf( '<option value="%s"%s>%s</option>', esc_attr( $key ), selected( $_REQUEST['capshow'], $key, false ), esc_html( $value ) );
637649
}
638650
echo '</select>';
639651
}
@@ -655,9 +667,9 @@ public function extra_tablenav( $which ) {
655667

656668
if ( ! empty( $output ) ) {
657669
echo '<select name="usershow" id="hs-filter-usershow">';
658-
printf( '<option value="">%s</option>', __( 'All Users', 'aryo-activity-log' ) );
670+
printf( '<option value="">%s</option>', esc_html__( 'All Users', 'aryo-activity-log' ) );
659671
foreach ( $output as $key => $value ) {
660-
printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['usershow'], $key, false ), $value );
672+
printf( '<option value="%s"%s>%s</option>', esc_attr( $key ), selected( $_REQUEST['usershow'], $key, false ), esc_html( $value ) );
661673
}
662674
echo '</select>';
663675
}
@@ -668,19 +680,16 @@ public function extra_tablenav( $which ) {
668680
$_REQUEST['typeshow'] = '';
669681
}
670682

671-
$output = array();
683+
echo '<select name="typeshow" id="hs-filter-typeshow">';
684+
printf( '<option value="">%s</option>', esc_html__( 'All Topics', 'aryo-activity-log' ) );
672685
foreach ( $this->data_types as $object_type ) {
673-
$output[] = sprintf(
686+
printf(
674687
'<option value="%s"%s>%s</option>',
675-
$object_type,
688+
esc_attr( $object_type ),
676689
selected( $_REQUEST['typeshow'], $object_type, false ),
677-
__( $object_type, 'aryo-activity-log' )
690+
esc_html( $object_type )
678691
);
679692
}
680-
681-
echo '<select name="typeshow" id="hs-filter-typeshow">';
682-
printf( '<option value="">%s</option>', __( 'All Topics', 'aryo-activity-log' ) );
683-
echo implode( '', $output );
684693
echo '</select>';
685694
}
686695

@@ -697,13 +706,16 @@ public function extra_tablenav( $which ) {
697706
if ( ! isset( $_REQUEST['showaction'] ) )
698707
$_REQUEST['showaction'] = '';
699708

700-
$output = array();
701-
foreach ( $actions as $action )
702-
$output[] = sprintf( '<option value="%s"%s>%s</option>', $action->action, selected( $_REQUEST['showaction'], $action->action, false ), $this->get_action_label( $action->action ) );
703-
704709
echo '<select name="showaction" id="hs-filter-showaction">';
705-
printf( '<option value="">%s</option>', __( 'All Actions', 'aryo-activity-log' ) );
706-
echo implode( '', $output );
710+
printf( '<option value="">%s</option>', esc_html__( 'All Actions', 'aryo-activity-log' ) );
711+
foreach ( $actions as $action ) {
712+
printf(
713+
'<option value="%s"%s>%s</option>',
714+
esc_attr( $action->action ),
715+
selected( $_REQUEST['showaction'], $action->action, false ),
716+
esc_html( $this->get_action_label( $action->action ) )
717+
);
718+
}
707719
echo '</select>';
708720
}
709721

@@ -740,7 +752,7 @@ public function extra_tablenav( $which ) {
740752

741753
foreach ( $filters as $filter ) {
742754
if ( ! empty( $_REQUEST[ $filter ] ) ) {
743-
echo '<a href="' . $this->get_filtered_link() . '" id="aal-reset-filter"><span class="dashicons dashicons-dismiss"></span>' . __( 'Reset Filters', 'aryo-activity-log' ) . '</a>';
755+
echo '<a href="' . esc_url( $this->get_filtered_link() ) . '" id="aal-reset-filter"><span class="dashicons dashicons-dismiss"></span>' . esc_html__( 'Reset Filters', 'aryo-activity-log' ) . '</a>';
744756
break;
745757
}
746758
}
@@ -881,8 +893,8 @@ public function search_box( $text, $input_id ) {
881893
$input_id = $input_id . '-search-input';
882894
?>
883895
<p class="search-box">
884-
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
885-
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php echo esc_attr( $search_data ); ?>" />
896+
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $text ); ?>:</label>
897+
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php echo esc_attr( $search_data ); ?>" />
886898
<?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
887899
</p>
888900
<?php

‎classes/class-aal-admin-ui.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ public function create_admin_menu() {
2121

2222
public function activity_log_page_func() {
2323
$this->get_list_table()->prepare_items();
24+
$page_slug = isset( $_REQUEST['page'] ) ? sanitize_key( wp_unslash( $_REQUEST['page'] ) ) : 'activity-log-page';
2425
?>
2526
<div class="wrap">
26-
<h1 class="aal-page-title"><?php _ex( 'Activity Log', 'Page and Menu Title', 'aryo-activity-log' ); ?></h1>
27+
<h1 class="aal-page-title"><?php echo esc_html_x( 'Activity Log', 'Page and Menu Title', 'aryo-activity-log' ); ?></h1>
2728

2829
<form id="activity-filter" method="get">
29-
<input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
30+
<input type="hidden" name="page" value="<?php echo esc_attr( $page_slug ); ?>" />
3031
<?php $this->get_list_table()->display(); ?>
3132
</form>
3233
</div>

‎classes/class-aal-api.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function _get_ip_address() {
7575

7676
$visitor_ip_address = '';
7777
if ( ! empty( $_SERVER[ $header_key ] ) ) {
78-
$visitor_ip_address = $_SERVER[ $header_key ];
78+
$visitor_ip_address = sanitize_text_field( wp_unslash( $_SERVER[ $header_key ] ) );
7979
}
8080

8181
$remote_address = apply_filters( 'aal_get_ip_address', $visitor_ip_address );

0 commit comments

Comments
 (0)