PluginProbe
VK Blocks / 1.14.1
VK Blocks v1.14.1
1.126.4 1.126.3 1.126.1 1.126.2 1.126.0 1.125.0 1.124.0 1.123.0 1.122.0 1.121.0 1.120.0 1.119.2 1.119.1 1.119.0 1.118.7 1.82.0.0 1.82.0.1 1.83.0.0 1.83.0.1 1.84.0.0 1.84.0.1 1.85.0.2 1.85.0.3 1.85.1.0 1.85.1.1 All 287 releases
vk-blocks / vk-blocks.php

vk-blocks.php in VK Blocks 1.14.1, at vk-blocks.php

116 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.14.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 * @package vk-blocks
13 */
14
15 // Do not load directly.
16 defined( 'ABSPATH' ) || die();
17
18 /* function_exists は VK Blocks 無料版の無効化が正常に動作しなかった場合のフォールバック */
19 if ( ! function_exists( 'vkblocks_get_version' ) ) {
20 /**
21 * Get Plugin Version
22 *
23 * @return string
24 */
25 function vkblocks_get_version() {
26 $data = get_file_data( __FILE__, array( 'version' => 'Version' ) );
27 return $data['version'];
28 }
29 }
30
31 /* function_exists は VK Blocks 無料版の無効化が正常に動作しなかった場合のフォールバック */
32 if ( ! function_exists( 'vkblocks_deactivate_plugin' ) ) {
33 /**
34 * Plugin deactive function
35 *
36 * @param string $plugin_path Plugin path to disable.
37 * @return void
38 */
39 function vkblocks_deactivate_plugin( $plugin_path ) {
40 include_once ABSPATH . 'wp-admin/includes/plugin.php';
41 if ( is_plugin_active( $plugin_path ) ) {
42 $active_plugins = get_option( 'active_plugins' );
43 // delete active plugin.
44 $active_plugins = array_diff( $active_plugins, array( $plugin_path ) );
45 // re index active plugin.
46 $active_plugins = array_values( $active_plugins );
47 update_option( 'active_plugins', $active_plugins );
48 }
49 }
50 }
51
52 /**
53 * Deactive VK Blocks ( Free )
54 *
55 * 関数名�
56 �れると無料版 VK Blocks の宣言と被ってエラーになるので一時的な回避処理で無名関数を利用している
57 */
58 add_action(
59 'admin_init',
60 function() {
61 $plugin_base_dir = dirname( __FILE__ );
62 include_once ABSPATH . 'wp-admin/includes/plugin.php';
63 if ( is_plugin_active( 'vk-blocks-pro/vk-blocks.php' ) ) {
64 // Deactive Plugin VK Blocks ( free ).
65 if ( function_exists( 'vkblocks_deactivate_plugin' ) ) {
66 vkblocks_deactivate_plugin( 'vk-blocks/vk-blocks.php' );
67 }
68 }
69 // Deactive ExUnit included VK Blocks.
70 $options = get_option( 'vkExUnit_common_options' );
71 if ( ! empty( $options['active_vk-blocks'] ) ) {
72 $options['active_vk-blocks'] = false;
73 update_option( 'vkExUnit_common_options', $options );
74 }
75 },
76 9999
77 );
78
79 if ( is_admin() && ! is_network_admin() ) {
80 $options = get_option( 'vkExUnit_common_options' );
81 if ( ! empty( $options['active_vk-blocks'] ) ) {
82 $options['active_vk-blocks'] = false;
83 update_option( 'vkExUnit_common_options', $options );
84
85 add_action(
86 'admin_notices',
87 function() {
88 echo '<div class="updated notice"><p>';
89 echo esc_html( __( 'Disabled Blocks module on VK All in One Expansion Unit. Because VK-Blocks Plugin running.', 'vk-blocks' ) );
90 echo '</p></div>';
91 }
92 );
93 }
94 }
95
96 /**
97 * Load VK Blocks
98 */
99 require_once plugin_dir_path( __FILE__ ) . 'inc/vk-blocks-config.php';
100
101 /**
102 * Load updater ( Pro version only )
103 */
104 $plugin_base_dir = plugin_dir_path( __FILE__ );
105 if ( strpos( $plugin_base_dir, 'vk-blocks-pro' ) !== false ) {
106 $updater_url = plugin_dir_path( __FILE__ ) . 'inc/vk-blocks-pro/plugin-update-checker/plugin-update-checker.php';
107 if ( file_exists( $updater_url ) ) {
108 require plugin_dir_path( __FILE__ ) . 'inc/vk-blocks-pro/plugin-update-checker/plugin-update-checker.php';
109 $my_update_checker = Puc_v4_Factory::buildUpdateChecker(
110 'https://vws.vektor-inc.co.jp/updates/?action=get_metadata&slug=vk-blocks-pro',
111 __FILE__,
112 'vk-blocks-pro'
113 );
114 }
115 }
116