| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Video Player for YouTube |
| 5 |
* Plugin URI: http://bplugins.com |
| 6 |
* Description: A simple, accessible, fully customizable & user friendly YouTube Video Player for Wordpress. |
| 7 |
* Version: 2.0.9 |
| 8 |
* Author: bPlugins |
| 9 |
* Author URI: http://abuhayatpolash.com |
| 10 |
* License: GPLv3 |
| 11 |
* Text Domain: yt-player |
| 12 |
* Domain Path: /languages |
| 13 |
*/ |
| 14 |
if ( !defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
// Exit if accessed directly. |
| 17 |
} |
| 18 |
//--------------Fremius Integration------------------ |
| 19 |
if ( function_exists( 'ytp_fs' ) ) { |
| 20 |
ytp_fs()->set_basename( false, __FILE__ ); |
| 21 |
} else { |
| 22 |
// DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE `function_exists` CALL ABOVE TO PROPERLY WORK. |
| 23 |
if ( !function_exists( 'ytp_fs' ) ) { |
| 24 |
function ytp_fs() { |
| 25 |
global $ytp_fs; |
| 26 |
if ( !isset( $ytp_fs ) ) { |
| 27 |
// Activate multisite network integration. |
| 28 |
if ( !defined( 'WP_FS__PRODUCT_5836_MULTISITE' ) ) { |
| 29 |
define( 'WP_FS__PRODUCT_5836_MULTISITE', true ); |
| 30 |
} |
| 31 |
// Include Freemius SDK. |
| 32 |
require_once dirname( __FILE__ ) . '/vendor/freemius/start.php'; |
| 33 |
// if ( file_exists( dirname(__FILE__) . '/vendor/freemius/start.php' ) ) { |
| 34 |
// require_once dirname(__FILE__) . '/vendor/freemius/start.php'; |
| 35 |
// } else if ( file_exists( dirname(__FILE__) . '/vendor/freemius-lite/start.php' ) ) { |
| 36 |
// require_once dirname(__FILE__) . '/vendor/freemius-lite/start.php'; |
| 37 |
// } |
| 38 |
$ytp_fs = fs_dynamic_init( array( |
| 39 |
'id' => '5836', |
| 40 |
'slug' => 'yt-player', |
| 41 |
'type' => 'plugin', |
| 42 |
'public_key' => 'pk_829fc74e7bb67d3d555c68048933d', |
| 43 |
'is_premium' => false, |
| 44 |
'has_addons' => false, |
| 45 |
'has_paid_plans' => true, |
| 46 |
'trial' => array( |
| 47 |
'days' => 7, |
| 48 |
'is_require_payment' => true, |
| 49 |
), |
| 50 |
'menu' => array( |
| 51 |
'slug' => 'edit.php?post_type=ytplayer', |
| 52 |
'first-path' => 'edit.php?post_type=ytplayer&page=dashboard', |
| 53 |
'support' => false, |
| 54 |
), |
| 55 |
'is_live' => true, |
| 56 |
'is_org_compliant' => true, |
| 57 |
) ); |
| 58 |
} |
| 59 |
return $ytp_fs; |
| 60 |
} |
| 61 |
|
| 62 |
// Init Freemius. |
| 63 |
ytp_fs(); |
| 64 |
// Signal that SDK was initiated. |
| 65 |
do_action( 'ytp_fs_loaded' ); |
| 66 |
} |
| 67 |
/*Some Set-up*/ |
| 68 |
define( 'YTP_PLUGIN_DIR', plugin_dir_url( __FILE__ ) ); |
| 69 |
define( 'YTP_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 70 |
define( 'YTP_PLUGIN_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] === 'localhost' ? time() : '2.0.9' ) ); |
| 71 |
define( 'YTP_IMPORT_VER', '1.0.0' ); |
| 72 |
if ( file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) { |
| 73 |
require_once dirname( __FILE__ ) . '/vendor/autoload.php'; |
| 74 |
} |
| 75 |
require_once plugin_dir_path( __FILE__ ) . 'inc/LicenseActivation.php'; |
| 76 |
require_once plugin_dir_path( __FILE__ ) . '/youtube-player.php'; |
| 77 |
add_action( 'plugins_loaded', function () { |
| 78 |
// load_plugin_textdomain('yt-player', false, dirname(plugin_basename(__FILE__)) . '/languages'); // Removed because WP automatically loads translations since 4.6 |
| 79 |
if ( !class_exists( 'CSF' ) ) { |
| 80 |
require_once __DIR__ . '/vendor/codestar-framework/codestar-framework.php'; |
| 81 |
require_once __DIR__ . '/youtube-player.php'; |
| 82 |
} |
| 83 |
if ( class_exists( 'YTP\\Init' ) ) { |
| 84 |
YTP\Init::register_services(); |
| 85 |
} |
| 86 |
} ); |
| 87 |
add_action( 'init', function () { |
| 88 |
// import data |
| 89 |
if ( get_option( 'ytp_import_ver', '0' ) < YTP_IMPORT_VER ) { |
| 90 |
$players = new WP_Query(array( |
| 91 |
'post_type' => 'ytplayer', |
| 92 |
'post_status' => 'any', |
| 93 |
'posts_per_page' => -1, |
| 94 |
)); |
| 95 |
while ( $players->have_posts() ) { |
| 96 |
$players->the_post(); |
| 97 |
$id = get_the_ID(); |
| 98 |
if ( !get_post_meta( $id, 'isGutenberg', true ) ) { |
| 99 |
update_post_meta( $id, 'isGutenberg', true ); |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
} ); |
| 104 |
function ytp_import_btn( $links ) { |
| 105 |
array_unshift( $links, '<a id="ytp_import_btn" href="#">Import</a>' ); |
| 106 |
return $links; |
| 107 |
} |
| 108 |
|
| 109 |
$plugin = plugin_basename( __FILE__ ); |
| 110 |
add_filter( "plugin_action_links_{$plugin}", 'ytp_import_btn' ); |
| 111 |
} |