Version Description
- Admin: Re-introduced 'Options' admin screen under Settings > Options. Code has been completely refactored using native WP List Table. New features: Searchbox, item per page preference (default: 100), sortable columns, bulk delete and ability to edit serialized values.
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.6.1 |
Comparing to | |
See all releases |
Code changes from version 0.6.0.2 to 0.6.1
- acf-extended.php +4 -2
- assets/acf-extended.css +13 -0
- includes/admin/options.class.php +266 -0
- includes/admin/options.php +499 -160
- includes/admin/settings.php +0 -44
- includes/admin/views/html-options-edit.php +61 -0
- includes/admin/views/html-options-list.php +38 -0
- includes/core/menu.php +48 -0
- readme.txt +14 -5
acf-extended.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
-
* Version: 0.6.
|
6 |
* Author: hwk
|
7 |
* Author URI: https://hwk.fr
|
8 |
* Text Domain: acfe
|
@@ -49,12 +49,14 @@ function acfe_load(){
|
|
49 |
require_once(ACFE_PATH . 'includes/core/compatibility.php');
|
50 |
require_once(ACFE_PATH . 'includes/core/enqueue.php');
|
51 |
require_once(ACFE_PATH . 'includes/core/helpers.php');
|
|
|
52 |
|
53 |
/**
|
54 |
* Admin Pages
|
55 |
*/
|
|
|
56 |
require_once(ACFE_PATH . 'includes/admin/settings.php');
|
57 |
-
|
58 |
|
59 |
/**
|
60 |
* Fields settings
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.6.1
|
6 |
* Author: hwk
|
7 |
* Author URI: https://hwk.fr
|
8 |
* Text Domain: acfe
|
49 |
require_once(ACFE_PATH . 'includes/core/compatibility.php');
|
50 |
require_once(ACFE_PATH . 'includes/core/enqueue.php');
|
51 |
require_once(ACFE_PATH . 'includes/core/helpers.php');
|
52 |
+
require_once(ACFE_PATH . 'includes/core/menu.php');
|
53 |
|
54 |
/**
|
55 |
* Admin Pages
|
56 |
*/
|
57 |
+
require_once(ACFE_PATH . 'includes/admin/options.php');
|
58 |
require_once(ACFE_PATH . 'includes/admin/settings.php');
|
59 |
+
|
60 |
|
61 |
/**
|
62 |
* Fields settings
|
assets/acf-extended.css
CHANGED
@@ -118,4 +118,17 @@ td.acf-field-group-category a{
|
|
118 |
.column-acfe-autosync-json{
|
119 |
width:65px;
|
120 |
text-align:center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
118 |
.column-acfe-autosync-json{
|
119 |
width:65px;
|
120 |
text-align:center;
|
121 |
+
}
|
122 |
+
|
123 |
+
.settings_page_acfe-options .column-option_id{
|
124 |
+
width:65px;
|
125 |
+
}
|
126 |
+
|
127 |
+
.settings_page_acfe-options .column-option_name{
|
128 |
+
width:435px;
|
129 |
+
}
|
130 |
+
|
131 |
+
.settings_page_acfe-options .column-autoload{
|
132 |
+
width:100px;
|
133 |
+
text-align:center;
|
134 |
}
|
includes/admin/options.class.php
ADDED
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
if (!class_exists( 'WP_List_Table'))
|
7 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
8 |
+
|
9 |
+
class ACFE_Admin_Options_List extends WP_List_Table{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Constructor
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
public function __construct(){
|
16 |
+
|
17 |
+
parent::__construct(array(
|
18 |
+
'singular' => __('Option', 'acfe'),
|
19 |
+
'plural' => __('Options', 'acfe'),
|
20 |
+
'ajax' => false
|
21 |
+
));
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Retrieve data from the database
|
28 |
+
*
|
29 |
+
* @param int $per_page
|
30 |
+
* @param int $page_number
|
31 |
+
*
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public static function get_options($per_page = 100, $page_number = 1, $search = ''){
|
35 |
+
|
36 |
+
global $wpdb;
|
37 |
+
|
38 |
+
$sql = "SELECT * FROM {$wpdb->options}";
|
39 |
+
|
40 |
+
if(!empty($search)){
|
41 |
+
|
42 |
+
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
if(empty($_REQUEST['orderby'])){
|
47 |
+
|
48 |
+
$sql .= ' ORDER BY option_id ASC';
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
else{
|
53 |
+
|
54 |
+
$sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']);
|
55 |
+
$sql .= !empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC';
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
$sql .= " LIMIT $per_page";
|
60 |
+
$sql .= ' OFFSET ' . ($page_number - 1) * $per_page;
|
61 |
+
|
62 |
+
|
63 |
+
$result = $wpdb->get_results($sql, 'ARRAY_A');
|
64 |
+
|
65 |
+
return $result;
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Returns the count of records in the database.
|
72 |
+
*
|
73 |
+
* @return null|string
|
74 |
+
*/
|
75 |
+
public static function record_count($search = ''){
|
76 |
+
|
77 |
+
global $wpdb;
|
78 |
+
|
79 |
+
$sql = "SELECT COUNT(*) FROM {$wpdb->options}";
|
80 |
+
|
81 |
+
if(!empty($search)){
|
82 |
+
|
83 |
+
$sql .= ' WHERE option_name LIKE \'%' . $search . '%\'';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
return $wpdb->get_var($sql);
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/** Text displayed when no data is available */
|
93 |
+
public function no_items(){
|
94 |
+
|
95 |
+
_e('No options avaliable.', 'acfe');
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Render a column when no column specific method exist.
|
102 |
+
*
|
103 |
+
* @param array $item
|
104 |
+
* @param string $column_name
|
105 |
+
*
|
106 |
+
* @return mixed
|
107 |
+
*/
|
108 |
+
public function column_default($item, $column_name){
|
109 |
+
|
110 |
+
if($column_name == 'option_id'){
|
111 |
+
|
112 |
+
return $item['option_id'];
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
elseif($column_name == 'option_value'){
|
117 |
+
|
118 |
+
if(is_serialized($item['option_value']) || $item['option_value'] != strip_tags($item['option_value']))
|
119 |
+
return '<pre style="max-height:200px; overflow:auto; white-space: pre;">' . print_r(maybe_unserialize($item['option_value']), true) . '</pre>';
|
120 |
+
|
121 |
+
|
122 |
+
return $item['option_value'];
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
elseif($column_name == 'autoload'){
|
127 |
+
|
128 |
+
return $item['autoload'];
|
129 |
+
|
130 |
+
}else{
|
131 |
+
|
132 |
+
return print_r($item, true);
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Render the bulk edit checkbox
|
140 |
+
*
|
141 |
+
* @param array $item
|
142 |
+
*
|
143 |
+
* @return string
|
144 |
+
*/
|
145 |
+
public function column_cb($item){
|
146 |
+
|
147 |
+
return sprintf(
|
148 |
+
'<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['option_id']
|
149 |
+
);
|
150 |
+
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Method for name column
|
156 |
+
*
|
157 |
+
* @param array $item an array of DB data
|
158 |
+
*
|
159 |
+
* @return string
|
160 |
+
*/
|
161 |
+
public function column_option_name($item){
|
162 |
+
|
163 |
+
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
164 |
+
|
165 |
+
$title = '<strong>' . $item['option_name'] . '</strong>';
|
166 |
+
|
167 |
+
$actions = array(
|
168 |
+
'edit' => sprintf('<a href="?page=%s&action=edit&option=%s">' . __('Edit') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id'])),
|
169 |
+
'delete' => sprintf('<a href="?page=%s&action=delete&option=%s&_wpnonce=%s">' . __('Delete') . '</a>', esc_attr($_REQUEST['page']), absint($item['option_id']), $delete_nonce),
|
170 |
+
);
|
171 |
+
|
172 |
+
return $title . $this->row_actions($actions);
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Associative array of columns
|
179 |
+
*
|
180 |
+
* @return array
|
181 |
+
*/
|
182 |
+
public function get_columns(){
|
183 |
+
|
184 |
+
$columns = array(
|
185 |
+
'cb' => '<input type="checkbox" />',
|
186 |
+
'option_id' => __('ID', 'acfe'),
|
187 |
+
'option_name' => __('Name', 'acfe'),
|
188 |
+
'option_value' => __('Value', 'acfe'),
|
189 |
+
'autoload' => __('Autoload', 'acfe'),
|
190 |
+
);
|
191 |
+
|
192 |
+
return $columns;
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Columns to make sortable.
|
199 |
+
*
|
200 |
+
* @return array
|
201 |
+
*/
|
202 |
+
public function get_sortable_columns(){
|
203 |
+
|
204 |
+
$sortable_columns = array(
|
205 |
+
'option_id' => array('option_id', true),
|
206 |
+
'option_name' => array('option_name', true),
|
207 |
+
'option_value' => array('option_value', true),
|
208 |
+
'autoload' => array('autoload', true),
|
209 |
+
);
|
210 |
+
|
211 |
+
return $sortable_columns;
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Returns an associative array containing the bulk action
|
217 |
+
*
|
218 |
+
* @return array
|
219 |
+
*/
|
220 |
+
public function get_bulk_actions(){
|
221 |
+
|
222 |
+
$actions = array(
|
223 |
+
'bulk-delete' => __('Delete')
|
224 |
+
);
|
225 |
+
|
226 |
+
return $actions;
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Handles data query and filter, sorting, and pagination.
|
233 |
+
*/
|
234 |
+
public function prepare_items(){
|
235 |
+
|
236 |
+
// Get columns
|
237 |
+
$this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
|
238 |
+
|
239 |
+
// Vars
|
240 |
+
$per_page = $this->get_items_per_page('options_per_page', 100);
|
241 |
+
$current_page = $this->get_pagenum();
|
242 |
+
|
243 |
+
// Search
|
244 |
+
$search = (isset( $_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
245 |
+
|
246 |
+
// Get items
|
247 |
+
$this->items = self::get_options($per_page, $current_page, $search);
|
248 |
+
/*
|
249 |
+
foreach($this->items as &$item){
|
250 |
+
$item = json_encode($item);
|
251 |
+
}*/
|
252 |
+
|
253 |
+
// Get total
|
254 |
+
$total_items = self::record_count($search);
|
255 |
+
|
256 |
+
if(!empty($search))
|
257 |
+
$per_page = $total_items;
|
258 |
+
|
259 |
+
$this->set_pagination_args(array(
|
260 |
+
'total_items' => $total_items,
|
261 |
+
'per_page' => $per_page
|
262 |
+
));
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
}
|
includes/admin/options.php
CHANGED
@@ -3,204 +3,543 @@
|
|
3 |
if(!defined('ABSPATH'))
|
4 |
exit;
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
));
|
21 |
|
22 |
}
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
if(empty($pagenow) || $pagenow != 'options-general.php' || !isset($_GET['page']) || $_GET['page'] != 'acfe-options')
|
29 |
-
return;
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
$
|
37 |
-
foreach((array) $options as $option){
|
38 |
-
if($option->option_name == '')
|
39 |
-
continue;
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
}
|
45 |
|
46 |
-
|
|
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
$fields = array();
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
$
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
|
59 |
$fields[] = array(
|
60 |
-
'
|
61 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
);
|
63 |
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
'title' => 'Options',
|
69 |
-
|
70 |
-
'location' => array(
|
71 |
-
array(
|
72 |
-
array(
|
73 |
-
'param' => 'options_page',
|
74 |
-
'operator' => '==',
|
75 |
-
'value' => 'acfe-options',
|
76 |
-
),
|
77 |
-
),
|
78 |
-
),
|
79 |
|
80 |
-
'
|
81 |
-
'
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
'collapsed' => '',
|
104 |
-
'min' => 0,
|
105 |
-
'max' => 0,
|
106 |
-
'layout' => 'table',
|
107 |
-
'button_label' => __('Add option'),
|
108 |
-
'value' => $fields,
|
109 |
-
'sub_fields' => array(
|
110 |
-
array(
|
111 |
-
'label' => 'Option name',
|
112 |
-
'key' => 'field_acfe_option_name',
|
113 |
-
'name' => 'acfe_field_option_name',
|
114 |
-
'type' => 'text',
|
115 |
-
'instructions' => '',
|
116 |
-
'required' => 0,
|
117 |
-
'conditional_logic' => 0,
|
118 |
-
'wrapper' => array(
|
119 |
-
'width' => 33,
|
120 |
-
'class' => '',
|
121 |
-
'id' => '',
|
122 |
-
),
|
123 |
-
'acfe_validate' => '',
|
124 |
-
'acfe_update' => '',
|
125 |
-
'acfe_permissions' => '',
|
126 |
-
'default_value' => '',
|
127 |
-
'placeholder' => '',
|
128 |
-
'prepend' => '',
|
129 |
-
'append' => '',
|
130 |
-
'maxlength' => '',
|
131 |
-
),
|
132 |
-
array(
|
133 |
-
'label' => 'Option value',
|
134 |
-
'key' => 'field_acfe_option_value',
|
135 |
-
'name' => 'acfe_option_value',
|
136 |
-
'type' => 'text',
|
137 |
-
'instructions' => '',
|
138 |
-
'required' => 0,
|
139 |
-
'conditional_logic' => 0,
|
140 |
-
'wrapper' => array(
|
141 |
-
'width' => '',
|
142 |
-
'class' => '',
|
143 |
-
'id' => '',
|
144 |
-
),
|
145 |
-
'acfe_validate' => '',
|
146 |
-
'acfe_update' => '',
|
147 |
-
'acfe_permissions' => '',
|
148 |
-
'default_value' => '',
|
149 |
-
'placeholder' => '',
|
150 |
-
'prepend' => '',
|
151 |
-
'append' => '',
|
152 |
-
'maxlength' => '',
|
153 |
-
),
|
154 |
-
),
|
155 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
),
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$
|
167 |
-
$
|
168 |
-
|
169 |
-
$field['value'] = print_r(maybe_unserialize($field['value']), true);
|
170 |
}
|
171 |
-
|
172 |
-
return $field;
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
-
|
|
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
-
|
|
|
194 |
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
|
|
203 |
$_POST['acf'] = array();
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
}
|
3 |
if(!defined('ABSPATH'))
|
4 |
exit;
|
5 |
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Options WP List Table
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
require_once(ACFE_PATH . 'includes/admin/options.class.php');
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Options Menu
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
add_action('admin_menu', 'acfe_options_menu');
|
18 |
+
function acfe_options_menu(){
|
19 |
|
20 |
+
$hook = add_submenu_page(
|
21 |
+
'options-general.php',
|
22 |
+
__('Options'),
|
23 |
+
__('Options'),
|
24 |
+
acf_get_setting('capability'),
|
25 |
+
'acfe-options'
|
26 |
+
);
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Options Screen
|
32 |
+
*
|
33 |
+
*/
|
34 |
+
add_filter('set-screen-option', 'acfe_options_screen', 10, 3);
|
35 |
+
function acfe_options_screen($status, $option, $value){
|
36 |
+
|
37 |
+
return $value;
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Options Enqueue
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
add_action('admin_print_scripts-settings_page_acfe-options', 'acfe_options_enqueue');
|
46 |
+
function acfe_options_enqueue(){
|
47 |
+
|
48 |
+
wp_enqueue_style('acf-input');
|
49 |
+
wp_enqueue_script('acf-input');
|
50 |
+
wp_enqueue_style('acf-extended', plugins_url('assets/acf-extended.css', ACFE_FILE), false, null);
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Options Load
|
56 |
+
*
|
57 |
+
*/
|
58 |
+
add_action('load-settings_page_acfe-options', 'acfe_options_load');
|
59 |
+
function acfe_options_load(){
|
60 |
+
|
61 |
+
// Messages
|
62 |
+
if(isset($_REQUEST['message']) && !empty($_REQUEST['message']))
|
63 |
+
do_action('acfe/options/load/message=' . $_REQUEST['message']);
|
64 |
+
|
65 |
+
// Default Action
|
66 |
+
$action = 'list';
|
67 |
+
|
68 |
+
// Request Action
|
69 |
+
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
70 |
+
$action = $_REQUEST['action'];
|
71 |
+
|
72 |
+
// Request Action2
|
73 |
+
elseif(isset($_REQUEST['action2']) && !empty($_REQUEST['action2']) && $_REQUEST['action2'] != '-1')
|
74 |
+
$action = $_REQUEST['action2'];
|
75 |
|
76 |
+
// Do Action: Specific
|
77 |
+
do_action('acfe/options/load/action=' . $action, $action);
|
78 |
+
|
79 |
+
// Do Action
|
80 |
+
do_action('acfe/options/load', $action);
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Options HTML
|
86 |
+
*
|
87 |
+
*/
|
88 |
+
add_action('settings_page_acfe-options', 'acfe_options_html');
|
89 |
+
function acfe_options_html(){
|
90 |
+
|
91 |
+
// Default Action
|
92 |
+
$action = 'list';
|
93 |
+
|
94 |
+
// Request Action
|
95 |
+
if(isset($_REQUEST['action']) && !empty($_REQUEST['action']) && $_REQUEST['action'] != '-1')
|
96 |
+
$action = $_REQUEST['action'];
|
97 |
+
|
98 |
+
// Do Action: Specific
|
99 |
+
do_action('acfe/options/html/action=' . $action, $action);
|
100 |
+
|
101 |
+
// Do Action
|
102 |
+
do_action('acfe/options/html', $action);
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Options List: Load
|
108 |
+
*
|
109 |
+
*/
|
110 |
+
add_action('acfe/options/load/action=list', 'acfe_options_load_list');
|
111 |
+
function acfe_options_load_list(){
|
112 |
+
|
113 |
+
add_screen_option('per_page', array(
|
114 |
+
'label' => 'Options',
|
115 |
+
'default' => 100,
|
116 |
+
'option' => 'options_per_page'
|
117 |
));
|
118 |
|
119 |
}
|
120 |
|
121 |
+
/**
|
122 |
+
* Options List: HTML
|
123 |
+
*
|
124 |
+
*/
|
125 |
+
add_filter('acfe/options/html/action=list', 'acfe_options_html_list');
|
126 |
+
function acfe_options_html_list(){
|
127 |
|
128 |
+
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-list.php');
|
|
|
|
|
129 |
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Options Delete: Load
|
134 |
+
*
|
135 |
+
*/
|
136 |
+
add_action('acfe/options/load/action=delete', 'acfe_options_load_delete');
|
137 |
+
function acfe_options_load_delete(){
|
138 |
|
139 |
+
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
|
|
|
|
|
|
140 |
|
141 |
+
if(!wp_verify_nonce($nonce, 'acfe_options_delete_option'))
|
142 |
+
wp_die('Cheatin’, huh?');
|
143 |
+
|
144 |
+
acfe_options_delete_option(absint($_GET['option']));
|
145 |
+
|
146 |
+
wp_redirect(sprintf('?page=%s&message=deleted', esc_attr($_REQUEST['page'])));
|
147 |
+
exit;
|
148 |
+
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Options Delete: Message
|
153 |
+
*
|
154 |
+
*/
|
155 |
+
add_action('acfe/options/load/message=deleted', 'acfe_options_load_delete_message');
|
156 |
+
function acfe_options_load_delete_message(){
|
157 |
+
|
158 |
+
acf_add_admin_notice(__('Option has been deleted'), 'success');
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Options Bulk Delete: Load
|
164 |
+
*
|
165 |
+
*/
|
166 |
+
add_action('acfe/options/load/action=bulk-delete', 'acfe_options_load_bulk_delete');
|
167 |
+
function acfe_options_load_bulk_delete(){
|
168 |
+
|
169 |
+
$nonce = esc_attr($_REQUEST['_wpnonce']);
|
170 |
+
|
171 |
+
if(!wp_verify_nonce($nonce, 'bulk-options'))
|
172 |
+
wp_die('Cheatin’, huh?');
|
173 |
+
|
174 |
+
$delete_ids = esc_sql($_REQUEST['bulk-delete']);
|
175 |
+
|
176 |
+
foreach($delete_ids as $id){
|
177 |
+
|
178 |
+
acfe_options_delete_option($id);
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
wp_redirect(sprintf('?page=%s&message=bulk-deleted', esc_attr($_REQUEST['page'])));
|
183 |
+
exit;
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Options Bulk Delete: Message
|
189 |
+
*
|
190 |
+
*/
|
191 |
+
add_action('acfe/options/load/message=bulk-deleted', 'acfe_options_load_bulk_delete_message');
|
192 |
+
function acfe_options_load_bulk_delete_message(){
|
193 |
+
|
194 |
+
acf_add_admin_notice(__('Options have been deleted'), 'success');
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Options Delete: Function
|
200 |
+
*
|
201 |
+
*/
|
202 |
+
function acfe_options_delete_option($id){
|
203 |
+
|
204 |
+
global $wpdb;
|
205 |
+
|
206 |
+
$wpdb->delete(
|
207 |
+
"{$wpdb->options}",
|
208 |
+
array('option_id' => $id),
|
209 |
+
array('%d')
|
210 |
+
);
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Options Edit: Load
|
216 |
+
*
|
217 |
+
*/
|
218 |
+
add_action('acfe/options/load/action=edit', 'acfe_options_load_edit');
|
219 |
+
add_action('acfe/options/load/action=add', 'acfe_options_load_edit');
|
220 |
+
function acfe_options_load_edit($action){
|
221 |
+
|
222 |
+
// Nonce
|
223 |
+
if(acf_verify_nonce('acfe-options-edit')){
|
224 |
+
|
225 |
+
// Save data
|
226 |
+
if(acf_validate_save_post(true)){
|
227 |
+
|
228 |
+
acf_save_post('acfe_options_edit');
|
229 |
+
|
230 |
+
$redirect = add_query_arg(array('message' => 'updated'));
|
231 |
+
|
232 |
+
if($action == 'add')
|
233 |
+
$redirect = sprintf('?page=%s&message=added', esc_attr($_REQUEST['page']));
|
234 |
+
|
235 |
+
wp_redirect($redirect);
|
236 |
+
exit;
|
237 |
+
|
238 |
+
}
|
239 |
|
240 |
}
|
241 |
|
242 |
+
// Load acf scripts
|
243 |
+
acf_enqueue_scripts();
|
244 |
|
245 |
+
// Actions
|
246 |
+
add_action('acf/input/admin_head', 'acfe_options_edit_metabox');
|
247 |
+
|
248 |
+
// Add columns support
|
249 |
+
add_screen_option('layout_columns', array(
|
250 |
+
'max' => 2,
|
251 |
+
'default' => 2
|
252 |
+
));
|
253 |
+
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Options Edit: HTML
|
258 |
+
*
|
259 |
+
*/
|
260 |
+
add_filter('acfe/options/html/action=edit', 'acfe_options_html_edit');
|
261 |
+
add_filter('acfe/options/html/action=add', 'acfe_options_html_edit');
|
262 |
+
function acfe_options_html_edit(){
|
263 |
+
|
264 |
+
acf_get_view(ACFE_PATH . '/includes/admin/views/html-options-edit.php');
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Options Edit: Metabox
|
270 |
+
*
|
271 |
+
*/
|
272 |
+
function acfe_options_edit_metabox(){
|
273 |
+
|
274 |
+
$option = array(
|
275 |
+
'option_id' => 0,
|
276 |
+
'option_name' => '',
|
277 |
+
'option_value' => '',
|
278 |
+
'autoload' => 'no',
|
279 |
+
);
|
280 |
+
|
281 |
+
if(isset($_REQUEST['option']) && !empty($_REQUEST['option'])){
|
282 |
+
|
283 |
+
$option_id = absint($_REQUEST['option']);
|
284 |
+
|
285 |
+
global $wpdb;
|
286 |
+
|
287 |
+
$get_option = $wpdb->get_row("SELECT * FROM {$wpdb->options} WHERE option_id = '$option_id'", 'ARRAY_A');
|
288 |
+
if(!empty($get_option))
|
289 |
+
$option = $get_option;
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
$field_group = array(
|
294 |
+
'ID' => 0,
|
295 |
+
'key' => 'group_acfe_options_edit',
|
296 |
+
'style' => 'default',
|
297 |
+
'label_placement' => 'left',
|
298 |
+
'instruction_placement' => 'label',
|
299 |
+
'fields' => array()
|
300 |
+
);
|
301 |
|
302 |
$fields = array();
|
303 |
+
|
304 |
+
$fields[] = array(
|
305 |
+
'label' => __('Name'),
|
306 |
+
'key' => 'field_acfe_options_edit_name',
|
307 |
+
'name' => 'field_acfe_options_edit_name',
|
308 |
+
'type' => 'text',
|
309 |
+
'prefix' => 'acf',
|
310 |
+
'instructions' => '',
|
311 |
+
'required' => true,
|
312 |
+
'conditional_logic' => false,
|
313 |
+
'default_value' => '',
|
314 |
+
'placeholder' => '',
|
315 |
+
'prepend' => '',
|
316 |
+
'append' => '',
|
317 |
+
'maxlength' => '',
|
318 |
+
'value' => $option['option_name'],
|
319 |
+
'wrapper' => array(
|
320 |
+
'width' => '',
|
321 |
+
'class' => '',
|
322 |
+
'id' => '',
|
323 |
+
),
|
324 |
+
);
|
325 |
+
|
326 |
+
// Serialized || HTML
|
327 |
+
if(is_serialized($option['option_value']) || $option['option_value'] != strip_tags($option['option_value'])){
|
328 |
|
329 |
+
$type = 'serilized';
|
330 |
+
$instructions = 'Use this <a href="https://duzun.me/playground/serialize" target="_blank">online tool</a> to unserialize/seriliaze data.';
|
331 |
|
332 |
+
if($option['option_value'] != strip_tags($option['option_value'])){
|
333 |
+
|
334 |
+
$type = 'HTML';
|
335 |
+
$instructions = '';
|
336 |
+
|
337 |
+
}
|
338 |
|
339 |
$fields[] = array(
|
340 |
+
'label' => __('Value <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>'),
|
341 |
+
'key' => 'field_acfe_options_edit_value',
|
342 |
+
'name' => 'field_acfe_options_edit_value',
|
343 |
+
'type' => 'textarea',
|
344 |
+
'prefix' => 'acf',
|
345 |
+
'instructions' => $instructions,
|
346 |
+
'required' => false,
|
347 |
+
'conditional_logic' => false,
|
348 |
+
'default_value' => '',
|
349 |
+
'placeholder' => '',
|
350 |
+
'prepend' => '',
|
351 |
+
'append' => '',
|
352 |
+
'maxlength' => '',
|
353 |
+
'value' => $option['option_value'],
|
354 |
+
'class' => 'code',
|
355 |
+
'wrapper' => array(
|
356 |
+
'width' => '',
|
357 |
+
'class' => '',
|
358 |
+
'id' => '',
|
359 |
+
),
|
360 |
);
|
361 |
|
362 |
}
|
363 |
|
364 |
+
// String
|
365 |
+
else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
|
367 |
+
$type = '';
|
368 |
+
if(!empty($option['option_value']))
|
369 |
+
$type = '<code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">string</code>';
|
370 |
+
|
371 |
+
$fields[] = array(
|
372 |
+
'label' => __('Value ' . $type),
|
373 |
+
'key' => 'field_acfe_options_edit_value',
|
374 |
+
'name' => 'field_acfe_options_edit_value',
|
375 |
+
'type' => 'text',
|
376 |
+
'prefix' => 'acf',
|
377 |
+
'instructions' => '',
|
378 |
+
'required' => false,
|
379 |
+
'conditional_logic' => false,
|
380 |
+
'default_value' => '',
|
381 |
+
'placeholder' => '',
|
382 |
+
'prepend' => '',
|
383 |
+
'append' => '',
|
384 |
+
'maxlength' => '',
|
385 |
+
'value' => $option['option_value'],
|
386 |
+
'wrapper' => array(
|
387 |
+
'width' => '',
|
388 |
+
'class' => '',
|
389 |
+
'id' => '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
),
|
391 |
+
);
|
392 |
+
|
393 |
+
}
|
394 |
+
|
395 |
+
$fields[] = array(
|
396 |
+
'label' => __('Autoload'),
|
397 |
+
'key' => 'field_acfe_options_edit_autoload',
|
398 |
+
'name' => 'field_acfe_options_edit_autoload',
|
399 |
+
'type' => 'select',
|
400 |
+
'prefix' => 'acf',
|
401 |
+
'instructions' => '',
|
402 |
+
'required' => true,
|
403 |
+
'conditional_logic' => false,
|
404 |
+
'default_value' => '',
|
405 |
+
'placeholder' => '',
|
406 |
+
'prepend' => '',
|
407 |
+
'append' => '',
|
408 |
+
'maxlength' => '',
|
409 |
+
'value' => $option['autoload'],
|
410 |
+
'choices' => array(
|
411 |
+
'no' => __('No'),
|
412 |
+
'yes' => __('Yes'),
|
413 |
),
|
414 |
+
'wrapper' => array(
|
415 |
+
'width' => '',
|
416 |
+
'class' => '',
|
417 |
+
'id' => '',
|
418 |
+
),
|
419 |
+
);
|
420 |
|
421 |
+
$field_group['fields'] = $fields;
|
422 |
+
|
423 |
+
$metabox_submit_title = __('Submit','acf');
|
424 |
+
$metabox_main_title = __('Add Option');
|
425 |
+
|
426 |
+
if(!empty($option['option_id'])){
|
427 |
+
|
428 |
+
$metabox_submit_title = __('Edit','acf');
|
429 |
+
$metabox_main_title = __('Edit Option');
|
430 |
+
|
|
|
431 |
}
|
|
|
|
|
432 |
|
433 |
+
// Submit Metabox
|
434 |
+
add_meta_box('submitdiv', $metabox_submit_title, function($post, $args) use($option){
|
435 |
+
|
436 |
+
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
|
437 |
+
|
438 |
+
?>
|
439 |
+
<div id="major-publishing-actions">
|
440 |
+
|
441 |
+
<?php if(!empty($option['option_id'])){ ?>
|
442 |
+
|
443 |
+
<div id="delete-action">
|
444 |
+
<a class="submitdelete deletion" style="color:#a00;" href="<?php echo sprintf('?page=%s&action=%s&option=%s&_wpnonce=%s', esc_attr($_REQUEST['page']), 'delete', $option['option_id'], $delete_nonce); ?>"><?php _e('Delete'); ?></a>
|
445 |
+
</div>
|
446 |
+
|
447 |
+
<?php } ?>
|
448 |
|
449 |
+
<div id="publishing-action">
|
450 |
+
<span class="spinner"></span>
|
451 |
+
<input type="submit" accesskey="p" value="<?php _e('Update'); ?>" class="button button-primary button-large" id="publish" name="publish">
|
452 |
+
</div>
|
453 |
+
|
454 |
+
<div class="clear"></div>
|
455 |
+
|
456 |
+
</div>
|
457 |
+
<?php
|
458 |
+
}, 'acf_options_page', 'side', 'high');
|
459 |
|
460 |
+
// Main Metabox
|
461 |
+
add_meta_box('acf-group_acfe_options_edit', $metabox_main_title, function($post, $args){
|
462 |
|
463 |
+
// extract args
|
464 |
+
extract($args); // all variables from the add_meta_box function
|
465 |
+
extract($args); // all variables from the args argument
|
466 |
|
467 |
+
// vars
|
468 |
+
$o = array(
|
469 |
+
'id' => $id,
|
470 |
+
'key' => $field_group['key'],
|
471 |
+
'style' => $field_group['style'],
|
472 |
+
'label' => $field_group['label_placement'],
|
473 |
+
'editLink' => '',
|
474 |
+
'editTitle' => __('Edit field group', 'acf'),
|
475 |
+
'visibility' => true
|
476 |
+
);
|
477 |
|
478 |
+
// load fields
|
479 |
+
$fields = $field_group['fields'];
|
480 |
|
481 |
+
// render
|
482 |
+
acf_render_fields($fields, 'acfe-options-edit', 'div', $field_group['instruction_placement']);
|
483 |
+
|
484 |
+
?>
|
485 |
+
<script type="text/javascript">
|
486 |
+
if(typeof acf !== 'undefined'){
|
487 |
+
|
488 |
+
acf.newPostbox(<?php echo json_encode($o); ?>);
|
489 |
+
|
490 |
}
|
491 |
+
</script>
|
492 |
+
<?php
|
493 |
+
|
494 |
+
}, 'acf_options_page', 'normal', 'high', array('field_group' => $field_group));
|
495 |
+
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Options Edit: Save
|
500 |
+
*
|
501 |
+
*/
|
502 |
+
add_action('acf/save_post', 'acfe_options_edit_save_post', 5);
|
503 |
+
function acfe_options_edit_save_post($post_id){
|
504 |
+
|
505 |
+
// Validate
|
506 |
+
if(!in_array($post_id, array('acfe_options_edit')))
|
507 |
+
return;
|
508 |
+
|
509 |
+
// Vars
|
510 |
+
$option_name = wp_unslash($_POST['acf']['field_acfe_options_edit_name']);
|
511 |
+
$option_value = wp_unslash($_POST['acf']['field_acfe_options_edit_value']);
|
512 |
+
$autoload = $_POST['acf']['field_acfe_options_edit_autoload'];
|
513 |
+
|
514 |
+
// Value serialized?
|
515 |
+
$option_value = maybe_unserialize($option_value);
|
516 |
+
|
517 |
+
// Update
|
518 |
+
update_option($option_name, $option_value, $autoload);
|
519 |
|
520 |
+
// Flush ACF
|
521 |
$_POST['acf'] = array();
|
522 |
+
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Options Edit: Message
|
527 |
+
*
|
528 |
+
*/
|
529 |
+
add_action('acfe/options/load/message=updated', 'acfe_options_load_edit_message');
|
530 |
+
function acfe_options_load_edit_message(){
|
531 |
+
|
532 |
+
acf_add_admin_notice(__('Option has been updated'), 'success');
|
533 |
+
|
534 |
+
}
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Options Add: Message
|
538 |
+
*
|
539 |
+
*/
|
540 |
+
add_action('acfe/options/load/message=added', 'acfe_options_load_add_message');
|
541 |
+
function acfe_options_load_add_message(){
|
542 |
+
|
543 |
+
acf_add_admin_notice(__('Option has been added'), 'success');
|
544 |
|
545 |
}
|
includes/admin/settings.php
CHANGED
@@ -18,50 +18,6 @@ function acfe_admin_settings_menu(){
|
|
18 |
|
19 |
}
|
20 |
|
21 |
-
add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
|
22 |
-
function acfe_admin_settings_submenu_swap(){
|
23 |
-
|
24 |
-
global $submenu;
|
25 |
-
|
26 |
-
if(!isset($submenu['edit.php?post_type=acf-field-group']) || empty($submenu['edit.php?post_type=acf-field-group']))
|
27 |
-
return;
|
28 |
-
|
29 |
-
foreach($submenu['edit.php?post_type=acf-field-group'] as $ikey => $item){
|
30 |
-
|
31 |
-
// ACFE: Field Group Category
|
32 |
-
if($item[2] == 'edit-tags.php?taxonomy=acf-field-group-category'){
|
33 |
-
$temp_category = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
34 |
-
$temp_category_key = $ikey;
|
35 |
-
}
|
36 |
-
|
37 |
-
// ACFE: Settings
|
38 |
-
elseif($item[2] == 'acfe-settings'){
|
39 |
-
$temp_settings = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
40 |
-
$temp_settings_key = $ikey;
|
41 |
-
}
|
42 |
-
|
43 |
-
// Tools
|
44 |
-
elseif($item[2] == 'acf-tools'){
|
45 |
-
$temp_tools = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
46 |
-
$temp_tools_key = $ikey;
|
47 |
-
}
|
48 |
-
|
49 |
-
// Infos
|
50 |
-
elseif($item[2] == 'acf-settings-info'){
|
51 |
-
$temp_infos = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
52 |
-
$temp_infos_key = $ikey;
|
53 |
-
}
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
// Swapping
|
58 |
-
$submenu['edit.php?post_type=acf-field-group'][$temp_tools_key] = $temp_category;
|
59 |
-
$submenu['edit.php?post_type=acf-field-group'][$temp_infos_key] = $temp_settings;
|
60 |
-
$submenu['edit.php?post_type=acf-field-group'][$temp_category_key] = $temp_tools;
|
61 |
-
$submenu['edit.php?post_type=acf-field-group'][$temp_settings_key] = $temp_infos;
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
function acfe_admin_settings_html(){
|
66 |
?>
|
67 |
<div class="wrap" id="acfe-admin-settings">
|
18 |
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
function acfe_admin_settings_html(){
|
22 |
?>
|
23 |
<div class="wrap" id="acfe-admin-settings">
|
includes/admin/views/html-options-edit.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap acf-settings-wrap">
|
2 |
+
|
3 |
+
<?php
|
4 |
+
$title = __('Edit Option');
|
5 |
+
if($_REQUEST['action'] == 'add')
|
6 |
+
$title = __('Add Option');
|
7 |
+
?>
|
8 |
+
<h1 class="wp-heading-inline"><?php echo $title; ?></h1>
|
9 |
+
|
10 |
+
<hr class="wp-header-end" />
|
11 |
+
|
12 |
+
<form id="post" method="post" name="post">
|
13 |
+
|
14 |
+
<?php
|
15 |
+
|
16 |
+
// render post data
|
17 |
+
acf_form_data(array(
|
18 |
+
'screen' => 'acfe-options-edit',
|
19 |
+
'post_id' => 'acfe_options_edit',
|
20 |
+
));
|
21 |
+
|
22 |
+
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
23 |
+
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
24 |
+
|
25 |
+
?>
|
26 |
+
|
27 |
+
<div id="poststuff">
|
28 |
+
|
29 |
+
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
|
30 |
+
|
31 |
+
<!--
|
32 |
+
<div id="post-body-content">
|
33 |
+
<div id="titlediv">
|
34 |
+
<div id="titlewrap">
|
35 |
+
<input type="text" name="post_title" size="30" value="Post 4" id="title" spellcheck="true" autocomplete="off" />
|
36 |
+
</div>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
-->
|
40 |
+
|
41 |
+
<div id="postbox-container-1" class="postbox-container">
|
42 |
+
|
43 |
+
<?php do_meta_boxes('acf_options_page', 'side', null); ?>
|
44 |
+
|
45 |
+
</div>
|
46 |
+
|
47 |
+
<div id="postbox-container-2" class="postbox-container">
|
48 |
+
|
49 |
+
<?php do_meta_boxes('acf_options_page', 'normal', null); ?>
|
50 |
+
|
51 |
+
</div>
|
52 |
+
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<br class="clear" />
|
56 |
+
|
57 |
+
</div>
|
58 |
+
|
59 |
+
</form>
|
60 |
+
|
61 |
+
</div>
|
includes/admin/views/html-options-list.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap" id="acfe-admin-options">
|
2 |
+
|
3 |
+
<h1 class="wp-heading-inline"><?php _e('Options'); ?></h1> <span style="padding: 4px 6px;border-radius: 2px;background: #555;color: #fff;position: relative;top: -3px;font-weight: 600;margin-left: 4px;">BETA</span>
|
4 |
+
<a href="<?php echo sprintf('?page=%s&action=add', esc_attr($_REQUEST['page'])); ?>" class="page-title-action"><?php _e('Add New'); ?></a>
|
5 |
+
|
6 |
+
<hr class="wp-header-end" />
|
7 |
+
|
8 |
+
<div id="poststuff">
|
9 |
+
|
10 |
+
<div id="post-body" class="metabox-holder">
|
11 |
+
<div id="post-body-content">
|
12 |
+
<div class="meta-box-sortables ui-sortable">
|
13 |
+
<form method="post">
|
14 |
+
|
15 |
+
<?php
|
16 |
+
|
17 |
+
// WP List
|
18 |
+
$acfe_options_list = new ACFE_Admin_Options_List();
|
19 |
+
|
20 |
+
// Prepare items
|
21 |
+
$acfe_options_list->prepare_items();
|
22 |
+
|
23 |
+
$acfe_options_list->search_box('Search', 'search');
|
24 |
+
|
25 |
+
$acfe_options_list->display();
|
26 |
+
|
27 |
+
?>
|
28 |
+
|
29 |
+
</form>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<br class="clear" />
|
35 |
+
|
36 |
+
</div>
|
37 |
+
|
38 |
+
</div>
|
includes/core/menu.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(!defined('ABSPATH'))
|
4 |
+
exit;
|
5 |
+
|
6 |
+
add_action('admin_menu', 'acfe_admin_settings_submenu_swap', 999);
|
7 |
+
function acfe_admin_settings_submenu_swap(){
|
8 |
+
|
9 |
+
global $submenu;
|
10 |
+
|
11 |
+
if(!isset($submenu['edit.php?post_type=acf-field-group']) || empty($submenu['edit.php?post_type=acf-field-group']))
|
12 |
+
return;
|
13 |
+
|
14 |
+
foreach($submenu['edit.php?post_type=acf-field-group'] as $ikey => $item){
|
15 |
+
|
16 |
+
// ACFE: Field Group Category
|
17 |
+
if($item[2] == 'edit-tags.php?taxonomy=acf-field-group-category'){
|
18 |
+
$temp_category = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
19 |
+
$temp_category_key = $ikey;
|
20 |
+
}
|
21 |
+
|
22 |
+
// ACFE: Settings
|
23 |
+
elseif($item[2] == 'acfe-settings'){
|
24 |
+
$temp_settings = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
25 |
+
$temp_settings_key = $ikey;
|
26 |
+
}
|
27 |
+
|
28 |
+
// Tools
|
29 |
+
elseif($item[2] == 'acf-tools'){
|
30 |
+
$temp_tools = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
31 |
+
$temp_tools_key = $ikey;
|
32 |
+
}
|
33 |
+
|
34 |
+
// Infos
|
35 |
+
elseif($item[2] == 'acf-settings-info'){
|
36 |
+
$temp_infos = $submenu['edit.php?post_type=acf-field-group'][$ikey];
|
37 |
+
$temp_infos_key = $ikey;
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
41 |
+
|
42 |
+
// Swapping
|
43 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_tools_key] = $temp_category;
|
44 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_infos_key] = $temp_settings;
|
45 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_category_key] = $temp_tools;
|
46 |
+
$submenu['edit.php?post_type=acf-field-group'][$temp_settings_key] = $temp_infos;
|
47 |
+
|
48 |
+
}
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: acf, custom fields, meta, admin, fields, form, repeater, content
|
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.1.1
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 0.6.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -53,10 +53,10 @@ Set custom field group key. ie: `group_custom_name`
|
|
53 |
Display field group on all post types edition screen
|
54 |
|
55 |
* **New field group location: Post type Archive**
|
56 |
-
Display field group on post types archive screen. Fields
|
57 |
|
58 |
* **New field group location: Taxonomy Archive**
|
59 |
-
Display field group on taxonomies archive screen. Fields
|
60 |
|
61 |
== Field Groups List ==
|
62 |
|
@@ -145,6 +145,12 @@ Replaced the native WP Author Metabox with a dynamic version allowing to manage
|
|
145 |
|
146 |
Taxonomies list & edit views have been tweaked for a more consistent administration experience, using CSS/JS only. Views are now similar to post type edition screens.
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
== Installation ==
|
149 |
|
150 |
= Wordpress Install =
|
@@ -203,6 +209,9 @@ Usage example:
|
|
203 |
|
204 |
== Changelog ==
|
205 |
|
|
|
|
|
|
|
206 |
= 0.6.0.2 =
|
207 |
* Field Group: Lowered 'Field Group Data' Metabox priority which was too high and was displayed above fields.
|
208 |
|
@@ -211,8 +220,8 @@ Usage example:
|
|
211 |
* Admin: Temporarily removed the 'Options Beta' admin screen. Still needs some works.
|
212 |
|
213 |
= 0.6 =
|
214 |
-
* Field Group: New available location - Post type archive (under Post type). Field group will be displayed on post type list view, as a sidebar. Fields will be saved
|
215 |
-
* Field Group: New available location - Taxonomy archive (under Taxonomy). Field group will be displayed on taxonomy list view, as a sidebar. Fields will be saved
|
216 |
* Taxonomies: Taxonomies list & edit views have been tweaked for a more consistent administration experience, using CSS/JS only. Views are now similar to post type edition screens.
|
217 |
* Field Groups: Added a 'Third party' status (just like 'Sync available') in order to display local field groups thats are loaded by ACF, but not available in the ACF field group administration. Example: a field group is registered locally in the `functions.php` file.
|
218 |
* Dynamic Post Type: Added a configuration button next to the post type title, if the post type was generated by the Dynamic Post Type tool.
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.1.1
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 0.6.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
53 |
Display field group on all post types edition screen
|
54 |
|
55 |
* **New field group location: Post type Archive**
|
56 |
+
Display field group on post types archive screen. Fields are saved in the option: `{post_type}_options`
|
57 |
|
58 |
* **New field group location: Taxonomy Archive**
|
59 |
+
Display field group on taxonomies archive screen. Fields are saved in the option: `tax_{taxonomy}_options`
|
60 |
|
61 |
== Field Groups List ==
|
62 |
|
145 |
|
146 |
Taxonomies list & edit views have been tweaked for a more consistent administration experience, using CSS/JS only. Views are now similar to post type edition screens.
|
147 |
|
148 |
+
== Options ==
|
149 |
+
|
150 |
+
BETA: Manage WordPress options from Settings > Options.
|
151 |
+
|
152 |
+
* View, add, edit and delete options (string|serialized)
|
153 |
+
|
154 |
== Installation ==
|
155 |
|
156 |
= Wordpress Install =
|
209 |
|
210 |
== Changelog ==
|
211 |
|
212 |
+
= 0.6.1 =
|
213 |
+
* Admin: Re-introduced 'Options' admin screen under Settings > Options. Code has been completely refactored using native WP List Table. New features: Searchbox, item per page preference (default: 100), sortable columns, bulk delete and ability to edit serialized values.
|
214 |
+
|
215 |
= 0.6.0.2 =
|
216 |
* Field Group: Lowered 'Field Group Data' Metabox priority which was too high and was displayed above fields.
|
217 |
|
220 |
* Admin: Temporarily removed the 'Options Beta' admin screen. Still needs some works.
|
221 |
|
222 |
= 0.6 =
|
223 |
+
* Field Group: New available location - Post type archive (under Post type). Field group will be displayed on post type list view, as a sidebar. Fields will be saved in the option: `{post_type}_options`. Frontend usage example: `get_field('my_field', 'page_options')`.
|
224 |
+
* Field Group: New available location - Taxonomy archive (under Taxonomy). Field group will be displayed on taxonomy list view, as a sidebar. Fields will be saved in the option: `tax_{taxonomy}_options`. Frontend usage example: `get_field('my_field', 'tax_category_options')`.
|
225 |
* Taxonomies: Taxonomies list & edit views have been tweaked for a more consistent administration experience, using CSS/JS only. Views are now similar to post type edition screens.
|
226 |
* Field Groups: Added a 'Third party' status (just like 'Sync available') in order to display local field groups thats are loaded by ACF, but not available in the ACF field group administration. Example: a field group is registered locally in the `functions.php` file.
|
227 |
* Dynamic Post Type: Added a configuration button next to the post type title, if the post type was generated by the Dynamic Post Type tool.
|