Title: SlashPress
Author: Roy Orbitson
Published: <strong>Igbe 28, 2020</strong>
Last modified: Bélú 21, 2025

---

Ṣàwárí àwọn plugin

![](https://ps.w.org/slashpress/assets/banner-772x250.png?rev=3400159)

Plugin yìí **kò tíì ṣe àyẹ̀wò pẹ̀lú àwọn ìtújáde mẹ́ta pàtàkì tó kẹ́yìn ti WordPress**.
Ó lè jẹ́ pé a kò tọ́jú tàbí ṣe àtìlẹ́yìn fún un mọ́, ó sì lè ní àwọn ọ̀ràn ìbámu
nígbà tí a bá lò ó pẹ̀lú àwọn ẹ̀yà WordPress tuntun.

![](https://ps.w.org/slashpress/assets/icon-128x128.png?rev=2293582)

# SlashPress

 Láti ọwọ́ [Roy Orbitson](https://profiles.wordpress.org/lev0/)

[Ṣe ìgbàsílẹ̀](https://downloads.wordpress.org/plugin/slashpress.1.2.0.zip)

 * [Àwọn àlàyé](https://yor.wordpress.org/plugins/slashpress/#description)
 * [Àwọn àgbéyẹ̀wò](https://yor.wordpress.org/plugins/slashpress/#reviews)
 *  [Ìgbéwọlẹ̀](https://yor.wordpress.org/plugins/slashpress/#installation)
 * [Ìdàgbàsókè](https://yor.wordpress.org/plugins/slashpress/#developers)

 [Ìrànlọ́wọ́](https://wordpress.org/support/plugin/slashpress/)

## Àpèjúwe

ItÌtumọ̀ Yorùbá: ’s very easy to create a [custom slash command on Mattermost](https://developers.mattermost.com/integrate/slash-commands/custom/),
or [a private app on Slack](https://api.slack.com/apps) that has [the slash command feature](https://docs.slack.dev/interactivity/implementing-slash-commands/).
This plugin turns that convenient chat interface into a subscribable event using
standard WordPress filter & action hooks. This enables automation of tasks that 
need to be run on-demand, and provision of interactive help for them.

The hooks provided are as follows:

 * `slashpress_command_${command}`
 * `slashpress_command`
 * `slashpress_help_${command}`
 * `slashpress_help`

The subscribed events receive a helper object representing the sent slash command,
with methods to respond using Markdown or a rich response object the chat service
can render. Plugins may listen for a specific slash command or a site-wide one, 
and respond based on the command content. Long-running tasks (> 3 seconds) can provide
an immediate acknowledgement response, then later a result response; this is easily
achieved by ensuring a [proper cron invocation](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/)
for the site, then passing the helper object to `wp_schedule_single_event()` to 
run the task in the background and POST a status message back upon completion.

By itself, this plugin doesnÌtumọ̀ Yorùbá: ’t perform any tasks. It is aimed at 
developers and maintainers to abstract away the boring plumbing and authentication,
allowing you to keep your code DRY. It supports authentication by both tokens and
HMAC signatures. There is no limit on the number of such integrations this endpoint
can handle. Only POST method requests are accepted and sent so access logs are kept
clean. The interactive help keyword is configurable.

There is no logging, metrics, analytics, nags, or anything that would violate your
privacy or GDPR obligations contained in this plugin. It is not freemium; there 
is no ‘Pro’ version.

## Ìgbéwọlẹ̀

 1. Install and activate the usual way.
 2. Go to _Settings > SlashPress_, add a service ID.
 3. Copy its endpoint URL and insert them into your chat service integration.
 4. Copy the authentication credential from your integration back into the plugin settings
    and save.
 5. Test the integration by entering your slash command followed by `help` (or other
    default keyword).
 6. Subscribe to the provided hooks in your own plugin code.

## FAQ

### What is this good for?

Running any task any task that you want to start immediately from the comfort of
your chat app. ItÌtumọ̀ Yorùbá: ’s great for providing instant summaries, triggering
actions like backups, clearing/preloading caches of optimisation plugins, updating
copies of remote data.

Your code can respond with anything you need, from a simple `OK` to a full tabulated
response using Markdown:

    ```
    |Order stat|Count|
    |:---|---:|
    |New orders today|27|
    |Orders to fulfil|8|
    |Unpaid orders|2|
    ```

### So how do I use this thing?

A simple example is probably best:

    ```
    add_action(
        'slashpress_help'
        , function(SlashPress\Command $slash, string $help_terms) {
            $slash->addHelp('flubbers', '`flubbers` Gets the latest map of nearby flubbers.')
                ->addHelp('gronks', '`gronks` Updates the list of the top 100 gronks and their values.')
                ->addHelp('uncache', 'Site content not looking quite right? Use `uncache` to clear the out the generated pages.');
        }
        , 100
        , 2
    );

    add_filter(
        'slashpress_command'
        , function($initial_response, SlashPress\Command $slash) {
            if (!$slash->known) {
                $text = trim($slash->data['text']);
                switch ($text) {
                    case 'flubbers':
                    case 'gronks':
                        $slash->handled = true;
                        wp_schedule_single_event(time(), 'big_data_fetch_cron_event_hook', [$text, $slash]);
                        return 'Big data fetch queued.';
                    case 'uncache':
                        $slash->handled = true;
                        if (function_exists('w3tc_flush_posts')) {
                            w3tc_flush_posts();
                            return 'Cleared the post cache.';
                        }
                        return 'No cache found to clear.';
                }
            }
            return $initial_response;
        }
        , 10
        , 2
    );

    add_action(
        'big_data_fetch_cron_event_hook'
        , function(string $what = null, SlashPress\Command $slash = null) {
            $results_bad = $results = [];
            if (null == $what || 'flubbers' == $what) {
                if (fetch_flubbers()) {
                    $results[] = 'Flubbers fetched.';
                }
                else {
                    $results_bad[] = $results[] = 'Could not fetch the flubbers.';
                }
            }
            if (null == $what || 'gronks' == $what) {
                if (fetch_gronks()) {
                    $results[] = 'Gronks fetched.';
                }
                else {
                    $results_bad[] = $results[] = 'Could not fetch the gronks.';
                }
            }
            if ($slash) {
                if ($slash->canRespondDelayed()) {
                    $slash->respondDelayed(implode("  \n", $results));
                }
            }
            elseif ($results_bad) {
                echo implode("  \n", $results_bad);
            }
        }
    );
    ```

## Àwọn àgbéyẹ̀wò

Kò sí àwọn àgbéyẹ̀wò fún plugin yìí.

## Àwọn Olùkópa & Olùgbéejáde

“SlashPress” jẹ́ ètò ìṣàmúlò orísun ṣíṣí sílẹ̀. Àwọn ènìyàn wọ̀nyí ti ṣe ìkópa sí
plugin yìí.

Àwọn Olùkópa

 *   [ Roy Orbitson ](https://profiles.wordpress.org/lev0/)

[Túmọ̀ “SlashPress” sí èdè rẹ.](https://translate.wordpress.org/projects/wp-plugins/slashpress)

### Ṣe o nífẹ̀ẹ́ sí ìdàgbàsókè?

[Ṣàwárí koodu](https://plugins.trac.wordpress.org/browser/slashpress/), ṣàyẹ̀wò 
[ibi ìpamọ́ SVN](https://plugins.svn.wordpress.org/slashpress/), tàbí ṣe àgbékalẹ̀
sí [àkọsílẹ̀ ìdàgbàsókè](https://plugins.trac.wordpress.org/log/slashpress/) nípasẹ̀
[RSS](https://plugins.trac.wordpress.org/log/slashpress/?limit=100&mode=stop_on_copy&format=rss).

## Àkójọpọ̀ Meta

 *  Ẹ̀yà **1.2.0**
 *  Ìgbàgbọ́hùn tó kẹ́yìn **oṣù 10 sẹ́yìn**
 *  Àwọn ìgbéwọlẹ̀ tó ṣiṣẹ́ **Tó kéré sí 10**
 *  Ẹ̀yà WordPress ** 4.7.1 tàbí ju bẹ́ẹ̀ lọ **
 *  Dánwò dé **6.8.10**
 *  Ẹ̀yà PHP ** 7.0 tàbí ju bẹ́ẹ̀ lọ **
 *  Èdè
 * [English (US)](https://wordpress.org/plugins/slashpress/)
 * Àwọn àmì
 * [Mattermost](https://yor.wordpress.org/plugins/tags/mattermost/)[slack](https://yor.wordpress.org/plugins/tags/slack/)
 *  [Ìwòye Tó Péye](https://yor.wordpress.org/plugins/slashpress/advanced/)

## Àwọn ìbò

Kò sí ìwádìí tí a tíì fi ránṣẹ́.

[Your review](https://wordpress.org/support/plugin/slashpress/reviews/#new-post)

[Wo gbogbo àwọn àgbéyẹ̀wò](https://wordpress.org/support/plugin/slashpress/reviews/)

## Àwọn Olùkópa

 *   [ Roy Orbitson ](https://profiles.wordpress.org/lev0/)

## Ìrànlọ́wọ́

Nǹkan wà tí o fẹ́ sọ? Ṣé o nílò ìrànlọ́wọ́?

 [Wo àpéjọ ìrànlọ́wọ́](https://wordpress.org/support/plugin/slashpress/)