admin管理员组文章数量:1389783
We use automatic updates on our sites due to having many sites and so manual updates not being feasible in the low hosting costs.
But due to Wordpress or mainly plugin updates having the possibility to break your site, and due to not knowing when Wordpress would actually do the updates which could also occur every day, I would like to programatically update Wordpress and plugins in a functions.php or plugin so I can know the exact date and time it will run, and so we know to check for problems afterwards.
For example, I may choose Monday mornings 3am so our first action that morning is check all sites are working well, fix any issues, and then I know the rest of the week will be problem free :)
Does anyone know how to initiate a Wordpress and plugin update in the functions file or a plugin?
My idea is to disable all automatic updates generally, but then at a certain day and time to call the update function which would check if updates exist, and if they do, update them. I will add an email function to inform me what has been updated on what site so I can check that site.
If using automatic updates, this approach is far more controlled than if leaving Wordpress do it as and when it likes however many times every day.
Thanks
We use automatic updates on our sites due to having many sites and so manual updates not being feasible in the low hosting costs.
But due to Wordpress or mainly plugin updates having the possibility to break your site, and due to not knowing when Wordpress would actually do the updates which could also occur every day, I would like to programatically update Wordpress and plugins in a functions.php or plugin so I can know the exact date and time it will run, and so we know to check for problems afterwards.
For example, I may choose Monday mornings 3am so our first action that morning is check all sites are working well, fix any issues, and then I know the rest of the week will be problem free :)
Does anyone know how to initiate a Wordpress and plugin update in the functions file or a plugin?
My idea is to disable all automatic updates generally, but then at a certain day and time to call the update function which would check if updates exist, and if they do, update them. I will add an email function to inform me what has been updated on what site so I can check that site.
If using automatic updates, this approach is far more controlled than if leaving Wordpress do it as and when it likes however many times every day.
Thanks
Share Improve this question asked Feb 23, 2019 at 15:33 Laurence CopeLaurence Cope 15012 bronze badges 1- You can do a scheduled task everyday and put in the wp update function if the wp version has changed or if it is a new w version. – Ayed Mohamed Amine Commented Feb 23, 2019 at 18:41
2 Answers
Reset to default 3There's a question and an answer regarding WP (auto) updates here, How To/What triggers a Wordpress auto update?
The answer also has a link to a blog post on how to force WordPress auto-update.
Code snippet posted on the referenced blog,
<?php
// request-update.php
require( dirname(__FILE__) . '/wp-load.php' );
wp_maybe_auto_update();
?>
and
php ./request-update.php
Perhaps you can use this and a real (not WP) cron job to update your site(s) at a certain day and time.
Edit
Then there's the do_core_upgrade
function.
Edit 2
Oh, and then there's wp_update_plugins
and wp_update_themes
, too. These are defined in wp-includes/update.php (trac).
Edit 3
Actually, wp_ajax_update_plugin
might be better reference point for creating a custom plugin update process. There's also the Plugin_Upgrader
class. For themes there's wp_ajax_update_theme
for reference and Theme_Upgrader
class.
wp-disable-plugin-update.php smart updating knowledge growth WordPress code
/**
* Prevent update notification for plugin
* http://www.thecreativedev/disable-updates-for-specific-plugin-in-wordpress/
* Place in theme functions.php or at bottom of wp-config.php
*/
function disable_plugin_updates( $value ) {
if ( isset($value) && is_object($value) ) {
if ( isset( $value->response['plugin-folder/plugin.php'] ) ) {
unset( $value->response['plugin-folder/plugin.php'] );
}
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );
本文标签: functionsHow to update Wordpress and plugins at specific day and time in PHP
版权声明:本文标题:functions - How to update Wordpress and plugins at specific day and time in PHP? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744702373a2620632.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论