Skip to content

Commit

Permalink
Fix Squiz.Commenting.InlineComment.InvalidEndChar
Browse files Browse the repository at this point in the history
  • Loading branch information
bonny committed Nov 6, 2023
1 parent 2ec70e7 commit 3aeac51
Show file tree
Hide file tree
Showing 50 changed files with 432 additions and 478 deletions.
2 changes: 1 addition & 1 deletion dropins/class-donate-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function add_settings() {
'simple_history_settings_section_donate',
[ _x( 'Support development', 'donate settings headline', 'simple-history' ), 'volunteer_activism' ],
array( $this, 'settings_section_output' ),
Simple_History::SETTINGS_MENU_SLUG // same slug as for options menu page
Simple_History::SETTINGS_MENU_SLUG // same slug as for options menu page.
);
}

Expand Down
2 changes: 1 addition & 1 deletion dropins/class-event-details-dev-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function get_example_context() {
'pager_size_new' => '25',
'pager_size_prev' => '50',

// Format used by plugin and theme updates
// Format used by plugin and theme updates.
'theme_name' => 'Neve',
'theme_new_version' => '3.6.6',
'theme_current_version' => '3.6.4',
Expand Down
20 changes: 5 additions & 15 deletions dropins/class-export-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function downloadExport() {
add_filter( 'simple_history/header_time_ago_max_time', '__return_zero' );
add_filter( 'simple_history/header_just_now_max_time', '__return_zero' );

// Don't use "You" if event is initiated by the same user that does the export
// Don't use "You" if event is initiated by the same user that does the export.
add_filter( 'simple_history/header_initiator_use_you', '__return_false' );

$query = new Log_Query();
Expand Down Expand Up @@ -73,10 +73,9 @@ public function downloadExport() {
} elseif ( 'html' == $export_format ) {
$filename = 'simple-history-export-' . time() . '.html';
header( 'Content-Type: text/html' );
// header("Content-Disposition: attachment; filename='{$filename}'");
}

// Some formats need to output some stuff before the actual loops
// Some formats need to output some stuff before the actual loops.
if ( 'json' == $export_format ) {
$json_row = '[';
fwrite( $fp, $json_row );
Expand All @@ -95,9 +94,9 @@ public function downloadExport() {
// Paginate through all pages and all their rows.
$row_loop = 0;
while ( $page_current <= $pages_count + 1 ) {
// if ($page_current > 1) { break; } # To debug/test

foreach ( $events['log_rows'] as $one_row ) {
// if ( $row_loop > 10) { break; } # To debug/test

set_time_limit( 30 );

if ( 'csv' == $export_format ) {
Expand Down Expand Up @@ -155,20 +154,13 @@ public function downloadExport() {
$row_loop++;
}// End foreach().

// echo "<br>memory_get_usage:<br>"; print_r(memory_get_usage());
// echo "<br>memory_get_peak_usage:<br>"; print_r(memory_get_peak_usage());
// echo "<br>fetch next page";
flush();

// Fetch next page
// @TODO: must take into consideration that new items can be added while we do the fetch
// @TODO: must take into consideration that new items can be added while we do the fetch.
$page_current++;
$query_args['paged'] = $page_current;
$events = $query->query( $query_args );

// echo "<br>did fetch next page";
// echo "<br>memory_get_usage:<br>"; print_r(memory_get_usage());
// echo "<br>memory_get_peak_usage:<br>"; print_r(memory_get_peak_usage());
}// End while().

if ( 'json' == $export_format ) {
Expand All @@ -183,8 +175,6 @@ public function downloadExport() {
flush();

exit;

// echo "<br>done";
}// End if().
}

Expand Down
38 changes: 19 additions & 19 deletions dropins/class-filter-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public function gui_page_filters() {

global $wpdb;

// Start months filter
// Start months filter.
$table_name = $this->simple_history->get_events_table_name();
$loggers_user_can_read_sql_in = $this->simple_history->get_loggers_that_user_can_read( null, 'sql' );

// Get unique months
// Get unique months.
$cache_key = 'sh_filter_unique_months';
$result_months = get_transient( $cache_key );

Expand All @@ -82,12 +82,12 @@ public function gui_page_filters() {
// Default month = current month
// Mainly for performance reasons, since often
// it's not the users intention to view all events,
// but just the latest
// but just the latest.

// Determine if we limit the date range by default
// Determine if we limit the date range by default.
$daysToShow = 1;

// Start with the latest day
// Start with the latest day.
$numEvents = $this->simple_history->get_unique_events_for_days( $daysToShow );
$numPages = $numEvents / $this->simple_history->get_pager_size();

Expand Down Expand Up @@ -132,7 +132,7 @@ public function gui_page_filters() {
'numPages' => $numPages,
);

// If 30 days gives a big amount of pages, go back to 14 days
// If 30 days gives a big amount of pages, go back to 14 days.
if ( $numPages > 1000 ) {
$daysToShow = 14;
}
Expand All @@ -154,15 +154,15 @@ public function gui_page_filters() {
<?php

// custom date range
// since 2.8.1
// since 2.8.1.
printf(
'<option value="%1$s" %3$s>%2$s</option>',
'customRange', // 1 - value
esc_attr_x( 'Custom date range...', 'Filter dropin: filter custom range', 'simple-history' ), // 2 text
selected( $daysToShow, 'customRange', 0 )
);

// One day+ Last week + two weeks back + 30 days back
// One day+ Last week + two weeks back + 30 days back.
printf(
'<option value="%1$s" %3$s>%2$s</option>',
'lastdays:1', // 1 - value
Expand Down Expand Up @@ -198,7 +198,7 @@ public function gui_page_filters() {
selected( $daysToShow, 60, 0 )
);

// Months
// Months.
foreach ( $result_months as $row ) {
printf(
'<option value="%1$s">%2$s</option>',
Expand Down Expand Up @@ -347,11 +347,11 @@ class="SimpleHistory__filters__filter SimpleHistory__filters__filter--logger"
$logger_info = $logger['instance']->get_info();
$logger_slug = $logger['instance']->get_slug();

// Get labels for logger
// Get labels for logger.
if ( isset( $logger_info['labels']['search'] ) ) {
printf( '<optgroup label="%1$s">', esc_attr( $logger_info['labels']['search']['label'] ) );

// If all activity
// If all activity.
if ( ! empty( $logger_info['labels']['search']['label_all'] ) ) {
$arr_all_search_messages = array();
foreach ( $logger_info['labels']['search']['options'] as $option_messages ) {
Expand All @@ -365,7 +365,7 @@ class="SimpleHistory__filters__filter SimpleHistory__filters__filter--logger"
printf( '<option value="%2$s">%1$s</option>', esc_attr( $logger_info['labels']['search']['label_all'] ), esc_attr( implode( ',', $arr_all_search_messages ) ) );
}

// For each specific search option
// For each specific search option.
foreach ( $logger_info['labels']['search']['options'] as $option_key => $option_messages ) {
foreach ( $option_messages as $key => $val ) {
$option_messages[ $key ] = $logger_slug . ':' . $val;
Expand Down Expand Up @@ -487,12 +487,12 @@ public function ajax_simple_history_filters_search_user() {
$q = sanitize_text_field( wp_unslash( $_GET['q'] ?? '' ) );
$page_limit = isset( $_GET['page_limit'] ) ? (int) $_GET['page_limit'] : '';

// query and page limit must be set
// query and page limit must be set.
if ( ! $q || ! $page_limit ) {
wp_send_json_error();
}

// user must have list_users capability (default super admin + administrators have this)
// user must have list_users capability (default super admin + administrators have this).
if ( ! current_user_can( 'list_users' ) ) {
wp_send_json_error();
}
Expand All @@ -501,7 +501,7 @@ public function ajax_simple_history_filters_search_user() {
// because a user can change email
// search in context: user_id, user_email, user_login
// search in wp_users: login, nicename, user_email
// search and get users. make sure to use "fields" and "number" or we can get timeout/use lots of memory if we have a large amount of users
// search and get users. make sure to use "fields" and "number" or we can get timeout/use lots of memory if we have a large amount of users.
$results_user = get_users(
array(
'search' => "*{$q}*",
Expand All @@ -510,15 +510,15 @@ public function ajax_simple_history_filters_search_user() {
)
);

// add lower case id to user array
// add lower case id to user array.
array_walk(
$results_user,
function ( $val ) {
$val->id = $val->ID;
}
);

// add gravatars to user array
// add gravatars to user array.
array_walk( $results_user, array( $this, 'add_gravatar_to_user_array' ) );

$data = array(
Expand Down Expand Up @@ -562,7 +562,7 @@ public function add_gravatar_to_user_array( &$val, $index = null ) {
public function touch_time( $from_or_to, $edit = 1 ) {
global $wp_locale;

// Prefix = text before the inputs
// Prefix = text before the inputs.
$prefix = '';
$input_prefix = '';
if ( 'from' == $from_or_to ) {
Expand All @@ -573,7 +573,7 @@ public function touch_time( $from_or_to, $edit = 1 ) {
$input_prefix = 'to_';
}

// The default date to show in the inputs
// The default date to show in the inputs.
$date = gmdate( 'Y-m-d' );

$jj = mysql2date( 'd', $date, false );
Expand Down
8 changes: 4 additions & 4 deletions dropins/class-new-rows-notifier-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function ajax() {
);
}

// User must have capability to view the history page
// User must have capability to view the history page.
if ( ! current_user_can( $this->simple_history->get_view_history_capability() ) ) {
wp_send_json_error(
array(
Expand All @@ -95,7 +95,7 @@ public function ajax() {
$logQuery = new Log_Query();
$answer = $logQuery->query( $logQueryArgs );

// Use our own response array instead of $answer to keep size down
// Use our own response array instead of $answer to keep size down.
$json_data = array();

$numNewRows = $answer['total_row_count'] ?? 0;
Expand All @@ -105,9 +105,9 @@ public function ajax() {

if ( $numNewRows ) {
// We have new rows
// Append strings
// Append strings.
$textRowsFound = sprintf(
// translators: %s is the number of new events
// translators: %s is the number of new events.
_n( '%s new event', '%s new events', $numNewRows, 'simple-history' ),
$numNewRows
);
Expand Down
8 changes: 4 additions & 4 deletions dropins/class-quick-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function loaded() {
public function output_quick_stats() {
global $wpdb;

// Get number of events today
// Get number of events today.
$logQuery = new Log_Query();
$logResults = $logQuery->query(
array(
Expand All @@ -34,10 +34,10 @@ public function output_quick_stats() {

$total_row_count = (int) $logResults['total_row_count'];

// Get sql query for where to read only loggers current user is allowed to read/view
// Get sql query for where to read only loggers current user is allowed to read/view.
$sql_loggers_in = $this->simple_history->get_loggers_that_user_can_read( get_current_user_id(), 'sql' );

// Get number of users today, i.e. events with wp_user as initiator
// Get number of users today, i.e. events with wp_user as initiator.
$sql_users_today = sprintf(
'
SELECT
Expand Down Expand Up @@ -110,7 +110,7 @@ public function output_quick_stats() {
<?php
$msg_tmpl = '';

// No results today at all
// No results today at all.
if ( $total_row_count == 0 ) {
$msg_tmpl = __( 'No events today so far.', 'simple-history' );
} else {
Expand Down
16 changes: 8 additions & 8 deletions dropins/class-rss-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function add_settings() {
$settings_section_rss_id,
[ $rss_section_title, 'rss_feed' ],
array( $this, 'settings_section_output' ),
Simple_History::SETTINGS_MENU_SLUG // same slug as for options menu page
Simple_History::SETTINGS_MENU_SLUG // same slug as for options menu page.
);

// Enable/Disable RSS feed.
Expand Down Expand Up @@ -139,7 +139,7 @@ public function add_settings() {
public function is_rss_enabled() {
$is_enabled = false;

// User has never used the plugin we disable RSS feed
// User has never used the plugin we disable RSS feed.
if ( $this->get_rss_secret() === false && get_option( 'simple_history_enable_rss_feed' ) === false ) {
// We disable RSS by default, we use 0/1 to prevent fake disabled with bools from functions returning false for unset.
update_option( 'simple_history_enable_rss_feed', '0' );
Expand Down Expand Up @@ -250,12 +250,12 @@ public function output_rss() {
<atom:link href="<?php echo esc_url( $self_link ); ?>" rel="self" type="application/atom+xml" />
<?php

// Override capability check: if you have a valid rss_secret_key you can read it all
// Override capability check: if you have a valid rss_secret_key you can read it all.
$action_tag = 'simple_history/loggers_user_can_read/can_read_single_logger';
add_filter( $action_tag, '__return_true', 10, 0 );

// Modify header time output so it does not show relative date or time ago-format
// Because we don't know when a user reads the RSS feed, time ago format may be very inaccurate
// Because we don't know when a user reads the RSS feed, time ago format may be very inaccurate.
add_filter( 'simple_history/header_just_now_max_time', '__return_zero' );
add_filter( 'simple_history/header_time_ago_max_time', '__return_zero' );

Expand Down Expand Up @@ -300,14 +300,14 @@ public function output_rss() {
$queryResults = $logQuery->query( $args );

// Remove capability override after query is done
// remove_action( $action_tag, '__return_true', 10 );
// remove_action( $action_tag, '__return_true', 10 );.
foreach ( $queryResults['log_rows'] as $row ) {
$header_output = $this->simple_history->get_log_row_header_output( $row );
$text_output = $this->simple_history->get_log_row_plain_text_output( $row );
$details_output = $this->simple_history->get_log_row_details_output( $row );

// http://cyber.law.harvard.edu/rss/rss.html#ltguidgtSubelementOfLtitemgt
// $item_guid = home_url() . "?SimpleHistoryGuid=" . $row->id;
// $item_guid = home_url() . "?SimpleHistoryGuid=" . $row->id;.
$item_guid = esc_url( add_query_arg( 'SimpleHistoryGuid', $row->id, home_url() ) );
$item_link = esc_url( add_query_arg( 'SimpleHistoryGuid', $row->id, home_url() ) );

Expand Down Expand Up @@ -401,7 +401,7 @@ public function output_rss() {
?>
]]></description>
<?php
// author must be email to validate, but the field is optional, so we skip it
// author must be email to validate, but the field is optional, so we skip it.
/* <author><?php echo $row->initiator ?></author> */
?>
<pubDate><?php echo esc_xml( gmdate( 'D, d M Y H:i:s', strtotime( $row->date ) ) ); ?> GMT</pubDate>
Expand All @@ -416,7 +416,7 @@ public function output_rss() {
</rss>
<?php
} else {
// RSS secret was not ok
// RSS secret was not ok.
echo PHP_EOL;
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
Expand Down
6 changes: 3 additions & 3 deletions dropins/class-sidebar-dropin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function loaded() {
* Output default sidebar contents
*/
public function default_sidebar_contents() {
// Box about donation
// Box about donation.
$headline = _x( 'Donate to support development', 'Sidebar box', 'simple-history' );

$bodyDonate = sprintf(
Expand All @@ -45,7 +45,7 @@ public function default_sidebar_contents() {
</div>
';

// Box about review
// Box about review.
$headline = _x( 'Review this plugin if you like it', 'Sidebar box', 'simple-history' );

$body1 = sprintf(
Expand All @@ -66,7 +66,7 @@ public function default_sidebar_contents() {
</div>
';

// Box about support
// Box about support.
$boxSupport = sprintf(
'
<div class="postbox">
Expand Down
Loading

0 comments on commit 3aeac51

Please sign in to comment.