Skip to content

Commit

Permalink
Merge pull request #1460 from xwp/release/3.10.0
Browse files Browse the repository at this point in the history
Release version 3.10.0
  • Loading branch information
kasparsd authored Oct 9, 2023
2 parents 905683d + d3a1534 commit ec96a02
Show file tree
Hide file tree
Showing 28 changed files with 3,072 additions and 2,769 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint and Test

on: push

jobs:

lint:
name: Lint and Test
runs-on: ubuntu-22.04
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2

- name: Install NPM dependencies
run: npm install

- name: Install Composer dependencies
run: composer install

- name: Lint
run: npm run lint

- name: Pull Docker Images
run: docker-compose pull wordpress

- name: Test PHP
run: npm run phpunit

- name: Build
run: npm run build
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ before_install:

install:
- npm install
- composer install

script:
- npm run lint
Expand Down
2 changes: 0 additions & 2 deletions alerts/class-alert-type-menu-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ public function menu_alert( $wp_admin_bar ) {
/**
* Get a list of all current alert messages for current user.
*
* @todo update this for VIP. (get_user_meta)
*
* @return array List of alert messages
*/
public function get_messages() {
Expand Down
4 changes: 2 additions & 2 deletions alerts/class-alert-type-slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public function alert( $record_id, $recordarr, $alert ) {
'author_icon' => get_avatar_url( $user_id, 16 ),
'author_link' => admin_url( "admin.php?page=wp_stream&user_id=$user_id" ),
'author_name' => trim( "$user->first_name $user->last_name" ),
'fallback' => html_entity_decode( $recordarr['summary'] ),
'fallback' => html_entity_decode( $recordarr['summary'], ENT_COMPAT ),
'fields' => $fields,
'footer' => get_bloginfo( 'name' ),
'footer_icon' => get_site_icon_url( 16, $logo[0], $recordarr['blog_id'] ),
'title' => html_entity_decode( $recordarr['summary'] ),
'title' => html_entity_decode( $recordarr['summary'], ENT_COMPAT ),
'ts' => strtotime( $recordarr['created'] ),
);
if ( array_key_exists( 'object_id', $recordarr ) ) {
Expand Down
21 changes: 7 additions & 14 deletions classes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,17 @@ public function admin_enqueue_scripts( $hook ) {
* @return bool
*/
public function is_stream_screen() {
if ( is_admin() && false !== strpos( wp_stream_filter_input( INPUT_GET, 'page' ), $this->records_page_slug ) ) {
if ( ! is_admin() ) {
return false;
}

$page = wp_stream_filter_input( INPUT_GET, 'page' );
if ( is_string( $page ) && false !== strpos( $page, $this->records_page_slug ) ) {
return true;
}

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

Expand Down Expand Up @@ -1066,10 +1071,6 @@ public function get_users_record_meta( $authors ) {
* @return mixed
*/
public function get_user_meta( $user_id, $meta_key, $single = true ) {
if ( wp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) {
return get_user_attribute( $user_id, $meta_key );
}

return get_user_meta( $user_id, $meta_key, $single );
}

Expand All @@ -1084,10 +1085,6 @@ public function get_user_meta( $user_id, $meta_key, $single = true ) {
* @return int|bool
*/
public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
if ( wp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) {
return update_user_attribute( $user_id, $meta_key, $meta_value );
}

return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
}

Expand All @@ -1101,10 +1098,6 @@ public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value
* @return bool
*/
public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
if ( wp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) {
return delete_user_attribute( $user_id, $meta_key, $meta_value );
}

return delete_user_meta( $user_id, $meta_key, $meta_value );
}
}
2 changes: 1 addition & 1 deletion classes/class-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function get_avatar_src( $size = 80 ) {
}

if ( 1 === preg_match( '/src=([\'"])(.*?)\1/', $img, $matches ) ) {
$src = html_entity_decode( $matches[2] );
$src = html_entity_decode( $matches[2], ENT_COMPAT );
} else {
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions classes/class-filter-input.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ class Filter_Input {
* @var array
*/
public static $filter_callbacks = array(
FILTER_DEFAULT => null,
FILTER_DEFAULT => null,
// Validate.
FILTER_VALIDATE_BOOLEAN => 'is_bool',
FILTER_VALIDATE_EMAIL => 'is_email',
FILTER_VALIDATE_FLOAT => 'is_float',
FILTER_VALIDATE_INT => 'is_int',
FILTER_VALIDATE_IP => array( __CLASS__, 'is_ip_address' ),
FILTER_VALIDATE_REGEXP => array( __CLASS__, 'is_regex' ),
FILTER_VALIDATE_URL => 'wp_http_validate_url',
FILTER_VALIDATE_BOOLEAN => 'is_bool',
FILTER_VALIDATE_EMAIL => 'is_email',
FILTER_VALIDATE_FLOAT => 'is_float',
FILTER_VALIDATE_INT => 'is_int',
FILTER_VALIDATE_IP => array( __CLASS__, 'is_ip_address' ),
FILTER_VALIDATE_REGEXP => array( __CLASS__, 'is_regex' ),
FILTER_VALIDATE_URL => 'wp_http_validate_url',
// Sanitize.
FILTER_SANITIZE_EMAIL => 'sanitize_email',
FILTER_SANITIZE_ENCODED => 'esc_url_raw',
FILTER_SANITIZE_NUMBER_FLOAT => 'floatval',
FILTER_SANITIZE_NUMBER_INT => 'intval',
FILTER_SANITIZE_SPECIAL_CHARS => 'htmlspecialchars',
FILTER_SANITIZE_STRING => 'sanitize_text_field',
FILTER_SANITIZE_URL => 'esc_url_raw',
FILTER_SANITIZE_EMAIL => 'sanitize_email',
FILTER_SANITIZE_ENCODED => 'esc_url_raw',
FILTER_SANITIZE_NUMBER_FLOAT => 'floatval',
FILTER_SANITIZE_NUMBER_INT => 'intval',
FILTER_SANITIZE_SPECIAL_CHARS => 'htmlspecialchars',
FILTER_SANITIZE_FULL_SPECIAL_CHARS => 'sanitize_text_field',
FILTER_SANITIZE_URL => 'esc_url_raw',
// Other.
FILTER_UNSAFE_RAW => null,
FILTER_UNSAFE_RAW => null,
);

/**
Expand Down
6 changes: 3 additions & 3 deletions classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ public function get_hidden_columns() {
}

// Directly checking the user meta; to check whether user has changed screen option or not.
$hidden = $this->plugin->admin->get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );
$hidden = get_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', true );

// If user meta is not found; add the default hidden column 'id'.
if ( ! $hidden ) {
$hidden = array( 'id' );
$this->plugin->admin->update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
update_user_meta( $user->ID, 'manage' . $this->screen->id . 'columnshidden', $hidden );
}

return $hidden;
Expand Down Expand Up @@ -1139,7 +1139,7 @@ public function screen_controls( $status, $args ) {
if ( 'on' === $option && 'false' === $heartbeat ) {
$option = 'off';

$this->plugin->admin->update_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, 'off' );
update_user_meta( $user_id, $this->plugin->admin->live_update->user_meta_key, 'off' );
}

$nonce = wp_create_nonce( $this->plugin->admin->live_update->user_meta_key . '_nonce' );
Expand Down
12 changes: 6 additions & 6 deletions classes/class-live-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public function enable_live_update() {
check_ajax_referer( $this->user_meta_key . '_nonce', 'nonce' );

$input = array(
'checked' => FILTER_SANITIZE_STRING,
'user' => FILTER_SANITIZE_STRING,
'heartbeat' => FILTER_SANITIZE_STRING,
'checked' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'user' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
'heartbeat' => FILTER_SANITIZE_FULL_SPECIAL_CHARS,
);

$input = filter_input_array( INPUT_POST, $input );
Expand All @@ -72,14 +72,14 @@ public function enable_live_update() {
$user = (int) $input['user'];

if ( 'false' === $input['heartbeat'] ) {
$this->plugin->admin->update_user_meta( $user, $this->user_meta_key, 'off' );
update_user_meta( $user, $this->user_meta_key, 'off' );

wp_send_json_error( esc_html__( "Live updates could not be enabled because Heartbeat is not loaded.\n\nYour hosting provider or another plugin may have disabled it for performance reasons.", 'stream' ) );

return;
}

$success = $this->plugin->admin->update_user_meta( $user, $this->user_meta_key, $checked );
$success = update_user_meta( $user, $this->user_meta_key, $checked );

if ( $success ) {
wp_send_json_success( ( 'on' === $checked ) ? 'Live Updates enabled' : 'Live Updates disabled' );
Expand Down Expand Up @@ -183,7 +183,7 @@ public function heartbeat_received( $response, $data ) {
return $response;
}

$enable_stream_update = ( 'off' !== $this->plugin->admin->get_user_meta( get_current_user_id(), $this->user_meta_key ) );
$enable_stream_update = ( 'off' !== get_user_meta( get_current_user_id(), $this->user_meta_key ) );

// Register list table.
$this->list_table = new List_Table(
Expand Down
2 changes: 1 addition & 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.9.3';
const VERSION = '3.10.0';

/**
* WP-CLI command
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
},
"require-dev": {
"automattic/vipwpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"humanmade/mercator": "^1.0",
"johnpbloch/wordpress": "^6.0",
"johnpbloch/wordpress": "^6.3",
"php-coveralls/php-coveralls": "^2.5",
"phpcompatibility/php-compatibility": "^9.3",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^5.7",
"wp-cli/wp-cli-bundle": "^2.6",
"wp-coding-standards/wpcs": "^2.3",
"wp-phpunit/wp-phpunit": "^6.0",
"wp-phpunit/wp-phpunit": "^6.3",
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "2.9.23",
"wpackagist-plugin/jetpack": "10.0",
Expand All @@ -34,7 +36,7 @@
"process-timeout": 600,
"sort-packages": true,
"platform": {
"php": "5.6.20"
"php": "7.4"
},
"allow-plugins": {
"composer/installers": true,
Expand Down
Loading

0 comments on commit ec96a02

Please sign in to comment.