Skip to content

Commit

Permalink
Fix CS issues related to WPCS 3.x Update
Browse files Browse the repository at this point in the history
  • Loading branch information
carstingaxion committed Feb 28, 2024
1 parent 975ccce commit 9c20772
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
9 changes: 5 additions & 4 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<description>Coding standards for install.php</description>

<file>.</file>
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->

<!--
<exclude-pattern>*/bin/*</exclude-pattern>
Expand All @@ -13,15 +14,15 @@
<!-- Use figuren.theater Coding Standards -->
<rule ref="figurentheater" />

<!-- Allow functions without namespace -->
<!-- Allow functions without namespace
<rule ref="HM.Functions.NamespacedFunctions">
<exclude name="HM.Functions.NamespacedFunctions.MissingNamespace" />
</rule>
</rule> -->

<!-- Allow i18n without text-domain -->
<!-- Allow i18n without text-domain
<rule ref="WordPress.WP.I18n">
<exclude name="WordPress.WP.I18n.MissingArgDomain" />
</rule>
</rule> -->

<!-- Allow side-effects -->
<rule ref="PSR1.Files.SideEffects">
Expand Down
48 changes: 22 additions & 26 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param bool $blog_public Whether blog is public.
* @param string $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Default empty (random password).
* @param string $language Optional. Language chosen. Default empty.
*
* @return array{
* url: string,
Expand All @@ -37,7 +36,7 @@
* password_message: string
* }
*/
function wp_install( string $blog_title, string $user_name, string $user_email, bool $public, string $deprecated = '', string $user_password = '', string $language = '' ): array {
function wp_install( string $blog_title, string $user_name, string $user_email, bool $blog_public, string $deprecated = '', string $user_password = '' ): array {

if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.6' );
Expand All @@ -46,7 +45,7 @@ function wp_install( string $blog_title, string $user_name, string $user_email,
$install_defaults = [
'blogname' => $blog_title,
'admin_email' => $user_email,
'blog_public' => $public,
'blog_public' => $blog_public,
// Freshness of site - in the future, this could get more specific about actions taken, perhaps.
'fresh_site' => 1,
];
Expand All @@ -70,21 +69,21 @@ function wp_install( string $blog_title, string $user_name, string $user_email,

if ( ! $user_id && empty( $user_password ) ) {
$user_password = wp_generate_password( 12, false );
$message = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.' );
$message = __( '<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.', 'default' );
$user_id = wp_create_user( $user_name, $user_password, $user_email );
if ( ! is_wp_error( $user_id ) ) {
update_user_meta( $user_id, 'default_password_nag', true );
$user_created = true;
}
} elseif ( ! $user_id ) {
// Password has been provided.
$message = '<em>' . __( 'Your chosen password.' ) . '</em>';
$message = '<em>' . __( 'Your chosen password.', 'default' ) . '</em>';
$user_id = wp_create_user( $user_name, $user_password, $user_email );
if ( ! is_wp_error( $user_id ) ) {
$user_created = true;
}
} else {
$message = __( 'User already exists. Password inherited.' );
$message = __( 'User already exists. Password inherited.', 'default' );
}

// Make sure we do not deal with a WP_Error.
Expand Down Expand Up @@ -116,7 +115,7 @@ function wp_install( string $blog_title, string $user_name, string $user_email,
*
* @param WP_User $user The site owner.
*/
do_action( 'wp_install', $user );
do_action( 'wp_install', $user ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound

return [
'url' => $guessurl,
Expand Down Expand Up @@ -150,7 +149,8 @@ function wp_install_defaults( int $user_id ): void {
update_option( 'sidebars_widgets', [ 'wp_inactive_widgets' => [] ] );

/** Before a comment appears the comment author must have a previously approved comment: false */
update_option( 'comment_whitelist', 0 );
/** The parameter value 'comment_whitelist' has been deprecated since WordPress version 5.5.0. Use 'comment_previously_approved' instead. */
update_option( 'comment_previously_approved', 0 );

/**
* Run our custom install steps
Expand Down Expand Up @@ -199,7 +199,7 @@ function wp_install_defaults( int $user_id ): void {
function ft_install_defaults__post( int $user_id ): void {
global $wpdb;

$cat_tt_id = ft_install_defaults__category( $user_id );
$cat_tt_id = ft_install_defaults__category();

$now = current_time( 'mysql' );
$now_gmt = current_time( 'mysql', 1 );
Expand All @@ -212,10 +212,10 @@ function ft_install_defaults__post( int $user_id ): void {
}

if ( ! $first_post ) {
$first_post = "<!-- wp:paragraph -->\n<p>" .
$first_post = "<!-- wp:paragraph -->\n<p>"
/* translators: First post content. %s: Site link. */
__( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!' ) .
"</p>\n<!-- /wp:paragraph -->";
. __( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!', 'default' )
. "</p>\n<!-- /wp:paragraph -->";
}

// Cast to string - Brutus style.
Expand All @@ -238,9 +238,10 @@ function ft_install_defaults__post( int $user_id ): void {
'post_date_gmt' => $now_gmt,
'post_content' => $first_post,
'post_excerpt' => '',
'post_title' => __( 'Hallo Theaterwelt!' ),
/* translators: Default post slug. */
'post_name' => sanitize_title( _x( 'Hallo Theaterwelt', 'Default post slug' ) ),
/* translators: Default first-post title. */
'post_title' => _x( 'Hallo Theaterwelt', 'Default first-post title', 'figurentheater' ),
/* translators: Default first-post slug. */
'post_name' => sanitize_title( _x( 'Hallo Theaterwelt', 'Default first-post slug', 'figurentheater' ) ),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $first_post_guid,
Expand All @@ -267,16 +268,15 @@ function ft_install_defaults__post( int $user_id ): void {
/**
* Create Default category.
*
* @param integer $user_id The user who creates the term.
*
* @return integer
*/
function ft_install_defaults__category( int $user_id ): int {
function ft_install_defaults__category(): int {
global $wpdb;

$cat_name = __( 'Uncategorized' );
/* translators: Default category title. */
$cat_name = _x( 'Uncategorized', 'Default category title', 'default' );
/* translators: Default category slug. */
$cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
$cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug', 'default' ) );

$cat_id = 1;

Expand Down Expand Up @@ -324,11 +324,7 @@ function ( $option ) {
// Cast to string - Brutus style.
$_opt = '' . get_option( $option );
$_updated_option = str_replace( 'http://', 'https://', $_opt );

update_option(
$option,
$_updated_option
);
update_option( $option, $_updated_option );
},
$_options_to_change
);
Expand Down

0 comments on commit 9c20772

Please sign in to comment.