# Thời gian tiếp theo cho một sự kiện. Retrieve the next timestamp for an event. wp\_next\_scheduled (ok

```
if ( ! wp_next_scheduled( 'resend_code_api_error' ) ) {
    wp_schedule_event( time(), 'hourly', 'resend_code_api_error' );
}

add_action( 'resend_code_api_error', 'resend_code_api_error' );
function resend_code_api_error() {
    global $wpdb;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,API_OEC_ERROR_URL);
    curl_setopt($ch, CURLOPT_TIMEOUT,10);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec ($ch);
    curl_close ($ch);
    $server_output = json_decode($server_output, true);

    if($server_output['done']) {
        $records = $server_output['records'];

        if(count($records) > 0) {
            foreach ($records as $record) {
                $course = get_post($record['course_id']);
                // Kiểm tra xem record đã tạo thành công trước đó chưa
                $sql = "SELECT * FROM wp_log_api WHERE course_id = " . $record['course_id'] . " AND order_id = " . $record['order_id'];
                $temp = $wpdb->get_row($sql);
                if(!$temp || $temp->status != 2) {
                    // Gen lại code
                    do {
                        $code = wccg_get_random_coupon();
                        // Kiểm tra mã kích hoạt đã được tạo trước đó chưa
                        $checkSql = "SELECT id FROM wp_codes WHERE code = '" . $code . "'";
                        $codes = $wpdb->get_results($checkSql);
                        if(count($codes) > 0) {
                            $end = false;
                        } else {
                            $end = true;
                        }
                    } while ($end == false);
                    // Insert mã kích hoạt vào DB
                    $today = date('Y-m-d H:i:s');
                    if($code) {
                        $data = array(
                            'code' => $code,
                            'course_id' => $record['course_id'],
                            'is_active' => 0,
                            'status' => 1,
                            'customer_email' => $record['customer_email'],
                            'created_at' => $today,
                            'order_id' => $record['order_id'],
                            'source' => 'API'
                        );
                        $wpdb->insert('wp_codes', $data);
                        if($wpdb->insert_id) {
                            if($temp) {
                                // Cập nhật log
                                $wpdb->update('wp_log_api', array('api_status' => 1, 'code' => $code), array('id' => $temp['id']));
                            } else {
                                // Lưu log TMDT call API
                                $dataApi = array(
                                    'customer_email' => $record['customer_email'],
                                    'customer_name' => $record['customer_name'],
                                    'course_id' => $record['course_id'],
                                    'order_id' => $record['order_id'],
                                    'created_at' => date('Y-m-d :H:i:s'),
                                    'api_status' => 1,
                                    'source' => 'API',
                                );
                                $wpdb->insert('wp_log_api', $dataApi);
                            }

                            $subject = 'MÃ KÍCH HOẠT KHÓA HỌC';
                            $customer_name = $record['customer_name'];
                            $customer_email = $record['customer_email'];
                            $body = '<b>MÃ KÍCH HOẠT KHÓA HỌC ' . wc_strtoupper($course->post_title) . '</b><br/>';
                            $body .= 'Thân gửi học viên <b>' . $customer_name .'</b><br/>';
                            $body .= 'Vinmec xin xác nhận đã thanh toán thành công khóa học <b>' . $course->post_title . '</b> tại <a href="' . home_url() . '">songkhoe.vinmec.com</a> <br/>';
                            $body .= 'Mã kích hoạt khóa học của bạn là: <b>' . $code . '</b><br/>';
                            $body .= 'Hướng dẫn kích hoạt khóa học: <br/>';
                            $body .= '<b>(Lưu ý: chỉ kích hoạt một lần duy nhất) </b><br/>';
                            $body .= '<b>Bước 1:</b> Truy cập vào link: <a href="' . home_url() . '">songkhoe.vinmec.com</a> <br/>';
                            $body .= '<b>Bước 2:</b> Chọn nút "Đăng nhập" và nhập thông tin tài khoản của bạn <br/>';
                            $body .= '<b>Bước 3:</b> Chọn mục “Khóa học”, xem thông tin khóa học <br/>';
                            $body .= '<b>Bước 4:</b> Chọn nút “Kích hoạt khóa học”  <br/>';
                            $body .= '<b>Bước 5:</b> Nhập mã kích hoạt thành công và bắt đầu học ngay  <br/><br/>';
                            $body .= 'Cảm ơn sự quan tâm và ủng hộ của bạn.  <br/>';
                            $body .= 'Chúc các bạn có những trải nghiệm thú vị cùng <a href="' . home_url() .'">songkhoe.vinmec.com</a> <br/><br/>';
                            $body .= '<a href="#">Câu hỏi thường gặp</a> <br/>';
                            $body .= '<a href="#">Chính sách bảo mật thông tin</a> <br/><br/>';
                            $body .= '<b>Chú ý:</b> Đây là email tự động từ Hệ thống Y tế Vinmec. Quý khách vui lòng, không trả lời email này. <br/><br/>';
                            $body .= '<b>CÔNG TY CỔ PHẦN BỆNH VIỆN ĐA KHOA QUỐC TẾ VINMEC </b><br/>';
                            $body .= 'Địa chỉ: số 458 Minh Khai, phường Vĩnh Tuy, quận Hai Bà Trung, Hà Nội <br/>';
                            $body .= 'Liên hệ: <a href="mailto: info@vinmec.com">info@vinmec.com</a><br/>';
                            $headers = array('Content-Type: text/html; charset=UTF-8');
                            $result = wp_mail($customer_email, $subject, $body, $headers);
                            if($result) {
                                // Cập nhật log
                                $wpdb->update('wp_log_api', array('api_status' => 2), array('id' => $temp['id']));
                                $response['error'] = 200;
                                $response['message'] = 'Tạo mã kích hoạt và gửi email thành công';
                                wp_send_json_success( $response );
                            } else {
                                $response['error'] = 400;
                                $response['message'] = 'Gửi email không thành công';
                                wp_send_json_success( $response );
                            }
                        } else {
                            $response['error'] = 400;
                            $response['message'] = 'Tạo mã kích hoạt không thành công';
                            wp_send_json_success( $response );
                        }
                    } else {
                        $response['error'] = 400;
                        $response['message'] = 'Không thể tạo mã kích hoạt';
                        wp_send_json_success( $response );
                    }
                }
            }
        }
    }
}
```

Tham khảo:

{% embed url="<https://hotexamples.com/examples/-/-/wp_next_scheduled/php-wp_next_scheduled-function-examples.html>" %}

