| 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: 1.29.2.0 |
| 7 |
* Stable tag: 1.29.2.0 |
| 8 |
* Requires at least: 5.8 |
| 9 |
* Author: Vektor,Inc. |
| 10 |
* Author URI: https://vektor-inc.co.jp |
| 11 |
* Text Domain: vk-blocks |
| 12 |
* |
| 13 |
* @package vk-blocks |
| 14 |
*/ |
| 15 |
|
| 16 |
// Do not load directly. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
// Composer のファイルを読み込み ( composer install --no-dev ). |
| 22 |
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
| 23 |
// Set plugin dir path. |
| 24 |
define( 'VK_BLOCKS_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 25 |
// Set Plugin Dir URL. |
| 26 |
define( 'VK_BLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 27 |
|
| 28 |
/* |
| 29 |
無料版の VK Blocks の無効化が正常に動作しなかった場合に無料版の関数が� |
| 30 |
�に定義され |
| 31 |
重複 -> Fatal error になるため function_exists は フォールバックとして付与している |
| 32 |
*/ |
| 33 |
if ( ! function_exists( 'vk_blocks_get_version' ) ) { |
| 34 |
/** |
| 35 |
* Get Plugin Version |
| 36 |
* |
| 37 |
* @return string |
| 38 |
*/ |
| 39 |
function vk_blocks_get_version() { |
| 40 |
$data = get_file_data( __FILE__, array( 'version' => 'Version' ) ); |
| 41 |
return $data['version']; |
| 42 |
} |
| 43 |
} |
| 44 |
if ( ! function_exists( 'vk_blocks_deactivate_plugin' ) ) { |
| 45 |
/** |
| 46 |
* Plugin deactive function |
| 47 |
* |
| 48 |
* @param string $plugin_path Plugin path to disable. |
| 49 |
* @return void |
| 50 |
*/ |
| 51 |
function vk_blocks_deactivate_plugin( $plugin_path ) { |
| 52 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 53 |
if ( is_plugin_active( $plugin_path ) ) { |
| 54 |
$active_plugins = get_option( 'active_plugins' ); |
| 55 |
// delete active plugin. |
| 56 |
$active_plugins = array_diff( $active_plugins, array( $plugin_path ) ); |
| 57 |
// re index active plugin. |
| 58 |
$active_plugins = array_values( $active_plugins ); |
| 59 |
update_option( 'active_plugins', $active_plugins ); |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Deactive VK Blocks ( Free ) |
| 66 |
* |
| 67 |
* 関数名� |
| 68 |
�れると無料版 VK Blocks の宣言と被ってエラーになるので一時的な回避処理で無名関数を利用している |
| 69 |
*/ |
| 70 |
add_action( |
| 71 |
'admin_init', |
| 72 |
function() { |
| 73 |
$plugin_base_dir = dirname( __FILE__ ); |
| 74 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 75 |
if ( is_plugin_active( 'vk-blocks-pro/vk-blocks.php' ) ) { |
| 76 |
// Deactive Plugin VK Blocks ( free ). |
| 77 |
if ( function_exists( 'vk_blocks_deactivate_plugin' ) ) { |
| 78 |
vk_blocks_deactivate_plugin( 'vk-blocks/vk-blocks.php' ); |
| 79 |
} |
| 80 |
} |
| 81 |
// Deactive ExUnit included VK Blocks. |
| 82 |
$options = get_option( 'vkExUnit_common_options' ); |
| 83 |
if ( ! empty( $options['active_vk-blocks'] ) ) { |
| 84 |
$options['active_vk-blocks'] = false; |
| 85 |
update_option( 'vkExUnit_common_options', $options ); |
| 86 |
} |
| 87 |
|
| 88 |
// Deactive VK Grid Colomun Card Plugin |
| 89 |
if ( is_plugin_active( 'vk-gridcolcard/vk-gridcolcard.php' ) ) { |
| 90 |
if ( function_exists( 'vk_blocks_deactivate_plugin' ) ) { |
| 91 |
vk_blocks_deactivate_plugin( 'vk-gridcolcard/vk-gridcolcard.php' ); |
| 92 |
} |
| 93 |
} |
| 94 |
}, |
| 95 |
9999 |
| 96 |
); |
| 97 |
|
| 98 |
if ( is_admin() && ! is_network_admin() ) { |
| 99 |
$vk_blocks_options = get_option( 'vkExUnit_common_options' ); |
| 100 |
if ( ! empty( $vk_blocks_options['active_vk-blocks'] ) ) { |
| 101 |
$vk_blocks_options['active_vk-blocks'] = false; |
| 102 |
update_option( 'vkExUnit_common_options', $vk_blocks_options ); |
| 103 |
|
| 104 |
add_action( |
| 105 |
'admin_notices', |
| 106 |
function() { |
| 107 |
echo '<div class="updated notice"><p>'; |
| 108 |
echo esc_html( __( 'Disabled Blocks module on VK All in One Expansion Unit. Because VK-Blocks Plugin running.', 'vk-blocks' ) ); |
| 109 |
echo '</p></div>'; |
| 110 |
} |
| 111 |
); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Load VK Blocks |
| 117 |
*/ |
| 118 |
require_once plugin_dir_path( __FILE__ ) . 'inc/vk-blocks-config.php'; |
| 119 |
|
| 120 |
/** |
| 121 |
* Load updater ( Pro version only ) |
| 122 |
*/ |
| 123 |
$vk_blocks_plugin_base_dir = plugin_dir_path( __FILE__ ); |
| 124 |
if ( strpos( $vk_blocks_plugin_base_dir, 'vk-blocks-pro' ) !== false ) { |
| 125 |
|
| 126 |
// Cope with : WP HTTP Error: cURL error 60: SSL certificate problem: certificate has expired. |
| 127 |
add_filter( 'https_ssl_verify', '__return_false' ); |
| 128 |
|
| 129 |
$vk_blocks_update_checker = Puc_v4_Factory::buildUpdateChecker( |
| 130 |
'https://vws.vektor-inc.co.jp/updates/?action=get_metadata&slug=vk-blocks-pro', |
| 131 |
__FILE__, |
| 132 |
'vk-blocks-pro' |
| 133 |
); |
| 134 |
} |
| 135 |
|