AI Verified

Name

Add Training Videos to Wordpress Admin Sidebar

About

Ever wanted to add a Label to your Wordpress Sidebar called Training Vids that leads to a page that lists your specified YouTube Videos?

Language

PHP

Rating

Voted: 3 by 3 user(s)

How to Setup Snippet

Add this to Code Snippets, and then modify the label and YouTube URLs.

Codevault

WebSquadron

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

16/10/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Add Training Videos to Wordpress Admin Sidebar

 
                    
1function add_training_section_to_admin_menu() {
2 add_menu_page(
3 'Training Videos',
4 'Training Videos',
5 'manage_options',
6 'training-videos',
7 'display_training_videos_page',
8 'dashicons-video-alt2',
9 30
10 );
11}
12 
13function display_training_videos_page() {
14 $videos = array(
15 array(
16 'title' => 'How to Start a Web Design Business Super Course',
17 'url' => 'https://www.youtube.com/watch?v=1SWArSD0C34',
18 ),
19 array(
20 'title' => 'Page Speed Performance Boost',
21 'url' => 'https://www.youtube.com/watch?v=P4nepzKE0Fs',
22 ),
23 array(
24 'title' => 'How to Get Clients',
25 'url' => 'https://www.youtube.com/watch?v=NIye1vlSPYU',
26 ),
27 );
28 
29 ?>
30 <div class="wrap">
31 <h1>Training Videos</h1>
32 
33 <ul>
34 <?php foreach ( $videos as $video ) : ?>
35 <li>
36 <a href="<?php echo esc_url( $video['url'] ); ?>" target="_blank"><?php echo esc_html( $video['title'] ); ?></a>
37 </li>
38 <?php endforeach; ?>
39 </ul>
40 </div>
41 <?php
42}
43 
44add_action( 'admin_menu', 'add_training_section_to_admin_menu' );

3

Featured Snippet

Comments

  • IS

    1 year ago

    And if you ever want to show a PDF instead of a Video Link then use this format:
    'url'   => 'https://example.com/path/to/pdf',
  • 1 year ago

    The provided code snippet registers a new section in the WordPress admin menu called "Training Videos" and displays a list of training videos in that section. The implementation of this functionality is achieved through the use of two functions:
    
    add_training_section_to_admin_menu()
    This function registers a new menu item in the WordPress admin menu. It accepts the following arguments:
    
    $page_title (string): The text that appears in the title tag of the web page when the menu item is selected.
    $menu_title (string): The text that appears in the WordPress admin menu for this item.
    $capability (string): The capability required for a user to view this menu item.
    $menu_slug (string): The unique identifier for this menu item.
    $function (callable): The function that will be called when this menu item is selected.
    $icon_url (string): The URL for the icon that will be displayed next to this menu item.
    $position (int): The position of this menu item in the WordPress admin menu.
    In this code snippet, add_menu_page() is called with the appropriate arguments to create the "Training Videos" menu item.
    
    display_training_videos_page()
    This function is called when the "Training Videos" menu item is selected. It displays a list of training videos using the $videos array. The $videos array contains an array of associative arrays, each of which contains a title and a URL for a training video.
    
    The function creates an unordered list of video titles and links, using a foreach loop to iterate over the $videos array.
    
    add_action( 'admin_menu', 'add_training_section_to_admin_menu' );
    This line of code adds the add_training_section_to_admin_menu() function to the admin_menu action hook, which is called when the WordPress admin menu is initialized. This ensures that the "Training Videos" menu item is registered and displayed in the WordPress admin menu.
  • IS

    1 year ago

    Great explanation Justin :)
  • 1 year ago

    No need thank chatgpt. Just needed some info on what some of it did.
    
  • CE

    1 year ago

    Great snippet, thank you.  Tip for users: the menu displays for the administrator role. To get it to display for the editor role change line 5 from ‘manage_options’ to ‘publish_pages’

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

Unverified

0

Clamp

Added: 7 months ago

Last Updated: 7 months ago

Fluid Typography Code Snippet - Add the Tool to your Dashboard or Page

WordPress Admin

AI Verified

0

Block Editor: Show Outline Context Menus on Right-Click [SnipSnip.pro] - Vanilla JS Version

Added: 7 months ago

Last Updated: 1 month ago

ADMIN ONLY • When using Block Editor and right clicking on an item in the sidebar outline list of blocks, you'll now see that block's menu instead of the default browser context menu. You can still ta...

WordPress Admin

AI Verified

0

Filter Posts by Author dropdown

Added: 3 weeks ago

Last Updated: 3 weeks ago

Adds a dropdown to the posts screen to filter by author

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

31

Remove Unused Javascript

Added: 1 year ago

Last Updated: 2 weeks ago

Remove Unused Javascript - and improve your Page Speed Insight Score

WooCommerce

Pro Verified

9

Deactivate some WooCommerce Checkout Fields

Added: 1 year ago

Last Updated: 7 months ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 7 months ago

Last Updated: 3 weeks ago

This can be used for any WordPress Builder to aid working with CSS Grids.