Skip to content

Commit

Permalink
Merge pull request #459 from roots/log1x-docblock
Browse files Browse the repository at this point in the history
Clean up docblocks & commenting
  • Loading branch information
retlehs authored Feb 18, 2020
2 parents ee49476 + 1dab50f commit f9a77a0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 41 deletions.
12 changes: 10 additions & 2 deletions config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@

use Roots\WPConfig\Config;

/** @var string Directory containing all of the site's files */
/**
* Directory containing all of the site's files
*
* @var string
*/
$root_dir = dirname(__DIR__);

/** @var string Document Root */
/**
* Document Root
*
* @var string
*/
$webroot_dir = $root_dir . '/web';

/**
Expand Down
82 changes: 63 additions & 19 deletions web/app/mu-plugins/bedrock-autoloader.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
/**
* Plugin Name: Bedrock Autoloader
* Plugin URI: https://github.com/roots/bedrock/
* Description: An autoloader that enables standard plugins to be required just like must-use plugins. The autoloaded plugins are included during mu-plugin loading. An asterisk (*) next to the name of the plugin designates the plugins that have been autoloaded.
* Version: 1.0.0
* Author: Roots
* Author URI: https://roots.io/
* License: MIT License
* Plugin Name: Bedrock Autoloader
* Plugin URI: https://github.com/roots/bedrock/
* Description: An autoloader that enables standard plugins to be required just like must-use plugins. The autoloaded plugins are included during mu-plugin loading. An asterisk (*) next to the name of the plugin designates the plugins that have been autoloaded.
* Version: 1.0.0
* Author: Roots
* Author URI: https://roots.io/
* License: MIT License
*/

namespace Roots\Bedrock;
Expand All @@ -23,29 +23,59 @@
*/
class Autoloader
{
/** @var static Singleton instance */
/**
* Singleton instance.
*
* @var static
*/
private static $instance;

/** @var array Store Autoloader cache and site option */
/**
* Store Autoloader cache and site option.
*
* @var array
*/
private $cache;

/** @var array Autoloaded plugins */
/**
* Autoloaded plugins.
*
* @var array
*/
private $autoPlugins;

/** @var array Autoloaded mu-plugins */
/**
* Autoloaded mu-plugins.
*
* @var array
*/
private $muPlugins;

/** @var int Number of plugins */
/**
* Number of plugins.
*
* @var int
*/
private $count;

/** @var array Newly activated plugins */
/**
* Newly activated plugins.
*
* @var array
*/
private $activated;

/** @var string Relative path to the mu-plugins dir */
/**
* Relative path to the mu-plugins directory.
*
* @var string
*/
private $relativePath;

/**
* Create singleton, populate vars, and set WordPress hooks
* Create an instance of Autoloader.
*
* @return void
*/
public function __construct()
{
Expand All @@ -66,6 +96,8 @@ public function __construct()

/**
* Run some checks then autoload our plugins.
*
* @return void
*/
public function loadPlugins()
{
Expand All @@ -82,10 +114,10 @@ public function loadPlugins()

/**
* Filter show_advanced_plugins to display the autoloaded plugins.
* @param $show bool Whether to show the advanced plugins for the specified plugin type.
* @param $type string The plugin type, i.e., `mustuse` or `dropins`
* @return bool We return `false` to prevent WordPress from overriding our work
* {@internal We add the plugin details ourselves, so we return false to disable the filter.}
*
* @param bool $show Whether to show the advanced plugins for the specified plugin type.
* @param string $type The plugin type, i.e., `mustuse` or `dropins`
* @return bool We return `false` to prevent WordPress from overriding our work
*/
public function showInAdmin($show, $type)
{
Expand All @@ -110,6 +142,8 @@ public function showInAdmin($show, $type)

/**
* This sets the cache or calls for an update
*
* @return void
*/
private function checkCache()
{
Expand All @@ -124,9 +158,13 @@ private function checkCache()
}

/**
* Update mu-plugin cache.
*
* Get the plugins and mu-plugins from the mu-plugin path and remove duplicates.
* Check cache against current plugins for newly activated plugins.
* After that, we can update the cache.
*
* @return void
*/
private function updateCache()
{
Expand All @@ -143,9 +181,13 @@ private function updateCache()
}

/**
* Activate plugin hooks.
*
* This accounts for the plugin hooks that would run if the plugins were
* loaded as usual. Plugins are removed by deletion, so there's no way
* to deactivate or uninstall.
*
* @return void
*/
private function pluginHooks()
{
Expand All @@ -160,6 +202,8 @@ private function pluginHooks()

/**
* Check that the plugin file exists, if it doesn't update the cache.
*
* @return void
*/
private function validatePlugins()
{
Expand Down
18 changes: 9 additions & 9 deletions web/app/mu-plugins/disallow-indexing.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/*
Plugin Name: Disallow Indexing
Plugin URI: https://roots.io/bedrock/
Description: Disallow indexing of your site on non-production environments.
Version: 1.0.0
Author: Roots
Author URI: https://roots.io/
License: MIT License
*/
/**
* Plugin Name: Disallow Indexing
* Plugin URI: https://github.com/roots/bedrock/
* Description: Disallow indexing of your site on non-production environments.
* Version: 1.0.0
* Author: Roots
* Author URI: https://roots.io/
* License: MIT License
*/

if (defined('WP_ENV') && WP_ENV !== 'production' && !is_admin()) {
add_action('pre_option_blog_public', '__return_zero');
Expand Down
18 changes: 9 additions & 9 deletions web/app/mu-plugins/register-theme-directory.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/*
Plugin Name: Register Theme Directory
Plugin URI: https://roots.io/bedrock/
Description: Register default theme directory
Version: 1.0.0
Author: Roots
Author URI: https://roots.io/
License: MIT License
*/
/**
* Plugin Name: Register Theme Directory
* Plugin URI: https://github.com/roots/bedrock/
* Description: Register default theme directory
* Version: 1.0.0
* Author: Roots
* Author URI: https://roots.io/
* License: MIT License
*/

if (!defined('WP_DEFAULT_THEME')) {
register_theme_directory(ABSPATH . 'wp-content/themes');
Expand Down
5 changes: 3 additions & 2 deletions web/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

/** WordPress view bootstrapper */
/**
* WordPress View Bootstrapper
*/
define('WP_USE_THEMES', true);
require __DIR__ . '/wp/wp-blog-header.php';

0 comments on commit f9a77a0

Please sign in to comment.