These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Plugin Name: Tabulate |
||
4 | * Description: Manage relational tabular data within the WP admin area, using the full power of your MySQL database. |
||
5 | * Author: Sam Wilson |
||
6 | * Author URI: https://samwilson.id.au/ |
||
7 | * License: GPL-2.0+ |
||
8 | * Text Domain: tabulate |
||
9 | * Domain Path: /languages |
||
10 | * Version: 2.9.5 |
||
11 | */ |
||
12 | |||
13 | define( 'TABULATE_VERSION', '2.9.5' ); |
||
14 | define( 'TABULATE_SLUG', 'tabulate' ); |
||
15 | |||
16 | // Load textdomain. |
||
17 | add_action( 'plugins_loaded', function() { |
||
18 | load_plugin_textdomain( TABULATE_SLUG, false, basename( __DIR__ ) . '/languages/' ); |
||
19 | } ); |
||
20 | |||
21 | // Make sure Composer has been set up (for installation from Git, mostly). |
||
22 | if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
||
23 | add_action( 'admin_notices', function() { |
||
24 | $msg = __( 'Please run <kbd>composer install</kbd> prior to using Tabulate.', 'tabulate' ); |
||
25 | echo "<div class='error'><p>$msg</p></div>"; |
||
26 | } ); |
||
27 | return; |
||
28 | } |
||
29 | require __DIR__ . '/vendor/autoload.php'; |
||
30 | |||
31 | // Get the global database. |
||
32 | // This file contains the only global variables other than in the TestBase class; |
||
33 | // they're injected from here to everywhere else. |
||
34 | global $wpdb; |
||
0 ignored issues
–
show
|
|||
35 | |||
36 | // Set up the menus; their callbacks do the actual dispatching to controllers. |
||
37 | $menus = new \WordPress\Tabulate\Menus( $wpdb ); |
||
38 | $menus->init(); |
||
39 | |||
40 | // Add grants-checking callback. |
||
41 | add_filter( 'user_has_cap', '\\WordPress\\Tabulate\\DB\\Grants::check', 0, 3 ); |
||
42 | |||
43 | // Activation hooks. Uninstall is handled by uninstall.php. |
||
44 | register_activation_hook( __FILE__, [ $menus, 'activation' ] ); |
||
45 | |||
46 | // Register JSON API. |
||
47 | add_action( 'rest_api_init', function() use ( $wpdb ) { |
||
48 | $api_controller = new \WordPress\Tabulate\Controllers\ApiController( $wpdb, $_GET ); |
||
49 | $api_controller->register_routes(); |
||
50 | } ); |
||
51 | |||
52 | // Shortcode. |
||
53 | $shortcode = new \WordPress\Tabulate\Controllers\ShortcodeController( $wpdb ); |
||
54 | add_shortcode( TABULATE_SLUG, array( $shortcode, 'run' ) ); |
||
55 | |||
56 | // Dashboard widget. |
||
57 | add_action( 'wp_dashboard_setup', function() { |
||
58 | wp_add_dashboard_widget( TABULATE_SLUG . 'dashboard_widget', 'Tabulate', function() { |
||
59 | $template = new \WordPress\Tabulate\Template( 'quick_jump.html' ); |
||
60 | echo $template->render(); |
||
61 | } ); |
||
62 | } ); |
||
63 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state