Skip to content

Commit

Permalink
Merge pull request #1472 from xwp/release/4.0.0
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
kasparsd authored Jan 9, 2024
2 parents ec96a02 + 571ffe8 commit 0336294
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 115 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ before_install:
- docker-compose pull
- nvm install
- nvm use
# Lock to Composer version 1 for now.
- composer self-update --1

install:
- npm install
Expand Down
13 changes: 10 additions & 3 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ public function init() {
$this->network = new Network( $this->plugin );
$this->live_update = new Live_Update( $this->plugin );
$this->export = new Export( $this->plugin );

// Check if the host has configured the `REMOTE_ADDR` correctly.
$client_ip = $this->plugin->get_client_ip_address();
if ( empty( $client_ip ) && $this->is_stream_screen() ) {
$this->notice( __( 'Stream plugin can\'t determine a reliable client IP address! Please update the hosting environment to set the $_SERVER[\'REMOTE_ADDR\'] variable or use the wp_stream_client_ip_address filter to specify the verified client IP address!', 'stream' ) );
}
}

/**
Expand Down Expand Up @@ -541,9 +547,10 @@ public function is_stream_screen() {
return true;
}

$screen = get_current_screen();
if ( Alerts::POST_TYPE === $screen->post_type ) {
return true;
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();

return ( Alerts::POST_TYPE === $screen->post_type );
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions classes/class-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function update_meta( $meta_key, $meta_value, $prev_value = '' ) {
/**
* Determine the title of the alert.
*
* @todo enhance human readibility
* @todo enhance human readability
* @return string The title of the alert
*/
public function get_title() {
Expand All @@ -207,7 +207,7 @@ public function get_title() {
}

/**
* Retreive current alert type object
* Retrieve current alert type object
*
* @return Alert_Type
*/
Expand Down
2 changes: 1 addition & 1 deletion classes/class-live-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function gather_updated_items( $last_time, $args = array() ) {
/**
* Handles live updates for Stream Post List
*
* @action heartbeat_recieved
* @action heartbeat_received
*
* @param array $response Response to be sent to heartbeat tick.
* @param array $data Data from heartbeat send.
Expand Down
26 changes: 4 additions & 22 deletions classes/class-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class Log {
*/
public $plugin;

/**
* Hold Current visitors IP Address.
*
* @var string
*/
private $ip_address;


/**
* Previous Stream record ID, used for chaining same-session records
*
Expand All @@ -42,12 +34,6 @@ class Log {
public function __construct( $plugin ) {
$this->plugin = $plugin;

// Support proxy mode by checking the `X-Forwarded-For` header first.
$ip_address = wp_stream_filter_input( INPUT_SERVER, 'HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP );
$ip_address = $ip_address ? $ip_address : wp_stream_filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );

$this->ip_address = $ip_address;

// Ensure function used in various methods is pre-loaded.
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
Expand Down Expand Up @@ -87,9 +73,11 @@ public function log( $connector, $message, $args, $object_id, $context, $action,
return false;
}

$ip_address = $this->plugin->get_client_ip_address();

$user = new \WP_User( $user_id );

if ( $this->is_record_excluded( $connector, $context, $action, $user ) ) {
if ( $this->is_record_excluded( $connector, $context, $action, $user, $ip_address ) ) {
return false;
}

Expand Down Expand Up @@ -140,7 +128,7 @@ function ( $var ) {
'connector' => (string) $connector,
'context' => (string) $context,
'action' => (string) $action,
'ip' => (string) $this->ip_address,
'ip' => (string) $ip_address,
'meta' => (array) $stream_meta,
);

Expand Down Expand Up @@ -174,12 +162,6 @@ public function is_record_excluded( $connector, $context, $action, $user = null,
$user = wp_get_current_user();
}

if ( is_null( $ip ) ) {
$ip = $this->ip_address;
} else {
$ip = wp_stream_filter_var( $ip, FILTER_VALIDATE_IP );
}

if ( ! empty( $user->roles ) ) {
$roles = array_values( $user->roles );
$role = $roles[0];
Expand Down
4 changes: 2 additions & 2 deletions classes/class-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,13 @@ public function get_settings_translations( $labels ) {
* Wrapper for the settings API to work on the network settings page
*/
public function network_options_action() {
$allowed_referers = array(
$allowed_referrers = array(
$this->network_settings_page_slug,
$this->default_settings_page_slug,
);

// @codingStandardsIgnoreLine
if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers, true ) ) {
if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referrers, true ) ) {
return;
}

Expand Down
21 changes: 20 additions & 1 deletion classes/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Plugin {
*
* @const string
*/
const VERSION = '3.10.0';
const VERSION = '4.0.0';

/**
* WP-CLI command
Expand Down Expand Up @@ -90,6 +90,13 @@ class Plugin {
*/
public $locations = array();

/**
* IP address for the current request to be associated with the log entry.
*
* @var null|false|string Valid IP address, null if not set, false if invalid.
*/
protected $client_ip_address;

/**
* Class constructor
*/
Expand Down Expand Up @@ -138,6 +145,9 @@ public function __construct() {
// Load logger class.
$this->log = apply_filters( 'wp_stream_log_handler', new Log( $this ) );

// Set the IP address for the current request.
$this->client_ip_address = wp_stream_filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );

// Load settings and connectors after widgets_init and before the default init priority.
add_action( 'init', array( $this, 'init' ), 9 );

Expand Down Expand Up @@ -315,4 +325,13 @@ public function is_mustuse() {

return false;
}

/**
* Get the IP address for the current request.
*
* @return false|null|string Valid IP address, null if not set, false if invalid.
*/
public function get_client_ip_address() {
return apply_filters( 'wp_stream_client_ip_address', $this->client_ip_address );
}
}
2 changes: 1 addition & 1 deletion connectors/class-connector-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function action_links( $links, $record ) {
/* translators: %s: a post type singular name (e.g. "Post") */
$links[ sprintf( esc_html_x( 'Restore %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $untrash;
/* translators: %s: a post type singular name (e.g. "Post") */
$links[ sprintf( esc_html_x( 'Delete %s Permenantly', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
$links[ sprintf( esc_html_x( 'Delete %s Permanently', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
} else {
/* translators: %s a post type singular name (e.g. "Post") */
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = get_edit_post_link( $post->ID );
Expand Down
2 changes: 1 addition & 1 deletion connectors/class-connector-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public function get_serialized_field_label( $option_name, $field_key ) {
/**
* Filter allows for insertion of serialized labels
*
* @param array $lables Serialized labels
* @param array $labels Serialized labels
* @return array Updated array of serialzed labels
*/
$labels = apply_filters( 'wp_stream_serialized_labels', $labels );
Expand Down
2 changes: 1 addition & 1 deletion connectors/class-connector-taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function action_links( $links, $record ) {
}

/**
* Catch registration of taxonomies after inital loading, so we can cache its labels
* Catch registration of taxonomies after initial loading, so we can cache its labels
*
* @action registered_taxonomy
*
Expand Down
2 changes: 1 addition & 1 deletion connectors/class-connector-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function action_links( $links, $record ) {
}

/**
* Get an array of role lables assigned to a specific user.
* Get an array of role labels assigned to a specific user.
*
* @param object|int $user User object or user ID to get roles for.
*
Expand Down
2 changes: 1 addition & 1 deletion connectors/class-connector-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public function exclude_order_post_types( $post_types ) {
* Prevent the Stream Comments connector from logging status
* change comments on orders
*
* @filter wp_stream_commnent_exclude_comment_types
* @filter wp_stream_comment_exclude_comment_types
*
* @param array $comment_types Ignored post types.
*
Expand Down
2 changes: 1 addition & 1 deletion connectors/class-connector-wordpress-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function action_links( $links, $record ) {
/* translators: %s: a post type singular name (e.g. "Post") */
$links[ sprintf( esc_html_x( 'Restore %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $untrash;
/* translators: %s: a post type singular name (e.g. "Post") */
$links[ sprintf( esc_html_x( 'Delete %s Permenantly', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
$links[ sprintf( esc_html_x( 'Delete %s Permanently', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
} else {
/* translators: %s: a post type singular name (e.g. "Post") */
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = get_edit_post_link( $post->ID );
Expand Down
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @param int $filter The ID of the filter to apply.
* @param mixed $options Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array.
*
* @return Value of the requested variable on success, FALSE if the filter fails, or NULL if the $variable_name is not set.
* @return mixed|false|null Value of the requested variable on success, FALSE if the filter fails, or NULL if the $variable_name is not set.
*/
function wp_stream_filter_input( $type, $variable_name, $filter = null, $options = array() ) {
return call_user_func_array( array( '\WP_Stream\Filter_Input', 'super' ), func_get_args() );
Expand Down
32 changes: 16 additions & 16 deletions includes/lib/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -1971,8 +1971,8 @@ public function endOfWeek()
}

/**
* Modify to the next occurance of a given day of the week.
* If no dayOfWeek is provided, modify to the next occurance
* Modify to the next occurrence of a given day of the week.
* If no dayOfWeek is provided, modify to the next occurrence
* of the current day of the week. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
Expand All @@ -1990,8 +1990,8 @@ public function next($dayOfWeek = null)
}

/**
* Modify to the previous occurance of a given day of the week.
* If no dayOfWeek is provided, modify to the previous occurance
* Modify to the previous occurrence of a given day of the week.
* If no dayOfWeek is provided, modify to the previous occurrence
* of the current day of the week. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
*
Expand All @@ -2009,7 +2009,7 @@ public function previous($dayOfWeek = null)
}

/**
* Modify to the first occurance of a given day of the week
* Modify to the first occurrence of a given day of the week
* in the current month. If no dayOfWeek is provided, modify to the
* first day of the current month. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
Expand All @@ -2030,7 +2030,7 @@ public function firstOfMonth($dayOfWeek = null)
}

/**
* Modify to the last occurance of a given day of the week
* Modify to the last occurrence of a given day of the week
* in the current month. If no dayOfWeek is provided, modify to the
* last day of the current month. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
Expand All @@ -2051,8 +2051,8 @@ public function lastOfMonth($dayOfWeek = null)
}

/**
* Modify to the given occurance of a given day of the week
* in the current month. If the calculated occurance is outside the scope
* Modify to the given occurrence of a given day of the week
* in the current month. If the calculated occurrence is outside the scope
* of the current month, then return false and no modifications are made.
* Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.
*
Expand All @@ -2071,7 +2071,7 @@ public function nthOfMonth($nth, $dayOfWeek)
}

/**
* Modify to the first occurance of a given day of the week
* Modify to the first occurrence of a given day of the week
* in the current quarter. If no dayOfWeek is provided, modify to the
* first day of the current quarter. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
Expand All @@ -2086,7 +2086,7 @@ public function firstOfQuarter($dayOfWeek = null)
}

/**
* Modify to the last occurance of a given day of the week
* Modify to the last occurrence of a given day of the week
* in the current quarter. If no dayOfWeek is provided, modify to the
* last day of the current quarter. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
Expand All @@ -2101,8 +2101,8 @@ public function lastOfQuarter($dayOfWeek = null)
}

/**
* Modify to the given occurance of a given day of the week
* in the current quarter. If the calculated occurance is outside the scope
* Modify to the given occurrence of a given day of the week
* in the current quarter. If the calculated occurrence is outside the scope
* of the current quarter, then return false and no modifications are made.
* Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.
*
Expand All @@ -2122,7 +2122,7 @@ public function nthOfQuarter($nth, $dayOfWeek)
}

/**
* Modify to the first occurance of a given day of the week
* Modify to the first occurrence of a given day of the week
* in the current year. If no dayOfWeek is provided, modify to the
* first day of the current year. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
Expand All @@ -2137,7 +2137,7 @@ public function firstOfYear($dayOfWeek = null)
}

/**
* Modify to the last occurance of a given day of the week
* Modify to the last occurrence of a given day of the week
* in the current year. If no dayOfWeek is provided, modify to the
* last day of the current year. Use the supplied consts
* to indicate the desired dayOfWeek, ex. static::MONDAY.
Expand All @@ -2152,8 +2152,8 @@ public function lastOfYear($dayOfWeek = null)
}

/**
* Modify to the given occurance of a given day of the week
* in the current year. If the calculated occurance is outside the scope
* Modify to the given occurrence of a given day of the week
* in the current year. If the calculated occurrence is outside the scope
* of the current year, then return false and no modifications are made.
* Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.
*
Expand Down
2 changes: 1 addition & 1 deletion languages/stream-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -2582,7 +2582,7 @@ msgstr ""
#: connectors/class-connector-wordpress-seo.php:160
#, php-format
msgctxt "Post type singular name"
msgid "Delete %s Permenantly"
msgid "Delete %s Permanently"
msgstr ""

#: connectors/class-connector-posts.php:104
Expand Down
2 changes: 1 addition & 1 deletion local/docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM wordpress:php${PHP_VERSION}-apache
# Default version which supports the default PHP 7.4.
ARG XDEBUG_VERSION=2.9.6

# Include our Composer vendor binrary path into global path.
# Include our Composer vendor binary path into global path.
ENV PATH="/var/www/html/wp-content/plugins/stream-src/vendor/bin:${PATH}"

RUN apt-get update; \
Expand Down
Loading

0 comments on commit 0336294

Please sign in to comment.