-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwp-graphql-metabox.php
64 lines (55 loc) · 1.43 KB
/
wp-graphql-metabox.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Plugin Name: WPGraphQL Meta Box Integration
* Plugin URI: https://github.com/hsimah-services/wp-graphql-metabox
* Description: WP GraphQL provider for Meta Box
* Author: hsimah
* Author URI: http://www.hsimah.com
* Version: 0.5.0
* Text Domain: wpgraphql-metabox
* License: GPL-3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* @package WPGraphQL_MetaBox
* @author hsimah
* @version 0.5.0
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('WPGraphQL_MetaBox')) {
add_action('admin_init', function () {
$versions = [
'wp-graphql' => '1.0.4',
'metabox' => '5.3.3'
];
if (
!class_exists('RWMB_Loader') ||
!class_exists('WPGraphQL') ||
(defined('WPGRAPHQL_VERSION') && version_compare(WPGRAPHQL_VERSION, $versions['wp-graphql'], 'lt')) ||
(defined('RWMB_VER') && version_compare(RWMB_VER, $versions['metabox'], 'lt'))
) {
/**
* For users with lower capabilities, don't show the notice
*/
if (!current_user_can('manage_options')) {
return false;
}
add_action(
'admin_notices',
function () use ($versions) {
?>
<div class="error notice">
<p>
<?php _e(vsprintf('Both WPGraphQL (v%s+) and Meta Box (v%s+) must be active for "wp-graphql-metabox" to work', $versions), 'wpgraphql-metabox'); ?>
</p>
</div>
<?php
}
);
return false;
}
});
require_once __DIR__ . '/class-metabox.php';
}