-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-graphql-mb-relationships.php
executable file
·65 lines (56 loc) · 1.55 KB
/
wp-graphql-mb-relationships.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
65
<?php
/**
* Plugin Name: WP GraphQL MB Relationships
* Plugin URI: https://github.com/hsimah/wp-graphql-mb-relationships
* Description: WP GraphQL provider for MB Relationships
* Author: hsimah
* Author URI: http://www.hsimah.com
* Version: 0.4.0
* Text Domain: wpgraphql-mb-relationships
* License: GPL-3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* @package WPGraphQL_MB_Relationships
* @author hsimah
* @version 0.4.0
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('WPGraphQL_MB_Relationships')) {
add_action('admin_init', function () {
$min_versions = [
'wpgraphql' => '0.8.1',
'metabox' => '1.10.3',
];
if (
class_exists('MBR_Loader') &&
class_exists('WPGraphQL') &&
(defined('WPGRAPHQL_VERSION') && version_compare(WPGRAPHQL_VERSION, $min_versions['wpgraphql'], 'lt')) &&
(defined('RWMB_VER') && version_compare(RWMB_VER, $min_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 ($min_versions) {
?>
<div class="error notice">
<p>
<?php _e(vsprintf('Both WPGraphQL (v%s+) and MB Relationships (v%s+) must be active for "wp-graphql-mb-relationships" to work', $min_versions), 'wpgraphql-mb-relationships'); ?>
</p>
</div>
<?php
}
);
return false;
}
});
require_once __DIR__ . '/class-mb-relationships.php';
\WPGraphQL_MB_Relationships::instance();
}