Task Scheduler

Task Scheduler

Wordpress plugin

Install on Wordpress

App Details

Handle Massive Number of Actions

Do you have specific tasks which need to run at your desired time? Do you use WordPress as a proxy to generate data from external sources? As WordPress has evolved into a phase of application platforms, a more enhanced task management system needed to emerge.

Currently, with WP Cron, if you register a large number of actions, for example, 1000 tasks to run immediately and one of them stalls, it affects all the other actions preventing them from being loaded at the scheduled time. Also, the scheduled tasks won’t be triggered if there is no visitor on the site. The goal of this plugin is to resolve such issues and become the perfect solution for WordPress powered back-end application servers to provide full-brown API functionalities.

What it does

  • (optional) creates periodic background access to the site.
  • triggers tasks registered by the site owner at desired time or interval.

Built-in Actions

  • Delete Posts – performs bulk deletion of posts based on the post type, post statuses, taxonomy, and taxonomy terms.
  • Send Email – sends email to specified email addresses.
  • Clean Transients – deletes expired transients (caches).
  • Check Web Sites – accesses specified web pages and checks certain keywords.
  • Run PHP Scripts – runs PHP scripts of your choosing.

Custom Action Modules

Extensible

This is designed to be fully extensible and developers can add custom modules including actions and occurrence types.

Create a Custom Action

You can run your custom action with Task Scheduler and run it at scheduled times, once a day, with a fixed interval, or whatever you set with the plugin.

Place the code that includes the module in your plugin or functions.php of the activated theme.

1. Decide your action slug which also serves as a WordPress filter hook.

Say, you pick my_custom_action as an action name.

2. Use the add_filter() WordPress core function to hook into the action.

/** * Called when the Task Scheduler plugin gets loaded. */ function doMyCustomAction( $isExitCode, $oRoutine ) { /** * Do you stuff here. */ TaskScheduler_Debug::log( $oRoutine->getMeta() ); return 1; } /** * Set the 'my_custom_action' custom action slug in the Select Action screen * via Dashboard -> Task Scheduler -> Add New Task. */ add_filter( 'my_custom_action', 'doMyCustomAction', 10, 2 ); 

Please note that we use add_filter() not add_action() in order to return an exit code.

Return 1 if the task completes and 0 when there is a problem. You can pass any value except null.

3. Go to Dashboard -> Task Scheduler -> Add New Task. Proceed with the wizard and when you get the Select Action screen after setting up the occurrence, type my_custom_action, the one you defined in the above step.

The action slug set in the field will be triggered at the scheduled time.

It will be easier for you to modify an existent code. You can download the zip file and install it on your site.

Create a Custom Action Module

If you want your action to be listed in the Select Action screen, you need to create an action module.

To create an action module, you need to define a class by extending a base class that Task Scheduler prepares for you.

1. Define your custom action module class by extending the TaskScheduler_Action_Base class.

