PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8.9.5
Advanced Custom Fields: Extended v0.8.9.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-post.php
acf-extended / includes Last commit date
admin 3 years ago field-groups 3 years ago fields 3 years ago fields-settings 3 years ago locations 3 years ago modules 2 years ago screens 3 years ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 3 years ago acfe-field-group-functions.php 3 years ago acfe-file-functions.php 3 years ago acfe-form-functions.php 3 years ago acfe-helper-functions.php 3 years ago acfe-meta-functions.php 3 years ago acfe-post-functions.php 3 years ago acfe-screen-functions.php 3 years ago acfe-template-functions.php 3 years ago acfe-term-functions.php 3 years ago acfe-user-functions.php 3 years ago acfe-wp-functions.php 3 years ago assets.php 3 years ago compatibility-6.0.php 2 years ago compatibility.php 3 years ago field-extend.php 3 years ago field.php 3 years ago hooks.php 3 years ago init.php 3 years ago local-meta.php 3 years ago module-acf.php 3 years ago module-db.php 3 years ago module-l10n.php 3 years ago module-legacy.php 3 years ago module-manager.php 3 years ago module-post.php 2 years ago module-posts.php 3 years ago module-upgrades.php 3 years ago module.php 3 years ago multilang.php 3 years ago settings.php 3 years ago third-party.php 3 years ago upgrades.php 3 years ago
module-post.php
272 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_module_post')):
8
9 class acfe_module_post{
10
11 /**
12 * construct
13 */
14 function __construct(){
15
16 add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 5, 2);
17 add_action('trashed_post', array($this, 'trashed_post'));
18 add_action('untrashed_post', array($this, 'untrashed_post'));
19 add_action('deleted_post', array($this, 'deleted_post'));
20 add_filter('post_updated_messages', array($this, 'post_updated_messages'));
21
22 }
23
24
25 /**
26 * add_meta_boxes
27 *
28 * add_meta_boxes
29 *
30 * @param $post_type
31 * @param $post
32 */
33 function add_meta_boxes($post_type, $post){
34
35 // globals
36 global $item, $module;
37
38 // validate post
39 if(!isset($post)){
40 return;
41 }
42
43 // get module
44 $module = acfe_get_module_by_item($post->ID);
45
46 if(!$module){
47 return;
48 }
49
50 $item = $module->get_item($post->ID);
51
52 add_filter('admin_body_class', array($this, 'admin_body_class'));
53 add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
54 add_filter('acfe/localize_data', array($this, 'localize_data'));
55 add_action('post_submitbox_misc_actions', array($this, 'post_submitbox_misc_actions'));
56 add_filter('submenu_file', array($this, 'submenu_file'));
57
58 // remove native wp slug metabox
59 remove_meta_box('slugdiv', $module->post_type, 'normal');
60
61 // register field groups
62 foreach($module->get_field_groups() as $field_group){
63 acf_add_local_field_group($field_group);
64 }
65
66 // actions
67 $module->do_module_action('acfe/module/load_post');
68
69 }
70
71
72 /**
73 * admin_body_class
74 *
75 * @param $classes
76 *
77 * @return string
78 */
79 function admin_body_class($classes){
80
81 global $module;
82
83 $classes .= " acfe-module acfe-module-post acfe-module-{$module->name}";
84 return $classes;
85
86 }
87
88
89 /**
90 * admin_enqueue_scripts
91 *
92 * acf/input/admin_enqueue_scripts
93 */
94 function admin_enqueue_scripts(){
95
96 // no autosave
97 wp_dequeue_script('autosave');
98
99 // remove default 'draft' post status on post-new.php
100 // this fix an issue when user press 'enter' when creating a new item
101 global $post;
102 $post->post_status = 'publish';
103
104 }
105
106
107 /**
108 * localize_data
109 *
110 * acfe/localize_data
111 *
112 * @param $data
113 *
114 * @return mixed
115 */
116 function localize_data($data){
117
118 global $module, $item;
119
120 $data['module'] = array(
121 'name' => $module->name,
122 'screen' => 'post',
123 'messages' => array(
124 'status' => $item['active'] ? __('Active', 'acf') : __('Inactive', 'acf'),
125 'label' => sprintf(__('%s value is required', 'acf'), $module->get_label('enter_title')),
126 ),
127 );
128
129 return $data;
130
131 }
132
133
134 /**
135 * post_submitbox_misc_actions
136 */
137 function post_submitbox_misc_actions(){
138
139 global $module, $item;
140
141 $links = $module->get_export_links($item);
142
143 if($links): ?>
144 <div class="misc-pub-section acfe-misc-export">
145 <span class="dashicons dashicons-editor-code"></span>
146 <?php _e('Export', 'acfe'); ?>: <?php echo implode(' ', $links); ?>
147 </div>
148 <?php endif;
149
150 }
151
152
153 /**
154 * submenu_file
155 * @return string
156 */
157 function submenu_file(){
158
159 global $module;
160 return "edit.php?post_type={$module->post_type}";
161
162 }
163
164
165 /**
166 * trashed_post
167 *
168 * @param $post_id
169 */
170 function trashed_post($post_id){
171
172 // get module
173 $module = acfe_get_module_by_item($post_id);
174
175 if($module){
176 $module->trash_item($post_id);
177 }
178
179 }
180
181
182 /**
183 * untrashed_post
184 *
185 * @param $post_id
186 */
187 function untrashed_post($post_id){
188
189 // get module
190 $module = acfe_get_module_by_item($post_id);
191
192 if($module){
193 $module->untrash_item($post_id);
194 }
195
196 }
197
198
199 /**
200 * deleted_post
201 *
202 * @param $post_id
203 */
204 function deleted_post($post_id){
205
206 // get module
207 $module = acfe_get_module_by_item($post_id);
208
209 if($module){
210 $module->delete_item($post_id);
211 }
212
213 }
214
215
216 /**
217 * post_updated_messages
218 *
219 * @param $messages
220 *
221 * @return mixed
222 */
223 function post_updated_messages($messages){
224
225 /*
226 * 0 => '', // Unused. Messages start at index 1.
227 * 1 => __( 'Post updated.' ) . $view_post_link_html,
228 * 2 => __( 'Custom field updated.' ),
229 * 3 => __( 'Custom field deleted.' ),
230 * 4 => __( 'Post updated.' ),
231 * 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
232 * 6 => __( 'Post published.' ) . $view_post_link_html,
233 * 7 => __( 'Post saved.' ),
234 * 8 => __( 'Post submitted.' ) . $preview_post_link_html,
235 * 9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
236 * 10 => __( 'Post draft updated.' ) . $preview_post_link_html,
237 */
238
239 $modules = acfe_get_modules();
240
241 foreach($modules as $module){
242
243 // label
244 $label = $module->get_label();
245
246 // append to messages
247 $messages[ $module->post_type ] = array(
248 0 => '', // unused. messages start at index 1
249 1 => sprintf(__('%s updated.', 'acfe'), $label),
250 2 => sprintf(__('%s updated.', 'acfe'), $label),
251 3 => sprintf(__('%s deleted.', 'acfe'), $label),
252 4 => sprintf(__('%s updated.', 'acfe'), $label),
253 5 => false, // no revisions support
254 6 => sprintf(__('%s published.', 'acfe'), $label),
255 7 => sprintf(__('%s saved.', 'acfe'), $label),
256 8 => sprintf(__('%s submitted.', 'acfe'), $label),
257 9 => sprintf(__('%s scheduled.', 'acfe'), $label),
258 10 => sprintf(__('%s draft updated.', 'acfe'), $label),
259 );
260
261 }
262
263 // return
264 return $messages;
265
266 }
267
268 }
269
270 acf_new_instance('acfe_module_post');
271
272 endif;