Skip to content

Commit 38b7662

Browse files
committed
Fix to coding standards as best we can
Will have to wait for other #14 and #15 to be merged to do it properly
1 parent 3167989 commit 38b7662

File tree

5 files changed

+42
-32
lines changed

5 files changed

+42
-32
lines changed

app/App.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?php
2+
/**
3+
* Class to initialize the application
4+
*/
25

36
namespace DeliciousBrains\SpinupWPComposerSite;
47

8+
/**
9+
* App class to initialize the application
10+
*/
511
class App {
612

713
/**
8-
* Load custom site code
14+
* Load custom site code
915
*/
1016
public function register() {
1117
}
1218

1319
/**
1420
* Helper for defining constants if not already defined.
1521
*
16-
* @param string $key
17-
* @param mixed $value
22+
* @param string $key The name of the constant to define
23+
* @param mixed $value The value to give the constant
1824
*/
1925
public static function define( $key, $value ) {
2026
if ( defined( $key ) ) {
@@ -25,8 +31,10 @@ public static function define( $key, $value ) {
2531
}
2632

2733
/**
28-
* @param $name
29-
* @param $arguments
34+
* This allows the environment to be queried using magic methods like App::is_env_<environment>
35+
*
36+
* @param string $name The name of the magic method
37+
* @param $arguments The arguments to the magic method
3038
*
3139
* @return bool
3240
*/
@@ -36,4 +44,4 @@ public static function __callStatic( $name, $arguments ) {
3644
return $env === env( 'WP_ENV' );
3745
}
3846
}
39-
}
47+
}

config/app.php

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* Your base production configuration goes in this file. Environment-specific
54
* overrides go in their respective config/environments/{{WP_ENV}}.php file.
@@ -9,7 +8,7 @@
98
* can.
109
*/
1110

12-
use \DeliciousBrains\SpinupWPComposerSite\App;
11+
use DeliciousBrains\SpinupWPComposerSite\App;
1312

1413
$root_dir = dirname( __DIR__ );
1514
$webroot_dir = $root_dir . '/public';
@@ -23,7 +22,7 @@
2322
* Use Dotenv to set required environment variables and load .env file in root
2423
*/
2524
$env_files = file_exists( $root_dir . '/.env.local' ) ? [ '.env', '.env.local' ] : [ '.env' ];
26-
$dotenv = Dotenv\Dotenv::createUnsafeImmutable($root_dir, $env_files, false);
25+
$dotenv = Dotenv\Dotenv::createUnsafeImmutable( $root_dir, $env_files, false );
2726
if ( file_exists( $root_dir . '/.env' ) ) {
2827
$dotenv->load();
2928
$dotenv->required( [ 'DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL' ] );
@@ -40,36 +39,36 @@
4039
App::define( 'WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR );
4140
App::define( 'WP_CONTENT_URL', WP_HOME . CONTENT_DIR );
4241

43-
App::define('DB_NAME', env('DB_NAME'));
44-
App::define('DB_USER', env('DB_USER'));
45-
App::define('DB_PASSWORD', env('DB_PASSWORD'));
46-
App::define('DB_HOST', env('DB_HOST') ?: 'localhost');
47-
App::define('DB_CHARSET', 'utf8mb4');
48-
App::define('DB_COLLATE', '');
49-
$table_prefix = env('DB_PREFIX') ?: 'wp_';
42+
App::define( 'DB_NAME', env( 'DB_NAME' ) );
43+
App::define( 'DB_USER', env( 'DB_USER' ) );
44+
App::define( 'DB_PASSWORD', env( 'DB_PASSWORD' ) );
45+
App::define( 'DB_HOST', env( 'DB_HOST' ) ?: 'localhost' );
46+
App::define( 'DB_CHARSET', 'utf8mb4' );
47+
App::define( 'DB_COLLATE', '' );
48+
$table_prefix = env( 'DB_PREFIX' ) ?: 'wp_';
5049

5150
// Set other constants from env file.
52-
foreach( array_keys($dotenv->load()) as $key ) {
53-
App::define($key, env( $key ));
51+
foreach ( array_keys( $dotenv->load() ) as $key ) {
52+
App::define( $key, env( $key ) );
5453
}
5554

56-
// Environment config
55+
// Environment config.
5756
$env_config = __DIR__ . '/environments/' . WP_ENV . '.php';
5857
if ( file_exists( $env_config ) ) {
5958
require_once $env_config;
6059
}
6160

62-
App::define('AUTOMATIC_UPDATER_DISABLED', true);
63-
App::define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false);
64-
// Disable the plugin and theme file editor in the admin
65-
App::define('DISALLOW_FILE_EDIT', true);
66-
// Disable plugin and theme updates and installation from the admin
67-
App::define('DISALLOW_FILE_MODS', true);
61+
App::define( 'AUTOMATIC_UPDATER_DISABLED', true );
62+
App::define( 'DISABLE_WP_CRON', env( 'DISABLE_WP_CRON' ) ?: false );
63+
// Disable the plugin and theme file editor in the admin.
64+
App::define( 'DISALLOW_FILE_EDIT', true );
65+
// Disable plugin and theme updates and installation from the admin.
66+
App::define( 'DISALLOW_FILE_MODS', true );
6867

69-
// Secret keys
68+
// Secret keys.
7069
if ( ! file_exists( __DIR__ . '/keys.php' ) ) {
7170
$keys = file_get_contents( 'https://api.wordpress.org/secret-key/1.1/salt/' );
72-
file_put_contents( __DIR__ . '/keys.php', '<?php use ' . App::class . '; ' . str_replace( 'define(', 'App::define(', $keys ) );
71+
file_put_contents( __DIR__ . '/keys.php', '<?php use ' . App::class . ";\n" . str_replace( 'define(', 'App::define(', $keys ) );
7372
}
7473
include __DIR__ . '/keys.php';
7574

public/content/mu-plugins/app.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<?php
2-
// Bootstrap our site code
3-
( new DeliciousBrains\SpinupWPComposerSite\App() )->register();
2+
/**
3+
* Bootstrap our site code
4+
*/
5+
6+
( new DeliciousBrains\SpinupWPComposerSite\App() )->register();

public/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @var bool
1313
*/
14-
define('WP_USE_THEMES', true);
14+
define( 'WP_USE_THEMES', true );
1515

1616
/** Loads the WordPress Environment and Template */
17-
require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );
17+
require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );

public/wp-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
*/
77
require_once dirname( __DIR__ ) . '/vendor/autoload.php';
88
require_once dirname( __DIR__ ) . '/config/app.php';
9-
require_once ABSPATH . 'wp-settings.php';
9+
require_once ABSPATH . 'wp-settings.php';

0 commit comments

Comments
 (0)