Skip to content

Commit

Permalink
Fix CS issues (related to WPCS 3.0 update)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion committed Feb 15, 2024
1 parent 65303ac commit 8b05ada
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 45 deletions.
16 changes: 2 additions & 14 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,17 @@
<description>Coding standards for ft-theming</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,
when package is tested
and not running within ft-platform
-->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/wp-content/*</exclude-pattern>

<!-- Use figuren.theater Coding Standards -->
<rule ref="figurentheater" />

<!--
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="figurentheater"/>
</property>
</properties>
</rule> -->

</ruleset>
8 changes: 4 additions & 4 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*
* @return void
*/
function register() :void {
function register(): void {

$default_settings = [
'enabled' => true, // Needs to be set.
'wp-better-emails' => false,
];
$options = [
$options = [
'defaults' => $default_settings,
];

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

// Plugins.
WP_Better_Emails\bootstrap();
Expand All @@ -58,7 +58,7 @@ function bootstrap() :void {
*
* @return array<string, string> The colors to retrieve indexed by their slug.
*/
function get_all_colors() : array {
function get_all_colors(): array {
$_global_settings = wp_get_global_settings( [ 'color', 'palette' ] );
if ( ! \is_array( $_global_settings ) || ! isset( $_global_settings['theme'] ) || ! \is_array( $_global_settings['theme'] ) ) {
return [];
Expand Down
11 changes: 6 additions & 5 deletions inc/theming/defer-async-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {

add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\load', 0 );
}
Expand All @@ -39,7 +39,7 @@ function bootstrap() :void {
*
* @return void
*/
function load() : void {
function load(): void {

if ( is_admin() ) {
return;
Expand All @@ -61,7 +61,7 @@ function load() : void {
*
* @return string
*/
function load_async( string $tag, string $handle, string $src ) : string {
function load_async( string $tag, string $handle, string $src ): string {

// If this is alrady done, do nothing and return original $tag.
if ( strpos( $tag, 'defer' ) || strpos( $tag, 'async' ) ) {
Expand Down Expand Up @@ -109,7 +109,7 @@ function load_async( string $tag, string $handle, string $src ) : string {
*
* @return string
*/
function load_defered( string $tag, string $handle, string $src ) : string {
function load_defered( string $tag, string $handle, string $src ): string {

// If this is alrady done, do nothing and return original $tag.
if ( strpos( $tag, 'defer' ) || strpos( $tag, 'async' ) ) {
Expand All @@ -118,7 +118,8 @@ function load_defered( string $tag, string $handle, string $src ) : string {

$scripts_to_defer = array_flip(
apply_filters(
__NAMESPACE__ . '\\scripts_to_defer', [
__NAMESPACE__ . '\\scripts_to_defer',
[
'mediaelement-core',
'mediaelement-migrate',
'mediaelement-vimeo',
Expand Down
11 changes: 5 additions & 6 deletions inc/theming/favicon-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
use function add_action;
use function content_url;
use function get_blog_option;

use function wp_redirect;
use function wp_redirect; // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect

/**
* Bootstrap module, when enabled.
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {
add_action( 'do_faviconico', __NAMESPACE__ . '\\load' );
}

Expand All @@ -27,7 +26,7 @@ function bootstrap() :void {
*
* @return void
*/
function load() : void {
function load(): void {
/**
* Needs attention!
*
Expand All @@ -49,9 +48,9 @@ function load() : void {
* The favicon request doesn't work with
* wp_safe_redirect( $url )
*
* So just go the old way.
* So just go the old wa ignore phpcs yelling at us.
*/
if ( wp_redirect( $url ) ) {
if ( wp_redirect( $url ) ) { // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
exit;
}
}
7 changes: 3 additions & 4 deletions inc/theming/no-jquery-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

namespace Figuren_Theater\Theming\No_Jquery_Migrate;

use function add_action;

use WP_Scripts;
use function add_action;

/**
* Bootstrap module, when enabled.
Expand All @@ -19,7 +18,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {
add_action( 'wp_default_scripts', __NAMESPACE__ . '\\load', 0 );
}

Expand All @@ -30,7 +29,7 @@ function bootstrap() :void {
*
* @return void
*/
function load( WP_Scripts $scripts ) : void {
function load( WP_Scripts $scripts ): void {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff(
$scripts->registered['jquery']->deps,
Expand Down
14 changes: 7 additions & 7 deletions inc/theming/themed-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {
// Earliest 'do_action' of wp-login.php.
add_action( 'login_enqueue_scripts', __NAMESPACE__ . '\\load', 0 );
}
Expand All @@ -30,7 +30,7 @@ function bootstrap() :void {
*
* @return void
*/
function load() : void {
function load(): void {

// Removes the language dropdown from the login screen.
add_filter( 'login_display_language_dropdown', '__return_false' );
Expand All @@ -52,7 +52,7 @@ function load() : void {
*
* @return array<string, string>
*/
function ft_get_relevant_colors() : array {
function ft_get_relevant_colors(): array {
// 1. defaults
$relevant_colors = [];

Expand Down Expand Up @@ -89,7 +89,7 @@ function ft_get_relevant_colors() : array {
*
* @return void
*/
function ft_login_logo_image_styles() :void {
function ft_login_logo_image_styles(): void {

$relevant_colors = ft_get_relevant_colors();
?>
Expand Down Expand Up @@ -180,10 +180,10 @@ function ft_login_logo_image_styles() :void {
* With a fall back for the f.t Plattform Logo, if none is set.
* Requires WordPress v5.2+ in order to use the 'login_headertext' filter
*
* @param string $login_header_text [description]
* @return string [description]
* @param string $login_header_text The login header logo link text.
* @return string
*/
function ft_login_logo_image( string $login_header_text ) : string {
function ft_login_logo_image( string $login_header_text ): string {

$_logo_width = 100;
$_logo_src = get_site_icon_url(
Expand Down
10 changes: 5 additions & 5 deletions inc/wp-better-emails/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @return void
*/
function bootstrap() :void {
function bootstrap(): void {

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

Expand Down Expand Up @@ -56,7 +56,7 @@ function load_plugin() {
*
* @return void
*/
function filter_options() : void {
function filter_options(): void {
/*
* Plain-text default template
*/
Expand Down Expand Up @@ -98,7 +98,7 @@ function filter_options() : void {
*
* @return void
*/
function remove_menu() : void {
function remove_menu(): void {
remove_submenu_page( 'options-general.php', 'wpbe_options' );
}

Expand All @@ -123,7 +123,7 @@ function get_default_from() {
*
* @return string
*/
function get_default_from_email() : string {
function get_default_from_email(): string {

if ( getenv( 'FT_SMTP_USER' ) ) {
return getenv( 'FT_SMTP_USER' );
Expand All @@ -139,7 +139,7 @@ function get_default_from_email() : string {
*
* @return array<string, string>
*/
function wpbe_tags( array $tags ) : array {
function wpbe_tags( array $tags ): array {
$tags['impressum'] = do_shortcode( '[impressum titles="0"]' );

return $tags;
Expand Down

0 comments on commit 8b05ada

Please sign in to comment.