Giter Site home page Giter Site logo

Comments (6)

YahnisElsts avatar YahnisElsts commented on May 29, 2024 1

I see that in your plugin, the function that creates the update checker instances is attached to the admin_init hook. Could it be that MainWP performs updates in a context where the admin_init hook doesn't get triggered? In that case, the updates wouldn't show up because the update checker wouldn't have been initialized.

I'm not sure if that could also affect the numbers in the admin menu. Still, as a test, it might be worth moving the functions to a much earlier hook, like plugins_loaded.

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 29, 2024 1

If you want to control when exactly PUC checks for updates, one way would be to pass 0 as the fourth argument to buildUpdateChecker(). This argument is the "check period", and setting it to zero disables automatic checks. Then you can have your plugin trigger update checks directly by calling the $updateChecker->checkForUpdates() method.

Note that you will still need to initialize the update checker on other pages, or the updates won't show up in the admin.

from plugin-update-checker.

stingray82 avatar stingray82 commented on May 29, 2024

This was perfect, it was so tiny I would never have worked it out thank you;

I now need to work out how to get it to run 4 times a day for updates and that should be it done now thanks again

from plugin-update-checker.

stingray82 avatar stingray82 commented on May 29, 2024

it's running every single time and every single page I am running in my admin area, any suggestions on how to limit it to only plugins and updates or Ideally, 4 times a day for it to run and the updates be there for the twice-daily WordPress check is enough for me, I suspect this will work for the 4 times a day but I am not sure how to restrict where it runs.
`
// Activation hook
/register_activation_hook(FILE, 'ninja_updater_schedule_tasks');
// Deactivation hook
register_deactivation_hook(FILE, 'ninja_updater_deactivate');
add_action( 'ninja_updater_check_plugins', 'ninja_updater_check_plugins' );
add_action( 'ninja_updater_check_themes', 'ninja_updater_check_themes' );
/

function ninja_custom_cron_schedule( $schedules ) {
$schedules['every_six_hours'] = array(
'interval' => 21600, // Every 6 hours
'display' => __( 'Every 6 hours' ),
);
return $schedules;
}
add_filter( 'cron_schedules', 'ninja_custom_cron_schedule' );

function ninja_updater_schedule_tasks() {
error_log('ninja_updater_schedule_tasks has been executed at ' . date('Y-m-d H:i:s')); // Add this line for debugging

if (!wp_next_scheduled('ninja_updater_check_plugins')) {
    // Schedule plugin check every 6 hours
    wp_schedule_event(time(), 'every_six_hours', 'ninja_updater_check_plugins');
}

if (!wp_next_scheduled('ninja_updater_check_themes')) {
    // Schedule theme check every 6 hours
    wp_schedule_event(time(), 'every_six_hours', 'ninja_updater_check_themes');
}

}
// On Deactivate
function ninja_updater_deactivate() {
// Remove the scheduled events for checking plugins and themes
wp_clear_scheduled_hook('ninja_updater_check_plugins');
wp_clear_scheduled_hook('ninja_updater_check_themes');
}
`

Thanks Again

from plugin-update-checker.

stingray82 avatar stingray82 commented on May 29, 2024

Thanks I think I understood but I think I've done something wrong now I get no checking at all, the modifications I made are here
https://github.com/stingray82/ninja-updater-pd/

You can see the commit here:
stingray82/ninja-updater-pd@9030db1

I will take another look this evening, thanks again for you help

from plugin-update-checker.

YahnisElsts avatar YahnisElsts commented on May 29, 2024

$updateChecker was a placeholder. In practice, you of course need to call checkForUpdates() on your actual update checker instance(s). Also, as I mentioned, you'll need to pass a zero as the 4th argument to buildUpdateChecker(). The third argument is the slug, but you can use an empty string if you want PUC to automatically assign a slug.

from plugin-update-checker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.