How to manage dependency registration in NopCommerce 3.90 depending upon plugin installed or not? - nopcommerce

I have created one plugin, in that I am overriding some methods from ProductService (and more). For that I have registered my CustomProductServie to IProductService.
While my Plugin is installed, it is working fine but after uninstalling the plugin. it is overriding ProductService methods. (NopCommerce 3.90)

You can check using plugin description name as follows,
var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("PluginSystemName");
If pluginDescriptoris null, plugin is not installed. Also note, you need to add reference of IPluginFinder interface in your class.

Related

Can an SBT plugin embed tasks from another plugin?

I've created a plugin that generates some web resources that need to be compiled using the sbt-webpack plugin. Ideally my plugin would just have a task bundle that will generate some resources and then it will bundle them with the webpack task from the sbt-webpack plugin.
What is the right way to incorporate tasks from different plugins into the code defining my tasks in my plugin?
Declaring a dependency on another plugin should be enough. You need to add this line to your auto-plugin:
override def requires = stejskal.sbt.WebpackPlugin
This will ensure that sbt-webpack is enabled whenever your plugins is and its settings will be loaded before the ones you define in your plugin. Plus whatever keys sbt-webpack adds to its autoImport object will be available to the users of your plugin as well.

Update hook in wordpress not fired

I want to perform a database operation on plugin update. My current version of plugin doesn't have this hook. I added the following code in the updated version. I am using the following code, but this doesn't work.
add_action( 'upgrader_process_complete', 'init_plugin_update', 10, 2 );
function init_plugin_update( $upgrader_object, $options ) {
error_log('test123');
}
I have seen WooCommerce using the same hook. So is there something i am unaware of ? Won't the new plugin file get loaded before this action ?
The upgrader_process_complete hook, as it's stated in the Codex:
Fires when the upgrader process is complete.
But it's also stated in the Notes:
Use with caution: When you use the upgrader_process_complete action hook in your plugin and your plugin is the one which under upgrade, then this action will run the old version of your plugin.
Effectively it means, if your current version of the plugin is 1.0 and it doesn't have this hook, and you're updating the plugin to version 2.0 which has that hook - it won't get fired.
Further Problems with this and other hooks
To perform a database upgrade (in case your version 2.0 has a different table structure) you obviously can't use this hook.
There is another scenario - when your plugin is updated via FTP and not the admin interface (for example you push some file changes through GIT CI/CD pipelines) - none of the hooks will get fired.
The solution
Manually manage the database version of your plugin.
Save the current plugin version in the database with
add_option.
On init hook (or even better, on
admin_init hook, because it gets triggered only during an admin
request - the Core uses this technique) perform a check if the
current version of the plugin is equal as the saved version in the
database. Use get_option and compare that with the version hardcoded in the plugin itself
If there's a mismatch, that means that the database runs
off of the old codebase and you need to update it

drupal core install module and change the enable link to work with module_filter

I am using the filter module which makes it easier to manage modules which uses "/admin/modules?filter=" to list specific modules.
Since in core when installing new modules it displays the "enable newly added module" link, which actually only links to all modules,
I was wondering if it might be possible to create a custom module that replaces that link and redirects instead to "/admin/modules?filter=NEWLY_INSTALLED_MODULES_SEPARATED_BY_%20" ?
https://www.drupal.org/project/module_filter/issues/2952200#comment-12584379

How to find out what process is using wp_mail?

While enabling Sendgrid plugin I get such a message:
SendGrid: wp_mail has been declared by another process or plugin
An interesting thing is that I disable all plugins and enabling this plugin I still get this error. Is it possible to see what kind of process is using wp_mail?
Refer below scenario,
1. Maybe plugin not supported your WP version.
2. This plugin may used WP core class or function because of that this second time declaration error may occur.

How to add wordpress plugin update available code

I have been googling for a while now but can find anywhere or a good resource which explain how to add functionality to your plugin that you see when a plugin is ready for a update.
Can someone explain how to add this functionality to a wp plugin, so you get the following when updating the plugin
There is a new version of User Access Manager available. View version
1.2.2 details or update automatically.
??? can someone point me in the right direction please.
Thanks
That line is build-in wordpress code. To enable it, you have to use wordpress code plugin repository.

Resources