Plugin Directory

Changeset 2143715


Ignore:
Timestamp:
08/22/2019 12:28:17 PM (7 years ago)
Author:
2plus2is4
Message:

0.7

  • Freemius added
  • No content on the page bug fixed
  • CSS classes changed
  • Text and new play button added
  • Vimeo support in premium plan added
Location:
simple-youtube-gdpr
Files:
411 added
4 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • simple-youtube-gdpr/trunk/README.txt

    r2084315 r2143715  
    1 === Simple YouTube GDPR ===
     1===  WordPress YouTube and Vimeo videos security Plugin (GDPR) ===
    22Contributors: 2plus2is4
    33Donate link: https://money.yandex.ru/to/41001417963743
    4 Tags: iframe, youtube, gdpr
     4Tags: iframe, YouTube, GDPR, Vimeo, thumbnails, Consent, Compliance
    55Requires at least: 5.0.1
    6 Tested up to: 5.2
    7 Stable tag: 0.6
     6Tested up to: 5.2.2
     7Stable tag: 0.7
    88Requires PHP: 5.2.4
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Replaces all YouTube video iframes with a local image and loads a no cookie version of video.
     12Integrate YouTube and Vimeo videos securely!
    1313
    1414== Description ==
    1515
    16 Finds all YouTube videos in Posts and Pages and replaces them with a local static image (video thumbnail)
     16Simple YouTube GDPR automatically detects and blocks Iframes from YouTube and Vimeo. Only with a click by the visitor the content is loaded.
     17
     18Simple YouTube GDPR automatically saves YouTube and Vimeo thumbnails locally without the visitor's IP address being transmitted to the video platform.
     19
     20![Plays Vimeo Video](https://alexeyvolkov.com/images/syg.gif)
    1721
    1822Features:
    1923
    20 *   No YouTube Cookies
     24*   Google gets NO cookies
    2125*   No content changes required
    2226*   Allows you to keep YouTube videos under GDPR law
    2327
     28== Want more? ==
     29If you enjoy this plugin and you want your other content to be safe, consider purchasing the [premium version](https://checkout.freemius.com/mode/dialog/plugin/4426/plan/7118/).
     30
     31= Premium features =
     32* Integrate Vimeo videos securely!
     33
    2434== Installation ==
     351. Go to “plugins” in your Wordpress Dashboard, and click “add new”.
     361. Click “upload”, and select the downloaded zip file.
    2537
    26 1. Upload the plugin files to the `/wp-content/plugins/simple-youtube-gdpr` directory, or install the plugin through the WordPress plugins screen directly.
    27 1. Activate the plugin through the 'Plugins' menu in WordPress
     381. Activate.
    28391. Enjoy!
    2940
     
    3243= Does 'Local' mean my server downloads all the images? =
    3344
    34 Yes. Probably you can find a folder `/wp-content/uploads/simple-youtube-gdpr-thumbnails` with all the images inside
     45Yes. Usually you can find a folder `/wp-content/uploads/simple-youtube-gdpr-thumbnails` with all the images inside
    3546
    3647= Does youtube send cookies? =
     
    4960
    5061Yes. Class:
    51 * `youtube_lazyload` - main wrapping `<div>`
    52 * `youtube_lazyload__img` - the thumbnail
    53 * `youtube_lazyload__play` - thumbnail play button
    54 * `youtube_lazyload__iframe` - youtube `<iframe>`
     62* `syg__box` - main wrapping `<div>` (`syg__box-%SERVICE%` where `%SERVICE%` can be youtube or vimeo)
     63* `syg__box__img` - the thumbnail
     64* `syg__box__text__btn` - thumbnail play button
     65* `syg__box-youtube-iframe` - video `<iframe>` (where `%SERVICE%` can be youtube or vimeo)
    5566
    5667= What are standard width and height of iframe? =
     
    65761. Apply scripts so that if user clicks iframe appears
    6677
     78== Screenshots ==
     79
     80Integrate YouTube and Vimeo videos securely!
     81
     821. YouTube video is replaced with a static preview image and a play button.
     83
    6784== Changelog ==
     85
     86= 0.7 =
     87
     88* CSS classes were changed
    6889
    6990= 0.6 =
     
    7495== Upgrade Notice ==
    7596
     97= 0.7 =
     98* No content on the page bug is fixed.
     99* New design of play button
     100* Consent Text is added
    76101= 0.6 =
    77 Twenty Nineteen theme bug fixed. It replace the whole WordPress <figure> tag with an image.
     102Twenty Nineteen theme bug is fixed. It replaces the whole WordPress <figure> tag with an image.
  • simple-youtube-gdpr/trunk/includes/class-simple-youtube-gdpr.php

    r2080878 r2143715  
    7171            $this->version = SIMPLE_YOUTUBE_GDPR_VERSION;
    7272        } else {
    73             $this->version = '0.6';
     73            $this->version = '0.7';
    7474        }
    7575        $this->plugin_name = 'simple-youtube-gdpr';
  • simple-youtube-gdpr/trunk/languages/simple-youtube-gdpr-de_DE.po

    r2072368 r2143715  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: \n"
    4 "POT-Creation-Date: \n"
    5 "PO-Revision-Date: \n"
     3"Project-Id-Version: Simple YouTube GDPR\n"
     4"POT-Creation-Date: 2019-08-22 15:02+0300\n"
     5"PO-Revision-Date: 2019-08-22 15:03+0300\n"
     6"Last-Translator: \n"
    67"Language-Team: \n"
     8"Language: de_DE\n"
    79"MIME-Version: 1.0\n"
    810"Content-Type: text/plain; charset=UTF-8\n"
    911"Content-Transfer-Encoding: 8bit\n"
    10 "X-Generator: Poedit 2.2.1\n"
    11 "Last-Translator: Alexey Volkov <[email protected]>\n"
     12"X-Generator: Poedit 2.0.7\n"
     13"X-Poedit-Basepath: ..\n"
    1214"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    13 "Language: de\n"
     15"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
     16"X-Poedit-WPHeader: simple-youtube-gdpr.php\n"
     17"X-Poedit-SourceCharset: UTF-8\n"
     18"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
     19"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
     20"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
     21"X-Poedit-SearchPath-0: .\n"
     22"X-Poedit-SearchPathExcluded-0: *.js\n"
    1423
    15 #: /public/class-simple-youtube-gdpr-public.php:200
     24#: public/class-simple-youtube-gdpr-public.php:221
    1625msgid "Click to Play Video"
    1726msgstr "Anklicken um abzuspielen"
    1827
    19 #: /public/class-simple-youtube-gdpr-public.php:201
     28#: public/class-simple-youtube-gdpr-public.php:222
    2029msgid "YouTube Video Thumbnail"
    2130msgstr "YouTube Video Miniaturansicht"
     31
     32#: public/class-simple-youtube-gdpr-public.php:225
     33msgid "By loading the video, you agree to YouTube's privacy policy."
     34msgstr ""
     35"Durch das Laden des Videos stimmst du den Datenschutzbestimmungen von "
     36"YouTube zu."
     37
     38#: public/class-simple-youtube-gdpr-public.php:227
     39#, fuzzy
     40#| msgid "https://policies.google.com/privacy?hl=en&amp;gl=en"
     41msgid "https://policies.google.com/privacy?hl=en"
     42msgstr "https://policies.google.com/privacy?hl=de"
     43
     44#: public/class-simple-youtube-gdpr-public.php:228
     45#: public/class-simple-youtube-gdpr-public.php:257
     46msgid "Learn more"
     47msgstr "Google-Datenschutzerklärung"
     48
     49#: public/class-simple-youtube-gdpr-public.php:231
     50#: public/class-simple-youtube-gdpr-public.php:260
     51msgid "Load video"
     52msgstr "Video laden"
     53
     54#: public/class-simple-youtube-gdpr-public.php:254
     55#, fuzzy
     56#| msgid "By loading the video, you agree to YouTube's privacy policy."
     57msgid "By loading the video, you agree to Vimeo's privacy policy."
     58msgstr ""
     59"Durch das Laden des Videos stimmst du den Datenschutzbestimmungen von "
     60"YouTube zu."
     61
     62#: public/class-simple-youtube-gdpr-public.php:256
     63#, fuzzy
     64#| msgid "https://policies.google.com/privacy?hl=en&amp;gl=en"
     65msgid "https://vimeo.com/privacy"
     66msgstr "https://policies.google.com/privacy?hl=de"
     67
     68#: simple-youtube-gdpr.php:101
     69msgid "Click to Upgrade your plan"
     70msgstr "Klicken Sie hier, um Ihren Plan zu aktualisieren"
     71
     72#: simple-youtube-gdpr.php:101
     73msgid "Get Vimeo Blocker!"
     74msgstr "Holen Sie sich Vimeo Blocker!"
     75
     76#. Plugin Name of the plugin/theme
     77msgid "Simple YouTube GDPR"
     78msgstr "Simple YouTube GDPR"
     79
     80#. Plugin URI of the plugin/theme
     81msgid "https://alexeyvolkov.com/blog/simple-youtube-gdpr"
     82msgstr "https://alexeyvolkov.com/blog/simple-youtube-gdpr"
     83
     84#. Description of the plugin/theme
     85msgid "Integrate YouTube and Vimeo videos securely!"
     86msgstr "Integrieren Sie YouTube- und Vimeo-Videos sicher!"
     87
     88#. Author of the plugin/theme
     89msgid "Alexey Volkov"
     90msgstr "Alexey Volkov"
     91
     92#. Author URI of the plugin/theme
     93msgid "https://alexeyvolkov.com/"
     94msgstr "https://alexeyvolkov.com/"
     95
     96#~ msgid ""
     97#~ "Replaces all YouTube video iframes with a local image and loads a no "
     98#~ "cookie version of video."
     99#~ msgstr ""
     100#~ "Ersetzt alle YouTube-Video-Iframes durch ein lokales Bild und lädt eine "
     101#~ "No-Cookie-Version des Videos."
  • simple-youtube-gdpr/trunk/languages/simple-youtube-gdpr-ru_RU.po

    r2072368 r2143715  
    11msgid ""
    22msgstr ""
    3 "Project-Id-Version: \n"
    4 "POT-Creation-Date: \n"
    5 "PO-Revision-Date: \n"
     3"Project-Id-Version: Simple YouTube GDPR\n"
     4"POT-Creation-Date: 2019-08-22 15:03+0300\n"
     5"PO-Revision-Date: 2019-08-22 15:05+0300\n"
     6"Last-Translator: \n"
    67"Language-Team: \n"
     8"Language: ru_RU\n"
    79"MIME-Version: 1.0\n"
    810"Content-Type: text/plain; charset=UTF-8\n"
    911"Content-Transfer-Encoding: 8bit\n"
    10 "X-Generator: Poedit 2.2.1\n"
    11 "Last-Translator: Alexey Volkov <[email protected]>\n"
    12 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
    13 "Language: ru\n"
     12"X-Generator: Poedit 2.0.7\n"
     13"X-Poedit-Basepath: ..\n"
     14"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
     15"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
     16"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
     17"X-Poedit-WPHeader: simple-youtube-gdpr.php\n"
     18"X-Poedit-SourceCharset: UTF-8\n"
     19"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
     20"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
     21"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
     22"X-Poedit-SearchPath-0: .\n"
     23"X-Poedit-SearchPathExcluded-0: *.js\n"
    1424
    15 #: /public/class-simple-youtube-gdpr-public.php:200
     25#: public/class-simple-youtube-gdpr-public.php:221
    1626msgid "Click to Play Video"
    1727msgstr "Нажмите для запуска видео"
    1828
    19 #: /public/class-simple-youtube-gdpr-public.php:201
     29#: public/class-simple-youtube-gdpr-public.php:222
    2030msgid "YouTube Video Thumbnail"
    2131msgstr "Миниатюра YouTube видео"
     32
     33#: public/class-simple-youtube-gdpr-public.php:225
     34msgid "By loading the video, you agree to YouTube's privacy policy."
     35msgstr ""
     36"Загружая видео, вы соглашаетесь с политикой конфиденциальности YouTube."
     37
     38#: public/class-simple-youtube-gdpr-public.php:227
     39#, fuzzy
     40#| msgid "https://policies.google.com/privacy?hl=en&amp;gl=en"
     41msgid "https://policies.google.com/privacy?hl=en"
     42msgstr "https://policies.google.com/privacy?hl=ru"
     43
     44#: public/class-simple-youtube-gdpr-public.php:228
     45#: public/class-simple-youtube-gdpr-public.php:257
     46msgid "Learn more"
     47msgstr "Политика конфиденциальности Google"
     48
     49#: public/class-simple-youtube-gdpr-public.php:231
     50#: public/class-simple-youtube-gdpr-public.php:260
     51msgid "Load video"
     52msgstr "Запустить видео"
     53
     54#: public/class-simple-youtube-gdpr-public.php:254
     55#, fuzzy
     56#| msgid "By loading the video, you agree to YouTube's privacy policy."
     57msgid "By loading the video, you agree to Vimeo's privacy policy."
     58msgstr ""
     59"Загружая видео, вы соглашаетесь с политикой конфиденциальности YouTube."
     60
     61#: public/class-simple-youtube-gdpr-public.php:256
     62#, fuzzy
     63#| msgid "https://policies.google.com/privacy?hl=en&amp;gl=en"
     64msgid "https://vimeo.com/privacy"
     65msgstr "https://policies.google.com/privacy?hl=ru"
     66
     67#: simple-youtube-gdpr.php:101
     68msgid "Click to Upgrade your plan"
     69msgstr "Нажмите, чтобы обновить план"
     70
     71#: simple-youtube-gdpr.php:101
     72msgid "Get Vimeo Blocker!"
     73msgstr "Vimeo блокировщик!"
     74
     75#. Plugin Name of the plugin/theme
     76msgid "Simple YouTube GDPR"
     77msgstr "Блокировщик YouTube видео"
     78
     79#. Plugin URI of the plugin/theme
     80msgid "https://alexeyvolkov.com/blog/simple-youtube-gdpr"
     81msgstr "https://alexeyvolkov.com/blog/simple-youtube-gdpr"
     82
     83#. Description of the plugin/theme
     84msgid "Integrate YouTube and Vimeo videos securely!"
     85msgstr "Вставляйте YouTube и Vimeo видео абсолютно безопасно!"
     86
     87#. Author of the plugin/theme
     88msgid "Alexey Volkov"
     89msgstr "Алексей Волков"
     90
     91#. Author URI of the plugin/theme
     92msgid "https://alexeyvolkov.com/"
     93msgstr "https://alexeyvolkov.com/"
     94
     95#~ msgid ""
     96#~ "Replaces all YouTube video iframes with a local image and loads a no "
     97#~ "cookie version of video."
     98#~ msgstr ""
     99#~ "Заменяет YouTube iframe локальным изображением и загружает версию видео "
     100#~ "без файлов cookie."
  • simple-youtube-gdpr/trunk/languages/simple-youtube-gdpr.pot

    r2072368 r2143715  
    66msgid "YouTube Video Thumbnail"
    77msgstr ""
     8
     9#: /public/class-simple-youtube-gdpr-public.php:202
     10msgid "By loading the video, you agree to YouTube's privacy policy."
     11msgstr ""
     12
     13#: /public/class-simple-youtube-gdpr-public.php:203
     14msgid "https://policies.google.com/privacy?hl=en&amp;gl=en"
     15msgstr ""
     16
     17#: /public/class-simple-youtube-gdpr-public.php:203
     18msgid "Learn more"
     19msgstr ""
     20
     21#: /public/class-simple-youtube-gdpr-public.php:204
     22msgid "Load video"
     23msgstr ""
  • simple-youtube-gdpr/trunk/public/class-simple-youtube-gdpr-public.php

    r2080878 r2143715  
    1010 * @subpackage Simple_Youtube_Gdpr/public
    1111 */
    12 
    1312/**
    1413 * The public-facing functionality of the plugin.
     
    2120 * @author     Alexey Volkov <[email protected]>
    2221 */
    23 class Simple_Youtube_Gdpr_Public {
     22class Simple_Youtube_Gdpr_Public
     23{
     24    /**
     25     * The ID of this plugin.
     26     *
     27     * @since    0.6
     28     * @access   private
     29     * @var      string $plugin_name The ID of this plugin.
     30     */
     31    private  $plugin_name ;
     32    /**
     33     * The version of this plugin.
     34     *
     35     * @since    0.6
     36     * @access   private
     37     * @var      string $version The current version of this plugin.
     38     */
     39    private  $version ;
     40    /**
     41     * Initialize the class and set its properties.
     42     *
     43     * @param string $plugin_name The name of the plugin.
     44     * @param string $version The version of this plugin.
     45     *
     46     * @since    0.6
     47     *
     48     */
     49    public function __construct( $plugin_name, $version )
     50    {
     51        $this->plugin_name = $plugin_name;
     52        $this->version = $version;
     53    }
     54   
     55    /**
     56     * Register the stylesheets for the public-facing side of the site.
     57     *
     58     * @since    0.6
     59     */
     60    public function enqueue_styles()
     61    {
     62        /**
     63         * This function is provided for demonstration purposes only.
     64         *
     65         * An instance of this class should be passed to the run() function
     66         * defined in Simple_Youtube_Gdpr_Loader as all of the hooks are defined
     67         * in that particular class.
     68         *
     69         * The Simple_Youtube_Gdpr_Loader will then create the relationship
     70         * between the defined hooks and the functions defined in this
     71         * class.
     72         */
     73        wp_enqueue_style(
     74            $this->plugin_name,
     75            plugin_dir_url( __FILE__ ) . 'css/simple-youtube-gdpr-public.css',
     76            array(),
     77            $this->version,
     78            'all'
     79        );
     80    }
     81   
     82    /**
     83     * Register the JavaScript for the public-facing side of the site.
     84     *
     85     * @since    0.6
     86     */
     87    public function enqueue_scripts()
     88    {
     89        /**
     90         * This function is provided for demonstration purposes only.
     91         *
     92         * An instance of this class should be passed to the run() function
     93         * defined in Simple_Youtube_Gdpr_Loader as all of the hooks are defined
     94         * in that particular class.
     95         *
     96         * The Simple_Youtube_Gdpr_Loader will then create the relationship
     97         * between the defined hooks and the functions defined in this
     98         * class.
     99         */
     100        wp_enqueue_script(
     101            $this->plugin_name,
     102            plugin_dir_url( __FILE__ ) . 'js/simple-youtube-gdpr-public.js',
     103            array( 'jquery' ),
     104            $this->version,
     105            false
     106        );
     107    }
     108   
     109    /**
     110     * Filter the Content of pages and posts
     111     * LazyLoad youtube videos
     112     *
     113     * @param string $content Original HTML.
     114     *
     115     * @return string $content
     116     */
     117    public function filter_content( $content )
     118    {
     119        $content = $this->lazyloadIframes( $content );
     120        return $content;
     121    }
     122   
     123    /**
     124     * Finds iframes in the HTML provided and call the methods to lazyload them
     125     *
     126     * @param string $html Original HTML.
     127     *
     128     * @return string
     129     */
     130    private function lazyloadIframes( $html, $container = 'figure.wp-block-embed-youtube' )
     131    {
     132        $html = str_get_html( $html );
     133        // get html dom from string
     134       
     135        if ( empty($html) ) {
     136            return false;
     137            // there are no elements
     138        }
     139       
     140        /**
     141         * YouTube
     142         */
     143        foreach ( $html->find( $container ) as $figure ) {
     144            // find youtube embed blocks
     145            if ( '' === trim( $figure->innertext ) ) {
     146                // if empty -> next item
     147                continue;
     148            }
     149            foreach ( $figure->find( 'iframe' ) as $iframe ) {
     150                if ( '' === trim( $iframe->src ) ) {
     151                    // if empty -> next item
     152                    continue;
     153                }
     154                try {
     155                    $imgHTML = $this->getThumbnail( $iframe->outertext );
     156                    // send <iframe> and get <div.syg__box> <img> </div>
     157                    $imgDiv = str_get_html( $imgHTML );
     158                    // from raw HTML to Node Object
     159                    $iframe = $imgDiv->find( 'div.syg__box' )[0];
     160                    // Find the only one(first) div.syg__box
     161                } catch ( Exception $e ) {
     162                    continue;
     163                }
     164            }
     165            // Replace <figure> with <img>
     166            if ( !$iframe->class ) {
     167                // if no class -> create
     168                $iframe->class = '';
     169            }
     170            $iframe->class = $iframe->class . ' ' . $figure->class;
     171            // syg__box wp-block-embed-youtube
     172            $figure->outertext = $iframe->outertext;
     173        }
     174        // is__premium_only
     175        return $html->outertext;
     176    }
     177   
     178    /**
     179     * Replaces the iframe provided by the Youtube thumbnail
     180     *
     181     * @param array $iframe Array of matched elements.
     182     *
     183     * @return bool|string
     184     */
     185    private function getThumbnail( $iframeHTML, $type = 'youtube' )
     186    {
     187        $iframeHTML = str_get_html( $iframeHTML );
     188        $iframe = $iframeHTML->find( 'iframe' )[0];
     189        // Find the only one(first) iframe
     190        $upload_dir = wp_upload_dir();
     191        // wp_upload_dir()[baseurl] => http://example.com/content/uploads
     192        switch ( $type ) {
     193            case 'youtube':
     194                $youtube_id = esc_html( $this->getIDFromURL( $iframe->src ) );
     195                // get YouTube ID (fM6JWeQFnNk)
     196                if ( !$youtube_id ) {
     197                    return false;
     198                }
     199                if ( !$this->isThumbnailExists( $youtube_id ) ) {
     200                    $this->save_local_thumbnail( $youtube_id );
     201                }
     202                $youtube_lazyload = '<div class="syg__box syg__box-youtube">' . '<img src="' . $upload_dir['baseurl'] . '/simple-youtube-gdpr-thumbnails/' . md5( $youtube_id ) . '.jpg" title="' . esc_html( __( 'Click to Play Video', 'simple-youtube-gdpr' ) ) . '" class="syg__box__img" id="' . $youtube_id . '" alt="' . esc_html( __( 'YouTube Video Thumbnail', 'simple-youtube-gdpr' ) ) . '" decoding="async" referrerpolicy="no-referrer">' . '<div class="syg__box__text">' . '<p> ' . esc_html( __( 'By loading the video, you agree to YouTube\'s privacy policy.', 'simple-youtube-gdpr' ) ) . '<br > ' . '<a href = "' . esc_html( __( 'https://policies.google.com/privacy?hl=en', 'simple-youtube-gdpr' ) ) . '" target="_blank" rel="noopener" > ' . esc_html( __( 'Learn more', 'simple-youtube-gdpr' ) ) . '</a > ' . '</p > ' . '<p ><a class="syg__box__text__btn" role = "button" > ' . esc_html( __( 'Load video', 'simple-youtube-gdpr' ) ) . '</a ></p > ' . '</div > ' . '</div > ';
     203                // .syg__box
     204                return $youtube_lazyload;
     205                break;
     206            case 'vimeo':
     207                break;
     208        }
     209        return false;
     210    }
     211   
     212    /**
     213     * Gets the Video ID from the URL provided
     214     *
     215     * @param string $url URL to search.
     216     *
     217     * @return bool|string
     218     */
     219    private function getIDFromURL( $url, $type = 'youtube' )
     220    {
     221        switch ( $type ) {
     222            case 'vimeo':
     223                break;
     224            default:
     225                $pattern = '#^(?:https?:)?(?://)?(?:www\\.)?(?:youtu\\.be|youtube\\.com|youtube-nocookie\\.com)/(?:embed/|v/|watch/?\\?v=)?([\\w-]{11})#iU';
     226                break;
     227        }
     228        $result = preg_match( $pattern, $url, $matches );
     229        if ( !$result ) {
     230            return false;
     231        }
     232        switch ( $type ) {
     233            case 'vimeo':
     234                break;
     235            default:
     236                // exclude YouTube playlist.
     237                if ( 'youtube' == $type && 'videoseries' === $matches[1] ) {
     238                    return false;
     239                }
     240                return $matches[1];
     241                break;
     242        }
     243        return '';
     244        // never reach this point
     245    }
     246   
     247    /**
     248     * Checks if youtube video thumbnail already exists
     249     *
     250     * @param int $video_id Video ID.
     251     *
     252     * @return bool
     253     */
     254    private function isThumbnailExists( $video_id )
     255    {
     256        $youtube_id = esc_html( $video_id );
     257        $upload_dir = wp_upload_dir();
     258        return file_exists( $upload_dir['basedir'] . '/simple-youtube-gdpr-thumbnails/' . md5( $video_id ) . '.jpg' );
     259    }
     260   
     261    /**
     262     * Loads youtube video thumbnail from img.youtube.com
     263     *
     264     * First it tries to upload a SD quality -> HQ -> Default one
     265     *
     266     * @param int $video_id YouTube ID.
     267     *
     268     * @return void
     269     */
     270    private function save_local_thumbnail( $video_id, $type = 'youtube' )
     271    {
     272        switch ( $type ) {
     273            case 'vimeo':
     274                break;
     275            default:
     276                $video_id = esc_html( $video_id );
     277                $image_url_sddefault = 'https://img.youtube.com/vi/' . $video_id . '/sddefault.jpg';
     278                $image_url_hqdefault = 'https://img.youtube.com/vi/' . $video_id . '/hqdefault.jpg';
     279                $image_url_default = 'https://img.youtube.com/vi/' . $video_id . '/default.jpg';
     280                if ( !($image_data = file_get_contents( $image_url_sddefault )) ) {
     281                    if ( !($image_data = file_get_contents( $image_url_hqdefault )) ) {
     282                        $image_data = file_get_contents( $image_url_default );
     283                    }
     284                }
     285                break;
     286        }
     287        $upload_dir = wp_upload_dir();
     288        // wp_upload_dir()[baseurl] => http://example.com/content/uploads
     289        $upload_dir['path'] = $upload_dir['basedir'] . '/simple-youtube-gdpr-thumbnails/';
     290        // Set upload folder
     291        $image_name = md5( $video_id ) . '.jpg';
     292        // Make it MD5 -> so all (_!@#$%^)(*&) symbols are sanitized
     293        $unique_file_name = wp_unique_filename( $upload_dir['path'], $image_name );
     294        // Generate unique name
     295        $filename = basename( $unique_file_name );
     296        // Create image file name.
     297        // Check folder permission and define file location
     298       
     299        if ( wp_mkdir_p( $upload_dir['path'] ) ) {
     300            $file = $upload_dir['path'] . '/' . $filename;
     301        } else {
     302            $file = $upload_dir['basedir'] . '/' . $filename;
     303        }
     304       
     305        // Create the image  file on the server
     306        file_put_contents( $file, $image_data );
     307    }
    24308
    25     /**
    26      * The ID of this plugin.
    27      *
    28      * @since    0.6
    29      * @access   private
    30      * @var      string $plugin_name The ID of this plugin.
    31      */
    32     private $plugin_name;
    33 
    34     /**
    35      * The version of this plugin.
    36      *
    37      * @since    0.6
    38      * @access   private
    39      * @var      string $version The current version of this plugin.
    40      */
    41     private $version;
    42 
    43     /**
    44      * Initialize the class and set its properties.
    45      *
    46      * @since    0.6
    47      *
    48      * @param      string $plugin_name The name of the plugin.
    49      * @param      string $version The version of this plugin.
    50      */
    51     public function __construct( $plugin_name, $version ) {
    52 
    53         $this->plugin_name = $plugin_name;
    54         $this->version     = $version;
    55 
    56     }
    57 
    58     /**
    59      * Register the stylesheets for the public-facing side of the site.
    60      *
    61      * @since    0.6
    62      */
    63     public function enqueue_styles() {
    64 
    65         /**
    66          * This function is provided for demonstration purposes only.
    67          *
    68          * An instance of this class should be passed to the run() function
    69          * defined in Simple_Youtube_Gdpr_Loader as all of the hooks are defined
    70          * in that particular class.
    71          *
    72          * The Simple_Youtube_Gdpr_Loader will then create the relationship
    73          * between the defined hooks and the functions defined in this
    74          * class.
    75          */
    76 
    77         wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/simple-youtube-gdpr-public.css',
    78             array(), $this->version, 'all' );
    79 
    80         // Adds custom CSS
    81         $custom_css = "
    82                 .youtube_lazyload__play{
    83                         background: url('" . plugin_dir_url( __FILE__ ) . "img/youtube.png') no-repeat;
    84                 }";
    85         wp_add_inline_style( $this->plugin_name, $custom_css );
    86     }
    87 
    88     /**
    89      * Register the JavaScript for the public-facing side of the site.
    90      *
    91      * @since    0.6
    92      */
    93     public function enqueue_scripts() {
    94 
    95         /**
    96          * This function is provided for demonstration purposes only.
    97          *
    98          * An instance of this class should be passed to the run() function
    99          * defined in Simple_Youtube_Gdpr_Loader as all of the hooks are defined
    100          * in that particular class.
    101          *
    102          * The Simple_Youtube_Gdpr_Loader will then create the relationship
    103          * between the defined hooks and the functions defined in this
    104          * class.
    105          */
    106 
    107         wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/simple-youtube-gdpr-public.js',
    108             array( 'jquery' ), $this->version, false );
    109 
    110     }
    111 
    112     /**
    113      * Filter the Content of pages and posts
    114      * LazyLoad youtube videos
    115      *
    116      * @param string $content Original HTML.
    117      *
    118      * @return string $content
    119      */
    120     public function filter_content( $content ) {
    121         if ( is_single() || is_page() ) {
    122             $content = $this->lazyloadIframes( $content );
    123         }
    124 
    125         return $content;
    126     }
    127 
    128     /**
    129      * Finds iframes in the HTML provided and call the methods to lazyload them
    130      *
    131      * @param string $html Original HTML.
    132      *
    133      * @return string
    134      */
    135     private function lazyloadIframes( $html, $container = 'figure.wp-block-embed-youtube' ) {
    136         $html = str_get_html( $html );
    137         foreach ( $html->find( $container ) as $figure ) {
    138             if ( '' === trim( $figure->innertext ) ) {// if empty -> next item
    139                 continue;
    140             }
    141 
    142             foreach ( $figure->find( 'iframe' ) as $iframe ) {
    143                 if ( '' === trim( $iframe->src ) ) {// if empty -> next item
    144                     continue;
    145                 }
    146                 $imgHTML = $this->getThumbnail( $iframe->outertext );// send <iframe> and get <div.youtube_lazyload> <img> </div>
    147                 $imgDiv  = str_get_html( $imgHTML );// from raw HTML to Node Object
    148                 $iframe  = $imgDiv->find( 'div.youtube_lazyload' )[0];// Find the only one(first) div.youtube_lazyload
    149             }
    150 
    151             // Replace <figure> with <img>
    152             if ( ! $iframe->class ) {// if no class -> create
    153                 $iframe->class = '';
    154             }
    155             $iframe->class     = $iframe->class . ' ' . $figure->class;
    156             $figure->outertext = $iframe->outertext;
    157         }
    158 
    159         return $html->outertext;
    160     }
    161 
    162     /**
    163      * Replaces the iframe provided by the Youtube thumbnail
    164      *
    165      * @param array $iframe Array of matched elements.
    166      *
    167      * @return bool|string
    168      */
    169     private function getThumbnail( $iframeHTML ) {
    170         $iframeHTML = str_get_html( $iframeHTML );
    171         $iframe     = $iframeHTML->find( 'iframe' )[0];// Find the only one(first) iframe
    172         $youtube_id = esc_html( $this->getYoutubeIDFromURL( $iframe->src ) );// get YouTube ID (fM6JWeQFnNk)
    173 
    174         if ( ! $youtube_id ) {
    175             return false;
    176         }
    177         if ( ! $this->isThumbnailExists( $youtube_id ) ) {
    178             $this->save_local_thumbnail( $youtube_id );
    179         }
    180 
    181         /**
    182          * Array
    183          * (
    184          * [path] => C:\development\xampp\htdocs\example.com/content/uploads/2012/04
    185          * [url] => http://example.com/content/uploads/2012/04
    186          * [subdir] => /2012/04
    187          * [basedir] => C:\~\example.com/content/uploads
    188          * [baseurl] => http://example.com/content/uploads
    189          * [error] =>
    190          * )
    191          */
    192         $upload_dir       = wp_upload_dir();
    193         $youtube_lazyload = '<div class="youtube_lazyload"><img src="' . $upload_dir['baseurl'] . '/simple-youtube-gdpr-thumbnails/' . md5( $youtube_id ) . '.jpg" title="' . __( 'Click to Play Video',
    194                 'simple-youtube-gdpr' ) . '" class="youtube_lazyload__img" id="' . $youtube_id . '" alt="' . __( 'YouTube Video Thumbnail',
    195                 'simple-youtube-gdpr' ) . '" decoding="async" referrerpolicy="no-referrer"><div class="youtube_lazyload__play"></div></div>';
    196 
    197         return $youtube_lazyload;
    198     }
    199 
    200     /**
    201      * Gets the Youtube ID from the URL provided
    202      *
    203      * @param string $url URL to search.
    204      *
    205      * @return bool|string
    206      */
    207     private function getYoutubeIDFromURL( $url ) {
    208         $pattern = '#^(?:https?:)?(?://)?(?:www\.)?(?:youtu\.be|youtube\.com|youtube-nocookie\.com)/(?:embed/|v/|watch/?\?v=)?([\w-]{11})#iU';
    209         $result  = preg_match( $pattern, $url, $matches );
    210 
    211         if ( ! $result ) {
    212             return false;
    213         }
    214 
    215         // exclude playlist.
    216         if ( 'videoseries' === $matches[1] ) {
    217             return false;
    218         }
    219 
    220         return $matches[1];
    221     }
    222 
    223     /**
    224      * Checks if youtube video thumbnail already exists
    225      *
    226      * @param int $youtube_id YouTube ID.
    227      *
    228      * @return bool
    229      */
    230     private function isThumbnailExists( $youtube_id ) {
    231         $youtube_id = esc_html( $youtube_id );
    232         $upload_dir = wp_upload_dir();
    233 
    234         return file_exists( $upload_dir['basedir'] . '/simple-youtube-gdpr-thumbnails/' . md5( $youtube_id ) . '.jpg' );
    235     }
    236 
    237     /**
    238      * Loads youtube video thumbnail from img.youtube.com
    239      *
    240      * First it tries to upload a SD quality -> HQ -> Default one
    241      *
    242      * @param int $youtube_id YouTube ID.
    243      *
    244      * @return void
    245      */
    246     private function save_local_thumbnail( $youtube_id ) {
    247         $youtube_id          = esc_html( $youtube_id );
    248         $image_url_sddefault = 'https://img.youtube.com/vi/' . $youtube_id . '/sddefault.jpg';
    249         $image_url_hqdefault = 'https://img.youtube.com/vi/' . $youtube_id . '/hqdefault.jpg';
    250         $image_url_default   = 'https://img.youtube.com/vi/' . $youtube_id . '/default.jpg';
    251         $image_name          = md5( $youtube_id ) . '.jpg';// Make it MD5 -> so all (_!@#$%^)(*&) symbols are sanitized
    252         $upload_dir          = wp_upload_dir();
    253         $upload_dir['path']  = $upload_dir['basedir'] . '/simple-youtube-gdpr-thumbnails/';// Set upload folder
    254         if ( ! $image_data = file_get_contents( $image_url_sddefault ) ) {
    255             if ( ! $image_data = file_get_contents( $image_url_hqdefault ) ) {
    256                 $image_data = file_get_contents( $image_url_default );
    257             }
    258         }
    259         $unique_file_name = wp_unique_filename( $upload_dir['path'], $image_name ); // Generate unique name
    260         $filename         = basename( $unique_file_name ); // Create image file name.
    261 
    262         // Check folder permission and define file location
    263         if ( wp_mkdir_p( $upload_dir['path'] ) ) {
    264             $file = $upload_dir['path'] . '/' . $filename;
    265         } else {
    266             $file = $upload_dir['basedir'] . '/' . $filename;
    267         }
    268 
    269         // Create the image  file on the server
    270         file_put_contents( $file, $image_data );
    271     }
    272309}
  • simple-youtube-gdpr/trunk/public/css/simple-youtube-gdpr-public.css

    r2072368 r2143715  
    1 .youtube_lazyload {
     1.syg__box {
     2    display: inline-block;
    23    position: relative;
    34    overflow: hidden;
     
    56}
    67
    7 .youtube_lazyload__img {
     8.syg__box__img {
    89    display: block;
    910    margin: auto;
    1011    max-width: 100%;
    1112    border: none;
    12     cursor: pointer;
    1313    -webkit-transition: .4s all;
    1414    -moz-transition: .4s all;
     
    1717}
    1818
    19 .youtube_lazyload__img:hover {
     19.syg__box:hover .syg__box__img {
    2020    -webkit-filter: brightness(75%);
    2121    filter: brightness(75%);
    2222}
    2323
    24 .youtube_lazyload__play {
    25     height: 72px;
    26     width: 72px;
    27     left: 50%;
     24.syg__box__text {
     25    position: absolute;
     26    height: auto;
     27    width: 100%;
     28    left: 0;
    2829    top: 50%;
    29     margin-left: -36px;
    30     margin-top: -36px;
    31     position: absolute;
     30    text-align: center;
     31    -webkit-transform: translateY(-50%);
     32    -ms-transform: translateY(-50%);
     33    transform: translateY(-50%);
     34
     35    background-color: rgba(0, 0, 0, 0.8);
     36    color: white;
     37}
     38
     39.syg__box__text p {
     40    margin: 2em 0;
     41}
     42
     43.syg__box__text__btn {
     44    background: red;
     45    color: #fff;
     46    display: inline-flex;
     47    -webkit-box-align: center;
     48    -ms-flex-align: center;
     49    align-items: center;
     50    -webkit-box-pack: center;
     51    -ms-flex-pack: center;
     52    justify-content: center;
     53    border-radius: .1em;
     54    padding: .5em 1em;
     55    text-decoration: none !important;
     56    -webkit-transition: background-color .125s linear;
     57    -o-transition: background-color .125s linear;
     58    transition: background-color .125s linear;
     59}
     60
     61
     62/* Premium Code Stripped by Freemius */
     63
     64.syg__box__text__btn::before {
     65    background: url("data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0' y='0' width='78' height='78' viewBox='0, 0, 78, 78'%3E%3Cg id='Layer_1'%3E%3Cg%3E%3Cpath d='M7.5,71.5 L7.5,7.5 L55.5,37.828 L7.5,71.5' fill='%23ffffff'/%3E%3Cpath d='M7.5,71.5 L7.5,7.5 L55.5,37.828 L7.5,71.5' fill-opacity='0' stroke='%23ffffff' stroke-width='12' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") no-repeat center;
     66    background-size: auto;
     67    background-size: contain;
     68    content: " ";
     69    display: inline-block;
     70    margin-right: 4px;
     71    height: 1.1em;
     72    width: .8em;
     73}
     74
     75.syg__box__text__btn:hover {
     76    background: #fff;
     77    color: red;
    3278    cursor: pointer
    3379}
     80
     81
     82/* Premium Code Stripped by Freemius */
     83
     84.syg__box__text__btn:hover::before {
     85    background: url("data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0' y='0' width='78' height='78' viewBox='0, 0, 78, 78'%3E%3Cg id='Layer_1'%3E%3Cg%3E%3Cpath d='M7.5,71.5 L7.5,7.5 L55.5,37.828 L7.5,71.5' fill='%23ff0000'/%3E%3Cpath d='M7.5,71.5 L7.5,7.5 L55.5,37.828 L7.5,71.5' fill-opacity='0' stroke='%23ff0000' stroke-width='12' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") no-repeat center;
     86    background-size: contain;
     87    content: " ";
     88}
     89
     90
     91/* Premium Code Stripped by Freemius */
  • simple-youtube-gdpr/trunk/public/js/simple-youtube-gdpr-public.js

    r2072368 r2143715  
    44
    55    $(window).load(function () {
    6         youtube_lazyload();
     6        video_lazyload();
    77    });
    88
    99    /**
    10      * Loops in all ```.youtube_lazyload```
    11      * Assign onClick for each item
     10     * Loops in all ```.syg__box```
     11     * Assign onClick for each item`s button
    1212     */
    13     function youtube_lazyload() {
    14         var youtube = document.querySelectorAll(".youtube_lazyload");
     13    function video_lazyload() {
     14        var videos = document.querySelectorAll(".syg__box");
    1515
    16         // if we don't have youtube videos -> return
    17         if (typeof(youtube) === 'undefined' || youtube === null || !youtube) {
    18             console.warn('No YouTube Videos found');
     16        // if we don't have videos -> return
     17        if (typeof (videos) === 'undefined' || videos === null || !videos) {
     18            console.warn('No Videos found');
    1919            return;
    2020        }
    2121
    22         for (var i = 0; i < youtube.length; i++) {
     22        for (var i = 0; i < videos.length; i++) {// loop in all videos boxes
    2323
    24             youtube[i].addEventListener("click", function () {
    2524
    26                 var youtubeImage = this.getElementsByClassName('youtube_lazyload__img')[0];
    27                 // if we don't have youtube image -> return
    28                 if (typeof(youtubeImage) === 'undefined' || youtubeImage === null || !youtubeImage) {
     25            // Get Play Button
     26            var syg__box__text__btn = videos[i].getElementsByClassName('syg__box__text__btn')[0];
     27            // if we don't have videos play button -> return
     28            if (typeof (syg__box__text__btn) === 'undefined' || syg__box__text__btn === null || !syg__box__text__btn) {
     29                console.warn('No YouTube Play Button found');
     30                return;
     31            }
     32            // Put click events on Play buttons
     33            syg__box__text__btn.addEventListener("click", function () {
     34                var videoContainer__local = this.parentNode.parentNode.parentNode;
     35                // Get Text
     36                var syg__box__text = videoContainer__local.getElementsByClassName('syg__box__text')[0];
     37                // if we don't have video text -> return
     38                if (typeof (syg__box__text) === 'undefined' || syg__box__text === null || !syg__box__text) {
     39                    console.warn('No YouTube Text found');
     40                    return;
     41                }
     42                // Get Background Image - Preview Thumbnail
     43                var videoImage = videoContainer__local.getElementsByClassName('syg__box__img')[0];
     44                // if we don't have video image -> return
     45                if (typeof (videoImage) === 'undefined' || videoImage === null || !videoImage) {
    2946                    console.warn('No YouTube Image found');
    3047                    return;
    3148                }
     49                // Change - Replace
     50                if (videoContainer__local.classList.contains('syg__box-youtube')) {
     51                    videoContainer__local.replaceChild(getYouTubeIFrame(videoImage), videoImage);
     52                }
     53               
     54/* Premium Code Stripped by Freemius */
    3255
    33                 var playButton = this.getElementsByClassName('youtube_lazyload__play')[0];
    34                 // if we don't have youtube play button -> return
    35                 if (typeof(playButton) === 'undefined' || playButton === null || !playButton) {
    36                     console.warn('No YouTube Play Button found');
    37                     return;
    38                 }
    39                 // remove play button
    40                 this.removeChild(playButton);
    41                 // replace an image with an iframe
    42                 this.replaceChild(getIFrame(youtubeImage), youtubeImage);
    43             });// addEventListener
     56                // Remove
     57                videoContainer__local.removeChild(syg__box__text);
     58            });
    4459        }// for youtube
    4560    }
     
    5267     * @return element iframe
    5368     */
    54     function getIFrame(youtubeImg) {
     69    function getYouTubeIFrame(youtubeImg) {
    5570        // if we don't have youtube image -> return
    56         if (typeof(youtubeImg) === 'undefined' || youtubeImg === null || !youtubeImg) {
     71        if (typeof (youtubeImg) === 'undefined' || youtubeImg === null || !youtubeImg) {
    5772            console.warn('No YouTube Image found');
    5873            return;
     
    6984        // set height if an image had it
    7085        iframe.setAttribute('height', (youtubeImg.getAttribute('height') > 0) ? (youtubeImg.getAttribute('height')) : '315');
    71         iframe.setAttribute('class', 'youtube_lazyload__iframe');
     86        iframe.setAttribute('class', 'syg__box-youtube-iframe');
    7287        // The Referer header will not be sent.
    7388        iframe.setAttribute('referrerpolicy', 'no-referrer');
     
    7691    }// getIFrame
    7792
     93   
     94/* Premium Code Stripped by Freemius */
     95
     96
    7897})(jQuery);
  • simple-youtube-gdpr/trunk/simple-youtube-gdpr.php

    r2080878 r2143715  
    1616 * Plugin Name:       Simple YouTube GDPR
    1717 * Plugin URI:        https://alexeyvolkov.com/blog/simple-youtube-gdpr
    18  * Description:       Replaces all YouTube video iframes with a local image and loads a no cookie verion of video.
    19  * Version:           0.6
     18 * Description:       Integrate YouTube and Vimeo videos securely!
     19 * Version:           0.7
    2020 * Author:            Alexey Volkov
    2121 * Author URI:        https://alexeyvolkov.com/
     
    2525 * Domain Path:       /languages
    2626 */
    27 
    28 // If this file is called directly, abort.
    29 if ( ! defined( 'WPINC' ) ) {
    30     die;
     27/**
     28 * Freemius
     29 */
     30if ( !defined( 'ABSPATH' ) ) {
     31    exit;
    3132}
    3233
    33 /**
    34  * Currently plugin version.
    35  * Start at version 0.6 and use SemVer - https://semver.org
    36  * Rename this for your plugin and update it as you release new versions.
    37  */
    38 define( 'SIMPLE_YOUTUBE_GDPR_VERSION', '0.6' );
    39 
    40 /**
    41  * The code that runs during plugin activation.
    42  * This action is documented in includes/class-simple-youtube-gdpr-activator.php
    43  */
    44 function activate_simple_youtube_gdpr() {
    45     require_once plugin_dir_path( __FILE__ ) . 'includes/class-simple-youtube-gdpr-activator.php';
    46     Simple_Youtube_Gdpr_Activator::activate();
     34if ( function_exists( 'syg_fs' ) ) {
     35    syg_fs()->set_basename( false, __FILE__ );
     36} else {
     37    if ( !function_exists( 'syg_fs' ) ) {
     38        // ... Freemius integration snippet ...
     39       
     40        if ( !function_exists( 'syg_fs' ) ) {
     41            // Create a helper function for easy SDK access.
     42            function syg_fs()
     43            {
     44                global  $syg_fs ;
     45               
     46                if ( !isset( $syg_fs ) ) {
     47                    // Include Freemius SDK.
     48                    require_once dirname( __FILE__ ) . '/freemius/start.php';
     49                    $syg_fs = fs_dynamic_init( array(
     50                        'id'             => '4426',
     51                        'slug'           => 'simple-youtube-gdpr',
     52                        'premium_slug'   => 'simple-youtube-gdpr-gold',
     53                        'type'           => 'plugin',
     54                        'public_key'     => 'pk_72bcdfa58a1ac164e91d2916748e0',
     55                        'is_premium'     => false,
     56                        'premium_suffix' => 'premium',
     57                        'has_addons'     => false,
     58                        'has_paid_plans' => true,
     59                        'menu'           => array(
     60                        'first-path' => 'plugins.php',
     61                        'contact'    => false,
     62                        'support'    => false,
     63                    ),
     64                        'is_live'        => true,
     65                    ) );
     66                }
     67               
     68                return $syg_fs;
     69            }
     70           
     71            // Init Freemius.
     72            syg_fs();
     73            // Signal that SDK was initiated.
     74            do_action( 'syg_fs_loaded' );
     75        }
     76   
     77    }
     78    // ... Your plugin's main file logic ...
     79    // If this file is called directly, abort.
     80    if ( !defined( 'WPINC' ) ) {
     81        die;
     82    }
     83    /**
     84     * Plugin Action links
     85     *
     86     * @param $links
     87     *
     88     * @return array
     89     */
     90    add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'add_action_links' );
     91    function add_action_links( $links )
     92    {
     93        $mylinks = array( '<a href="' . syg_fs()->get_upgrade_url() . '" title="' . esc_html( __( 'Click to Upgrade your plan' ) ) . '"><strong style="display: inline;">' . esc_html( __( 'Get Vimeo Blocker!', 'simple-youtube-gdpr' ) ) . '</strong></a>' );
     94        return array_merge( $mylinks, $links );
     95    }
     96   
     97    add_filter(
     98        'plugin_row_meta',
     99        'add_plugin_row_meta',
     100        10,
     101        2
     102    );
     103    function add_plugin_row_meta( $links, $file )
     104    {
     105       
     106        if ( strpos( $file, 'simple-youtube-gdpr.php' ) !== false ) {
     107            $new_links = array(
     108                'donate' => '<a href="https://money.yandex.ru/to/41001417963743" target="_blank" title="Payment in RUB - Russian Rubles">&hearts; Donate</a>',
     109            );
     110            $links = array_merge( $links, $new_links );
     111        }
     112       
     113        return $links;
     114    }
     115   
     116    /**
     117     * Currently plugin version.
     118     * Start at version 0.6 and use SemVer - https://semver.org
     119     * Rename this for your plugin and update it as you release new versions.
     120     */
     121    define( 'SIMPLE_YOUTUBE_GDPR_VERSION', '0.7' );
     122    /**
     123     * The code that runs during plugin activation.
     124     * This action is documented in includes/class-simple-youtube-gdpr-activator.php
     125     */
     126    function activate_simple_youtube_gdpr()
     127    {
     128        require_once plugin_dir_path( __FILE__ ) . 'includes/class-simple-youtube-gdpr-activator.php';
     129        Simple_Youtube_Gdpr_Activator::activate();
     130    }
     131   
     132    /**
     133     * The code that runs during plugin deactivation.
     134     * This action is documented in includes/class-simple-youtube-gdpr-deactivator.php
     135     */
     136    function deactivate_simple_youtube_gdpr()
     137    {
     138        require_once plugin_dir_path( __FILE__ ) . 'includes/class-simple-youtube-gdpr-deactivator.php';
     139        Simple_Youtube_Gdpr_Deactivator::deactivate();
     140    }
     141   
     142    register_activation_hook( __FILE__, 'activate_simple_youtube_gdpr' );
     143    register_deactivation_hook( __FILE__, 'deactivate_simple_youtube_gdpr' );
     144    /**
     145     * The core plugin class that is used to define internationalization,
     146     * admin-specific hooks, and public-facing site hooks.
     147     */
     148    require plugin_dir_path( __FILE__ ) . 'includes/class-simple-youtube-gdpr.php';
     149    /**
     150     * Begins execution of the plugin.
     151     *
     152     * Since everything within the plugin is registered via hooks,
     153     * then kicking off the plugin from this point in the file does
     154     * not affect the page life cycle.
     155     *
     156     * @since    0.6
     157     */
     158    function run_simple_youtube_gdpr()
     159    {
     160        $plugin = new Simple_Youtube_Gdpr();
     161        $plugin->run();
     162    }
     163   
     164    run_simple_youtube_gdpr();
    47165}
    48 
    49 /**
    50  * The code that runs during plugin deactivation.
    51  * This action is documented in includes/class-simple-youtube-gdpr-deactivator.php
    52  */
    53 function deactivate_simple_youtube_gdpr() {
    54     require_once plugin_dir_path( __FILE__ ) . 'includes/class-simple-youtube-gdpr-deactivator.php';
    55     Simple_Youtube_Gdpr_Deactivator::deactivate();
    56 }
    57 
    58 register_activation_hook( __FILE__, 'activate_simple_youtube_gdpr' );
    59 register_deactivation_hook( __FILE__, 'deactivate_simple_youtube_gdpr' );
    60 
    61 /**
    62  * The core plugin class that is used to define internationalization,
    63  * admin-specific hooks, and public-facing site hooks.
    64  */
    65 require plugin_dir_path( __FILE__ ) . 'includes/class-simple-youtube-gdpr.php';
    66 
    67 /**
    68  * Begins execution of the plugin.
    69  *
    70  * Since everything within the plugin is registered via hooks,
    71  * then kicking off the plugin from this point in the file does
    72  * not affect the page life cycle.
    73  *
    74  * @since    0.6
    75  */
    76 function run_simple_youtube_gdpr() {
    77 
    78     $plugin = new Simple_Youtube_Gdpr();
    79     $plugin->run();
    80 
    81 }
    82 run_simple_youtube_gdpr();
Note: See TracChangeset for help on using the changeset viewer.