Skip to content

Instantly share code, notes, and snippets.

@ianmjones
Last active April 11, 2016 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianmjones/e3128d04ce517ab0e4cfe2bd10ce347e to your computer and use it in GitHub Desktop.
Save ianmjones/e3128d04ce517ab0e4cfe2bd10ce347e to your computer and use it in GitHub Desktop.
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