Skip to content

Commit

Permalink
Upgrading figuren-theater/code-quality (0.8.1 => 1.1.1) (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion authored Feb 21, 2024
2 parents d7e2113 + 15056a4 commit 686dc9c
Show file tree
Hide file tree
Showing 16 changed files with 623 additions and 473 deletions.
7 changes: 2 additions & 5 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
<description>Coding standards for ft-security</description>

<file>.</file>

<!--
<exclude-pattern>*/bin/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern> -->
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->

<!--
is created during composer install,
Expand All @@ -30,6 +26,7 @@
<property name="text_domain" type="array">
<element value="figurentheater"/>
<element value="two-factor"/>
<element value="default"/>
</property>
</properties>
</rule>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
"config": {
"allow-plugins": {
"composer/installers": true,
"phpstan/extension-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true
}
},
"extra": {
Expand Down
803 changes: 524 additions & 279 deletions composer.lock

Large diffs are not rendered by default.

22 changes: 4 additions & 18 deletions inc/disable-login-errors/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

namespace Figuren_Theater\Security\Disable_Login_Errors;

use WP_Error;
use function __;
use function add_action;

use function add_filter;
use function __;
use WP_Error;

/**
* Set up hooks.
Expand All @@ -30,12 +29,8 @@ function bootstrap() {
*
* @param string $username Username or email address.
* @param WP_Error $error A WP_Error object with the authentication failure details.
*
* @subpackage [subpackage]
* @version 2022-10-13
* @author Carsten Bach
*/
function load( string $username, WP_Error $error ) : void {
function load( string $username, WP_Error $error ): void {

if ( empty( $error->errors ) ) {
return;
Expand Down Expand Up @@ -69,7 +64,6 @@ function load( string $username, WP_Error $error ) : void {
// Add our filter to prevent theese error message for security reasons.
add_filter( 'login_errors', __NAMESPACE__ . '\\nice_hint', 99, 1 );
}

}

/**
Expand All @@ -79,21 +73,13 @@ function load( string $username, WP_Error $error ) : void {
* why a password might be wrong.
* This helps securing the site, against external attacks.
*
* @subpackage [subpackage]
* @version 2022-10-10
* @author Carsten Bach
*
* @param string $error Login error message.
*
* @return string General error text.
*/
function nice_hint( string $error ) : string {
function nice_hint(): string {

return sprintf(
'<strong>%1$s</strong><br>%2$s',
__( 'Nicht textsicher?', 'figurentheater' ),
__( 'Alles auf Anfang, bitte!', 'figurentheater' )
);
}


14 changes: 7 additions & 7 deletions inc/email-address-encoder/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {
/*
* The Plugin allows to define the following constants for convenience.
*
Expand All @@ -47,7 +47,7 @@ function bootstrap() :void {
*
* @return void
*/
function load_plugin() :void {
function load_plugin(): void {

require_once FT_VENDOR_DIR . PLUGINPATH; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant

Expand All @@ -71,7 +71,7 @@ function load_plugin() :void {
*
* @return string The path to the MO file or an empty string if unloading is needed.
*/
function unload_i18n( string $mofile, string $domain ) : string {
function unload_i18n( string $mofile, string $domain ): string {
// Check if the domain is 'email-address-encoder'.
if ( 'email-address-encoder' === $domain ) {
// If the domain is 'email-address-encoder', prevent loading and return an empty string.
Expand All @@ -87,11 +87,11 @@ function unload_i18n( string $mofile, string $domain ) : string {
*
* @return void
*/
function filter_options() :void {
function filter_options(): void {

$_options = [
'eae_filter_priority' => 1000,
'eae_search_in' => 'filters',
'eae_search_in' => 'filters',
// lets see what the automatic email-detector will tell us,
// but only us and only locally
//
Expand All @@ -103,7 +103,7 @@ function filter_options() :void {
//
// 'eae_notices' => ( \WP_DEBUG ) ? '0' : '1',
// the Admin_Bar/email-encoder.js is not working.
'eae_notices' => '1',
'eae_notices' => '1',
];

/*
Expand All @@ -122,6 +122,6 @@ function filter_options() :void {
*
* @return void
*/
function remove_menu() :void {
function remove_menu(): void {
remove_submenu_page( 'options-general.php', 'eae' );
}
14 changes: 7 additions & 7 deletions inc/limit-login-attempts-reloaded/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {

add_action( 'Figuren_Theater\loaded', __NAMESPACE__ . '\\filter_options', 11 );

Expand All @@ -34,7 +34,7 @@ function bootstrap() :void {
*
* @return void
*/
function load_plugin() :void {
function load_plugin(): void {

$config = Figuren_Theater\get_config()['modules']['security'];
if ( ! $config['limit-login-attempts-reloaded'] ) {
Expand All @@ -55,11 +55,11 @@ function load_plugin() :void {
/**
* Handle site-options
*
* @param array<string, string> $active_sitewide_plugins Array of site-wide installed plugins
* @param array<string, string> $active_sitewide_plugins Array of site-wide installed plugins.
*
* @return array<string, string>
*/
function filter_site_option( array $active_sitewide_plugins ) :array {
function filter_site_option( array $active_sitewide_plugins ): array {
$active_sitewide_plugins[ BASENAME ] = BASENAME;
return $active_sitewide_plugins;
}
Expand All @@ -69,7 +69,7 @@ function filter_site_option( array $active_sitewide_plugins ) :array {
*
* @return void
*/
function filter_options() :void {
function filter_options(): void {

$_options = [
'limit_login_allow_local_options' => 0, // Do not use FALSE, because it gets handled as "non existing option", so the query will be done.
Expand Down Expand Up @@ -129,7 +129,7 @@ function filter_options() :void {
/**
* Disables the annoying dashboard admin notice to leave a review on the plugin.
*/
function remove_admin_notice() : void {
function remove_admin_notice(): void {

global $limit_login_attempts_obj;
remove_action( 'admin_notices', [ $limit_login_attempts_obj, 'show_leave_review_notice' ] );
Expand All @@ -140,6 +140,6 @@ function remove_admin_notice() : void {
*
* @return void
*/
function remove_menu() :void {
function remove_menu(): void {
remove_submenu_page( 'settings.php', 'limit-login-attempts' );
}
4 changes: 2 additions & 2 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @return void
*/
function register() :void {
function register(): void {

$default_settings = [
'enabled' => true, // Needs to be set.
Expand All @@ -43,7 +43,7 @@ function register() :void {
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {

// Plugins.
Email_Address_Encoder\bootstrap();
Expand Down
8 changes: 4 additions & 4 deletions inc/passwords-evolved/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {

add_action( 'Figuren_Theater\loaded', __NAMESPACE__ . '\\filter_options', 11 );

Expand All @@ -34,7 +34,7 @@ function bootstrap() :void {
*
* @return void
*/
function load_plugin() :void {
function load_plugin(): void {

require_once FT_VENDOR_DIR . PLUGINPATH; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant

Expand All @@ -46,7 +46,7 @@ function load_plugin() :void {
*
* @return void
*/
function filter_options() :void {
function filter_options(): void {

$_options = [
'passwords_evolved_enforced_roles' => [
Expand Down Expand Up @@ -75,6 +75,6 @@ function filter_options() :void {
*
* @return void
*/
function remove_menu() :void {
function remove_menu(): void {
remove_submenu_page( 'settings.php', 'passwords-evolved' );
}
10 changes: 5 additions & 5 deletions inc/passwords-not-weak/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {
add_action( 'login_head', __NAMESPACE__ . '\\no_weak_password_header' );
add_action( 'load-profile.php', __NAMESPACE__ . '\\disable_weak_pws_checkbox_admin' );
}
Expand All @@ -24,7 +24,7 @@ function bootstrap() :void {
*
* @return void
*/
function disable_weak_pws_checkbox_admin() :void {
function disable_weak_pws_checkbox_admin(): void {
add_action( 'admin_head', __NAMESPACE__ . '\\no_weak_password_header' );
}

Expand All @@ -33,7 +33,7 @@ function disable_weak_pws_checkbox_admin() :void {
*
* @return void
*/
function no_weak_password_header() :void {
echo'<style>.pw-weak{display:none!important}</style>';
echo'<script>var ft_pwc = document.getElementById("pw-checkbox"); if (ft_pwc !== null) ft_pwc.disabled = true;</script>';
function no_weak_password_header(): void {
echo '<style>.pw-weak{display:none!important}</style>';
echo '<script>var ft_pwc = document.getElementById("pw-checkbox"); if (ft_pwc !== null) ft_pwc.disabled = true;</script>';
}
Loading

0 comments on commit 686dc9c

Please sign in to comment.