afragen / wp-dependency-installer

A lightweight class to add to WordPress plugins/themes to automatically install plugin dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Required dependencies installation messages

davidessayan opened this issue · comments

Hello,

First, thank you for this interesting library !
I was just wondering if I did something wrong because when a plugin is required, the auto-installation process shows update messages in a funny way :

image

As you can see, update messages are showing before the "Screen options" button.
Is there anything to do about that ?

Thank you !

That's strange. Are there any console errors?

Nothing in console unfortunately.
Actually, notices are generated before the doctype :

image

This is the way I am running wpdi (from a custom plugin) :

include_once( __DIR__ . '/../vendor/autoload.php' );

$plugins = array( ... );

add_action('plugins_loaded', function() use ($plugins){
    $wpdi = WP_Dependency_Installer::instance( __DIR__ );
    $wpdi->register( $plugins )->run();
});

Can you try testing with a default theme?

Of course !
Please find my simple test below :

Context :

WP Version : 6.4.2
Theme : twentytwentyfour
Plugins : No plugin / Fresh install

File : functions.php

add_action('init', function () {
	WP_Dependency_Installer::instance( __DIR__ )->run();
});

File : wp-dependencies.json

[
  {
    "name": "Query Monitor",
    "host": "wordpress",
    "slug": "query-monitor/query-monitor.php",
    "uri": "https://wordpress.org/plugins/query-monitor/",
    "required": true
  },
  {
    "name": "Git Updater",
    "host": "github",
    "slug": "git-updater/git-updater.php",
    "uri": "afragen/git-updater",
    "branch": "master",
    "optional": false,
    "token": null
  },
  {
    "name": "Yoast SEO",
    "host": "wordpress",
    "slug": "wordpress-seo/wp-seo.php",
    "uri": "https://fr.wordpress.org/plugins/wordpress-seo/",
    "required": true
  }
]

Result

Notices are showing before the doctype.
This seems to happen when the installed plugin needs a translation update :

image

Final result when the document is fully loaded :
image

I think you've discovered the issue.

I load the installation messages in the notice but I don't handle translation updates or their messages.

I'm open to PRs if you can figure it out.🙂

Ok :)

I guess I may have found a workaround.
The problem is that WP_Upgrader_Skin is not silent.

So I had a look of what's happening here : /wp-admin/plugin-install.php

On this page, the installation process use WP_Ajax_Upgrader_Skin which seems to work in our context.
With this skin, we no longer have translation messages printed by the Wordpress show_message() function.

Can you please have a look and tell me what do you think about this solution ?

davidessayan@1fcca91