## PHP wp\_next\_scheduled Examples

**PHP wp\_next\_scheduled - 30 examples found**. These are the top rated real world PHP examples of **wp\_next\_scheduled** extracted from open source projects. You can rate examples to help us improve the quality of examples.Programming Language: PHPMethod/Function: wp\_next\_scheduledExamples at hotexamples.com: 30RELATED[ThemeMock](https://hotexamples.com/examples/-/ThemeMock/-/php-thememock-class-examples.html)[ImprovementsBuildingsActualUses](https://hotexamples.com/examples/-/ImprovementsBuildingsActualUses/-/php-improvementsbuildingsactualuses-class-examples.html)[Base](https://hotexamples.com/examples/modsync/Base/-/php-base-class-examples.html)[PageHelper](https://hotexamples.com/examples/-/PageHelper/-/php-pagehelper-class-examples.html)[GOTMLS\_update\_status](https://hotexamples.com/examples/-/-/GOTMLS_update_status/php-gotmls_update_status-function-examples.html)[GroupQuery](https://hotexamples.com/examples/-/GroupQuery/-/php-groupquery-class-examples.html)[database\_add](https://hotexamples.com/examples/-/-/database_add/php-database_add-function-examples.html)[ldap\_get\_option](https://hotexamples.com/examples/-/-/ldap_get_option/php-ldap_get_option-function-examples.html)[yii\widgets\Pjax](https://hotexamples.com/examples/-/yii%255Cwidgets%255CPjax/-/php-yii%255cwidgets%255cpjax-class-examples.html)[ReceiptLine](https://hotexamples.com/examples/-/ReceiptLine/-/php-receiptline-class-examples.html)RELATED IN LANGS[BitTreeDecoder (C#)](https://csharp.hotexamples.com/examples/_/BitTreeDecoder/-/php-bittreedecoder-class-examples.html)[DeleteBandwidthRateLimitRequestMarshaller (C#)](https://csharp.hotexamples.com/examples/-/DeleteBandwidthRateLimitRequestMarshaller/-/php-deletebandwidthratelimitrequestmarshaller-class-examples.html)[block\_write\_full\_page (C++)](https://cpp.hotexamples.com/examples/-/-/block_write_full_page/cpp-block_write_full_page-function-examples.html)[elf\_begin (C++)](https://cpp.hotexamples.com/examples/-/-/elf_begin/cpp-elf_begin-function-examples.html)[LogError (Go)](https://golang.hotexamples.com/examples/qiaoqiao.common/-/LogError/golang-logerror-function-examples.html)[LoggingHandler (Go)](https://golang.hotexamples.com/examples/util/-/LoggingHandler/golang-logginghandler-function-examples.html)[UnitPrinter (Java)](https://java.hotexamples.com/examples/soot.jimple/UnitPrinter/-/java-unitprinter-class-examples.html)[ReplyContext (Java)](https://java.hotexamples.com/examples/test.pi.testinterfacepackage/ReplyContext/-/java-replycontext-class-examples.html)[Cookie (Python)](https://python.hotexamples.com/examples/invenio.webinterface_handler_wsgi_utils/Cookie/-/python-cookie-class-examples.html)[cbcdecrypt (Python)](https://python.hotexamples.com/examples/c16/-/cbcdecrypt/python-cbcdecrypt-function-examples.html)Google BookmarkFacebookTwitterPrintEmailMoreEXAMPLE #11   Show fileFile: [class.fileaway\_cleanup.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNguyenkain%2Fstrida.vn%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Ffile-away%2Flib%2Fclass.fileaway_cleanup.php) Project: [Nguyenkain/strida.vn](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FNguyenkain%2Fstrida.vn)

```
 public function __construct()
 {
     if (!wp_next_scheduled('fileaway_scheduled_cleanup')) {
         wp_schedule_event(time(), 'hourly', 'fileaway_scheduled_cleanup');
     }
     add_action('fileaway_scheduled_cleanup', array($this, 'cleanup'));
 }
```

[![](https://go.ezodn.com/charity/https/charity-ads.s3.amazonaws.com/charity_ads/300x250.png)](https://www.cormghana.org/sponsor?utm_source=ezoic)EXAMPLE #21   Show fileFile: [class-itsec-logger.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fhelloworld-digital%2Finsightvision%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fithemes-security-pro%2Fclass-itsec-logger.php) Project: [helloworld-digital/insightvision](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fhelloworld-digital%2Finsightvision)

```
	function __construct() {

		global $itsec_globals;

		//make sure the log file info is there or generate it. This should only affect beta users.
		if ( ! isset( $itsec_globals['settings']['log_info'] ) ) {

			$itsec_globals['settings']['log_info'] = substr( sanitize_title( get_bloginfo( 'name' ) ), 0, 20 ) . '-' . ITSEC_Lib::get_random( mt_rand( 0, 10 ) );

			update_site_option( 'itsec_global', $itsec_globals['settings'] );

		}

		//Make sure the logs directory was created
		if ( ! is_dir( $itsec_globals['ithemes_log_dir'] ) ) {
			@mkdir( trailingslashit( $itsec_globals['ithemes_dir'] ) . 'logs' );
		}

		//don't create a log file if we don't need it.
		if ( isset( $itsec_globals['settings']['log_type'] ) && $itsec_globals['settings']['log_type'] !== 0 ) {

			$this->log_file = $itsec_globals['ithemes_log_dir'] . '/event-log-' . $itsec_globals['settings']['log_info'] . '.log';
			$this->start_log(); //create a log file if we don't have one

		}

		$this->logger_modules  = array(); //array to hold information on modules using this feature
		$this->logger_displays = array(); //array to hold metabox information
		$this->module_path     = ITSEC_Lib::get_module_path( __FILE__ );

		add_action( 'plugins_loaded', array( $this, 'register_modules' ) );

		add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) ); //enqueue scripts for admin page

		//Run database cleanup daily with cron
		if ( ! wp_next_scheduled( 'itsec_purge_logs' ) ) {
			wp_schedule_event( time(), 'daily', 'itsec_purge_logs' );
		}

		add_action( 'itsec_purge_logs', array( $this, 'purge_logs' ) );

		if ( is_admin() ) {

			require( trailingslashit( $itsec_globals['plugin_dir'] ) . 'core/lib/class-itsec-wp-list-table.php' ); //used for generating log tables

			add_action( 'itsec_add_admin_meta_boxes', array( $this, 'add_admin_meta_boxes' ) ); //add log meta boxes

		}

		if ( isset( $_POST['itsec_clear_logs'] ) && $_POST['itsec_clear_logs'] === 'clear_logs' ) {

			global $itsec_clear_all_logs;

			$itsec_clear_all_logs = true;

			add_action( 'plugins_loaded', array( $this, 'purge_logs' ) );

		}

	}
```

EXAMPLE #31   Show fileFile: [tracking.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fdreadfra%2Fsuperba%2Fblob%2Fmaster%2Fwp-content%2Fthemes%2Foneengine%2Fplugins%2Fadmin-core%2Ftracking.php) Project: [dreadfra/superba](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fdreadfra%2Fsuperba)

```
 public function load($parent)
 {
     $this->parent = $parent;
     //delete_option('redux-framework-tracking');
     $this->options = get_option('redux-framework-tracking');
     $this->options['dev_mode'] = $parent->args['dev_mode'];
     if (!isset($this->options['hash']) || !$this->options['hash'] || empty($this->options['hash'])) {
         $this->options['hash'] = md5(site_url() . '-' . $_SERVER['REMOTE_ADDR']);
         update_option('redux-framework-tracking', $this->options);
     }
     if (isset($_GET['redux_framework_disable_tracking']) && !empty($_GET['redux_framework_disable_tracking'])) {
         $this->options['allow_tracking'] = false;
         update_option('redux-framework-tracking', $this->options);
     }
     if (isset($_GET['redux_framework_enable_tracking']) && !empty($_GET['redux_framework_enable_tracking'])) {
         $this->options['allow_tracking'] = true;
         update_option('redux-framework-tracking', $this->options);
     }
     if (isset($_GET['page']) && $_GET['page'] == $this->parent->args['page_slug']) {
         if (!isset($this->options['allow_tracking'])) {
             add_action('admin_enqueue_scripts', array($this, '_enqueue_tracking'));
         } else {
             if (!isset($this->options['tour']) && ($this->parent->args['dev_mode'] == "true" || $this->parent->args['page_slug'] == "redux_demo")) {
                 add_action('admin_enqueue_scripts', array($this, '_enqueue_newsletter'));
             }
         }
     }
     if (isset($this->options['allow_tracking']) && $this->options['allow_tracking'] == true) {
         // The tracking checks daily, but only sends new data every 7 days.
         if (!wp_next_scheduled('redux_tracking')) {
             wp_schedule_event(time(), 'daily', 'redux_tracking');
         }
         add_action('redux_tracking', array($this, 'tracking'));
     }
 }
```

EXAMPLE #40   Show fileFile: [sandbox-functionality.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fdiddledan%2Fmeta-environment%2Fblob%2Fmaster%2Fwordcamp.dev%2Fsandbox-functionality.php) Project: [diddledan/meta-environment](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fdiddledan%2Fmeta-environment)

```
/**
 * Run cron jobs more frequently so don't have to wait to test results
 */
function wordcamp_dev_test_cron_jobs()
{
    /** @var $camptix CampTix_Plugin */
    /** @var $camptix_network_dashboard CampTix_Network_Dashboard */
    /** @var $WCOR_Mailer WCOR_Mailer */
    global $camptix, $camptix_network_dashboard, $WCOR_Mailer;
    // Schedule custom events
    if (!wp_next_scheduled('wordcamp_dev_10_seconds')) {
        wp_schedule_event(time(), '10-seconds', 'wordcamp_dev_10_seconds');
    }
    if (!wp_next_scheduled('wordcamp_dev_30_seconds')) {
        wp_schedule_event(time(), '30-seconds', 'wordcamp_dev_30_seconds');
    }
    if (!wp_next_scheduled('wordcamp_dev_45_seconds')) {
        wp_schedule_event(time(), '45-seconds', 'wordcamp_dev_45_seconds');
    }
    if (!wp_next_scheduled('wordcamp_dev_60_seconds')) {
        wp_schedule_event(time(), '60-seconds', 'wordcamp_dev_60_seconds');
    }
    // Fire cron jobs on fast hooks
    if (isset($camptix_network_dashboard)) {
        add_action('wordcamp_dev_10_seconds', array($camptix_network_dashboard, 'gather_events_data'));
        add_action('wordcamp_dev_60_seconds', array($camptix_network_dashboard, 'update_revenue_reports_data'));
    }
    if (isset($WCOR_Mailer)) {
        add_action('wordcamp_dev_10_seconds', array($WCOR_Mailer, 'send_timed_emails'));
    }
}
```

EXAMPLE #50   Show fileFile: [ClientTest.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2F10up%2Fwp-gears%2Fblob%2Fmaster%2Ftests%2FWpGears%2FClientTest.php) Project: [10up/wp-gears](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2F10up%2Fwp-gears)

```
 function test_it_creates_cron_event_on_add()
 {
     $actual = $this->client->add('cron_action_a');
     $this->assertTrue($actual);
     $next_event = wp_next_scheduled('cron_action_a', array());
     $this->assertEquals(time(), $next_event, '', 1000);
 }
```

EXAMPLE #60   Show fileFile: [class-itsec-file-change.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fjfbelisle%2Fmagexpress%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fbetter-wp-security%2Fcore%2Fmodules%2Fclass-itsec-file-change.php) Project: [jfbelisle/magexpress](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fjfbelisle%2Fmagexpress)

```
 /**
  * Setup the module's functionality
  *
  * Loads the file change detection module's unpriviledged functionality including
  * performing the scans themselves
  *
  * @since 4.0.0
  *
  * @return void
  */
 function run()
 {
     global $itsec_globals;
     $this->settings = get_site_option('itsec_file_change');
     $this->running = false;
     $this->excludes = array('file_change.lock', $itsec_globals['ithemes_backup_dir'], $itsec_globals['ithemes_log_dir'], '.lock');
     $interval = 86400;
     //Run daily
     // If we're splitting the file check run it every 6 hours.
     if (isset($this->settings['split']) && true === $this->settings['split']) {
         $interval = 12342;
     }
     add_filter('itsec_logger_modules', array($this, 'itsec_logger_modules'));
     add_filter('itsec_sync_modules', array($this, 'itsec_sync_modules'));
     //register sync modules
     add_action('itsec_execute_file_check_cron', array($this, 'execute_file_check'));
     //Action to execute during a cron run.
     if ((!defined('DOING_AJAX') || DOING_AJAX === false) && isset($this->settings['enabled']) && true === $this->settings['enabled'] && isset($this->settings['last_run']) && $itsec_globals['current_time'] - $interval > $this->settings['last_run'] && (!defined('ITSEC_FILE_CHECK_CRON') || false === ITSEC_FILE_CHECK_CRON)) {
         wp_clear_scheduled_hook('itsec_file_check');
         add_action('init', array($this, 'execute_file_check'));
     } elseif (defined('ITSEC_FILE_CHECK_CRON') && true === ITSEC_FILE_CHECK_CRON && !wp_next_scheduled('itsec_execute_file_check_cron')) {
         //Use cron if needed
         wp_schedule_event(time(), 'daily', 'itsec_execute_file_check_cron');
     }
 }
```

EXAMPLE #70   Show fileFile: [class-itsec-file-change.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FGarth619%2FFemi9%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fbetter-wp-security%2Fcore%2Fmodules%2Fclass-itsec-file-change.php) Project: [Garth619/Femi9](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FGarth619%2FFemi9)

```
 /**
  * Setup the module's functionality
  *
  * Loads the file change detection module's unpriviledged functionality including
  * performing the scans themselves
  *
  * @since 4.0.0
  *
  * @return void
  */
 function run()
 {
     global $itsec_globals;
     $settings = ITSEC_Modules::get_settings('file-change');
     $interval = 86400;
     //Run daily
     // If we're splitting the file check run it every 6 hours.
     if (isset($settings['split']) && true === $settings['split']) {
         $interval = 12342;
     }
     add_action('itsec_execute_file_check_cron', array($this, 'run_scan'));
     //Action to execute during a cron run.
     add_filter('itsec_logger_displays', array($this, 'itsec_logger_displays'));
     //adds logs metaboxes
     add_filter('itsec_logger_modules', array($this, 'itsec_logger_modules'));
     add_filter('itsec_sync_modules', array($this, 'itsec_sync_modules'));
     //register sync modules
     if ((!defined('DOING_AJAX') || DOING_AJAX === false) && isset($settings['last_run']) && $itsec_globals['current_time'] - $interval > $settings['last_run'] && (!defined('ITSEC_FILE_CHECK_CRON') || false === ITSEC_FILE_CHECK_CRON)) {
         wp_clear_scheduled_hook('itsec_file_check');
         add_action('init', array($this, 'run_scan'));
     } elseif (defined('ITSEC_FILE_CHECK_CRON') && true === ITSEC_FILE_CHECK_CRON && !wp_next_scheduled('itsec_execute_file_check_cron')) {
         //Use cron if needed
         wp_schedule_event(time(), 'daily', 'itsec_execute_file_check_cron');
     }
 }
```

EXAMPLE #80   Show fileFile: [wpmudev-dash-notification.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Folechka1505%2Fhungrylemur%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fwp-smushit%2Fextras%2Fwpmudev-dash-notification.php) Project: [olechka1505/hungrylemur](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Folechka1505%2Fhungrylemur)

```
 function init()
 {
     global $wpmudev_un;
     if (class_exists('WPMUDEV_Dashboard') || isset($wpmudev_un->version) && version_compare($wpmudev_un->version, '3.4', '<')) {
         return;
     }
     // Schedule update cron on main site only
     if (is_main_site()) {
         if (!wp_next_scheduled('wpmudev_scheduled_jobs')) {
             wp_schedule_event(time(), 'twicedaily', 'wpmudev_scheduled_jobs');
         }
         add_action('wpmudev_scheduled_jobs', array($this, 'updates_check'));
     }
     add_action('delete_site_transient_update_plugins', array(&$this, 'updates_check'));
     //refresh after upgrade/install
     add_action('delete_site_transient_update_themes', array(&$this, 'updates_check'));
     //refresh after upgrade/install
     if (is_admin() && current_user_can('install_plugins')) {
         add_action('site_transient_update_plugins', array(&$this, 'filter_plugin_count'));
         add_action('site_transient_update_themes', array(&$this, 'filter_theme_count'));
         add_filter('plugins_api', array(&$this, 'filter_plugin_info'), 101, 3);
         //run later to work with bad autoupdate plugins
         add_filter('themes_api', array(&$this, 'filter_plugin_info'), 101, 3);
         //run later to work with bad autoupdate plugins
         add_action('admin_init', array(&$this, 'filter_plugin_rows'), 15);
         //make sure it runs after WP's
         add_action('core_upgrade_preamble', array(&$this, 'disable_checkboxes'));
         add_action('activated_plugin', array(&$this, 'set_activate_flag'));
         //remove version 1.0
         remove_action('admin_notices', 'wdp_un_check', 5);
         remove_action('network_admin_notices', 'wdp_un_check', 5);
         //remove version 2.0, a bit nasty but only way
         remove_all_actions('all_admin_notices', 5);
         //if dashboard is installed but not activated
         if (file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php')) {
             if (!get_site_option('wdp_un_autoactivated')) {
                 //include plugin API if necessary
                 if (!function_exists('activate_plugin')) {
                     require_once ABSPATH . 'wp-admin/includes/plugin.php';
                 }
                 $result = activate_plugin('/wpmudev-updates/update-notifications.php', network_admin_url('admin.php?page=wpmudev'), is_multisite());
                 if (!is_wp_error($result)) {
                     //if autoactivate successful don't show notices
                     update_site_option('wdp_un_autoactivated', 1);
                     return;
                 }
             }
             add_action('admin_print_styles', array(&$this, 'notice_styles'));
             add_action('all_admin_notices', array(&$this, 'activate_notice'), 5);
         } else {
             //dashboard not installed at all
             if (get_site_option('wdp_un_autoactivated')) {
                 update_site_option('wdp_un_autoactivated', 0);
                 //reset flag when dashboard is deleted
             }
             add_action('admin_print_styles', array(&$this, 'notice_styles'));
             add_action('all_admin_notices', array(&$this, 'install_notice'), 5);
         }
     }
 }
```

EXAMPLE #90   Show fileFile: [functions-scrape.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FCityOfPrescott%2Ftabula-rasa_city-of-prescott%2Fblob%2Fmaster%2Ffunctions-scrape.php) Project: [CityOfPrescott/tabula-rasa\_city-of-prescott](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FCityOfPrescott%2Ftabula-rasa_city-of-prescott)

```
function cron_schedule()
{
    // Public Notices
    if (!wp_next_scheduled('cron_notices_hourly')) {
        wp_schedule_event(time(), 'hourly', 'cron_notices_hourly');
    }
    // News
    if (!wp_next_scheduled('cron_news_hourly')) {
        wp_schedule_event(time(), 'hourly', 'cron_news_hourly');
    }
    /*
    	// Events
    	if ( !wp_next_scheduled( 'cron_events_hourly' ) ) {
    wp_schedule_event(time(), 'hourly', 'cron_events_hourly');
    	}
    	
    
    
    	if ( !wp_next_scheduled( 'cron_notices_minute' ) ) {
    wp_schedule_event(time(), 'minute', 'cron_notices_minute');
    	}		
    	
    
    	
    	// News
    	if ( !wp_next_scheduled( 'cron_news_minute' ) ) {
    wp_schedule_event(time(), 'minute', 'cron_news_minute');
    	}		
    */
    // Test by the minute
    if (!wp_next_scheduled('cron_events_minute')) {
        wp_schedule_event(time(), 'minute', 'cron_events_minute');
    }
}
```

EXAMPLE #100   Show fileFile: [class-poller.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fibericode%2Fboxzilla-wp%2Fblob%2Fmaster%2Fsrc%2Fclass-poller.php) Project: [ibericode/boxzilla-wp](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fibericode%2Fboxzilla-wp)

```
 /**
  * Add hooks.
  */
 public function hook()
 {
     if (!wp_next_scheduled('boxzilla_check_license_status')) {
         wp_schedule_event(time(), 'daily', 'boxzilla_check_license_status');
     }
     add_action('boxzilla_check_license_status', array($this, 'run'));
 }
```

EXAMPLE #110   Show fileFile: [WsdScheduler.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fyarwalker%2Fecobyt%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fwp-security-scan%2Fres%2FWsdScheduler.php) Project: [yarwalker/ecobyt](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fyarwalker%2Fecobyt)

```
 /**
  * Register a cron task
  * @param string $cronActionName The name of the action that will be registered with wp-cron
  * @param string $callback The function to register with wp-cron
  * @param string $interval can only be one of the following: hourly, daily and twicedaily if no other custom intervals are registered. Defaults to daily
  * @return void
  */
 public static function registerCronTask($cronActionName, $callback, $interval = 'daily')
 {
     if (!is_callable($callback)) {
         return;
     }
     // if cron disabled -> run callback
     if (!self::canRegisterCronTask()) {
         self::registerTask($callback);
         return;
     }
     $interval = strtolower($interval);
     if (empty($interval)) {
         $interval = 'daily';
     } else {
         // check to see if the time interval is valid
         $timeIntervals = wp_get_schedules();
         if (!array_key_exists($interval, $timeIntervals)) {
             $interval = 'daily';
         }
     }
     // avoid duplicate crons
     add_action($cronActionName, $callback);
     if (!wp_next_scheduled($cronActionName)) {
         wp_schedule_event(time(), $interval, $cronActionName);
         array_push(self::$_cronTasks, $cronActionName);
     }
 }
```

EXAMPLE #120   Show fileFile: [cbrobot.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpratikparmar111%2Fcblogger-robot%2Fblob%2Fmaster%2Fcbrobot.php) Project: [pratikparmar111/cblogger-robot](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpratikparmar111%2Fcblogger-robot)

```
function cbrobot_create_cronjob()
{
    $options = unserialize(get_option("cbrobot_options"));
    if (!wp_next_scheduled('cbrobot_job_event')) {
        wp_schedule_event(time(), $options['cbrobot_time'], 'cbrobot_job_event');
    }
}
```

EXAMPLE #130   Show fileFile: [fp\_rac\_cron.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbear12345678%2Fkeylessoption%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Frac%2Ffp_rac_cron.php) Project: [bear12345678/keylessoption](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbear12345678%2Fkeylessoption)

```
 public static function fp_rac_cron_job_setting_savings()
 {
     wp_clear_scheduled_hook('rac_cron_job');
     if (wp_next_scheduled('rac_cron_job') == false) {
         wp_schedule_event(time(), 'xhourly', 'rac_cron_job');
     }
 }
```

EXAMPLE #140   Show fileFile: [class\_eab\_scheduler.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fnayabbukhari%2Fcirculocristiano%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fevents-and-bookings%2Fclass_eab_scheduler.php) Project: [nayabbukhari/circulocristiano](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fnayabbukhari%2Fcirculocristiano)

```
 private function _add_hooks()
 {
     add_action('eab_scheduled_jobs', array($this, 'archive_old_events'));
     if (!wp_next_scheduled('eab_scheduled_jobs')) {
         wp_schedule_event(eab_current_time(), 'hourly', 'eab_scheduled_jobs');
     }
 }
```

EXAMPLE #150   Show fileFile: [custom-fonts.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Frenatodex%2Fsubmundo-blogstore%2Fblob%2Fmaster%2Fwp-content%2Fthemes%2Fmrtailor%2Fcustom-fonts.php) Project: [renatodex/submundo-blogstore](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Frenatodex%2Fsubmundo-blogstore)

```
 function cliv_create_recurring_schedule()
 {
     if (!wp_next_scheduled('cliv_recurring_cron_job')) {
         //shedule event to run after every hour
         wp_schedule_event(time(), 'daily', 'cliv_recurring_cron_job');
     }
 }
```

EXAMPLE #160   Show fileFile: [wordpress-slack.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbarzik%2FSlack-Notifications%2Fblob%2Fmaster%2Fwordpress-slack.php) Project: [barzik/Slack-Notifications](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbarzik%2FSlack-Notifications)

```
 /**
  * Perform one-time operations on plugin deactivation.
  *
  * @since   1.0.0
  */
 public function plugin_deactivate()
 {
     // Remove version check.
     wp_unschedule_event(wp_next_scheduled('slack_notif_check_versions'), 'slack_notif_check_versions');
     // Remove settings from database.
     delete_option('slack_webhook_endpoint');
     delete_option('slack_channel_name');
     delete_option('slack_bot_username');
     delete_option('slack_bot_image');
     delete_option('slack_notif_core_update');
     delete_option('slack_notif_theme_update');
     delete_option('slack_notif_plugin_update');
     delete_option('slack_notif_new_post');
     delete_option('slack_notif_new_page');
     delete_option('slack_notif_new_comment');
     delete_option('slack_notif_new_user');
     delete_option('slack_notif_admin_logged');
     delete_option('slack_notif_core_version');
     delete_option('slack_notif_theme_version');
     delete_option('slack_notif_plugins_version');
     // Delte custom post types settings.
     foreach ($this->postTypes as $postType) {
         delete_option('slack_notif_new_' . $postType->name);
     }
 }
```

EXAMPLE #170   Show fileFile: [gateway.paypal-chained-payments.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fnikwin333%2Fpcu_project%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fevents-manager-pro-paypal-chained-payments-master%2Fadd-ons%2Fgateway.paypal-chained-payments.php) Project: [nikwin333/pcu\_project](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fnikwin333%2Fpcu_project)

```
 /**
  * Sets up gateaway and adds relevant actions/filters
  */
 function __construct()
 {
     //Booking Interception
     if ($this->is_active() && absint(get_option('em_' . $this->gateway . '_booking_timeout')) > 0) {
         $this->count_pending_spaces = true;
     }
     parent::__construct();
     $this->status_txt = __('Awaiting PayPal Payment', 'em-pro');
     add_action('admin_enqueue_scripts', array(&$this, 'gateway_admin_js'));
     if ($this->is_active()) {
         add_action('em_gateway_js', array(&$this, 'em_gateway_js'));
         //Gateway-Specific
         add_action('em_template_my_bookings_header', array(&$this, 'say_thanks'));
         //say thanks on my_bookings page
         add_filter('em_bookings_table_booking_actions_4', array(&$this, 'bookings_table_actions'), 1, 2);
         //add_filter('em_my_bookings_booking_actions', array(&$this,'em_my_bookings_booking_actions'),1,2);
         //set up cron
         $timestamp = wp_next_scheduled('emp_paypal_cron');
         if (absint(get_option('em_paypal_booking_timeout')) > 0 && !$timestamp) {
             $result = wp_schedule_event(time(), 'em_minute', 'emp_paypal_cron');
         } elseif (!$timestamp) {
             wp_unschedule_event($timestamp, 'emp_paypal_cron');
         }
     } else {
         //unschedule the cron
         wp_clear_scheduled_hook('emp_paypal_cron');
     }
 }
```

EXAMPLE #180   Show fileFile: [remove-duplicate-posts.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Frrasco09%2Fremove-duplicate-posts%2Fblob%2Fmaster%2Fremove-duplicate-posts.php) Project: [rrasco09/remove-duplicate-posts](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Frrasco09%2Fremove-duplicate-posts)

```
function run_on_activate()
{
    // schedule the cron job to remove duplicate posts
    if (!wp_next_scheduled('remove_duplicate_posts')) {
        wp_schedule_event(time(), 'hourly', 'remove_duplicate_posts');
    }
}
```

EXAMPLE #190   Show fileFile: [class-wpmudev-dashboard-api.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FdevelopmentDM2%2FWhohaha%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fwpmudev-updates%2Fclass-wpmudev-dashboard-api.php) Project: [developmentDM2/Whohaha](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FdevelopmentDM2%2FWhohaha)

```
 /**
  * Set up the API module.
  *
  * @since 4.0.0
  * @internal
  */
 public function __construct()
 {
     if (WPMUDEV_CUSTOM_API_SERVER) {
         $this->server_root = trailingslashit(WPMUDEV_CUSTOM_API_SERVER);
     }
     $this->server_url = $this->server_root . $this->rest_api;
     if (defined('WPMUDEV_APIKEY') && WPMUDEV_APIKEY) {
         $this->api_key = WPMUDEV_APIKEY;
     } else {
         // If 'clear_key' is present in URL then do not load the key from DB.
         $this->api_key = get_site_option('wpmudev_apikey');
     }
     // Schedule automatic data update on the main site of the network.
     if (is_main_site()) {
         if (!wp_next_scheduled('wpmudev_scheduled_jobs')) {
             wp_schedule_event(time(), 'twicedaily', 'wpmudev_scheduled_jobs');
         }
         add_action('wpmudev_scheduled_jobs', array($this, 'refresh_membership_data'));
     } elseif (wp_next_scheduled('wpmudev_scheduled_jobs')) {
         // In case the cron job was already installed in a sub-site...
         wp_clear_scheduled_hook('wpmudev_scheduled_jobs');
     }
     /**
      * Run custom initialization code for the API module.
      *
      * @since  4.0.0
      * @var  WPMUDEV_Dashboard_Api The dashboards API module.
      */
     do_action('wpmudev_dashboard_api_init', $this);
 }
```

EXAMPLE #200   Show fileFile: [cachehelper.class.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fgeminorum%2Fgmember%2Fblob%2Fmaster%2Fcachehelper.class.php) Project: [geminorum/gmember](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fgeminorum%2Fgmember)

```
 function zt_schedule_ga_refresh()
 {
     if (!wp_next_scheduled('zt-refresh-top-posts')) {
         wp_schedule_event(time(), 'zt-refresh-top-posts');
     }
     add_action('zt-refresh-top-posts', 'zt_refresh_top_posts');
 }
```

EXAMPLE #210   Show fileFile: [plugin-update-checker.class.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FAndysean%2Fagilephilippines.org%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Ffeed-them-premium%2Fplugin-update-checker.class.php) Project: [Andysean/agilephilippines.org](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FAndysean%2Fagilephilippines.org)

```
 /**
  * Install the hooks required to run periodic update checks and inject update info 
  * into WP data structures. 
  * 
  * @return void
  */
 function installHooks()
 {
     //Override requests for plugin information
     add_filter('plugins_api', array(&$this, 'injectInfo'), 10, 3);
     //Insert our update info into the update array maintained by WP
     add_filter('site_transient_update_plugins', array(&$this, 'injectUpdate'));
     //WP 3.0+
     add_filter('transient_update_plugins', array(&$this, 'injectUpdate'));
     //WP 2.8+
     //Set up the periodic update checks
     $cronHook = 'check_plugin_updates-' . $this->slug;
     if ($this->checkPeriod > 0) {
         //Trigger the check via Cron
         add_filter('cron_schedules', array(&$this, '_addCustomSchedule'));
         if (!wp_next_scheduled($cronHook) && !defined('WP_INSTALLING')) {
             $scheduleName = 'every' . $this->checkPeriod . 'hours';
             wp_schedule_event(time(), $scheduleName, $cronHook);
         }
         add_action($cronHook, array(&$this, 'checkForUpdates'));
         //In case Cron is disabled or unreliable, we also manually trigger
         //the periodic checks while the user is browsing the Dashboard.
         add_action('admin_init', array(&$this, 'maybeCheckForUpdates'));
     } else {
         //Periodic checks are disabled.
         wp_clear_scheduled_hook($cronHook);
     }
     //Add action for extra notifications
     add_action('in_plugin_update_message-' . $this->pluginFile, array(&$this, 'maybeInjectUpgradeNotice'), 10, 2);
 }
```

EXAMPLE #220   Show fileFile: [import-stream.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fantoniorequenalorente%2FFanpage-import%2Fblob%2Fmaster%2Fcomponents%2Fimport-stream.php) Project: [antoniorequenalorente/Fanpage-import](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fantoniorequenalorente%2FFanpage-import)

```
 /**
  * Initializes the Component.
  * @since 1.0.0
  */
 function __construct()
 {
     $this->name = get_class($this);
     $this->page_id = skip\value('fbfpi_settings', 'page_id');
     $this->stream_language = skip\value('fbfpi_settings', 'stream_language');
     $this->update_interval = skip\value('fbfpi_settings', 'update_interval');
     $this->update_num = skip\value('fbfpi_settings', 'update_num');
     $this->link_target = skip\value('fbfpi_settings', 'link_target');
     if ('' == $this->page_id) {
         $this->errors[] = sprintf(__('<a href="%s">Fanpage ID have to be provided.</a>', 'fbfpi'), get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=ComponentFacebookFanpageImportAdminSettings');
     }
     if ('' == $this->stream_language) {
         $this->stream_language = 'en_US';
     }
     if ('' == $this->update_interval) {
         $this->update_interval = 'hourly';
     }
     if ('' == $this->update_num) {
         $this->update_num = 10;
     }
     // Scheduling import
     if (!wp_next_scheduled('fanpage_import')) {
         wp_schedule_event(time(), $this->update_interval, 'fanpage_import');
     }
     add_action('fanpage_import', array($this, 'import'));
     // Importing now!
     if (array_key_exists('bfpi-now', $_POST) && '' != $_POST['bfpi-now']) {
         add_action('init', array($this, 'import'), 12);
     }
     // For testing of import
     // Adding notices
     add_action('admin_notices', array($this, 'admin_notices'));
 }
```

EXAMPLE #230   Show fileFile: [cron.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FBorn1988%2FWordPress%2Fblob%2Fmaster%2Fcron.php) Project: [Born1988/WordPress](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FBorn1988%2FWordPress)

```
/**
 * Schedules a hook to run only once.
 *
 * Schedules a hook which will be executed once by the WordPress actions core at
 * a time which you specify. The action will fire off when someone visits your
 * WordPress site, if the schedule time has passed.
 *
 * @since 2.1.0
 * @link https://codex.wordpress.org/Function_Reference/wp_schedule_single_event
 *
 * @param int $timestamp Timestamp for when to run the event.
 * @param string $hook Action hook to execute when cron is run.
 * @param array $args Optional. Arguments to pass to the hook's callback function.
 * @return false|void False when an event is not scheduled.
 */
function wp_schedule_single_event($timestamp, $hook, $args = array())
{
    // Make sure timestamp is a positive integer
    if (!is_numeric($timestamp) || $timestamp <= 0) {
        return false;
    }
    // Don't schedule a duplicate if there's already an identical event due within 10 minutes of it
    $next = wp_next_scheduled($hook, $args);
    if ($next && abs($next - $timestamp) <= 10 * MINUTE_IN_SECONDS) {
        return false;
    }
    $crons = _get_cron_array();
    $event = (object) array('hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args);
    /**
     * Filter a single event before it is scheduled.
     *
     * @since 3.1.0
     *
     * @param object $event An object containing an event's data.
     */
    $event = apply_filters('schedule_event', $event);
    // A plugin disallowed this event
    if (!$event) {
        return false;
    }
    $key = md5(serialize($event->args));
    $crons[$event->timestamp][$event->hook][$key] = array('schedule' => $event->schedule, 'args' => $event->args);
    uksort($crons, "strnatcasecmp");
    _set_cron_array($crons);
}
```

EXAMPLE #240   Show fileFile: [class-itsec-lockout.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FHaydt45%2Fjustinhaydt.com%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fbetter-wp-security%2Fclass-itsec-lockout.php) Project: [Haydt45/justinhaydt.com](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2FHaydt45%2Fjustinhaydt.com)

```
 function __construct($core)
 {
     $this->core = $core;
     $this->lockout_modules = array();
     //array to hold information on modules using this feature
     //Run database cleanup daily with cron
     if (!wp_next_scheduled('itsec_purge_lockouts')) {
         wp_schedule_event(time(), 'daily', 'itsec_purge_lockouts');
     }
     add_action('itsec_purge_lockouts', array($this, 'purge_lockouts'));
     //Check for host lockouts
     add_action('init', array($this, 'check_lockout'));
     // Ensure that locked out users are prevented from checking logins.
     add_filter('authenticate', array($this, 'check_authenticate_lockout'), 30);
     // Updated temp whitelist to ensure that admin users are automatically added.
     add_action('init', array($this, 'update_temp_whitelist'), 0);
     //Register all plugin modules
     add_action('plugins_loaded', array($this, 'register_modules'));
     //Set an error message on improper logout
     add_action('login_head', array($this, 'set_lockout_error'));
     //Process clear lockout form
     add_action('itsec_admin_init', array($this, 'release_lockout'));
     //Register Logger
     add_filter('itsec_logger_modules', array($this, 'register_logger'));
     //Register Sync
     add_filter('itsec_sync_modules', array($this, 'register_sync'));
     add_action('itsec-settings-page-init', array($this, 'init_settings_page'));
     add_action('itsec-logs-page-init', array($this, 'init_settings_page'));
 }
```

EXAMPLE #250   Show fileFile: [class-wc-square-inventory-poll.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Flilweirdward%2Fblofishwordpress%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fwoocommerce-square%2Fclass-wc-square-inventory-poll.php) Project: [lilweirdward/blofishwordpress](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Flilweirdward%2Fblofishwordpress)

```
 public function run_schedule()
 {
     $frequency = apply_filters('woocommerce_square_inventory_poll_frequency', 'hourly');
     if (!wp_next_scheduled('woocommerce_square_inventory_poll')) {
         wp_schedule_event(current_time('timestamp'), $frequency, 'woocommerce_square_inventory_poll');
     }
 }
```

EXAMPLE #260   Show fileFile: [cron.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Falons182%2F4energy%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fpost-views-counter%2Fcron.php) Project: [alons182/4energy](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Falons182%2F4energy)

```
 /**
  * Check whether WP Cron needs to add new task.
  */
 public function check_cron()
 {
     if (!is_admin()) {
         return;
     }
     // set wp cron task
     if (Post_Views_Counter()->get_attribute('options', 'general', 'cron_run')) {
         // not set or need to be updated?
         if (!wp_next_scheduled('pvc_reset_counts') || Post_Views_Counter()->get_attribute('options', 'general', 'cron_update')) {
             // task is added but need to be updated
             if (Post_Views_Counter()->get_attribute('options', 'general', 'cron_update')) {
                 // remove old schedule
                 wp_clear_scheduled_hook('pvc_reset_counts');
                 // set update to false
                 $general = Post_Views_Counter()->get_attribute('options', 'general');
                 $general['cron_update'] = false;
                 // update settings
                 update_option('post_views_counter_settings_general', $general);
             }
             // set schedule
             wp_schedule_event(Post_Views_Counter()->get_instance('counter')->get_timestamp(Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'type'), Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'number')), 'post_views_counter_interval', 'pvc_reset_counts');
         }
     } else {
         // remove schedule
         wp_clear_scheduled_hook('pvc_reset_counts');
         remove_action('pvc_reset_counts', array(&$this, 'reset_counts'));
     }
 }
```

EXAMPLE #270   Show fileFile: [wp-google-authenticator.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fdishuostec%2FWP-Google-Authenticator%2Fblob%2Fmaster%2Fwp-google-authenticator.php) Project: [dishuostec/WP-Google-Authenticator](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fdishuostec%2FWP-Google-Authenticator)

```
/**
 * Remove plugin data from database
 */
function wpga_uninstallPlugin()
{
    /* Plugin main options */
    delete_option(WPGA_PREFIX . '_options');
    delete_option(WPGA_PREFIX . '_used_totp');
    $args = array('meta_query' => array('relation' => 'OR', array('key' => 'wpga_attempts', 'value' => '', 'compare' => '!='), array('key' => 'wpga_secret', 'value' => '', 'compare' => '!=')));
    $users = new WP_User_Query($args);
    /* Delete all user metas */
    if (!empty($users->results)) {
        foreach ($users->results as $key => $user) {
            delete_user_meta($user->ID, 'wpga_active');
            delete_user_meta($user->ID, 'wpga_attempts');
            delete_user_meta($user->ID, 'wpga_secret');
            delete_user_meta($user->ID, 'wpga_backup_key');
            delete_user_meta($user->ID, 'wpga_backup_key_time');
            delete_user_meta($user->ID, 'wpga_apps_passwords');
            delete_user_meta($user->ID, 'wpga_apps_passwords_log');
        }
    }
    /**
     * Remove cron task
     */
    $timestamp = wp_next_scheduled('wpas_clean_totps');
    wp_unschedule_event($timestamp, 'wpas_clean_totps');
}
```

EXAMPLE #280   Show fileFile: [class-itsec-lockout.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fjacko5%2Fbjj%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fbetter-wp-security%2Fclass-itsec-lockout.php) Project: [jacko5/bjj](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fjacko5%2Fbjj)

```
 function __construct()
 {
     $this->lockout_modules = array();
     //array to hold information on modules using this feature
     //Run database cleanup daily with cron
     if (!wp_next_scheduled('itsec_purge_lockouts')) {
         wp_schedule_event(time(), 'daily', 'itsec_purge_lockouts');
     }
     add_action('itsec_purge_lockouts', array($this, 'purge_lockouts'));
     //Check for host lockouts
     add_action('init', array($this, 'check_lockout'));
     //Register all plugin modules
     add_action('plugins_loaded', array($this, 'register_modules'));
     //Set an error message on improper logout
     add_action('login_head', array($this, 'set_lockout_error'));
     //Add the metabox
     add_action('itsec_add_admin_meta_boxes', array($this, 'add_admin_meta_boxes'));
     //Process clear lockout form
     add_action('itsec_admin_init', array($this, 'release_lockout'));
     //Register Logger
     add_filter('itsec_logger_modules', array($this, 'register_logger'));
     //Register Sync
     add_filter('itsec_sync_modules', array($this, 'register_sync'));
     //Add Javascripts script
     add_action('admin_enqueue_scripts', array($this, 'admin_script'));
     //enqueue scripts for admin page
     //Run ajax for temp whitelist
     add_action('wp_ajax_itsec_temp_whitelist_ajax', array($this, 'itsec_temp_whitelist_ajax'));
 }
```

EXAMPLE #290   Show fileFile: [class-wp-user-avatar-admin.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Ftuanlibra%2Fthptxuanang%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Fwp-user-avatar%2Fclass-wp-user-avatar-admin.php) Project: [tuanlibra/thptxuanang](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Ftuanlibra%2Fthptxuanang)

```
 /**
  * Settings saved to wp_options
  * @since 1.4
  * @uses add_option()
  */
 public function wpua_options()
 {
     add_option('avatar_default_wp_user_avatar', "");
     add_option('wp_user_avatar_allow_upload', '0');
     add_option('wp_user_avatar_disable_gravatar', '0');
     add_option('wp_user_avatar_edit_avatar', '1');
     add_option('wp_user_avatar_resize_crop', '0');
     add_option('wp_user_avatar_resize_h', '96');
     add_option('wp_user_avatar_resize_upload', '0');
     add_option('wp_user_avatar_resize_w', '96');
     add_option('wp_user_avatar_tinymce', '1');
     add_option('wp_user_avatar_upload_size_limit', '0');
     if (wp_next_scheduled('wpua_has_gravatar_cron_hook')) {
         $cron = get_option('cron');
         $new_cron = '';
         foreach ($cron as $key => $value) {
             if (is_array($value)) {
                 if (array_key_exists('wpua_has_gravatar_cron_hook', $value)) {
                     unset($cron[$key]);
                 }
             }
         }
         update_option('cron', $cron);
     }
 }
```

EXAMPLE #300   Show fileFile: [github-embed.php](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpattyland%2Fwp-github-oembed%2Fblob%2Fmaster%2Fgithub-embed.php) Project: [pattyland/wp-github-oembed](https://hotexamples.com/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpattyland%2Fwp-github-oembed)

```
 /**
  * Make sure we have a scheduled event set to clear down the oEmbed cache until
  * WordPress supports cache_age in oEmbed responses.
  */
 function schedule_expiry()
 {
     if (!wp_next_scheduled('github_embed_cron')) {
         $frequency = apply_filters('github_embed_cache_frequency', 'daily');
         wp_schedule_event(time(), $frequency, 'github_embed_cron');
     }
 }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnphp.gitbook.io/learnphp/wordpress-advand/thoi-gian-tiep-theo-cho-mot-su-kien.-retrieve-the-next-timestamp-for-an-event.-wp_next_scheduled-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
