# Tutorial Video Dashboard Widget

> Embeds a how-to video on the dashboard, such as a walkthrough recorded for your client, with an optional short message.

- Type: PHP
- Runs: Admin only
- Category: [Dashboard](https://wpide.com/library/category/dashboard/)
- Tags: dashboard, widget, video
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tutorial-video-dashboard-widget/

## Code

```php
$wpide_tutorial = array(
    'title'   => 'How to Edit Your Website',
    'video'   => 'https://www.youtube.com/watch?v=XXXXXXXXXXX', // YouTube, Vimeo or any oEmbed URL.
    'message' => 'Watch this short walkthrough before your first edit.',
);

add_action( 'wp_dashboard_setup', function () use ( $wpide_tutorial ) {
    wp_add_dashboard_widget( 'wpide_tutorial_video', esc_html( $wpide_tutorial['title'] ), function () use ( $wpide_tutorial ) {
        if ( $wpide_tutorial['message'] ) {
            echo '<p>' . esc_html( $wpide_tutorial['message'] ) . '</p>';
        }

        $embed = wp_oembed_get( $wpide_tutorial['video'], array( 'width' => 600 ) );

        echo $embed ? '<div class="wpide-video" style="aspect-ratio:16/9">' . str_replace( '<iframe ', '<iframe style="width:100%;height:100%" ', $embed ) . '</div>' : '<p><a href="' . esc_url( $wpide_tutorial['video'] ) . '" target="_blank" rel="noopener">Open the video</a></p>';
    } );
}, 1 );
```

## Notes

The oEmbed result is fetched from the video site; WordPress does not cache it outside posts, so keep the widget for clients only if needed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutorial Video Dashboard Widget" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
