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