| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Video Background Block |
| 4 |
* Description: Use video as background in section. |
| 5 |
* Version: 2.0.3 |
| 6 |
* Requires at least: 6.5 |
| 7 |
* Requires PHP: 7.4 |
| 8 |
* Author: bPlugins |
| 9 |
* Author URI: https://bplugins.com |
| 10 |
* License: GPL-2.0-or-later |
| 11 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 12 |
* Text Domain: video-background |
| 13 |
* @fs_free_only /vendor/freemius-lite |
| 14 |
*/ |
| 15 |
|
| 16 |
// ABS PATH |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 18 |
|
| 19 |
/** |
| 20 |
* Optional: deactivate free/pro duplicates on activation (your logic kept) |
| 21 |
*/ |
| 22 |
register_activation_hook( __FILE__, function () { |
| 23 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 24 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 25 |
} |
| 26 |
|
| 27 |
if ( is_plugin_active( 'video-background-block/index.php' ) ) { |
| 28 |
deactivate_plugins( 'video-background-block/index.php' ); |
| 29 |
} |
| 30 |
if ( is_plugin_active( 'video-background-block-pro/index.php' ) ) { |
| 31 |
deactivate_plugins( 'video-background-block-pro/index.php' ); |
| 32 |
} |
| 33 |
}); |
| 34 |
|
| 35 |
if ( function_exists( 'bvbb_fs' ) ) { |
| 36 |
bvbb_fs()->set_basename( true, __FILE__ ); |
| 37 |
} else { |
| 38 |
|
| 39 |
// Constant |
| 40 |
define( |
| 41 |
'VBB_VERSION', |
| 42 |
isset( $_SERVER['HTTP_HOST'] ) && |
| 43 |
( |
| 44 |
'localhost' === $_SERVER['HTTP_HOST'] || |
| 45 |
'plugins.local' === $_SERVER['HTTP_HOST'] |
| 46 |
) |
| 47 |
? time() |
| 48 |
: '2.0.3' |
| 49 |
); |
| 50 |
|
| 51 |
define( 'VBB_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 52 |
define( 'VBB_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
if ( ! function_exists( 'bvbb_fs' ) ) { |
| 57 |
function bvbb_fs() { |
| 58 |
global $bvbb_fs; |
| 59 |
|
| 60 |
if ( ! isset( $bvbb_fs ) ) { |
| 61 |
$fs_lite = VBB_DIR_PATH . '/vendor/freemius-lite/start.php'; |
| 62 |
if ( file_exists( $fs_lite ) ) { |
| 63 |
require_once $fs_lite; |
| 64 |
} else { |
| 65 |
// Freemius files missing -> avoid fatal |
| 66 |
return null; |
| 67 |
} |
| 68 |
|
| 69 |
$bvbbConfig = array( |
| 70 |
'id' => '20161', |
| 71 |
'slug' => 'video-background-block', |
| 72 |
'premium_slug' => 'video-background-block-pro', |
| 73 |
'type' => 'plugin', |
| 74 |
'public_key' => 'pk_c450cd26984f6b711540a633d4fa1', |
| 75 |
'is_premium' => false, |
| 76 |
'premium_suffix' => 'Pro', |
| 77 |
'has_premium_version' => true, |
| 78 |
'has_addons' => false, |
| 79 |
'has_paid_plans' => true, |
| 80 |
'menu' => array( |
| 81 |
'slug' => 'video-background-block-dashboard', |
| 82 |
'first-path' => 'admin.php?page=video-background-block-dashboard#/welcome', |
| 83 |
'contact' => false, |
| 84 |
'support' => false, |
| 85 |
), |
| 86 |
); |
| 87 |
|
| 88 |
$bvbb_fs = fs_lite_dynamic_init( $bvbbConfig ); |
| 89 |
} |
| 90 |
|
| 91 |
return $bvbb_fs; |
| 92 |
} |
| 93 |
|
| 94 |
// Init Freemius. |
| 95 |
bvbb_fs(); |
| 96 |
do_action( 'bvbb_fs_loaded' ); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
// Required files |
| 102 |
require_once VBB_DIR_PATH . 'includes/GetCSS.php'; |
| 103 |
require_once VBB_DIR_PATH . 'includes/adminMenu.php'; |
| 104 |
|
| 105 |
|
| 106 |
if ( ! class_exists( 'VBBPlugin' ) ) { |
| 107 |
class VBBPlugin { |
| 108 |
public function __construct() { |
| 109 |
add_action( 'init', array( $this, 'onInit' ) ); |
| 110 |
|
| 111 |
add_filter( 'plugin_action_links', [$this, 'pluginActionLinks'], 10, 2 ); |
| 112 |
add_filter( 'default_title', [$this, 'defaultTitle'], 10, 2 ); |
| 113 |
add_filter( 'default_content', [$this, 'defaultContent'], 10, 2 ); |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
public function onInit() { |
| 118 |
register_block_type( __DIR__ . '/build' ); |
| 119 |
} |
| 120 |
|
| 121 |
function defaultTitle( $title, $post ) { |
| 122 |
if ( 'page' === $post->post_type && isset( $_GET['title'] ) ) { |
| 123 |
return sanitize_text_field( wp_unslash( $_GET['title'] ) ); |
| 124 |
} |
| 125 |
return $title; |
| 126 |
} |
| 127 |
|
| 128 |
function defaultContent( $content, $post ) { |
| 129 |
if ( 'page' === $post->post_type && isset( $_GET['content'] ) ) { |
| 130 |
return wp_unslash( $_GET['content'] ); |
| 131 |
} |
| 132 |
return $content; |
| 133 |
} |
| 134 |
|
| 135 |
function pluginActionLinks( $links, $file ) { |
| 136 |
if( plugin_basename( __FILE__ ) === $file ) { |
| 137 |
$goProLink = admin_url( 'edit.php?post_type=apb&page=video-background-block-dashboard#/pricing' ); |
| 138 |
$helpDemosLink = admin_url( 'edit.php?post_type=apb&page=video-background-block-dashboard' ); |
| 139 |
|
| 140 |
$links['go-pro'] = sprintf( '<a href="%s" style="%s">%s</a>', $goProLink, 'color:#146ef5;font-weight:bold', __( 'Go Pro', 'video-background-block-dashboard' ) ); |
| 141 |
$links['help-and-demos'] = sprintf( '<a href="%s" style="%s">%s</a>', $helpDemosLink, 'color:#FF7A00;font-weight:bold', __( 'Help & Demos', 'video-background-block-dashboard' ) ); |
| 142 |
} |
| 143 |
|
| 144 |
return $links; |
| 145 |
} |
| 146 |
|
| 147 |
} |
| 148 |
new VBBPlugin; |
| 149 |
} |
| 150 |
} |
| 151 |
|