class TaskScheduler_SampleActionModule extends TaskScheduler_Action_Base { /** * The user constructor. * * This method is automatically called at the end of the class constructor. */ public function construct() {} /** * Returns the readable label of this action. * * This will be called when displaying the action in an pull-down select option, task listing table, or notification email message. */ public function getLabel( $sLabel ) { return __( 'Sample Action Module', 'task-scheduler-sample-action-module' ); } /** * Returns the description of the module. */ public function getDescription( $sDescription ) { return __( 'This is a sample action module.', 'task-scheduler-sample-action-module' ); } /** * Defines the behaviour of the task action. * */ public function doAction( $isExitCode, $oRoutine ) { /** * Write your own code here! Delete the below log method. * * Good luck! */ TaskScheduler_Debug::log( $oRoutine->getMeta() ); // Exit code. return 1; } } 

In the doAction() method of the above class, define the behaviour of your action what it does. The second parameter receives a routine object. The object has a public method named getMeta() which returns the associated arguments.

2. Use the task_scheduler_action_after_loading_plugin action hook to register your action module.

To register your action module, just instantiate the class you defined.

function loadTaskSchedulerSampleActionModule() { // Register a custom action module. include( dirname( __FILE__ ) . '/module/TaskScheduler_SampleActionModule.php' ); new TaskScheduler_SampleActionModule; } add_action( 'task_scheduler_action_after_loading_plugin', 'loadTaskSchedulerSampleActionModule' ); 

3. Go to Dashboard -> Task Scheduler -> Add New Task. Proceed the wizard and when you get the Select Action screen, choose your action.

You can set your custom arguments in the Argument (optional) field if necessary.

The set values will be stored in the argument element of the array returned by the getMeta() public method of the routine object.

It will be easier for you to modify an existent module. Get an example action module which comes as a plugin from this page. Download and activate it on your test site. Then modify the code, especially the doAction() method which defines the behavior of the action.

Create Threads

When your routine is too heavy and gets hung often, you can create threads that performs sub-routines of the main routine.

1. Define your thread class the TaskScheduler_Action_Base class.

class TaskScheduler_SampleActionModule_Thread extends TaskScheduler_Action_Base { /** * Returns the readable label of this action. * * This will be called when displaying the action in an pull-down select option, task listing table, or notification email message. */ public function getLabel( $sLabel ) { return __( 'Run a PHP Script', 'task-scheduler' ); } /** * Defines the behavior of the task action. */ public function doAction( $isExitCode, $oThread ) { // Do your stuff $_aThreadArguments = $oThread->getMeta(); TaskScheduler_Debug::log( $_aThreadArguments ); return 1; } } 

2. Instantiate the thread class.

In the construct() method of your action module class introduced above that calls threads, instantiate the thread class by passing a custom action name. Here we pass task_scheduler_my_thread as an example.

class TaskScheduler_SampleActionModule extends TaskScheduler_Action_Base { public function construct() { new TaskScheduler_SampleActionModule_Thread( 'task_scheduler_my_thread' ); } ... } 

3. Create a thread.

In the doAction() method of your action module class, create a thread with the createThread() method. The parameters are:

createThread( $sThreadActionHookName, $oRoutine, array $aThreadOptions, array $aSystemTaxonomyTerms=array(), $bAllowDuplicate ) 1. `$sThreadActionHookName` - (string, required) the slug that serves as an action hook name 2. `$oRoutine` - (object, required) the routine object that is passed to the second parameter of `doAction()`` method. 3. `$aThreadOptions` - (array, required) an associative array holding arguments to pass to the thread. 4. `$aSystemTaxonomyTerms` - (array, optional) an array holding taxonomy terms for the system the plugin provides. Default: `array()``. 5. `$bAllowDuplicate` - (boolean, optional) whether to allow threads to be created with same arguments. Default: `false`. 

Make sure the return value is null so that the routine will not close. Here we assume the $_aData variable holds lots of items so it must be processed separately by threads.

class TaskScheduler_SampleActionModule extends TaskScheduler_Action_Base { ... public function doAction( $isExitCode, $oRoutine ) { // Assuming this is big. $_aData = array( array( 'a', 'b', 'c' ), array( 'd', 'e', 'f', 'g' ), array( 'h', 'i' ), ); foreach( $_aData as $_aDatum ) { $_aArguments = array( 'datum' => $_aDatum, 'foo' => 'bar', ); $this->createThread( 'task_scheduler_my_thread', $oRoutine, $_aArguments ); } // Do not close this routine by returning 'null'. When all the threads are done, this routine will be automatically closed. return null; } ... } 

4. Process Passed Data from a Routine to a Thread.
In the thread class, retrieve the passed data.

class TaskScheduler_SampleActionModule_Thread extends TaskScheduler_Action_Base { ... /** * Defines the behavior of the task action. */ public function doAction( $isExitCode, $oThread ) { // Do your stuff $_aArguments = $oThread->getMeta(); $_sFoo = $_aArguments[ 'foo' ]; // is 'bar' $_aDatum = $_aArguments[ 'datum' ]; // is either array( 'a', 'b', 'c' ), array( 'd', 'e', 'f', 'g' ), or array( 'h', 'i' ) TaskScheduler_Debug::log( $_aArguments ); return 1; } } 

The entire code will look like this.

Action Module Class:

class TaskScheduler_SampleActionModule extends TaskScheduler_Action_Base { /** * The user constructor. * * This method is automatically called at the end of the class constructor. */ public function construct() { new TaskScheduler_SampleActionModule_Thread( 'task_scheduler_my_thread' ); } /** * Returns the readable label of this action. * * This will be called when displaying the action in an pull-down select option, task listing table, or notification email message. */ public function getLabel( $sLabel ) { return __( 'Sample Action Module', 'task-scheduler-sample-action-module' ); } /** * Returns the description of the module. */ public function getDescription( $sDescription ) { return __( 'This is a sample action module.', 'task-scheduler-sample-action-module' ); } public function doAction( $isExitCode, $oRoutine ) { // Assuming this is big. $_aData = array( array( 'a', 'b', 'c' ), array( 'd', 'e', 'f', 'g' ), array( 'h', 'i' ), ); foreach( $_aData as $_aDatum ) { $_aArguments = array( 'datum' => $_aDatum, 'foo' => 'bar', ); $this->createThread( 'task_scheduler_my_thread', $oRoutine, $_aArguments ); } // Do not close this routine by returning 'null'. When all the threads are done, this routine will be automatically closed. return null; } } 

Thread Class:

class TaskScheduler_SampleActionModule_Thread extends TaskScheduler_Action_Base { /** * Returns the readable label of this action. * * This will be called when displaying the action in an pull-down select option, task listing table, or notification email message. */ public function getLabel( $sLabel ) { return __( 'Run a PHP Script', 'task-scheduler' ); } /** * Defines the behavior of the task action. */ public function doAction( $isExitCode, $oThread ) { // Do your stuff $_aArguments = $oThread->getMeta(); $_sFoo = $_aArguments[ 'foo' ]; // is 'bar' $_aDatum = $_aArguments[ 'datum' ]; // is either array( 'a', 'b', 'c' ), array( 'd', 'e', 'f', 'g' ), or array( 'h', 'i' ) TaskScheduler_Debug::log( $_aArguments ); return 1; } } 

Don’t forget to instantiate the action module class.

new TaskScheduler_SampleActionModule; 

Terminologies

  • Task – a rule which defines what kind of action routine to be performed at a specified time.
  • Routine – a main action routine created by a task. Depending on the action, it creates an action thread to divide its routine.
  • Thread – a divided action sub-sequential routine created by a routine. For example, The email action creates threads and sends emails per thread instead of sending them all in one routine to avoid exceeding the PHP’s maximum execution time.

Pricing

Starting from $0 per month.

Check Out the Animated Number Counter Widget

By Common Ninja

Animated Number CounterTry For Free!

App Info

Rating

Reviewers

7 reviews

Tags

backend
background
task
tool
utility

Developed By

Michael Uno

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Forms

Forms plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Comments

Comments plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Maps

Maps plugins for Wordpress

Security

Security plugins for Wordpress

Translation

Translation plugins for Wordpress

Ads

Ads plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Chat

Chat plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Membership

Membership plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Contact

Contact plugins for Wordpress

Comments

Comments plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Animated Number Counter for Wordpress logo

Animated Number Counter

Show key stats with an animated number counter that draws attention, adds social proof, and helps increase trust and conversions.

Marketing Button for Wordpress logo

Marketing Button

Marketing button with text and an icon that highlights key offers, draws attention to promotions, and helps increase engagement and conversions.

Business Listings for Wordpress logo

Business Listings

Create business listings with a listings widget that presents companies clearly, supports easy organization, and helps visitors find the right services quickly.

Company Branch Flip Cards for Wordpress logo

Company Branch Flip Cards

Display locations with company branch flip cards that help customers find nearby offices, understand key details, and enjoy a smoother overall experience.

TikTok Carousel for Wordpress logo

TikTok Carousel

Show TikTok videos with a TikTok carousel that arranges clips in a smooth, customizable layout to boost engagement and keep visitors watching.

Lottie Player for Wordpress logo

Lottie Player

Use a Lottie player to embed lightweight JSON animations that improve visual design, keep pages fast, and create a smoother user experience.

Corner Coupon Pop-up for Wordpress logo

Corner Coupon Pop-up

Add a corner coupon pop-up to highlight discounts, collect emails, and drive user engagement without interrupting browsing.

Image Stack Gallery for Wordpress logo

Image Stack Gallery

Showcase photos with an image stack gallery that layers images in a stacked display with smooth transitions to create a visually striking presentation.

Threads Feed for Wordpress logo

Threads Feed

Show Threads posts in a live feed that keeps content fresh, builds social proof, and helps visitors engage on your site.

Glassdoor Reviews for Wordpress logo

Glassdoor Reviews

Show Glassdoor reviews to highlight employee feedback, strengthen employer brand, and help candidates trust your company.

Medium Feed for Wordpress logo

Medium Feed

Show Medium articles in a Medium feed that keeps content fresh, improves readability, and helps visitors discover more posts.

Corner Pop-up for Wordpress logo

Corner Pop-up

Add a floating corner pop-up to display updates or calls to action without disrupting the user experience or site flow.

More plugins

plugins You Might Like

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms