PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.5
Advanced Custom Fields: Extended v0.9.2.5
0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / module-posts.php
acf-extended / includes Last commit date
admin 1 month ago field-groups 1 month ago fields 1 month ago fields-settings 2 months ago forms 1 month ago locations 2 months ago modules 2 months ago screens 5 months ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 1 year ago acfe-field-group-functions.php 2 years ago acfe-file-functions.php 1 year ago acfe-form-functions.php 2 months ago acfe-helper-functions.php 1 month ago acfe-meta-functions.php 2 months ago acfe-post-functions.php 3 years ago acfe-screen-functions.php 3 years ago acfe-template-functions.php 1 year ago acfe-term-functions.php 3 years ago acfe-user-functions.php 3 years ago acfe-wp-functions.php 3 years ago assets.php 1 month ago compatibility-acf-5.8.php 2 months ago compatibility-acf-5.9.php 1 month ago compatibility-acf-6.5.php 1 month ago compatibility.php 1 month ago field-extend.php 2 months ago field.php 2 months ago hooks.php 3 years ago init.php 1 month ago local-meta.php 3 years ago module-acf.php 2 years ago module-db.php 3 years ago module-l10n.php 2 years ago module-legacy.php 3 years ago module-manager.php 2 months ago module-post.php 2 years ago module-posts.php 2 months ago module-upgrades.php 3 years ago module.php 2 months ago multilang.php 3 years ago revisions.php 2 months ago settings.php 3 years ago template-tags.php 7 months ago third-party.php 3 years ago upgrades.php 10 months ago
module-posts.php
296 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_module_posts')):
8
9 class acfe_module_posts{
10
11 /**
12 * construct
13 */
14 function __construct(){
15
16 add_action('acfe/load_posts', array($this, 'load_posts'));
17
18 }
19
20
21 /**
22 * load_posts
23 *
24 * @param $post_type
25 */
26 function load_posts($post_type){
27
28 // global
29 global $module;
30
31 // get module
32 $module = acfe_query_module(array('post_type' => $post_type));
33
34 // validate module
35 if(!$module){
36 return;
37 }
38
39 // post statuses
40 global $wp_post_statuses;
41 $wp_post_statuses['publish']->label_count = _n_noop('Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', 'acf');
42
43 add_filter('admin_body_class', array($this, 'admin_body_class'));
44 add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
45 add_filter('acfe/localize_data', array($this, 'localize_data'));
46 add_filter("manage_{$module->post_type}_posts_columns", array($this, 'manage_columns'));
47 add_action("manage_{$module->post_type}_posts_custom_column", array($this, 'manage_columns_html'), 10, 2);
48 add_filter('display_post_states', array($this, 'display_post_states'), 10, 2);
49 add_filter('post_row_actions', array($this, 'post_row_actions'), 10, 2);
50 add_filter('page_row_actions', array($this, 'post_row_actions'), 10, 2);
51 add_filter("bulk_actions-edit-{$module->post_type}", array($this, 'bulk_actions'));
52 add_filter("handle_bulk_actions-edit-{$module->post_type}", array($this, 'handle_bulk_actions'), 10, 3);
53
54 // actions
55 $module->do_module_action('acfe/module/load_posts');
56
57 }
58
59
60 /**
61 * admin_body_class
62 *
63 * @param $classes
64 *
65 * @return string
66 */
67 function admin_body_class($classes){
68
69 global $module;
70
71 $classes .= " acfe-module acfe-module-posts acfe-module-{$module->name}";
72 return $classes;
73
74 }
75
76
77 /**
78 * admin_enqueue_scripts
79 */
80 function admin_enqueue_scripts(){
81
82 // enqueue acf global js for tooltips
83 acf_enqueue_script('acf');
84 }
85
86
87 /**
88 * localize_data
89 *
90 * acfe/localize_data
91 *
92 * @param $data
93 *
94 * @return mixed
95 */
96 function localize_data($data){
97
98 global $module;
99
100 $data['module'] = array(
101 'name' => $module->name,
102 'screen' => 'posts',
103 );
104
105 return $data;
106
107 }
108
109
110 /**
111 * manage_columns
112 *
113 * manage_post_type_posts_columns
114 *
115 * @param $columns
116 *
117 * @return mixed
118 */
119 function manage_columns($columns){
120
121 global $module;
122
123 unset($columns['date']);
124
125 if(!empty($module->columns)){
126 $columns = array_merge($columns, $module->columns);
127 }
128
129 return $module->apply_module_filters('acfe/module/edit_columns', $columns);
130
131 }
132
133
134 /**
135 * manage_columns_html
136 *
137 * manage_post_type_posts_custom_column
138 *
139 * @param $column
140 * @param $post_id
141 */
142 function manage_columns_html($column, $post_id){
143
144 // get module
145 global $module;
146
147 // get item using post id
148 $item = $module->get_item($post_id);
149
150 // format column name with underscore
151 $column_method = str_replace('-', '_', $column);
152
153 // check column method exists in the module
154 if(method_exists($module, "edit_column_{$column_method}")){
155 $module->{"edit_column_{$column_method}"}($item); // pass item as argument
156 }
157
158 // actions
159 $module->do_module_action('acfe/module/edit_columns_html', $column, $item);
160
161 }
162
163
164 /**
165 * display_post_states
166 *
167 * @param $post_states
168 * @param $post
169 *
170 * @return mixed
171 */
172 function display_post_states($post_states, $post){
173
174 if($post->post_status === 'acf-disabled'){
175 $post_states['acf-disabled'] = '<span class="dashicons dashicons-hidden acf-js-tooltip" title="' . _x('Disabled', 'post status', 'acf') . '"></span>';
176 }
177
178 return $post_states;
179
180 }
181
182
183 /**
184 * post_row_actions
185 *
186 * page_row_actions
187 *
188 * @param $actions
189 * @param $post
190 *
191 * @return mixed
192 */
193 function post_row_actions($actions, $post){
194
195 global $module;
196
197 // hide on "trash" post status
198 if(!in_array($post->post_status, array('publish', 'acf-disabled'))){
199 return $actions;
200 }
201
202 $item = $module->get_item($post->ID);
203
204 unset($actions['inline'], $actions['inline hide-if-no-js']);
205
206 // View
207 if(!empty($module->view) && $item['active']){
208 $actions['view'] = '<a href="' . admin_url(sprintf($module->view, $item['name'])) . '">' . __('View') . '</a>';
209 }
210
211 // Tools
212 foreach($module->export_actions as $action){
213 $actions[ $action ] = $module->get_export_link($action, $item['name']);
214 }
215
216 return $actions;
217
218 }
219
220
221 /**
222 * bulk_actions
223 *
224 * bulk_actions-edit-post_type
225 *
226 * @param $actions
227 *
228 * @return mixed
229 */
230 function bulk_actions($actions){
231
232 global $module;
233
234 unset($actions['edit']);
235
236 foreach($module->export_actions as $action){
237 $actions["export_{$action}"] = __('Export', 'acfe') . ' ' . $module->get_export_action_label($action);
238 }
239
240 return $actions;
241
242 }
243
244
245 /**
246 * handle_bulk_actions
247 *
248 * handle_bulk_actions-edit-post_type
249 *
250 * @param $redirect
251 * @param $action
252 * @param $post_ids
253 *
254 * @return mixed|void
255 */
256 function handle_bulk_actions($redirect, $action, $post_ids){
257
258 global $module;
259
260 $post_ids = acfe_maybe_get_REQUEST('post');
261
262 if(!$post_ids){
263 return $redirect;
264 }
265
266 foreach($module->export_actions as $tool_action){
267
268 if($action !== "export_{$tool_action}"){
269 continue;
270 }
271
272 $keys = array();
273 foreach($post_ids as $post_id){
274
275 $item = $module->get_item($post_id);
276
277 if($item){
278 $keys[] = $item['name'];
279 }
280
281 }
282
283 wp_redirect($module->get_export_url($tool_action, implode('+', $keys)));
284 exit;
285
286 }
287
288 return $redirect;
289
290 }
291
292 }
293
294 acf_new_instance('acfe_module_posts');
295
296 endif;