Skip to content

Commit 0fed979

Browse files
author
Jerome Barbato
committed
merge
2 parents db115b4 + f2fb5f3 commit 0fed979

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

acf-extensions.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,30 @@ function include_acf_extensions_plugin() {
6464

6565
add_action('acf/include_field_types', 'include_acf_extensions_plugin');
6666

67+
add_action('acf/init', function (){
68+
69+
if( isset($_GET['clean-acf']) && $_GET['clean-acf'] && is_admin() && current_user_can('administrator')){
70+
71+
$folder = apply_filters('acf/settings/save_json', '');
72+
73+
foreach (glob($folder."/*.*") as $filename) {
74+
75+
$content = json_decode(file_get_contents($filename), true);
76+
foreach($content['fields'] as $i=>$field){
77+
78+
if(!($field['key']??false) || empty($field))
79+
unset($content['fields'][$i]);
80+
}
81+
file_put_contents($filename, json_encode($content, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
82+
}
83+
84+
global $wpdb;
85+
86+
$wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
87+
$wpdb->query("DELETE FROM $wpdb->posts WHERE post_type='acf-field'");
88+
}
89+
});
90+
6791
add_filter( 'mce_external_plugins', function ( $plugins ) {
6892
$plugins['table'] = content_url() . '/plugins/acf-extensions/js/tinymce/table/plugin.min.js';
6993
return $plugins;

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
---------
33

4+
##1.1.8
5+
#### Feature
6+
- added fields cleaning function, add ?clean-acf=1 in a backend url
7+
48
##1.1.7
59
#### Bugfix
610
- invalid `dynamic_select` component value

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"metabolism/acf-extensions",
3-
"version": "1.1.7",
3+
"version": "1.1.8",
44
"type": "wordpress-plugin",
55
"description": "ACF Extensions plugin with component, components, hidden field, dynamic select and latest posts field",
66
"license": "GPL-3.0-or-later"

css/input.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.acf-field-hidden, .acf-field-latest-posts{ display: none; }
22
.acf-field .acf-label:empty{ display: none }
33
.acf-tag-selector{ position: absolute; right: 0; bottom: 100%; width: auto; margin-bottom: 6px }
4-
.acf-tag-selector select{ width: auto!important; padding: 0 8px!important; padding-right: 30px!important; min-height: 26px; font-size: 12px }
4+
.acf-tag-selector select{ width: auto!important; padding: 0 8px!important; padding-right: 30px!important; min-height: 22px; font-size: 11px!important; }

0 commit comments

Comments
 (0)