| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: VK Blocks |
| 4 |
* Plugin URI: https://github.com/vektor-inc/vk-blocks |
| 5 |
* Description: This is a plugin that extends Gutenberg's blocks. |
| 6 |
* Version: 0.61.1 |
| 7 |
* Author: Vektor,Inc. |
| 8 |
* Author URI: https://vektor-inc.co.jp |
| 9 |
* Text Domain: vk-blocks |
| 10 |
*/ |
| 11 |
|
| 12 |
// Do not load directly. |
| 13 |
defined( 'ABSPATH' ) || die(); |
| 14 |
|
| 15 |
if ( ! function_exists( 'vkblocks_get_version' ) ) { |
| 16 |
function vkblocks_get_version() { |
| 17 |
$data = get_file_data( __FILE__, array( 'version' => 'Version' ) ); |
| 18 |
return $data['version']; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
/* |
| 23 |
Helpers ( Plugin only ) |
| 24 |
/*-------------------------------------------*/ |
| 25 |
if ( ! function_exists( 'vkblocks_deactivate_plugin' ) ) { |
| 26 |
/** |
| 27 |
* Plugin deactive function |
| 28 |
* |
| 29 |
* @param [type] $plugin_path [description] |
| 30 |
* @return [type] [description] |
| 31 |
*/ |
| 32 |
function vkblocks_deactivate_plugin( $plugin_path ) { |
| 33 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 34 |
if ( is_plugin_active( $plugin_path ) ) { |
| 35 |
$active_plugins = get_option( 'active_plugins' ); |
| 36 |
// delete item |
| 37 |
$active_plugins = array_diff( $active_plugins, array( $plugin_path ) ); |
| 38 |
// re index |
| 39 |
$active_plugins = array_values( $active_plugins ); |
| 40 |
update_option( 'active_plugins', $active_plugins ); |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
/* |
| 46 |
Deactive VK Blocks ( Free ) |
| 47 |
-------------------------------------------*/ |
| 48 |
/* 関数名� |
| 49 |
�れると無料版の宣言と被ってエラーになるので一時的な回避処理で無名関数を利用 */ |
| 50 |
add_action( |
| 51 |
'admin_init', |
| 52 |
function() { |
| 53 |
$plugin_base_dir = dirname( __FILE__ ); |
| 54 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 55 |
if ( is_plugin_active( 'vk-blocks-pro/vk-blocks.php' ) ) { |
| 56 |
// Deactive Plugin VK Blocks ( free ) |
| 57 |
if ( function_exists( 'vkblocks_deactivate_plugin' ) ) { |
| 58 |
vkblocks_deactivate_plugin( 'vk-blocks/vk-blocks.php' ); |
| 59 |
} |
| 60 |
} |
| 61 |
// Deactive ExUnit included VK Blocks |
| 62 |
$options = get_option( 'vkExUnit_common_options' ); |
| 63 |
if ( ! empty( $options['active_vk-blocks'] ) ) { |
| 64 |
$options['active_vk-blocks'] = false; |
| 65 |
update_option( 'vkExUnit_common_options', $options ); |
| 66 |
} |
| 67 |
}, |
| 68 |
9999 |
| 69 |
); |
| 70 |
|
| 71 |
if ( is_admin() && ! is_network_admin() ) { |
| 72 |
$options = get_option( 'vkExUnit_common_options' ); |
| 73 |
if ( ! empty( $options['active_vk-blocks'] ) ) { |
| 74 |
$options['active_vk-blocks'] = false; |
| 75 |
update_option( 'vkExUnit_common_options', $options ); |
| 76 |
|
| 77 |
add_action( |
| 78 |
'admin_notices', |
| 79 |
function() { |
| 80 |
echo '<div class="updated notice"><p>'; |
| 81 |
echo __( 'Disabled Blocks module. Because VK-Blocks Plugin running.', 'vk-blocks' ); |
| 82 |
echo '</p></div>'; |
| 83 |
} |
| 84 |
); |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
require_once 'inc/vk-blocks-config.php'; |
| 89 |
/* |
| 90 |
Load updater |
| 91 |
/*-------------------------------------------*/ |
| 92 |
$plugin_base_dir = dirname( __FILE__ ); |
| 93 |
if ( strpos( $plugin_base_dir, 'vk-blocks-pro' ) !== false ) { |
| 94 |
|
| 95 |
$updater_url = dirname( __FILE__ ) . '/inc/vk-blocks-pro/plugin-update-checker/plugin-update-checker.php'; |
| 96 |
if ( file_exists( $updater_url ) ) { |
| 97 |
require dirname( __FILE__ ) . '/inc/vk-blocks-pro/plugin-update-checker/plugin-update-checker.php'; |
| 98 |
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( |
| 99 |
'https://vws.vektor-inc.co.jp/updates/?action=get_metadata&slug=vk-blocks-pro', |
| 100 |
__FILE__, |
| 101 |
'vk-blocks-pro' |
| 102 |
); |
| 103 |
} |
| 104 |
} |
| 105 |
|