admin管理员组文章数量:1297182
a very specific question about upgrader_process_complete filter (but also upgrader_post_install). I must call some functions whenever specific themes/plugins are updated.
The code works perfectly when plugins/themes are updated through the WP update-core.php admin page, while they are not if plugins/themes are updated respectively from plugins/themes list page, through ajax.
Do you have any hint of the reason why? Or how can I hook into the ajax updater process? thanks
a very specific question about upgrader_process_complete filter (but also upgrader_post_install). I must call some functions whenever specific themes/plugins are updated.
The code works perfectly when plugins/themes are updated through the WP update-core.php admin page, while they are not if plugins/themes are updated respectively from plugins/themes list page, through ajax.
Do you have any hint of the reason why? Or how can I hook into the ajax updater process? thanks
Share Improve this question edited Aug 5, 2022 at 12:48 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Aug 5, 2022 at 9:21 a-codera-coder 4001 gold badge3 silver badges10 bronze badges2 Answers
Reset to default 0There's two thing that relates to this concern.
- The
upgrader_process_complete
action doesn't fire when the updater is running in bulk mode, aka multiple plugin updates. ref: https://core.trac.wordpress.org/browser/tags/6.0/src/wp-admin/includes/class-wp-upgrader.php#L826
// @see https://core.trac.wordpress.org/browser/tags/6.0/src/wp-admin/includes/class-wp-upgrader.php#L826
// @line 826 - 841.
if ( ! $options['is_multi'] ) {
do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
}
- The
wp_ajax_update_plugin
function, which is responsible for handing the ajax request performs the each plugin upgrade in bulk mode. ref: https://core.trac.wordpress.org/browser/tags/6.0/src/wp-admin/includes/ajax-actions.php#L4547
// @see https://core.trac.wordpress.org/browser/tags/6.0/src/wp-admin/includes/ajax-actions.php#L4547
// Line 4545 - 4547.
$skin = new WP_Ajax_Upgrader_Skin();
$upgrader = new Plugin_Upgrader( $skin );
$result = $upgrader->bulk_upgrade( array( $plugin ) );
Having explored the whole WP codex, I was missing a major point above all the rest: hooks priorities!
upgrader_process_complete
, upgrader_post_install
, (etc) hooks must be registered through an hook called also through WP ajax operations (eg. admin_init
).
I was mistakenly registering those filters on "admin_menu". Everything solved then!
本文标签: hooksupgraderprocesscomplete filter not fired using ajax updates
版权声明:本文标题:hooks - upgrader_process_complete filter not fired using ajax updates 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738474460a2088781.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论