PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
← All changes | tableberg.php +125 -29 0.0.21.1.5 View file →
@@ -1,12 +1,15 @@
1 1 <?php
2 +
2 3 /**
3 4 * Plugin Name: Tableberg
4 - * Description: Tableberg: table builder Gutenberg block
5 - * Version: 0.0.2
5 + * Plugin URI: https://tableberg.com/
6 + * Description: Table Block by Tableberg - Create Better Tables With Block Editor
7 + * Version: 1.1.5
6 8 * Requires at least: 6.1
7 9 * Requires PHP: 7.0
8 - * Author: Dotcamp
10 + * Author: Tableberg
11 + * Author URI: https://tableberg.com/
9 12 * License: GPL-2.0-or-later
10 13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 14 * Text Domain: tableberg
12 15 *
@@ -12,41 +15,134 @@
12 15 *
13 16 * @package Tableberg
14 17 */
15 18
16 -if ( ! defined( 'ABSPATH' ) ) {
17 - exit; // Exit if accessed directly.
19 +if (!defined('ABSPATH')) {
20 + exit;
18 21 }
22 +if (!defined('TABLEBERG_VERSION')) {
23 + define('TABLEBERG_VERSION', '1.1.5');
24 +}
25 +if (!defined('TABLEBERG_DIR_PATH')) {
26 + define('TABLEBERG_DIR_PATH', plugin_dir_path(__FILE__));
27 +}
19 28
20 -if ( ! defined( 'TABLEBERG_DIR_PATH' ) ) {
21 - define( 'TABLEBERG_DIR_PATH', plugin_dir_path( __FILE__ ) );
29 +if (!defined('TABLEBERG_URL')) {
30 + define('TABLEBERG_URL', plugin_dir_url(__FILE__));
22 31 }
32 +if (!defined('TABLEBERG_PLUGIN_FILE')) {
33 + define('TABLEBERG_PLUGIN_FILE', __FILE__);
34 +}
23 35
24 -if ( ! defined( 'TABLEBERG_URL' ) ) {
25 - define( 'TABLEBERG_URL', plugin_dir_url( __FILE__ ) );
36 +require_once __DIR__ . '/vendor/autoload.php';
37 +require_once __DIR__ . '/renderer/utils.php';
38 +
39 +if (!function_exists('tab_fs')) {
40 + function tab_fs() {
41 + global $tab_fs;
42 +
43 + if (!isset($tab_fs)) {
44 + require_once __DIR__ . '/vendor/freemius/start.php';
45 +
46 + $tab_fs = fs_dynamic_init(
47 + [
48 + 'id' => '14649',
49 + 'slug' => 'tableberg',
50 + 'type' => 'plugin',
51 + 'public_key' => 'pk_8043aa788c004c4b385af8384c74b',
52 + 'is_premium' => false,
53 + 'has_addons' => true,
54 + 'has_paid_plans' => false,
55 + 'is_org_compliant' => true,
56 + 'menu' => [
57 + 'slug' => 'tableberg-settings',
58 + 'first-path' => 'admin.php?page=tableberg-settings&route=welcome',
59 + ],
60 + ]
61 + );
62 + }
63 +
64 + return $tab_fs;
65 + }
66 +
67 + tab_fs();
68 + do_action('tab_fs_loaded');
26 69 }
27 70
28 -require_once __DIR__ . '/vendor/autoload.php';
71 +use Tableberg\Constants;
72 +use Tableberg\Renderer\Migrations\BlockContentMigrator;
73 +use Tableberg\Renderer\Table\TableRenderer;
74 +use Tableberg\Renderer\ToggleBlockRenderer;
29 75
30 -if ( ! class_exists( 'Tableberg' ) ) {
31 - /**
32 - * External Query Block main class.
33 - */
34 - class Tableberg {
76 +if (!class_exists('Tableberg')) {
77 + class Tableberg {
78 + public function __construct() {
79 + new Tableberg\Admin\Tableberg_Admin();
80 + add_action('init', [$this, 'register_blocks']);
81 + add_action(
82 + 'enqueue_block_editor_assets',
83 + [$this, 'localize_block_editor_assets']
84 + );
85 + add_action('wp_enqueue_scripts', [$this, 'localize_frontend_assets']);
35 86
87 + $restController = new Tableberg\DynamicData\RestController();
88 + add_action('rest_api_init', [$restController, 'register_routes']);
36 89
37 - /**
38 - * Constructor.
39 - *
40 - * @return void
41 - */
42 - public function __construct() {
43 - new Tableberg\Blocks\Button();
44 - new Tableberg\Blocks\Image();
45 - new Tableberg\Blocks\Table();
46 - new Tableberg\Blocks\Cell();
47 - new Tableberg\Blocks\Row();
48 - }
49 - }
90 + $migrator = new BlockContentMigrator();
91 + add_action('rest_api_init', [$migrator, 'register_rest_hooks']);
92 + add_filter('render_block_data', [$migrator, 'migrate_parsed_block']);
50 93
51 - new Tableberg();
94 + register_activation_hook(__FILE__, [$this, 'activate_plugin']);
95 + register_deactivation_hook(__FILE__, [$this, 'deactivate_plugin']);
96 + }
97 +
98 + public function localize_block_editor_assets() {
99 + $assets = new \Tableberg\Assets();
100 + $assets->register_blocks_assets();
101 + }
102 +
103 + public function localize_frontend_assets() {
104 + $assets = new \Tableberg\Assets();
105 + $assets->register_frontend_assets();
106 + }
107 +
108 + public function register_blocks() {
109 + $renderer = new TableRenderer();
110 +
111 + register_block_type_from_metadata(
112 + TABLEBERG_DIR_PATH . 'build/blocks/table/block.json',
113 + [
114 + 'render_callback' => [$renderer, 'render'],
115 + ]
116 + );
117 +
118 + $toggleBlockRenderer = new ToggleBlockRenderer();
119 +
120 + register_block_type_from_metadata(
121 + TABLEBERG_DIR_PATH . 'build/blocks/toggle/block.json',
122 + [
123 + 'render_callback' => [
124 + $toggleBlockRenderer, 'render',
125 + ],
126 + ]
127 + );
128 + }
129 +
130 + public function activate_plugin() {
131 + set_transient('_welcome_redirect_tableberg', true, 60);
132 +
133 + update_option('tableberg_version', TABLEBERG_VERSION);
134 + update_option('tableberg_installDate', date('Y-m-d h:i:s'));
135 +
136 + add_option('tableberg_review_notify', 'no');
137 + }
138 +
139 + public function deactivate_plugin() {
140 + delete_transient('_welcome_redirect_tableberg');
141 +
142 + delete_option('tableberg_version');
143 + delete_option('tableberg_installDate');
144 + }
145 + }
146 +
147 + new Tableberg();
52 148 }