Plugin Directory

Changeset 2829606


Ignore:
Timestamp:
12/06/2022 09:04:53 PM (3 years ago)
Author:
VBog
Message:

Version 1.6.2

Location:
bg-rutube-embed
Files:
14 added
3 edited

Legend:

Unmodified
Added
Removed
  • bg-rutube-embed/trunk/bg-rutube.php

    r2826273 r2829606  
    44    Plugin URI: http://bogaiskov.ru/plugin-bg-rutube-embed/
    55    Description: The plugin is the easiest way to embed RuTube videos in WordPress.
    6     Version: 1.6.1
     6    Version: 1.6.2
    77    Author: VBog
    88    Author URI: http://bogaiskov.ru
     
    3939    die( 'Sorry, you are not allowed to access this page directly.' );
    4040}
    41 define('BG_RUTUBE_VERSION', '1.6.1');
     41define('BG_RUTUBE_VERSION', '1.6.2');
    4242
    4343// Подключаем CSS и JS
     
    9696        description - описание плейлиста
    9797        sort='on' - сортировать плейлист по алфавиту
     98        perpage - количество элементов на странице
     99        limit - max размер плейлиста
    98100        mode - режим запуска видео при загрузке страницы
    99101            'preview' - заставка
    100102            'load' - загрузить видео во фрейм
    101103            'play' - загрузить видео во фрейм и воспроизвести
    102             '' - в соответствии с настройками плагина
     104       
     105        perpage, limit, mode = '' - в соответствии с настройками плагина
    103106       
    104107******************************************************************************************/
     
    111114        'sort' => '',
    112115        'perpage' => '',
     116        'limit' => '',
    113117        'mode' => ''
    114118    ), $atts ) );
     
    120124   
    121125    // Формируем список фильмов с RuTube из шорткода
    122     if (empty($id)) return "";                                          // Фильм не указан
    123     elseif (strlen($id) < 32) $playlist = bg_rutube_get_playlist ($id); // Плейлист RuTube
    124     else $playlist = bg_rutube_create_playlist ($id, $title, $description);// Фильм или список фильмов
    125    
     126    if (empty($id)) return "";                                                      // Фильм не указан
     127    elseif (strlen($id) < 32) $playlist = bg_rutube_get_playlist ($id, $limit);     // Плейлист RuTube
     128    else $playlist = bg_rutube_create_playlist ($id, $title, $description, $limit); // Фильм или список фильмов
     129
    126130    if(!$playlist || empty($playlist)) {
    127131        $quote = "<div class='tube-error'><p class='warning'>".__('Sorry, the video is temporarily unavailable.', 'bg-rutube-embed')."</p></div>";
     
    178182       
    179183******************************************************************************************/
    180 function bg_rutube_get_playlist ( $playlist_id ) {
     184function bg_rutube_get_playlist ( $playlist_id, $limit='' ) {
    181185    $playlist = array();
    182186    $tracks = array();
     
    187191    $transient = $val ? $val['transient'] : false;
    188192    $singular = $val ? $val['singular'] : false;
     193    if (empty($limit) && $limit != '0') $limit = $val ? $val['limit'] : 0;
    189194   
    190195    if (is_singular() || !$singular) {
     
    226231            }
    227232            $page++;
     233            if ($limit && count($tracks) >= $limit) {
     234                $tracks = array_slice($tracks, 0, $limit);
     235                break;
     236            }
    228237        }
    229238        if (!empty($tracks)) {
     
    232241            $playlist['description'] = $info['description'];
    233242            $playlist['thumbnail'] = $info['thumbnail_url'];
    234             $playlist['count'] = $info['videos_count'];
     243            if ($limit) $playlist['count'] = $limit;
     244            else $playlist['count'] = $info['videos_count'];
    235245            $playlist['tracks'] = $tracks;
    236246           
     
    242252        $playlist['description'] = $info['description'];
    243253        $playlist['thumbnail'] = $info['thumbnail_url'];
    244         $playlist['count'] = $info['videos_count'];
     254        if ($limit) $playlist['count'] = $limit;
     255        else $playlist['count'] = $info['videos_count'];
    245256        if (!$playlist['description']) $playlist['description'] = $playlist['title'];           
    246257    }
     
    253264   
    254265******************************************************************************************/
    255 function bg_rutube_create_playlist ($ids, $title='', $description='') {
     266function bg_rutube_create_playlist ($ids, $title='', $description='', $limit='') {
    256267    $playlist = array();
    257268    $tracks = array();
     
    261272    $transient = $val ? $val['transient'] : false;
    262273    $singular = $val ? $val['singular'] : false;
     274    if (empty($limit) && $limit != '0') $limit = $val ? $val['limit'] : 0;
    263275   
    264276    if (is_singular() || !$singular) {
     
    300312                error_log("Metadata. Empty or error answer from RuTube: ". $json." for ".$videoID, 0);
    301313            }
     314            if ($limit && count($tracks) >= $limit) break;
    302315        }
    303316        if (!empty($tracks)) {
     
    382395            $last_no = $current_page*$perpage;
    383396            if ($last_no > $playlist['count']) $last_no = $playlist['count'];
    384             $total = ((int) $playlist['count']/$perpage)+1;
     397            $total =(int) ceil((int) $playlist['count']/$perpage);
    385398           
    386399            $base_url = strtok(get_permalink(), '?');
  • bg-rutube-embed/trunk/inc/options.php

    r2826261 r2829606  
    11<?php
    22/**
    3  * Страница настроек плагина
     3 * Страница настроек плагина. Версия 1.6.2
    44 */
    55add_action('admin_menu', 'add_bg_rutube_options_page');
     
    4141    add_settings_field('bg_rutube_field3', __('Caching response of the RuTube API', 'bg-rutube-embed'), 'fill_bg_rutube_field3', 'bg_rutube_page', 'bg_rutube_section_id' );
    4242    add_settings_field('bg_rutube_field5', __('Paginate playlist', 'bg-rutube-embed'), 'fill_bg_rutube_field5', 'bg_rutube_page', 'bg_rutube_section_id' );
     43    add_settings_field('bg_rutube_field7', __('Max playlist length', 'bg-rutube-embed'), 'fill_bg_rutube_field7', 'bg_rutube_page', 'bg_rutube_section_id' );
    4344}
    4445
     
    8687}
    8788
     89## Заполняем опцию 7
     90function fill_bg_rutube_field7(){
     91    $val = get_option('bg_rutube_options');
     92    $limit = ($val && !empty($val['limit'])) ? $val['limit'] : 0;
     93    ?>
     94    <label><input type="number" id="limit" name="bg_rutube_options[limit]" value="<?php echo $limit; ?>" min="0" style="width:5em;" /> <?php _e( '(0 - not limited)', 'bg-rutube-embed'); ?></label>
     95    <?php
     96}
     97
    8898## Очистка данных
    8999function bg_rutube_sanitize_callback( $options ){
  • bg-rutube-embed/trunk/readme.txt

    r2826273 r2829606  
    77Requires at least: 3.0.1
    88Tested up to: 6.1.1
    9 Stable tag: 1.6.1
     9Stable tag: 1.6.2
    1010License: GPLv2
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1818Plugin allowed to embed [RuTube](https://rutube.ru/) videos in WordPress.  Just specify the **uuid** of the playlist or video in the shortcode. You can also specify a list of **uuid** separated by commas.
    1919
    20 `[rutube id="{uuid}" title="" description="" sort="" perpage=""]`
     20`[rutube id="{uuid}" title="" description="" sort="" perpage="" limit="" mode="" ]`
    2121
    2222*   `id` - **uuid** of the video or playlist, or list of videos **uuid** separated by commas;
     
    2525*   `sort="on"`- sort playlist by ABC (default: `sort=""` - don't sort);
    2626*   `perpage` - number of items per page (default: *empty* - use plugin's settings);
    27 *   `mode` - mode of start  video on page load:
    28 *    `'preview'` - preview image,
    29 *    `'load'` - load video into the frame,
    30 *    `'play'` - load video into the frame and play,
    31 *    `''` (empty) - use plugin's settings (by default).
     27*   `limit` - playlist size limit (default: *empty* - use plugin's settings);
     28*   `mode` - mode of start video on page load:
     29*    `"preview"` - preview image,
     30*    `"load"` - load video into the frame,
     31*    `"play"` - load video into the frame and play,
     32*    `''` (*empty*) - use plugin's settings (by default).
    3233
    3334
    3435To embed a single video or playlist, just enter its URL (https://rutube.ru/video/{**uuid**}/ or https://rutube.ru/plst/{**uuid**}/) оn a separate line.
    3536
    36 You can paginate videos in playlists. Choose number of items per page in the settings. 0 (zero) - don't paginate (by default).
     37You can choose mode of start video on page load in settings and shortcode.
    3738
    38 You can set number of items per page for each playlist in shortcode.
     39То paginate playlist сhoose number of items per page in the settings or shortcode. 0 (zero) - don't paginate (by default).
     40
     41If the playlist size is very large, you can limit it with "Max playlist size" option in the settings or shortcode. 0 (zero) - not limited (by default).
    3942
    4043== Installation ==
     
    5659== Changelog ==
    5760
     61= 1.6.2 =
     62
     63* New plugin option and shortcode parameter: mode of start  video on page load.
     64
    5865= 1.6.1 =
    5966
     
    6269= 1.6 =
    6370
    64 * New plugin option and shortcode parameter: mode of start  video on page load.
     71* New plugin option and shortcode parameter: playlist size limit.
    6572
    6673= 1.5.1 =
Note: See TracChangeset for help on using the changeset viewer.