PluginProbe
TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables / 2.3.0
TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables v2.3.0
2.3.0 2.2.14 2.2.13 2.2.12 2.2.11 2.2.10 2.2.9 2.2.8 2.2.7 2.2.6 2.2.5 2.2.4 2.2.3 trunk 1.0.0 1.0.1 2.0.0 2.0.1 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2
← All changes | table-builder-block.php +118 -27 2.2.5 → 2.3.0 View file →
@@ -1,19 +1,20 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: TableKit
4 - * Description: Powerful Table Builder for Gutenberg block editor.
3 + * Plugin Name: TableKit
4 + * Plugin URI: https://wpmet.com/plugin/gutenkit/
5 + * Description: Powerful Table Builder for Gutenberg block editor.
6 + * Version: 2.3.0
5 7 * Requires at least: 6.1
6 - * Requires PHP: 7.4
7 - * Plugin URI: https://wpmet.com/plugin/gutenkit/
8 - * Author: Wpmet
9 - * Version: 2.2.5
10 - * Author URI: https://wpmet.com/
11 - * License: GPL-3.0-or-later
12 - * License URI: https://www.gnu.org/licenses/gpl-3.0.html
8 + * Requires PHP: 7.4
9 + * Author: Wpmet
10 + * Author URI: https://wpmet.com/
11 + * License: GPL-3.0-or-later
12 + * License URI: https://www.gnu.org/licenses/gpl-3.0.html
13 + * Text Domain: table-builder-block
14 + * Domain Path: /languages
13 15 *
14 - * Text Domain: table-builder-block
15 - * Domain Path: /languages
16 + * @package TableKit
16 17 */
17 18
18 19 // Exit if accessed directly.
19 20 if ( ! defined( 'ABSPATH' ) ) {
@@ -19,13 +20,26 @@
19 20 if ( ! defined( 'ABSPATH' ) ) {
20 21 exit;
21 22 }
22 23
24 +/**
25 + * Main plugin bootstrap class for TableKit.
26 + */
23 27 final class TableBuilder {
24 - const VERSION = '2.2.5';
28 + const VERSION = '2.3.0';
25 29
30 + /**
31 + * Singleton instance.
32 + *
33 + * @var TableBuilder|null
34 + */
26 35 private static $instance = null;
27 36
37 + /**
38 + * Gets (and lazily creates) the singleton plugin instance.
39 + *
40 + * @return TableBuilder
41 + */
28 42 public static function get_instance(): TableBuilder {
29 43 if ( null === self::$instance ) {
30 44 self::$instance = new self();
31 45 }
@@ -31,24 +45,59 @@
31 45 }
32 46 return self::$instance;
33 47 }
34 48
49 + /**
50 + * Defines plugin constants and registers the plugin's core hooks.
51 + */
35 52 private function __construct() {
36 53 $this->define_constants();
37 54
38 - // Prevent redirects during programmatic plugin activation
39 - // This hook runs very early to intercept activation redirects from other plugins
40 - add_action( 'admin_init', [ $this, 'prevent_activation_redirect' ], 1 );
55 + // Prevent redirects during programmatic plugin activation.
56 + // This hook runs very early to intercept activation redirects from other plugins.
57 + add_action( 'admin_init', array( $this, 'prevent_activation_redirect' ), 1 );
41 58
42 - // Make sure ADD AUTOLOAD is scoped/vendor/scoper-autoload.php file
43 - require_once TABLE_BUILDER_BLOCK_PLUGIN_DIR . '/scoped/vendor/scoper-autoload.php';
59 + // Make sure ADD AUTOLOAD is scoped/deps/scoper-autoload.php file.
60 + require_once TABLE_BUILDER_BLOCK_PLUGIN_DIR . '/scoped/deps/scoper-autoload.php';
61 + require_once TABLE_BUILDER_BLOCK_INC_DIR . 'Elementor/TablekitElementor.php';
44 62
45 - // Fires after initialization of the GutenKit plugin
46 - add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] );
47 - add_action( 'admin_init', [ $this, 'maybe_redirect_to_onboard' ] );
63 + // Fires after initialization of the GutenKit plugin.
64 + add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
65 + add_action( 'admin_init', array( $this, 'maybe_redirect_to_onboard' ) );
66 +
67 + // Load translated strings for PHP (.mo). JS/React strings are handled
68 + // separately per-script via wp_set_script_translations() in Enqueue.php.
69 + add_action( 'init', array( $this, 'load_textdomain' ) );
48 70 }
49 71
72 + /**
73 + * Loads the plugin's PHP translation file.
74 + *
75 + * WordPress 5.9+ can auto-discover this from the "Text Domain"/"Domain Path"
76 + * plugin headers, but declaring it explicitly is the standard, version-safe
77 + * pattern and is required for translations shipped under
78 + * wp-content/languages/plugins/ instead of this plugin's own /languages folder.
79 + */
80 + public function load_textdomain(): void {
81 + // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound -- kept for translation delivery outside the WordPress.org directory (e.g. wp-content/languages/table-builder-block/ or a bundled distribution); WordPress.org itself auto-loads by slug since 4.6 and doesn't need this call.
82 + load_plugin_textdomain(
83 + 'table-builder-block',
84 + false,
85 + dirname( plugin_basename( __FILE__ ) ) . '/languages'
86 + );
87 + }
88 +
89 + /**
90 + * Plugin activation callback: records the install time and, on first
91 + * activation, primes the transients that trigger the onboarding redirect.
92 + *
93 + * @return void
94 + */
50 95 public static function activate(): void {
96 + if ( ! get_option( 'tablebuilder_installed_time' ) ) {
97 + add_option( 'tablebuilder_installed_time', time() );
98 + }
99 +
51 100 if ( get_transient( 'tablekit_skip_activation_redirect' ) ) {
52 101 return;
53 102 }
54 103
@@ -57,8 +106,13 @@
57 106 set_transient( 'tablebuilder_do_activation_redirect', 1, MINUTE_IN_SECONDS );
58 107 }
59 108 }
60 109
110 + /**
111 + * Defines the plugin's path/URL/version constants.
112 + *
113 + * @return void
114 + */
61 115 private function define_constants(): void {
62 116 define( 'TABLE_BUILDER_BLOCK_PLUGIN_VERSION', self::VERSION );
63 117 define( 'TABLE_BUILDER_BLOCK_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
64 118 define( 'TABLE_BUILDER_BLOCK_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
@@ -67,10 +121,14 @@
67 121 define( 'TABLE_BUILDER_BLOCK_DIR', TABLE_BUILDER_BLOCK_PLUGIN_DIR . 'build/blocks/' );
68 122 }
69 123
70 124
71 - // Prevent activation redirects when plugins are activated programmatically.
72 - // Intercepts wp_redirect/wp_safe_redirect during REST API activation.
125 + /**
126 + * Prevents activation redirects when plugins are activated programmatically.
127 + * Intercepts wp_redirect/wp_safe_redirect during REST API activation.
128 + *
129 + * @return void
130 + */
73 131 public function prevent_activation_redirect(): void {
74 132 if ( get_transient( 'tablekit_skip_activation_redirect' ) ) {
75 133 add_filter( 'wp_redirect', '__return_empty_string', 999 );
76 134 add_filter( 'wp_safe_redirect_fallback', '__return_empty_string', 999 );
@@ -76,29 +134,55 @@
76 134 add_filter( 'wp_safe_redirect_fallback', '__return_empty_string', 999 );
77 135 }
78 136 }
79 137
138 + /**
139 + * Boots the plugin's core classes once all plugins have loaded.
140 + *
141 + * @return void
142 + */
80 143 public function on_plugins_loaded(): void {
144 + /**
145 + * Fires right before TableKit's core classes are instantiated, on "plugins_loaded".
146 + *
147 + * @since Unknown
148 + */
149 + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- slash-namespaced hook name is this plugin's established public API (used by the Pro add-on); renaming would be a breaking change.
81 150 do_action( 'tablebuilder/before_init' );
82 151
152 + // Note: translations are already loaded via load_textdomain(), hooked to 'init'
153 + // in the constructor above (which runs before the 'init' callbacks registered
154 + // by the classes below) — no need to call load_plugin_textdomain() again here.
155 +
83 156 TableBuilder\Hooks\AssetGenerator::instance();
157 + TableBuilder\Core\ScriptTranslationMerger::instance();
84 158 TableBuilder\Core\Enqueue::instance();
85 159 TableBuilder\Core\RestApi::instance();
160 + TableBuilder\Config\CPT\TableCPT::instance();
86 161 TableBuilder\Config\Blocks::instance();
87 162 TableBuilder\Shortcode\Shortcode::instance();
88 163 TableBuilder\Admin\Admin::instance();
164 + TableKit_Elementor::init();
89 165
166 + // Receive deactivation reason data from the plugins-page modal.
167 + new TableBuilder\Routes\DeactivationFeedback();
168 +
90 169 if ( is_admin() ) {
91 170 TableBuilder\Libs\UtilityPackages::instance();
92 171 }
93 172
94 - // Data migration
95 - // TODO:: WIll be removed in next upcoming version
96 - (new TableBuilder\Core\DataMigration());
173 + // Data migration.
174 + // TODO:: Will be removed in next upcoming version.
175 + ( new TableBuilder\Core\DataMigration() );
97 176
98 - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), [ $this, 'plugin_action_link' ] );
177 + add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_link' ) );
99 178 }
100 179
180 + /**
181 + * Redirects to the onboarding screen right after activation, when eligible.
182 + *
183 + * @return void
184 + */
101 185 public function maybe_redirect_to_onboard(): void {
102 186 if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
103 187 return;
104 188 }
@@ -106,8 +190,9 @@
106 190 if ( ! get_transient( 'tablebuilder_do_activation_redirect' ) ) {
107 191 return;
108 192 }
109 193
194 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check (same pattern WP core uses internally) to skip a redirect during bulk activation; no state change.
110 195 if ( isset( $_GET['activate-multi'] ) ) {
111 196 delete_transient( 'tablebuilder_do_activation_redirect' );
112 197 return;
113 198 }
@@ -116,8 +201,14 @@
116 201 wp_safe_redirect( admin_url( 'admin.php?page=tablebuilder&onboard=1' ) );
117 202 exit;
118 203 }
119 204
205 + /**
206 + * Filter callback for the plugin's row action links (currently a no-op passthrough).
207 + *
208 + * @param array $plugin_actions Existing action links.
209 + * @return array Unmodified action links.
210 + */
120 211 public function plugin_action_link( array $plugin_actions ): array {
121 212 return $plugin_actions;
122 213 }
123 214 }
@@ -125,5 +216,5 @@
125 216 if ( class_exists( 'TableBuilder' ) ) {
126 217 TableBuilder::get_instance();
127 218 }
128 219
129 -register_activation_hook( __FILE__, [ 'TableBuilder', 'activate' ] );
220 +register_activation_hook( __FILE__, array( 'TableBuilder', 'activate' ) );