PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 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-db.php
acf-extended / includes Last commit date
admin 3 months ago field-groups 3 months ago fields 1 week ago fields-settings 3 months ago forms 3 months ago locations 3 months ago modules 1 week ago screens 3 months ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 3 months ago acfe-field-group-functions.php 3 months ago acfe-file-functions.php 1 year ago acfe-form-functions.php 3 months ago acfe-helper-array-functions.php 3 months ago acfe-helper-functions.php 3 months ago acfe-helper-multi-functions.php 3 months ago acfe-helper-string-functions.php 3 months ago acfe-meta-functions.php 3 months ago acfe-post-functions.php 3 months ago acfe-screen-functions.php 3 months ago acfe-template-functions.php 3 months ago acfe-term-functions.php 3 months ago acfe-user-functions.php 3 months ago acfe-wp-functions.php 3 years ago assets.php 3 months ago compatibility-acf-5.8.php 4 months ago compatibility-acf-5.9.php 3 months ago compatibility-acf-6.5.php 3 months ago compatibility-acf-6.8.6.php 1 week ago compatibility.php 3 months ago field-extend.php 4 months ago field.php 4 months ago hooks.php 3 months ago init.php 3 months ago local-meta.php 3 years ago media.php 3 months ago module-acf.php 3 months ago module-db.php 3 months ago module-l10n.php 3 months ago module-legacy.php 3 years ago module-manager.php 4 months ago module-post.php 3 months ago module-posts.php 4 months ago module-upgrades.php 3 years ago module.php 3 months ago multilang.php 3 months ago revisions.php 4 months ago screen.php 3 months ago settings.php 3 months ago template-tags.php 3 months ago third-party.php 3 years ago upgrades.php 3 months ago
module-db.php
198 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_module_db')):
8
9 class acfe_module_db{
10
11 /**
12 * construct
13 */
14 function __construct(){
15
16 add_action('acfe/module/updated_item', array($this, 'updated_item'), 10, 2);
17 add_action('acfe/module/trashed_item', array($this, 'deleted_item'), 10, 2);
18 add_action('acfe/module/deleted_item', array($this, 'deleted_item'), 10, 2);
19 add_action('acfe/module/include_items', array($this, 'include_items'));
20
21 }
22
23
24 /**
25 * updated_item
26 *
27 * acfe/module/updated_item
28 *
29 * @param $item
30 * @param $module
31 */
32 function updated_item($item, $module){
33
34 if(!$this->has_settings($module)){
35 return;
36 }
37
38 // cleanup keys
39 $export = $module->prepare_item_for_export($item);
40
41 // on update
42 if($item['ID']){
43
44 // get raw item from db
45 $raw_item = $module->get_item($item['ID']);
46
47 // delete old settings if name changed
48 if($raw_item['name'] && $raw_item['name'] !== $item['name'] && !acf_is_filter_enabled('acfe/module/update_unique_name')){
49 $this->delete_settings($module, $raw_item['name']);
50 }
51
52 }
53
54 // settings
55 $settings = $this->get_settings($module);
56 $settings[ $item['name'] ] = $export;
57
58 // update setting
59 ksort($settings);
60 $this->update_settings($module, $settings);
61
62 }
63
64
65 /**
66 * deleted_item
67 *
68 * acfe/module/deleted_item
69 *
70 * @param $item
71 * @param $module
72 */
73 function deleted_item($item, $module){
74
75 if(!$this->has_settings($module)){
76 return;
77 }
78
79 // WP appends '__trashed' to end of 'name' (post_name).
80 $name = str_replace('__trashed', '', $item['name']);
81
82 // delete settings
83 $this->delete_settings($module, $name);
84
85 }
86
87
88 /**
89 * include_items
90 *
91 * acfe/module/include_items
92 *
93 * @param $module
94 */
95 function include_items($module){
96
97 if(!$this->has_settings($module)){
98 return;
99 }
100
101 // get db settings
102 $settings = acfe_as_array($this->get_settings($module));
103
104 // loop
105 foreach($settings as $key => $item){
106
107 // set local
108 $item['local'] = 'db';
109 $item['local_file'] = "{$module->settings}.{$key}";
110
111 // add local item
112 $module->add_local_item($item);
113
114 }
115
116 }
117
118
119 /**
120 * has_settings
121 *
122 * @param $module
123 *
124 * @return bool
125 */
126 function has_settings($module){
127 return !empty($module->settings);
128 }
129
130
131 /**
132 * get_settings
133 *
134 * @param $module
135 * @param $selector
136 * @param $default
137 *
138 * @return mixed
139 */
140 function get_settings($module, $selector = null, $default = null){
141
142 if($selector === null){
143 $selector = $module->settings;
144 }else{
145 $selector = "{$module->settings}.{$selector}";
146 }
147
148 return acfe_get_settings($selector, $default);
149
150 }
151
152
153 /**
154 * update_settings
155 *
156 * @param $module
157 * @param $selector
158 * @param $value
159 */
160 function update_settings($module, $selector = null, $value = null){
161
162 if($value === null){
163 $value = $selector;
164 $selector = $module->settings;
165 }else{
166 $selector = "{$module->settings}.{$selector}";
167 }
168
169 acfe_update_settings($selector, $value);
170
171 }
172
173
174 /**
175 * delete_settings
176 *
177 * @param $module
178 * @param $selector
179 *
180 * @return mixed
181 */
182 function delete_settings($module, $selector = null){
183
184 if($selector === null){
185 $selector = $module->settings;
186 }else{
187 $selector = "{$module->settings}.{$selector}";
188 }
189
190 return acfe_delete_settings($selector);
191
192 }
193
194 }
195
196 acf_new_instance('acfe_module_db');
197
198 endif;