Plugin Directory

Changeset 2870073


Ignore:
Timestamp:
02/23/2023 02:53:30 PM (3 years ago)
Author:
RAD_
Message:

v0.8

Location:
simple-lazy-load-videos/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • simple-lazy-load-videos/trunk/includes/class-main.php

    r2862066 r2870073  
    3131            add_filter( 'oembed_dataparse', array( $this, 'change_oembed' ), 10, 3 );
    3232            add_action( 'save_post', array( $this, 'flush_oembed_cache' ), 10, 3 );
     33
     34            /** Add shortcodes */
     35            add_shortcode( 'sllv_video', array( $this, 'shortcode' ) );
    3336        }
    3437
     
    8184         */
    8285        function change_oembed( $return, $data, $url ) {
    83             $video = new SLLV_Template();
     86            $template = new SLLV_Template();
     87
    8488            if ( isset( $data->title ) ) {
    8589                $video_title = $data->title;
     
    9296                $video_id = $matches[1];
    9397
    94                 $return = $video->video( array(
     98                $return = $template->video( array(
    9599                    'provider'  => 'youtube',
    96100                    'title'     => $video_title,
     
    98102                    'url'       => 'https://youtu.be/' . $video_id,
    99103                    'thumbnail' => 'https://i.ytimg.com/vi/' . $video_id . '/' . $this->get_settings( 'youtube_thumbnail_size' ) . '.jpg',
    100                     'play'      => $video->youtube,
     104                    'play'      => $template->youtube,
    101105                ) );
    102             }
    103 
    104             if ( 'Vimeo' === $data->provider_name ) {
    105                 $return = $video->video( array(
     106            } elseif ( 'Vimeo' === $data->provider_name ) {
     107                $return = $template->video( array(
    106108                    'provider'  => 'vimeo',
    107109                    'title'     => $video_title,
     
    109111                    'url'       => 'https://vimeo.com/' . $data->video_id,
    110112                    'thumbnail' => substr( $data->thumbnail_url, 0, -3 ) . $this->get_settings( 'vimeo_thumbnail_size' ),
    111                     'play'      => $video->vimeo,
     113                    'play'      => $template->vimeo,
    112114                ) );
    113115            }
     
    125127        }
    126128
     129
     130        /**
     131         * Shortcode [sllv_video]
     132         */
     133        public function shortcode( $atts, $content ) {
     134            $atts = shortcode_atts( array(
     135
     136            ), $atts );
     137
     138            $template  = new SLLV_Template();
     139            $functions = new SLLV_Functions();
     140
     141            $video_url   = $content;
     142
     143            $determine_video = $functions->determine_video_url( $video_url );
     144
     145            if ( 'youtube' === $determine_video['type'] ) {
     146                $thumbnail = $functions->get_youtube_thumb( $determine_video['id'], $this->get_settings( 'youtube_thumbnail_size' ) );
     147                $play      = $template->youtube;
     148            } elseif ( 'vimeo' === $determine_video['type'] ) {
     149                $thumbnail = $functions->get_vimeo_thumb( $determine_video['id'] );
     150                $play      = $template->vimeo;
     151            }
     152
     153            $return = $template->video( array(
     154                'provider'  => $determine_video['type'],
     155                'title'     => __( 'Video', 'simple-lazy-load-videos' ),
     156                'id'        => $determine_video['id'],
     157                'url'       => $video_url,
     158                'thumbnail' => $thumbnail,
     159                'play'      => $play,
     160            ) );
     161
     162            return $return;
     163        }
     164
    127165    }
    128166}
  • simple-lazy-load-videos/trunk/languages/simple-lazy-load-videos.pot

    r2862066 r2870073  
    44"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    55"Project-Id-Version: Simple Lazy Load Videos\n"
    6 "POT-Creation-Date: 2023-02-08 14:28+0200\n"
     6"POT-Creation-Date: 2023-02-23 16:49+0200\n"
    77"PO-Revision-Date: 2020-01-08 15:52+0200\n"
    88"Last-Translator: \n"
     
    2222"X-Poedit-SearchPathExcluded-0: *.js\n"
    2323
    24 #: includes/class-main.php:87
     24#: includes/class-main.php:91 includes/class-main.php:155
    2525msgid "Video"
    2626msgstr ""
  • simple-lazy-load-videos/trunk/readme.txt

    r2866277 r2870073  
    33Tags: performance, video, vimeo, youtube
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=V5Q9SBB54LMDC&source=url
     5Requires at least: 5.0
    56Tested up to: 6.1.1
    67Requires PHP: 5.6
    7 Stable tag: 0.7.6
     8Stable tag: 0.8
    89License: GPLv2 or later
    910License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2324= How does this plugin work? =
    2425Instead of loading the iframe of your video on page load, it only loads the video preview image.
     26This will work automatically for all videos that have been inserted through the standard page editor.
     27= Is it possible to insert a video using a shortcode? =
     28Yes, you can use the `[sllv_video]` shortcode using a link to a YouTube or Vimeo video as its value, like:
     29
     30`[sllv_video]https://youtu.be/GywDFkY3z-c[/sllv_video]`
     31
     32= Can I embed a lazy loaded video into my template file? =
     33Yes, but you cannot insert a shortcode `[sllv_video]` into your template file directly.
     34You will need to pass the code into apply_shortcodes() function and display its output like this:
     35
     36`<?php echo apply_shortcodes( '[sllv_video]https://youtu.be/GywDFkY3z-c[/sllv_video]' ); ?>`
    2537
    2638== Screenshots ==
     
    2941
    3042== Changelog ==
     43= 0.8 =
     44* Add shortcode to display SLLV in theme templates
     45* Update Frequently Asked Questions
     46* Small code refactor
     47
    3148= 0.7.6 =
    3249* Fix editor styles
  • simple-lazy-load-videos/trunk/simple-lazy-load-videos.php

    r2866277 r2870073  
    44 * Plugin URI:        https://github.com/radkill/simple-lazy-load-videos
    55 * Description:       Simple Lazy Load for embedded video from Youtube and Vimeo
    6  * Version:           0.7.6
     6 * Version:           0.8
     7 * Requires at least: 5.0
    78 * Requires PHP:      5.6
    89 * Author:            Valerii Bohdanov
     
    5253require_once( SLLV_PATH . 'includes/class-template.php' );
    5354require_once( SLLV_PATH . 'includes/class-options.php' );
     55require_once( SLLV_PATH . 'includes/class-functions.php' );
    5456
    5557
Note: See TracChangeset for help on using the changeset viewer.