-
Notifications
You must be signed in to change notification settings - Fork 4
/
acf-native-fields.php
89 lines (76 loc) · 2.32 KB
/
acf-native-fields.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* ACF Native Fields by Winter ❄
*
* @link https://github.com/winteragency/wntr-acf-flexible-content-preview
* @since 1.0.0
* @package ACF_Native_Fields
*
* x-release-please-start-version
*
* @wordpress-plugin
* Plugin Name: ACF Native Fields
* Plugin URI: https://github.com/winteragency/acf-native-fields
* Description: An interface to move native WordPress fields and options into ACF for a cleaner editor layout
* Version: 1.2.1
* Requires at least: 6.0
* Requires PHP: 8.0
* Author: Winter Agency
* Author URI: http://winteragency.se
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: acf-native-fields
* Domain Path: /languages
*
* x-release-please-end
*/
if (!defined('ABSPATH')) {
exit();
}
class ACF_Native_Fields {
static $instance = false;
public $version = '1.2.1'; // x-release-please-version
function __construct() {
// Init plugin (check requirements etc)
add_action('admin_init', [$this, 'admin_init']);
// Add native field type to ACF
add_action('acf/include_field_types', [$this, 'include_native_field_type']);
}
public function admin_init() {
load_plugin_textdomain(
'acf-native-fields',
false,
dirname(plugin_basename(__FILE__)) . '/lang/',
);
// Require ACF
if (
current_user_can('activate_plugins') &&
!is_plugin_active('advanced-custom-fields/acf.php') &&
!is_plugin_active('advanced-custom-fields-pro/acf.php')
) {
add_action('admin_notices', [$this, 'require_acf']);
deactivate_plugins(plugin_basename(__FILE__));
if (isset($_GET['activate'])) {
unset($_GET['activate']);
}
}
}
public function require_acf() {
?>
<div class="error"><p><?php _e(
'ACF Native Fields requires Advanced Custom Fields v5+ to be installed and activated.',
'acf-native-fields',
); ?></p></div><?php
}
public function include_native_field_type() {
require dirname(__FILE__) . '/acf-native-field-type.php';
new acf_field_native();
}
static function &instance() {
if (false === self::$instance) {
self::$instance = new ACF_Native_Fields();
}
return self::$instance;
}
}
new ACF_Native_Fields();