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