{"id":36294748,"url":"https://github.com/rumur/wp-scheduling","last_synced_at":"2026-01-11T10:03:19.575Z","repository":{"id":62538180,"uuid":"273456767","full_name":"rumur/wp-scheduling","owner":"rumur","description":"[WordPress] Convenient way of working with a WordPress Cron ","archived":false,"fork":false,"pushed_at":"2020-07-14T08:04:48.000Z","size":62,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-26T17:59:28.529Z","etag":null,"topics":["cron","wordpress","wordpress-cron"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rumur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-19T09:39:38.000Z","updated_at":"2021-12-16T22:39:36.000Z","dependencies_parsed_at":"2022-11-02T16:01:24.655Z","dependency_job_id":null,"html_url":"https://github.com/rumur/wp-scheduling","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rumur/wp-scheduling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumur%2Fwp-scheduling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumur%2Fwp-scheduling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumur%2Fwp-scheduling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumur%2Fwp-scheduling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rumur","download_url":"https://codeload.github.com/rumur/wp-scheduling/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumur%2Fwp-scheduling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28299709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T08:21:30.231Z","status":"ssl_error","status_checked_at":"2026-01-11T08:21:26.882Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","wordpress","wordpress-cron"],"created_at":"2026-01-11T10:03:17.847Z","updated_at":"2026-01-11T10:03:19.564Z","avatar_url":"https://github.com/rumur.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `wp-scheduling` \nit's a package that provides a convenient way of working with a [WordPress Cron](https://developer.wordpress.org/plugins/cron/) functionality.\n\n## Package Installation  \n```composer require rumur/wp-scheduling```\n\n### Themosis 2.x\n```php console vendor:publish --provider='Rumur\\WordPress\\Scheduling\\WordPressScheduleServiceProvider'```\n\n### Sage 10.x\n```wp acorn vendor:publish --provider='Rumur\\WordPress\\Scheduling\\WordPressScheduleServiceProvider'```\n\n### Minimum Requirements:\n - PHP: 7.2+\n - WordPress: 5.3+\n\n### How to use it?\n\n```php\n\u003c?php\n// functions.php\n\n// With this method the Scheduler will add intervals it uses.\n\\Rumur\\WordPress\\Scheduling\\Schedule::registerIntoWordPress();\n```\n\n### Task as a `Class`.\nIn order to use a specific class as a Job, you can create any class you want, but this class must have `public` `handle` method   \n\n```php\n\u003c?php\n\nnamespace App\\Scheduling;\n\nclass HelloDolly\n{\n    protected $lyrics;\n\n    public function __construct($lyrics)\n    {\n        $this-\u003elyrics = $lyrics;\n    }\n    \n    // It can be an either `handle` or `__invoke` method\n    public function handle($args)\n    {\n        $id = $args['id'];\n    }\n}\n```\n\n```php\n\u003c?php\n\n// You can add a class as a Job.\n\\Rumur\\WordPress\\Scheduling\\Schedule::job(\n    new App\\Scheduling\\HelloDolly('Hello Rudy, well, hello Harry')\n)\n// You can add args for the task, all these args will be injected to the `handle` method \n-\u003ewith([ \n    'id' =\u003e 2020, \n    //...\n])\n    \n// You can add callbacks that will be executed when the task successfully performed.\n-\u003eonSuccess(static function() {\n    // Do something when the task is run successfully.\n})\n\n// You can add callbacks that will be executed when the task encounters an error.\n-\u003eonFailure(static function() {\n    // Do something when the task is failed.\n})\n\n// To ping a url when the task is failed.\n-\u003epingOnFailure('https://domain.com/?ping=true\u0026id=3790a0e1-3f51-4703-8962-8ed889e2cc7c\u0026action=failed')\n\n// To ping a url when the task is successfully performed.\n-\u003epingOnSuccess('https://domain.com/?ping=true\u0026id=3790a0e1-3f51-4703-8962-8ed889e2cc7c\u0026action=success')\n\n// Register the recurrence for a task.\n-\u003erunOnceInFiveMinutes();\n```\n\n### Task as a `Closure`, the `call` method takes any `callable` instance.\n```php\n\u003c?php\n// You can add a Closure as a Job.\n\\Rumur\\WordPress\\Scheduling\\Schedule::call(static function () {\n    // Do something when the task is running.\n})-\u003eonSuccess(static function ($task, $args) {\n    // Do something when the task is run successfully.\n})-\u003eonFailure(static function ($task, $args, $reason) {\n    // Do something when the task is failed.\n})\n\n// You can add args for the task\n-\u003ewith([ 'id' =\u003e 2020, /*...*/ ])\n\n// You can ping a url when the task is failed.\n-\u003epingOnFailure('https://domain.com/?ping=true\u0026id=3790a0e1-3f51-4703-8962-8ed889e2cc7c\u0026action=failed')\n\n// You can ping a url when the task is successfully performed.\n-\u003epingOnSuccess('https://domain.com/?ping=true\u0026id=3790a0e1-3f51-4703-8962-8ed889e2cc7c\u0026action=success')\n\n// Register the recurrence for a task and returns the configured task. \n-\u003erunEveryThirtyMinutes();\n```\n\n### Task as a function.\nIn order to set a task as function, you need to implement that function first and as far as the `Schedule::call` takes any `callable`\ninstance you just call it.\n```php\n\u003c?php\n// functions.php\n\nfunction my_own_task(array $args) {\n    // Do what you need to do.\n}\n```\n\n```php\n\u003c?php\n// *.php\n\n// You can add a function as a Job.\n\\Rumur\\WordPress\\Scheduling\\Schedule::call('my_own_task')-\u003eonSuccess(static function ($task, $args) {\n    // Do something when the task is run successfully.\n})-\u003eonFailure(static function ($task, $args, $reason) {\n    // Do something when the task is failed.\n})\n\n// You can add args for the task\n-\u003ewith([ 'id' =\u003e 2020, /*...*/ ])\n\n// You can ping a url when the task is failed.\n-\u003epingOnFailure('https://domain.com/?ping=true\u0026id=3790a0e1-3f51-4703-8962-8ed889e2cc7c\u0026action=failed')\n\n// You can ping a url when the task is successfully performed.\n-\u003epingOnSuccess('https://domain.com/?ping=true\u0026id=3790a0e1-3f51-4703-8962-8ed889e2cc7c\u0026action=success')\n\n// Register the recurrence for a task and returns the configured task. \n-\u003erunEveryThirtyMinutes();\n```\n \n### [Available recurrence](#available-recurrence)\nNote that these methods should be the last one in the chain, because it registers all options that was build for a task.\n \n | Recurrence                       | Description                                                              |\n |-------------------------------   |------------------------------------------------------------------------  |\n | `-\u003erunEveryMinute();`            | Register the task to run every minute                                    |\n | `-\u003erunEveryFiveMinutes();`       | Register the task to run every five minutes                              |\n | `-\u003erunEveryTenMinutes();`        | Register the task to run every ten minutes                               |\n | `-\u003erunEveryFifteenMinutes();`    | Register the task to run every fifteen minutes                           |\n | `-\u003erunEveryThirtyMinutes();`     | Register the task to run every thirty minutes                            |\n | `-\u003erunHourly();`                 | Register the task to run every hour                                      |\n | `-\u003erunDaily();`                  | Register the task to run every day                                       |\n | `-\u003erunWeekly();`                 | Register the task to run every week                                      |\n | `-\u003erunMonthly();`                | Register the task to run every month                                     |\n | `-\u003erunQuarterly();`              | Register the task to run every quarter                                   |\n | `-\u003erunYearly();`                 | Register the task to run every year                                      |\n | `-\u003erunOnceInMinute();`           | Register the task to run only once in minute                             |\n | `-\u003erunOnceInMinutes(45);`        | Register the task to run only once in 45 minutes                         |\n | `-\u003erunOnceInFiveMinutes();`      | Register the task to run only once in 5 minutes                          |\n | `-\u003erunOnceInTenMinutes();`       | Register the task to run only once in 10 minutes                         |\n | `-\u003erunOnceInFifteenMinutes();`   | Register the task to run only once in 15 minutes                         |\n | `-\u003erunOnceInThirtyMinutes();`    | Register the task to run only once in 30 minutes                         |\n | `-\u003erunOnceInHour();`             | Register the task to run only once in one hour                           |\n | `-\u003erunOnceInDay();`              | Register the task to run only once in one day                            |\n | `-\u003erunOnceInWeek();`             | Register the task to run only once in one week                           |\n | `-\u003erunOnceInMonth();`            | Register the task to run only once in one month                          |\n | `-\u003erunOnceInQuarter();`          | Register the task to run only once in a quarter                          |\n | `-\u003erunOnceInYear();`             | Register the task to run only once in a year                             |\n | `-\u003erunNow();`                    | Runs the task right now. The method mimics WordPress behavior, designed for a testing purpose. |\n \n ### [Available methods](#available-methods)\n \n | Method                           | Description                                                       |\n |-----------------------------     |------------------------------------------------------------       |\n | `-\u003eonFailure(callable $thing);`  | Adds listeners for a task that will be run when it's failed.     |\n | `-\u003eonSuccess(callable $thing);`  | Adds listeners for a task that will be run when it's performed.   |\n | `-\u003epingOnFailure(string $url);`  | Ping the url when the task is failed.                             |\n | `-\u003epingOnSuccess(string $url);`  | Ping the url when the task is successfully performed.             |\n | `-\u003ewith($data);`                 | The data for a task, that will be passed to `Closure` or `handle` method of the task. |\n \n ### How to add your own intervals?\n \n ```php\n\u003c?php\n// functions.php\n\n// Register the mandatory staff to WordPress.\nadd_action('init', static function() {\n    // In Order to add your own intervals\n    \n    // The simple an straight way to do that it's just use a `addInterval` method.\n    // Please Note that if you added an interval that already exists in a package,\n    // it will be replaced by a new one during the register time,\n    // however the system's ones that were added by a WordPress won't be touched and replaced. \n    \\Rumur\\WordPress\\Scheduling\\Schedule::addInterval('every-25-minutes', 25 * MINUTE_IN_SECONDS);\n    \n    // Or you can add in WordPress way as well \n    \\Rumur\\WordPress\\Scheduling\\Schedule::addInterval('every-45-minutes', [\n        'interval' =\u003e 45 * MINUTE_IN_SECONDS,\n        'display' =\u003e esc_html__('Every 45 Minutes'),\n    ]);\n\n    // With this method the Scheduler will add intervals it uses.\n    \\Rumur\\WordPress\\Scheduling\\Schedule::registerIntoWordPress();\n});\n```\n\n### How to set one task for more than one event?\nEvery chained method returns a `PendingTask` instance and this task might be assigned for a several recurrence.\n\n```php\n\u003c?php\n$pendingTask = \\Rumur\\WordPress\\Scheduling\\Schedule::job(\n    new App\\Scheduling\\HelloDolly('Hello Rudy, well, hello Harry')\n);\n\n$pendingTask-\u003erunOnceInWeek();\n$pendingTask-\u003erunEveryMinute();\n$pendingTask-\u003erunOnceInDays(33);\n$pendingTask-\u003erunOnceInWeeks(2);\n```\n\n### How to resign a job?\n```php\n\u003c?php\n\nuse Rumur\\WordPress\\Scheduling;\n\n$scheduledTask = Scheduling\\Schedule::job(\n    new App\\Scheduling\\HelloDolly('Hello Rudy, well, hello Harry')\n)-\u003erunOnceInWeek();\n\nScheduling\\Schedule::resign($scheduledTask);\n```\n \n ## License\n This package is licensed under the MIT License - see the [LICENSE.md](https://github.com/rumur/wp-scheduling/blob/master/LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumur%2Fwp-scheduling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frumur%2Fwp-scheduling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumur%2Fwp-scheduling/lists"}