Plugin Directory

Changeset 3304173


Ignore:
Timestamp:
06/01/2025 07:38:34 AM (7 months ago)
Author:
Annubis
Message:

add offset to channel list shortcode

Location:
video-manager-for-peertube
Files:
14 added
4 edited

Legend:

Unmodified
Added
Removed
  • video-manager-for-peertube/trunk/README.md

    r3304036 r3304173  
    2020
    2121[cbvmfp-last-channel-videos]
     22
     23with offset - start list with video no. 3
     24
     25[cbvmfp-last-channel-videos offset='2']
  • video-manager-for-peertube/trunk/readme.txt

    r3304165 r3304173  
    33Donate link: http://www.ericmaechler.com
    44Tags: Peertube, Video, Fediverse
    5 Version: 1.5
    6 Stable tag: 1.5
     5Version: 1.5.1
     6Stable tag: 1.5.1
    77Requires at least: 6.0
    88Tested up to: 6.8
     
    1717### Comming Soon
    1818a shortcode that recognises whether a livestream is running and then displays it or if none is running a video is displayed
     19
    1920
    2021### Available Shortcodes
     
    4243
    4344
     45Displays a list of embedded videos from a specific Peertube channel with offset
     46here the list is started with video no. 3 from your channel
    4447
     48`[cbvmfp-last-channel-videos offset='2']`
    4549
    4650
  • video-manager-for-peertube/trunk/show_last_videos_channel.php

    r3304036 r3304173  
    66    $cbvmfp_peertube_anzahl_videos = get_option('cbvmfp_peertube_anzahl_videos');
    77    $cbvmfp_peertube_channel = get_option('cbvmfp_peertube_channel');
     8
    89    // Shortcode-Attribute mit Standardwerten
    910    $atts = shortcode_atts([
    1011        'instance' => $cbvmfp_peertube_url,
    1112        'channel' => $cbvmfp_peertube_channel,
    12         'count' => $cbvmfp_peertube_anzahl_videos
    13     ], $atts, 'peertube-manager-channel');
     13        'count' => $cbvmfp_peertube_anzahl_videos,
     14        'offset' => 0
     15    ], $atts, 'cbvmfp-last-channel-videos');
    1416
    1517    // Prüfen, ob Kanalname angegeben ist
     
    1820    }
    1921
    20     // API-URL für Kanalvideos
     22    $offset = intval($atts['offset']);
     23    $count = intval($atts['count']);
     24
     25    // API-URL (wir holen mehr Videos, damit wir später "offset" anwenden können)
     26    $fetchCount = $offset + $count;
     27
    2128    $channelName = urlencode($atts['channel']);
    22     $apiUrl = $atts['instance'] . '/api/v1/video-channels/' . $channelName . '/videos?sort=-publishedAt&count=' . intval($atts['count']);
     29    $apiUrl = $atts['instance'] . '/api/v1/video-channels/' . $channelName . '/videos?sort=-publishedAt&count=' . $fetchCount;
    2330
    2431    // cURL anstoßen
     
    4350    }
    4451
     52    $videos = array_slice($data['data'], $offset, $count);
     53
     54    if (empty($videos)) {
     55        return '<p>' . __('No videos found after applying offset.', 'wordpress-peertube-manager') . '</p>';
     56    }
     57
    4558    // HTML-Ausgabe mit eingebetteten Videos
    4659    $output = '<div class="cbvmfp-video-embed-wrapper">';
    47     foreach ($data['data'] as $video) {
     60    foreach ($videos as $video) {
    4861        $embedUrl = esc_url($atts['instance'] . '/videos/embed/' . $video['uuid']);
    4962        $output .= '<div class="cbvmfp-video">';
     
    5366    $output .= '</div>';
    5467
    55 
    56 
    5768    return $output;
    5869}
  • video-manager-for-peertube/trunk/video-manager-for-peertube.php

    r3304036 r3304173  
    55Description: Integrate Peertube Videos into your WordPress (<a href="options-general.php?page=cbvmfp_settings">Settings</a>)
    66Author: Eric-Oliver Mächler
    7 Version: 1.5
     7Version: 1.5.1
    88Author URI: https://www.chefblogger.me
    99Requires at least: 6.0
Note: See TracChangeset for help on using the changeset viewer.