Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs #111

Merged
merged 3 commits into from
Mar 13, 2024
Merged

Docs #111

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[*.yml]
[{*.yml,*.toml}]
indent_style = space
indent_size = 2

Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
/.github export-ignore
/.wordpress-org export-ignore
/bin export-ignore
/docs export-ignore
/node_modules export-ignore
/tests export-ignore

# Files
/.gitattributes export-ignore
/.editorconfig export-ignore
/.gitignore export-ignore
/.npmrc export-ignore
/.nvmrc export-ignore
/CODE_OF_CONDUCT.md export-ignore
/codeception.dist.yml export-ignore
/composer.lock export-ignore
/CONTRIBUTING.md export-ignore
/docker-compose.yml export-ignore
/netlify.toml export-ignore
/package-lock.json export-ignore
/package.json export-ignore
/phpcs.xml.dist export-ignore
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/build
/docs/.vitepress/cache
/docs/.vitepress/dist
/node_modules
/vendor/*

Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "johnbillion/wp-crontrol",
"description": "WP Crontrol lets you view and control what's happening in the WP-Cron system.",
"homepage": "https://github.com/johnbillion/wp-crontrol/",
"homepage": "https://wp-crontrol.com",
"license": "GPL-2.0-or-later",
"type": "wordpress-plugin",
"authors": [
Expand Down
151 changes: 151 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { defineConfig } from 'vitepress'
import { RSSOptions, RssPlugin } from 'vitepress-plugin-rss'

const wpURL = 'https://wordpress.org/plugins/wp-crontrol/';
const ghURL = 'https://github.com/johnbillion/wp-crontrol';
const siteURL = 'https://wp-crontrol.com';
const year = new Date().getFullYear();

const RSS: RSSOptions = {
title: 'WP Crontrol',
baseUrl: siteURL,
copyright: `Copyright (c) 2012-${year}, John Blackbourn`,
description: 'Take control of WP-Cron',
filename: 'feed',
}

export default defineConfig({
title: 'WP Crontrol',
description: 'Take control of WP-Cron',
rewrites: {
'help/:page.md': 'help/:page/index.md',
'docs/:page.md': 'docs/:page/index.md',
'privacy.md': 'privacy/index.md',
},
head: [
[
'link',
{
rel: 'icon',
href: '/icon.svg',
},
],
[
'link',
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'WP Crontrol',
href: `${siteURL}/feed`,
},
]
],
themeConfig: {
logo: '/icon.svg',

nav: [
{
text: 'Home',
link: '/',
},
{
text: 'Download',
link: wpURL,
},
],

sidebar: [
{
text: 'Docs',
collapsed: false,
items: [
{
text: 'How to use WP Crontrol',
link: '/docs/how-to-use/',
},
{
text: 'PHP cron events',
link: '/docs/php-cron-events/',
},
{
text: 'What happens if I deactivate WP Crontrol?',
link: '/docs/deactivation/',
},
],
},
{
text: 'Help',
collapsed: false,
items: [
{
text: 'Cron events that have missed their schedule',
link: '/help/missed-cron-events/',
},
{
text: 'Problems with spawning a call to the WP Cron system',
link: '/help/problems-spawning-wp-cron/',
},
{
text: 'Problems adding or editing WP Cron events',
link: '/help/problems-managing-events/',
},
{
text: 'PHP default timezone is not set to UTC',
link: '/help/php-default-timezone/',
},
{
text: 'This interval is less than the cron lock timeout',
link: '/help/wp-cron-lock-timeout/',
},
],
},
{
text: 'GitHub Project',
link: ghURL,
},
{
text: 'Download on WordPress.org',
link: wpURL,
},
{
text: 'Privacy statement',
link: '/privacy/',
},
],

socialLinks: [
{
icon: 'github',
link: ghURL,
ariaLabel: 'WP Crontrol on GitHub',
},
{
icon: 'twitter',
link: 'https://twitter.com/johnbillion',
ariaLabel: 'WP Crontrol\'s author on Twitter',
},
],

editLink: {
pattern: 'https://github.com/johnbillion/wp-crontrol/edit/develop/docs/:path',
text: 'Edit this page on GitHub',
},

search: {
provider: 'local',
},

footer: {
copyright: `© 2012-${year}, <a href="https://johnblackbourn.com">John Blackbourn</a>. WP Crontrol is not associated with WordPress.`,
},
},
lastUpdated: true,
sitemap: {
hostname: siteURL,
},
vite: {
plugins: [
RssPlugin(RSS),
],
},
})
23 changes: 23 additions & 0 deletions docs/docs/deactivation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# What happens if I deactivate the WP Crontrol plugin?

If you deactivate or delete the WP Crontrol plugin, your existing cron events will remain in place and will mostly continue to run as they would normally, with some exceptions detailed below.

## Paused cron hooks

Any cron hooks that you've paused through WP Crontrol will be resumed because the paused functionality is provided by WP Crontrol. If you reactivate WP Crontrol, they will become paused again.

## PHP cron events

If you've created a PHP cron event with WP Crontrol, these events will remain in place after you deactivate WP Crontrol but they will _cease to operate_ because these events are processed by WP Crontrol. If you reactivate WP Crontrol, they will resume operating as normal.

## Custom schedules

If you've created a custom cron schedule from the Settings -> Cron Schedules screen, these schedules will no longer be available for use by cron events on your site because they get added by WP Crontrol.

Any cron event which uses a custom schedule will run at its next scheduled time as normal but will _not_ subsequently get rescheduled and will disappear.

If you reactivate WP Crontrol, your custom schedules will become available for use again.

## Edits to events

If you've edited a cron event and changed its arguments, next run time, or recurrence, these changes will persist because this data is stored in the standard WP-Cron system in WordPress.
76 changes: 76 additions & 0 deletions docs/docs/how-to-use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# How to use WP Crontrol

WP Crontrol enables you to view and control what’s happening in the WP-Cron system. From the admin screens you can:

* View all cron events along with their arguments, recurrence, callback functions, and when they are next due.
* Edit, delete, pause, resume, and immediately run cron events.
* Add new cron events.
* Bulk delete cron events.
* Add and remove custom cron schedules.
* Export and download cron event lists as a CSV file.

## Manage cron events

Go to the Tools → Cron Events menu to manage cron events.

From here you can see a list of all the currently scheduled cron events. If there is a large number of events, you can search, filter, and page through the list.

## Edit cron events

Click the Edit link next to an event to edit details such as its hook name, arguments, next run date, and recurrence.

## Add a new cron event

There are two steps to creating a functioning cron event that executes regularly. The first step is telling WordPress about the hook. This is the part that WP Crontrol was created to provide. The second step is calling a function when your hook is executed.

### Step one: Adding the hook

In the Tools → Cron Events admin panel, click on "Add New" and enter the details of the hook. You're best off using a hook name that conforms to normal PHP variable naming conventions. The event schedule is how often your hook will be executed. If you don't see a good interval, then add one first in the Settings → Cron Schedules admin panel.

### Step two: Writing the function

This part takes place in PHP code (for example, in the `functions.php` file from your theme). To execute your hook, WordPress runs an action. For this reason, we need to tell WordPress which function to execute when this action is run. The following line accomplishes that:

```php
add_action( 'my_hookname', 'my_function' );
```

The next step is to write your function. Here's a simple example:

```php
function my_function() {
wp_mail( 'hello@example.com', 'WP Crontrol', 'WP Crontrol rocks!' );
}
```

## Add a new PHP cron event

[See here for full information about creating PHP cron events](https://wp-crontrol.com/docs/php-cron-events).

## Pause cron events

Pausing a cron event is a way to prevent an event from running. This is more reliable than deleting an event because many plugins will immediately recreate events that are missing.

Pausing an event will disable all actions attached to the event's hook. The event itself will remain in place and will run according to its schedule, but all actions attached to its hook will be disabled. This renders the event inoperative but keeps it scheduled so as to remain fully compatible with events which would otherwise get automatically rescheduled when they're missing.

As pausing an event actually pauses its hook, all events that use the same hook will be paused or resumed when pausing and resuming an event. This is much more useful and reliable than pausing individual events separately.

## Delete cron events

Click the Delete link next to an event to delete it. If no Delete link is shown, it usually means the event is created by the WordPress core software and therefore cannot be deleted. If you want to remove the functionality, you can pause the event instead (see above).

If more than one event exists with a given hook name, you can delete all of them at once via the "Delete all events with this hook" link next to one of the events.

## Bulk delete cron events

You can delete multiple cron events by checking the checkboxes next to the events you wish to delete, then choosing the Delete option from the Bulk Actions menu, and clicking Apply. Events without a checkbox are events created by the WordPress core software and cannot be deleted.

## Export cron events

A CSV file of the event list can be exported and downloaded via the "Export" button. This file can be opened in any spreadsheet application.

## Manage cron schedules

In order to run at a recurring interval, a cron event needs to use a cron schedule. If the built-in cron schedules don't suit your needs then you can use WP Crontrol to add new schedules.

Go to the Settings → Cron Schedules menu to manage cron schedules.
35 changes: 35 additions & 0 deletions docs/docs/php-cron-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# PHP cron events

WP Crontrol includes a feature that allows administrative users to create events in the WP-Cron system that execute PHP code, subject to the restrictive security permissions documented below.

## Which users can manage PHP cron events?

Only users with the `edit_files` capability can manage PHP cron events in WP Crontrol. If a user does not have the capability to edit files in the WordPress admin area -- i.e. via the Plugin Editor or Theme Editor menu -- then they cannot add, edit, or delete a PHP cron event.

By default only Administrators have this capability, and with Multisite enabled only Super Admins have this capability.

If file editing has been disabled via [the `DISALLOW_FILE_MODS` or `DISALLOW_FILE_EDIT` configuration constants in WordPress](https://developer.wordpress.org/apis/wp-config-php/#disable-the-plugin-and-theme-file-editor) then adding, editing, or deleting a PHP cron event will not be permitted.

## Is this feature dangerous?

The user capability required to create and execute PHP code via WP Crontrol exactly matches that which is required to edit PHP files in a standard WordPress installation. Therefore, the user access level required to execute arbitrary PHP code does not change with WP Crontrol activated.

If you wish to prevent PHP cron events from being added or edited on your site then you can [add the `DISALLOW_FILE_EDIT` configuration constant to your `wp-config.php` file](https://developer.wordpress.org/apis/wp-config-php/#disable-the-plugin-and-theme-file-editor).

## How do I create a new PHP cron event?

In the Tools → Cron Events admin panel, click on "Add New". In the form that appears, select "PHP Cron Event" and enter the schedule and next run time. In the "Hook code" area, enter the PHP code that should be run when your cron event is executed. Don't include the PHP opening tag (`<?php`).

## Can I "lock" a PHP cron event so that other users cannot edit it?

Yes. You can create or edit a PHP cron event, save it, and then set the `DISALLOW_FILE_EDIT` constant to true (as documented above) to prevent further changes to the event from the Cron Events admin panel. The event will continue to run at its scheduled interval as expected.

If you need to edit the event in the future, you can temporarily remove the `DISALLOW_FILE_EDIT` constant, make your required changes to the event, and then restore the constant to re-lock it.

## How can I create a cron event that requests a URL?

From the Tools → Cron Events → Add New screen, create a PHP cron event that includes PHP that fetches the URL using the WordPress HTTP API. For example:

```php
wp_remote_get( 'http://example.com' );
```
Loading
Loading