Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Bedrock Autoloader package #519

Merged
merged 1 commit into from
May 20, 2020
Merged

Conversation

retlehs
Copy link
Member

@retlehs retlehs commented May 16, 2020

@aaemnnosttv
Copy link
Contributor

Awesome to finally see this happen! ❤️

Opened a PR against the autoloader repo which still has a few things that only belong here rather than in the package 🙂

@retlehs retlehs force-pushed the 299-use-bedrock-autoloader-package branch from 21bc13c to 49c8ac5 Compare May 16, 2020 15:03
@retlehs
Copy link
Member Author

retlehs commented May 16, 2020

@aaemnnosttv merged and updated this PR, thank you!

Copy link
Contributor

@austinpray austinpray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!!

@@ -11,233 +11,6 @@

namespace Roots\Bedrock;

if (!is_blog_installed()) {
return;
if (is_blog_installed() && class_exists(Autoloader::class)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@austinpray
Copy link
Contributor

@aaemnnosttv do you care about this? roots/bedrock-autoloader#7

@vinkla
Copy link

vinkla commented May 18, 2020

I'm so glad this has finally happened! Great work everybody 🙌

I've explored integrating Bedrock's autoloader into WordPlate. If we load the plugins within the pre_option_active_plugins hook there is no need to keep this as a mu-plugin. Instead we could load it from the wp-config.php file.

public function __construct()
{
    if (isset(self::$instance)) {
        return;
    }

    self::$instance = $this;

    require_once ABSPATH . 'wp-includes/plugin.php';

    add_filter('pre_option_active_plugins', function () {
        $this->relativePath = '/../' . basename(WPMU_PLUGIN_DIR);

        if (is_admin()) {
            add_filter('show_advanced_plugins', [$this, 'showInAdmin'], 0, 2);
        }

        $this->loadPlugins();
    });
}

This would mean we could remove the bedrock-autoloader.php plugin in this PR and load mu-plugins from the wp-config.php file.

What are your thoughts on this?

@austinpray
Copy link
Contributor

@vinkla Thank you for taking a look! Im interested in your idea, but note that it cannot live in the constructor as a side-effect. It makes testing difficult and side-effects in constructors is a strong anti-pattern. Ref roots/bedrock-autoloader#4

Working right now so can't respond in full.

@vinkla
Copy link

vinkla commented May 18, 2020

It makes testing difficult and side-effects in constructors is a strong anti-pattern.

Yes, this has been a pain point for us in WordPlate as well. Testing has been hard. I'll continue digging.

@retlehs retlehs force-pushed the 299-use-bedrock-autoloader-package branch from 49c8ac5 to 0f35caa Compare May 20, 2020 01:02
@retlehs retlehs merged commit 3c23dcf into master May 20, 2020
@retlehs retlehs deleted the 299-use-bedrock-autoloader-package branch May 20, 2020 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants