Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Barbato committed Jun 3, 2021
2 parents db115b4 + f2fb5f3 commit 0fed979
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions acf-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ function include_acf_extensions_plugin() {

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

add_action('acf/init', function (){

if( isset($_GET['clean-acf']) && $_GET['clean-acf'] && is_admin() && current_user_can('administrator')){

$folder = apply_filters('acf/settings/save_json', '');

foreach (glob($folder."/*.*") as $filename) {

$content = json_decode(file_get_contents($filename), true);
foreach($content['fields'] as $i=>$field){

if(!($field['key']??false) || empty($field))
unset($content['fields'][$i]);
}
file_put_contents($filename, json_encode($content, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
}

global $wpdb;

$wpdb->query("DELETE pm FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL");
$wpdb->query("DELETE FROM $wpdb->posts WHERE post_type='acf-field'");
}
});

add_filter( 'mce_external_plugins', function ( $plugins ) {
$plugins['table'] = content_url() . '/plugins/acf-extensions/js/tinymce/table/plugin.min.js';
return $plugins;
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
---------

##1.1.8
#### Feature
- added fields cleaning function, add ?clean-acf=1 in a backend url

##1.1.7
#### Bugfix
- invalid `dynamic_select` component value
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"metabolism/acf-extensions",
"version": "1.1.7",
"version": "1.1.8",
"type": "wordpress-plugin",
"description": "ACF Extensions plugin with component, components, hidden field, dynamic select and latest posts field",
"license": "GPL-3.0-or-later"
Expand Down
2 changes: 1 addition & 1 deletion css/input.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.acf-field-hidden, .acf-field-latest-posts{ display: none; }
.acf-field .acf-label:empty{ display: none }
.acf-tag-selector{ position: absolute; right: 0; bottom: 100%; width: auto; margin-bottom: 6px }
.acf-tag-selector select{ width: auto!important; padding: 0 8px!important; padding-right: 30px!important; min-height: 26px; font-size: 12px }
.acf-tag-selector select{ width: auto!important; padding: 0 8px!important; padding-right: 30px!important; min-height: 22px; font-size: 11px!important; }

0 comments on commit 0fed979

Please sign in to comment.