Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/abstracts/class-wpum-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ protected function get_parsed_id( $name, $nicename, $field ) {

if ( ! empty( $nicename ) ) {
return str_replace( ' ', '_', strtolower( $nicename ) );
} elseif ( empty( $nicename ) && $field->get_meta( 'user_meta_key' ) ) {
} elseif ( $field->get_meta( 'user_meta_key' ) ) {
return $field->get_meta( 'user_meta_key' );
}

Expand Down
3 changes: 2 additions & 1 deletion includes/abstracts/class-wpum-shortcode-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ protected function generate_listbox( $field ) {
/**
* Generate a textbox for the window.
*
* @param [type] $field
* @param array $field
*
* @return array|false
*/
Expand All @@ -257,6 +257,7 @@ protected function generate_textbox( $field ) {
'value' => '',
'classes' => '',
), $field );

if ( $this->validate( $field ) ) {
return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/abstracts/class-wpum-wp-db-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class WPUM_WP_DB_Table {
*/
protected $charset_collation = '';
/**
* @var WPDB Database object (usually $GLOBALS['wpdb'])
* @var \wpdb Database object (usually $GLOBALS['wpdb'])
*/
protected $db = false;
/** Methods ***************************************************************/
Expand Down
1 change: 1 addition & 0 deletions includes/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function wpum_restrict_wp_profile() {

$profile_redirect = wpum_get_option( 'backend_profile_redirect' );

// @phpstan-ignore-next-line IS_PROFILE_PAGE is defined in wp-admin/profile.php
if ( ! current_user_can( 'administrator' ) && IS_PROFILE_PAGE && $profile_redirect ) {
wp_safe_redirect( esc_url( get_permalink( $profile_redirect[0] ) ) );
exit;
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-wpum-permalinks-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function display_settings() {

<?php } else { ?>

<p><?php echo wp_kses_post( 'These settings control the permalinks used for users profiles. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'wp-user-manager' ); ?></p>
<p><?php esc_html_e( 'These settings control the permalinks used for users profiles. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'wp-user-manager' ); ?></p>

<table class="form-table">
<tbody>
Expand Down
6 changes: 3 additions & 3 deletions includes/admin/class-wpum-user-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ public function handle_users_role_bulk_add() {
$role = sanitize_text_field( wp_unslash( $_REQUEST['wpum-add-role-bottom'] ) );
}

$m_role = wpum_get_role( $role );
$roles = array_column( wpum_get_roles( false, true ), 'value' );
$roles = array_column( wpum_get_roles( false, true ), 'value' );

if ( empty( $role ) || ! in_array( $role, $roles, true ) ) {
return;
}

$count = 0;
$m_role = wpum_get_role( $role );
$count = 0;

$users = filter_input( INPUT_GET, 'users', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY );
if ( empty( $users ) ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/shortcodes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ function wpum_directory( $atts, $content = null ) {
}

// Exclude users if anything specified.
if ( $excluded_users && ! empty( $excluded_users ) ) {
if ( ! empty( $excluded_users ) ) {
$excluded_users = trim( str_replace( ' ', '', $excluded_users ) );
$args['exclude'] = explode( ',', $excluded_users );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/updates/WPUM_EDD_SL_Plugin_Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function show_update_notification( $file, $plugin ) {

// build a plugin list row, with update notification
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
// <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
echo '<td colspan="3" class="plugin-update colspanchange">';
echo '<div class="update-message notice inline notice-warning notice-alt">';
Expand Down
10 changes: 5 additions & 5 deletions includes/updates/class-wpum-license.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function handle_deactivate_license() {
* @param string $license
* @param string $site_url
*
* @return mixed|WP_Error|null
* @return object|WP_Error|null
*/
protected function api_request( $endpoint, $license, $site_url ) {
$api_params = array(
Expand Down Expand Up @@ -276,7 +276,7 @@ protected function api_request( $endpoint, $license, $site_url ) {
* @param string $license
* @param string $site_url
*
* @return mixed|WP_Error|null
* @return object|WP_Error|null
*/
protected function activate_license( $license, $site_url ) {
return $this->api_request( 'activate_license', $license, $site_url );
Expand All @@ -285,7 +285,7 @@ protected function activate_license( $license, $site_url ) {
/**
* @param string $site_url
*
* @return mixed|WP_Error|null
* @return object|WP_Error|null
*/
protected function deactivate_license( $site_url ) {
return $this->api_request( 'deactivate_license', $this->license, $site_url );
Expand Down Expand Up @@ -325,7 +325,7 @@ private function get_license_deactivation_url() {
}

/**
* @param array $license_data
* @param object $license_data
*
* @return array
*/
Expand All @@ -346,7 +346,7 @@ protected function prepare_license_data( $license_data ) {
'status' => $license_data->license,
);

if ( isset( $license_data->success ) && $license_data->success ) {
if ( isset( $license_data->success ) && $license_data->success && isset( $license_data->expires ) ) {
$data['expires'] = $license_data->expires;
}

Expand Down
24 changes: 23 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,31 @@ includes:
parameters:
scanFiles:
- vendor/htmlburger/carbon-fields/core/functions.php
- vendor/wpbp/widgets-helper/class.wph-widget.php
bootstrapFiles:
- tests/phpstan/bootstrap.php
dynamicConstantNames:
- COOKIEHASH
- COOKIE_DOMAIN
#level: 5
level: 0
level: 2
paths:
- wp-user-manager.php
- uninstall.php
- includes/
ignoreErrors:
# TDP docblock problem
-
message: '#^Result of static method TDP\\WP_Notice::instance\(\) \(void\) is used\.$#'
path: includes/class-wp-user-manager.php
count: 1
# `new static` in non-final class
-
message: '#^Unsafe usage of new static\(\)\.$#'
path: includes/roles/class-wpum-collection.php
count: 1
# Carbon Fields has general Container return type
-
message: '#^Call to an undefined method Carbon_Fields\\Container\\Container::set_page_parent\(\)\.$#'
path: includes/updates/class-wpum-updater-settings.php
count: 1
8 changes: 8 additions & 0 deletions tests/phpstan/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

define('WP_PLUGIN_DIR', './');
define('WPUM_PLUGIN_FILE', 'wp-user-manager.php');
define('WPUM_SLUG', 'wp-user-manager');
define('WPUM_VERSION', '0.0.0');
define('WPUM_PLUGIN_DIR', './');
define('WPUM_PLUGIN_URL', 'https://example.com');