Plugin Directory

Changeset 2801917


Ignore:
Timestamp:
10/20/2022 01:49:40 PM (3 years ago)
Author:
VBog
Message:

Version 1.5

Location:
bg-rutube-embed
Files:
15 added
4 edited

Legend:

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

    r2801058 r2801917  
    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.4.4
     6    Version: 1.5
    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.4.4');
     41define('BG_RUTUBE_VERSION', '1.5');
    4242
    4343// Подключаем CSS и JS
     
    104104        'title' => '',
    105105        'description' => '',
    106         'sort' => ''
     106        'sort' => '',
     107        'perpage' => ''
    107108    ), $atts ) );
    108109
     
    125126            });
    126127        }   
    127         $quote = bg_rutube_playlist_show ( $playlist );   
     128        $quote = bg_rutube_playlist_show ( $playlist, $perpage );   
    128129    }
    129130    return $quote;
     
    305306       
    306307******************************************************************************************/
    307 function bg_rutube_playlist_show ( $playlist) {
     308function bg_rutube_playlist_show ( $playlist, $perpage = '') {
     309    static $id=999;
     310
    308311    // Выводим на экран
    309312    if (empty($playlist)) return "";
    310313    $val = get_option('bg_rutube_options');
    311314    $singular = $val ? $val['singular'] : false;
     315    if (empty($perpage) && $perpage != '0') $perpage = ($val && !empty($val['perpage'])) ? $val['perpage'] : 0;
    312316
    313317    ob_start();
    314318    if (is_singular() || !$singular) {
    315         $uuid = '_'. random_int(1000, 9999);
    316         $track = $playlist['tracks'][0];
     319        $id++;
     320        $uuid = '_'.$id;
     321       
     322        if ($perpage > 0) {
     323            if (isset($_GET['v'.$uuid])) $current_page = $_GET['v'.$uuid];
     324            else $current_page = 1;
     325            $track_no = ($current_page-1)*$perpage;
     326            $last_no = $current_page*$perpage;
     327            if ($last_no > $playlist['count']) $last_no = $playlist['count'];
     328            $total = ((int) $playlist['count']/$perpage)+1;
     329           
     330            $base_url = strtok(get_permalink(), '?');
     331            $args = [
     332                'base'         => $base_url.'%_%',
     333                'format'       => '?v'.$uuid.'=%#%#bg_rutube_playlistContainer'.$uuid,
     334                'total'        => $total,
     335                'current'      => $current_page,
     336                'prev_next'    => false,
     337                'type'         => 'list',
     338            ];
     339        } else {
     340            $track_no = 0;
     341            $last_no = $playlist['count'];
     342        }   
     343           
     344        $track = $playlist['tracks'][$track_no];
    317345        $thumbnail = $track['thumbnail'];
    318346   
    319347?>
    320 <div id="bg_rutube_playlistContainer<?php echo esc_attr($uuid); ?>" class="bg_rutube_playlistContainer" data-uuid="<?php echo esc_attr($uuid); ?>" data-movie="<?php echo esc_attr($playlist['tracks'][0]['uuid']); ?>">
     348<div id="bg_rutube_playlistContainer<?php echo esc_attr($uuid); ?>" class="bg_rutube_playlistContainer" data-uuid="<?php echo esc_attr($uuid); ?>" data-movie="<?php echo esc_attr($playlist['tracks'][$track_no]['uuid']); ?>">
    321349    <div class="bg_rutube_centerVideo">
    322350        <div id="bg_rutube_videoContainer<?php echo esc_attr($uuid); ?>" class="bg_rutube_videoContainer" style="background-image: url('<?php echo esc_url($track['thumbnail']); ?>');">
     
    340368    <div class="bg_rutube_videoPlayList">
    341369    <table class="bg_rutube_videoPlayListTable">
    342     <?php foreach ($playlist['tracks'] as $track): ?>
     370    <?php
     371    for (; $track_no < $last_no && $track_no < $playlist['count']; $track_no++) :
     372        $track = $playlist['tracks'][$track_no];
     373    ?>
     374   
    343375        <tr class="bg_rutube_showRuTubeVideoLink<?php echo esc_attr($uuid); ?>" title="<?php _e( 'Play', 'bg-rutube-embed'); ?>: <?php echo esc_html($track['title']);?>" data-movie="<?php echo esc_attr($track['uuid']); ?>">
    344376            <td style="background-image: url('<?php echo esc_url($track['thumbnail']); ?>');">
     
    351383            </td>
    352384        </tr>
    353     <?php endforeach; ?>
     385       
     386    <?php endfor; ?>
    354387    </table>
     388    <?php if ($perpage > 0) echo '<div class="bg_rutube_paginate">'.  paginate_links( $args ) .'</div>'; ?>
    355389    </div>
    356390<?php endif; ?>
  • bg-rutube-embed/trunk/css/bg_rutube.css

    r2790474 r2801917  
    120120}
    121121
     122/* ============================
     123PAGINATION BUTTONS
     124============================ */
     125.bg_rutube_paginate {
     126  text-align: center; }
     127  .bg_rutube_paginate ul {
     128    list-style: none;
     129    margin: 0;
     130    padding: 0;
     131    text-align: center; }
     132  .bg_rutube_paginate li {
     133    display: inline; }
     134  .bg_rutube_paginate a {
     135    border-radius: 3px;
     136    box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px;
     137    margin: 1px 2px;
     138    padding: 5px 10px;
     139    display: inline-block;
     140    border-top: 1px solid #fff;
     141    text-decoration: none;
     142    color: #717171;
     143    font-size: smaller;
     144    font-family: "Helvetica Neueu", Helvetica, Arial, sans-serif;
     145    text-shadow: white 0 1px 0;
     146    background-color: #f5f5f5;
     147    background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#eaeaea));
     148    background-image: -webkit-linear-gradient(top, #f9f9f9, #eaeaea);
     149    background-image: -moz-linear-gradient(top, #f9f9f9, #eaeaea);
     150    background-image: -ms-linear-gradient(top, #f9f9f9, #eaeaea);
     151    background-image: -o-linear-gradient(top, #f9f9f9, #eaeaea);
     152    background-image: linear-gradient(top, #f9f9f9, #eaeaea);
     153    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9', EndColorStr='#eaeaea'); }
     154    .bg_rutube_paginate a:first-child, .bg_rutube_paginate a.first {
     155      margin-left: 0; }
     156    .bg_rutube_paginate a:last-child, .bg_rutube_paginate a.last {
     157      margin-right: 0; }
     158    .bg_rutube_paginate a:hover, .bg_rutube_paginate a:focus {
     159      border-color: #fff;
     160      background-color: #fdfdfd;
     161      background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#fafafa));
     162      background-image: -webkit-linear-gradient(top, #fefefe, #fafafa);
     163      background-image: -moz-linear-gradient(top, #fefefe, #fafafa);
     164      background-image: -ms-linear-gradient(top, #fefefe, #fafafa);
     165      background-image: -o-linear-gradient(top, #fefefe, #fafafa);
     166      background-image: linear-gradient(top, #fefefe, #fafafa);
     167      filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#fefefe', EndColorStr='#fafafa'); }
     168    .bg_rutube_paginate a.more {
     169      box-shadow: 0 0 0 0 transparent;
     170      border: 0 none;
     171      background: transparent;
     172      margin-left: 0;
     173      margin-right: 0; }
     174    .bg_rutube_paginate a.current {
     175      box-shadow: rgba(0, 0, 0, 0.75) 0 0 0 0 inset;
     176      border-color: #505050;
     177      color: #f2f2f2;
     178      text-shadow: black 0 1px 0;
     179      background-color: #676767;
     180      background-image: -webkit-gradient(linear, left top, left bottom, from(#5f5f5f), to(#5c5c5c));
     181      background-image: -webkit-linear-gradient(top, #5f5f5f, #5c5c5c);
     182      background-image: -moz-linear-gradient(top, #5f5f5f, #5c5c5c);
     183      background-image: -ms-linear-gradient(top, #5f5f5f, #5c5c5c);
     184      background-image: -o-linear-gradient(top, #5f5f5f, #5c5c5c);
     185      background-image: linear-gradient(top, #5f5f5f, #5c5c5c);
     186      filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#5f5f5f', EndColorStr='#5c5c5c'); }
  • bg-rutube-embed/trunk/inc/options.php

    r2713422 r2801917  
    3939    add_settings_field('bg_rutube_field1', __('Videos on post pages only', 'bg-rutube-embed'), 'fill_bg_rutube_field1', 'bg_rutube_page', 'bg_rutube_section_id' );
    4040    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' );
     41    add_settings_field('bg_rutube_field5', __('Paginate videos', 'bg-rutube-embed'), 'fill_bg_rutube_field5', 'bg_rutube_page', 'bg_rutube_section_id' );
    4142}
    4243
     
    5960}
    6061
     62## Заполняем опцию 5
     63function fill_bg_rutube_field5(){
     64    $val = get_option('bg_rutube_options');
     65    $perpage = ($val && !empty($val['perpage'])) ? $val['perpage'] : 0;
     66    ?>
     67    <label><input type="number" id="perpage" name="bg_rutube_options[perpage]" value="<?php echo $perpage; ?>" min="0" style="width:5em;" /> <?php _e( 'per page<br>(0 - don\'t paginate)', 'bg-rutube-embed'); ?></label>
     68    <?php
     69}
     70
    6171## Очистка данных
    6272function bg_rutube_sanitize_callback( $options ){
  • bg-rutube-embed/trunk/readme.txt

    r2801058 r2801917  
    77Requires at least: 3.0.1
    88Tested up to: 6.0.3
    9 Stable tag: 1.4.4
     9Stable tag: 1.5
    1010License: GPLv2
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2323*   `title` - playlist title (for list of **uuid** only);
    2424*   `description` - playlist description (for list of **uuid** only);
    25 *   `sort="on"`- sort playlist by ABC (default: `sort=""` - don't sort).
     25*   `sort="on"`- sort playlist by ABC (default: `sort=""` - don't sort);
     26*   `perpage` - number of items per page (default: 0 (zero) - don't paginate).
    2627
    2728To 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.
    2829
     30You can paginate videos in playlists. Choose number of items per page in the settings. 0 (zero) - don't paginate (by default).
     31
     32You can set number of items per page for each playlist in shortcode.
    2933
    3034== Installation ==
     
    4549
    4650== Changelog ==
     51
     52= 1.5 =
     53
     54* Pagination video in playlists.
    4755
    4856= 1.4.4 =
Note: See TracChangeset for help on using the changeset viewer.