Recent Posts
Online Members

 No online members at the moment

WordPress plugin - ...
 
Notifications
Clear all

WordPress plugin - YouTube Latest Videos Plugin


azmanagedit
(@azmanagedit)
Member Admin
Joined: 1 year ago
Posts: 88
Topic starter  

YouTube Latest Videos Plugin

This WordPress plugin fetches and displays the latest videos from a specified YouTube channel.

Installation Instructions:

  1. Download the Plugin:

    • Download the youtube-latest-videos.zip file.
  2. Install the Plugin:

    • Log in to your WordPress admin dashboard.
    • Navigate to Plugins > Add New.
    • Click on Upload Plugin.
    • Choose the youtube-latest-videos.zip file and click Install Now.
    • After installation, click Activate to activate the plugin.
  3. Configure the Plugin:

    • Open the youtube-latest-videos.php file in your code editor.
    • Replace YOUR_YOUTUBE_API_KEY with your actual YouTube Data API key.
    • Replace the channel ID in the code with the desired channel ID.
  4. Use the Shortcode:

  • Key Changes Made:

    1. Dynamic Channel ID: The vcf_display_latest_videos function now accepts an attribute channel_id from the shortcode, allowing you to specify different channels.
    2. Default Channel ID: If no channel ID is provided, it defaults to the one you previously specified.

    Using the Shortcodes:

    You can now use the following shortcodes to display videos from different channels:

    • Default Channel:

      vcf_latest_videos
    • Another Channel:

      vcf_latest_videos channel_id="CHANNEL_ID_HERE"

    Example Usage:

    • To display videos from the default channel:

      vcf_latest_videos
    • To display videos from another channel (replace CHANNEL_ID_HERE with the actual channel ID):

      vcf_latest_videos channel_id=""

    Instructions for Use:

    1. Create/Update the Plugin File:

      • If you have already created the plugin file, update it with this new code. If not, create a new file named youtube-latest-videos.php and paste this code into it.
    2. Update the API Key:

      • Replace YOUR_YOUTUBE_API_KEY with your actual YouTube Data API key.
    3. Upload the Plugin:

      • Follow the previous instructions to upload and activate the plugin.
    4. Use the Shortcode:

      • Add the shortcodes as mentioned above to any post or page to display the latest videos from different YouTube channels.

    This setup will allow you to easily showcase videos from multiple channels on your WordPress site. Let me know if you need further assistance!


   
Quote
azmanagedit
(@azmanagedit)
Member Admin
Joined: 1 year ago
Posts: 88
Topic starter  

To Help with API pulls.

Create a Custom Table for News Storage
Fetch News from NewsAPI and Store Locally
Display the Cached Data on the Frontend

image

Key Features:

  1. Database Caching: News is cached in the database for 12 hours to avoid repeated API calls.
  2. Search & Radio Buttons: Users can search news by typing a query or selecting default categories like "Israel," "Russia," or "Iran" with the radio buttons.
  3. Custom Table: A custom table is created in the WordPress database to store the news articles.
  4. Shortcode: The world_news shortcode can be used on any page or post to display the news.

   
ReplyQuote
azmanagedit
(@azmanagedit)
Member Admin
Joined: 1 year ago
Posts: 88
Topic starter  

Changes Made:

  1. Database Caching: Added a database caching mechanism that stores the video data for 12 hours. The table youtube_video_cache is created to hold the channel ID, video data, and timestamp.
  2. Columns Parameter: Added a columns attribute to the shortcode to specify how many videos to display per row. This is now controlled via CSS grid.
  3. Dynamic CSS for Grid Layout: The output is structured to create a CSS grid layout based on the specified number of columns.

Usage

To use the shortcode, you can specify the channel ID and the number of columns like this:

plaintext
vcf_latest_videos channel_id="YOUR_CHANNEL_ID" columns="3"

Replace "YOUR_CHANNEL_ID" with the actual channel ID you want to fetch videos from. This will display the videos

Key Changes:

  1. Flexbox Layout: The .video class is set to display: flex and flex-direction: column, ensuring that all child elements (iframe, title, description, and button) are stacked vertically and spaced evenly.
  2. Height Adjustment: The .video class has height: 100%, ensuring each video item has the same height, which keeps them aligned properly in the grid.
  3. Centered Text: The title, description, and button are center-aligned to create a more balanced look.
  4. Published Date: The code fetches the published date from the YouTube API (publishedAt) and formats it using PHP's date() function.
  5. Display Date: The formatted date is displayed in the video output as a new paragraph with the class video-date.
  6. Time Ago Calculation: The human_time_diff() function calculates how long ago the video was published based on the timestamp. This is then formatted as a string indicating how long ago the video was released (e.g., "3 days ago").
  7. Display: The formatted date and the time ago string are displayed together in the output

   
ReplyQuote
Share:

AZ Managed
IT Services llc

Contact us today to request a consultation and discover how our expert solutions can help your business thrive.