PluginProbe
Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch / trunk
Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch vtrunk
2.1.1 2.1.0 trunk 1.0 1.1 1.2 1.4.2 1.5.2 1.5.5 1.6.1 1.6.2 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
yt-player / yt-player.php

yt-player.php in Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch trunk, at yt-player.php

152 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch
4 * Plugin URI: http://bplugins.com
5 * Description: A simple, accessible, fully customizable & user friendly YouTube Video Player for Wordpress.
6 * Version: 2.1.1
7 * Author: bPlugins
8 * Author URI: http://abuhayatpolash.com
9 * License: GPLv3
10 * Text Domain: yt-player
11 * Domain Path: /languages
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18 if (function_exists('ytp_fs')) {
19 ytp_fs()->set_basename(true, __FILE__);
20 } else {
21 /*Some Set-up*/
22 if (!defined('YTP_PLUGIN_DIR')) {
23 define('YTP_PLUGIN_DIR', plugin_dir_url(__FILE__));
24 }
25 if (!defined('YTP_DIR_PATH')) {
26 define('YTP_DIR_PATH', plugin_dir_path(__FILE__));
27 }
28 if (!defined('YTP_PLUGIN_VERSION')) {
29 define('YTP_PLUGIN_VERSION', (isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] === 'localhost') ? time() : '2.1.1');
30 }
31 if (!defined('YTP_IMPORT_VER')) {
32 define('YTP_IMPORT_VER', '1.0.0');
33 }
34
35 if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) {
36 require_once(dirname(__FILE__) . '/vendor/autoload.php');
37 }
38
39 if (!function_exists('ytp_fs')) {
40 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
41 function ytp_fs() {
42 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
43 global $ytp_fs;
44
45 if (!isset($ytp_fs)) {
46 if (file_exists(dirname(__FILE__) . '/vendor/freemius/wordpress-sdk/start.php')) {
47 require_once dirname(__FILE__) . '/vendor/freemius/wordpress-sdk/start.php';
48 } else if (file_exists(dirname(__FILE__) . '/vendor/freemius/start.php')) {
49 require_once dirname(__FILE__) . '/vendor/freemius/start.php';
50 }
51
52 if (function_exists('fs_dynamic_init')) {
53 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
54 $ytp_fs = fs_dynamic_init(array(
55 'id' => '5836',
56 'slug' => 'yt-player',
57 'type' => 'plugin',
58 'public_key' => 'pk_829fc74e7bb67d3d555c68048933d',
59 'is_premium' => false,
60 'premium_slug' => 'yt-player-pro',
61 'premium_suffix' => 'Pro',
62 'has_premium_version' => true,
63 'has_addons' => false,
64 'has_paid_plans' => true,
65 'menu' => array(
66 'slug' => 'edit.php?post_type=ytplayer',
67 'first-path' => 'edit.php?post_type=ytplayer&page=dashboard',
68 'support' => false,
69 'contact' => false,
70 ),
71 ));
72 } else {
73 return null;
74 }
75 }
76
77 return $ytp_fs;
78 }
79
80 if (file_exists(dirname(__FILE__) . '/vendor/freemius/wordpress-sdk/start.php') || file_exists(dirname(__FILE__) . '/vendor/freemius/start.php')) {
81 ytp_fs();
82 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
83 do_action('ytp_fs_loaded');
84 }
85 }
86
87 require_once plugin_dir_path(__FILE__) . '/youtube-player.php';
88 }
89
90 // Auto-deactivate Pro version if Free version is activated
91 add_action('activated_plugin', function ($plugin) {
92 if ($plugin === plugin_basename(__FILE__)) {
93 if (!function_exists('deactivate_plugins')) {
94 require_once ABSPATH . 'wp-admin/includes/plugin.php';
95 }
96 $pro_plugins = array(
97 'yt-player-pro/yt-player.php',
98 'yt-player-pro/yt-player-pro.php',
99 'yt-player-premium/yt-player.php',
100 'yt-player-premium/yt-player-premium.php',
101 );
102 foreach ($pro_plugins as $pro_plugin) {
103 if (is_plugin_active($pro_plugin)) {
104 deactivate_plugins($pro_plugin);
105 }
106 }
107 }
108 });
109
110
111 add_action('plugins_loaded', function () {
112 // load_plugin_textdomain('yt-player', false, dirname(plugin_basename(__FILE__)) . '/languages'); // Removed because WP automatically loads translations since 4.6
113
114 if (!class_exists('CSF')) {
115 require_once(__DIR__ . '/vendor/codestar-framework/codestar-framework.php');
116 }
117
118 if (class_exists('YTP\\Init')) {
119 YTP\Init::register_services();
120 }
121 });
122
123 add_action('init', function () {
124 // import data
125 if (get_option('ytp_import_ver', '0') < YTP_IMPORT_VER) {
126 $players = new WP_Query(array(
127 'post_type' => 'ytplayer',
128 'post_status' => 'any',
129 'posts_per_page' => -1
130 ));
131
132 while ($players->have_posts()) {
133 $players->the_post();
134 $id = get_the_ID();
135 if (!get_post_meta($id, 'isGutenberg', true)) {
136 update_post_meta($id, 'isGutenberg', true);
137 }
138 };
139 }
140 });
141
142 if (!function_exists('ytp_import_btn')) {
143 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
144 function ytp_import_btn($links) {
145 array_unshift($links, '<a id="ytp_import_btn" href="#">Import</a>');
146 return $links;
147 }
148 }
149
150 $plugin = plugin_basename(__FILE__);
151 add_filter("plugin_action_links_$plugin", 'ytp_import_btn');
152