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

Required dependencies installation messages #71

Open
davidessayan opened this issue Jan 31, 2024 · 6 comments
Open

Required dependencies installation messages #71

davidessayan opened this issue Jan 31, 2024 · 6 comments

Comments

@davidessayan
Copy link

davidessayan commented Jan 31, 2024

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 !

@afragen
Copy link
Owner

afragen commented Feb 1, 2024

That's strange. Are there any console errors?

@davidessayan
Copy link
Author

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();
});

@afragen
Copy link
Owner

afragen commented Feb 5, 2024

Can you try testing with a default theme?

@davidessayan
Copy link
Author

davidessayan commented Feb 5, 2024

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

@afragen
Copy link
Owner

afragen commented Feb 5, 2024

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.🙂

@davidessayan
Copy link
Author

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

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

No branches or pull requests

2 participants