Create a gist now

Instantly share code, notes, and snippets.

Cron_Pixie::__construct
<?php
/**
* Cron_Pixie constructor.
*
* Registers all action and filter hooks if user can use widget.
*
* @param array $plugin_meta
*/
public function __construct( $plugin_meta = array() ) {
if ( empty( $plugin_meta ) ) {
return;
}
$this->plugin_meta = $plugin_meta;
// Usage of the plugin is restricted to Administrators.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Add the widget during dashboard set up.
add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widget' ) );
// Enqueue the CSS & JS scripts.
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
// AJAX handlers.
add_action( 'wp_ajax_cron_pixie_schedules', array( $this, 'ajax_schedules' ) );
add_action( 'wp_ajax_cron_pixie_events', array( $this, 'ajax_events' ) );
// Add a schedule of our own for testing.
add_filter( 'cron_schedules', array( $this, 'filter_cron_schedules' ) );
// Add an event to our test schedule.
$this->_create_test_event();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment