vk-blocks
Last commit date
inc
6 years ago
lib
6 years ago
readme.txt
6 years ago
screenshot-1.png
7 years ago
screenshot-2.png
7 years ago
vk-blocks.php
6 years ago
vk-blocks.php
88 lines
| 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.16.2 |
| 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 | require_once( 'inc/vk-blocks-config.php' ); |
| 16 | |
| 17 | add_action( |
| 18 | 'plugins_loaded', function () { |
| 19 | // Load language files. |
| 20 | load_plugin_textdomain( 'vk-blocks', false, 'vk-blocks/inc/vk-blocks/build/languages' ); |
| 21 | } |
| 22 | ); |
| 23 | |
| 24 | /*-------------------------------------------*/ |
| 25 | /* Helpers ( Plugin only ) |
| 26 | /*-------------------------------------------*/ |
| 27 | if ( ! function_exists( 'vkblocks_deactivate_plugin' ) ) { |
| 28 | /** |
| 29 | * Plugin deactive function |
| 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 | add_action( 'init', 'vkblocks_deactive_free_version' ); |
| 50 | function vkblocks_deactive_free_version() { |
| 51 | |
| 52 | $plugin_base_dir = dirname( __FILE__ ); |
| 53 | |
| 54 | // When this file loaded from Pro version |
| 55 | if ( strpos( $plugin_base_dir, 'vk-blocks-pro' ) !== false ) { |
| 56 | |
| 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 | |
| 70 | } |
| 71 | |
| 72 | /*-------------------------------------------*/ |
| 73 | /* Load updater |
| 74 | /*-------------------------------------------*/ |
| 75 | $plugin_base_dir = dirname( __FILE__ ); |
| 76 | if ( strpos( $plugin_base_dir, 'vk-blocks-pro' ) !== false ) { |
| 77 | |
| 78 | $updater_url = dirname( __FILE__ ) . '/inc/plugin-update-checker/plugin-update-checker.php'; |
| 79 | if ( file_exists( $updater_url ) ) { |
| 80 | require dirname( __FILE__ ) . '/inc/plugin-update-checker/plugin-update-checker.php'; |
| 81 | $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( |
| 82 | 'https://vws.vektor-inc.co.jp/updates/?action=get_metadata&slug=vk-blocks-pro', |
| 83 | __FILE__, |
| 84 | 'vk-blocks-pro' |
| 85 | ); |
| 86 | } |
| 87 | } |
| 88 |