• Resolved lynoo

    (@lynoo)


    I need to generate static files daily
    It’s possible to schedule Generate static files each day?

Viewing 1 replies (of 1 total)
  • Plugin Author patrickposner

    (@patrickposner)

    Hey @lynoo,

    sure you can do that!

    By default, Simply Static is running as a one-time cron, but you can use a little code snippet like the one below to automatically run a static export daily:

    <?php
    
    register_activation_hook( __FILE__, 'ss_setup_static_daily_export_cron' );
    
    /**
     * Setup a cron job to run daily.
     *
     * @return void
     */
    function ss_setup_static_daily_export_cron() {
    	if ( ! wp_next_scheduled( 'ss_static_export_daily_cron' ) ) {
    		wp_schedule_event( time(), 'daily', 'ss_static_export_daily_cron' );
    	}
    }
    
    add_action( 'ss_static_export_daily_cron', 'ss_run_static_export_cron_daily' );
    /**
     * Run a full static export daily.
     *
     * @return void
     */
    function ss_run_static_export_cron_daily() {
    	// Full static export
    	$simply_static = Simply_Static\Plugin::instance();
    	$simply_static->run_static_export();
    }

    Best regards,
    Patrick

Viewing 1 replies (of 1 total)
  • The topic ‘schedule Generate’ is closed to new replies.