jimi111
Forum Replies Created
-
Forum: Plugins
In reply to: [Advanced Custom Fields: Extended] Post Status, Post Type fieldsThanks a lot for the code! For me it would take probably a few hours to write this.
And especially for reducing database bloating with useless values
// Return null to not save the value as a metaIn case someone with very low programming skills like me need it for the post status.
/* * Field: My Post Status - Load Value */ add_filter('acf/load_value/name=post_status', 'acf_post_status_load', 10, 3); function acf_post_status_load($value, $post_id, $field){ // Bail early if not in a Post if(!is_numeric($post_id)) return $value; // Retrieve Current Post Status $post_status = get_post_status($post_id); // Force the Field value to load the Current Post Status $value = $post_status; // Return return $value; } /* * Field: My Post Status - Save Value */ add_filter('acf/update_value/name=post_status', 'my_acf_post_status_save', 10, 3); function my_acf_post_status_save($value, $post_id, $field){ // Bail early if not in a Post if(!is_numeric($post_id)) return $value; // Update Current Post to the selected Post Status wp_update_post(array( 'ID' => $post_id, 'post_status' => $value, )); // Return null to not save the value as a meta return null; }Forum: Plugins
In reply to: [Advanced Custom Fields: Extended] Post Status, Post Type fieldsThanks for the fast reply! Now I see, so at a current state they are just a value loaders for developers.
>I added the feature request to the Trello Board to let users automatically update the current post
Would be great!Hello
I just tested and it works like a charm! You are really really cool, man! Thanks a lot!I’m afraid it still broken.
This is how it normally works with manual export:
Add thise code to functions.phpadd_action('acf/init', 'acf_settings'); function acf_settings() { acf_update_setting('l10n', true); acf_update_setting('l10n_textdomain', 'theme'); }Go to ACF – Tools – Export Field Groups – Generate PHP
Result: Every string is wrapped in __()
ie. ‘label’ => __(‘Custom Label’, ‘theme’)Now with Extended auto sync:
Edit Field Group – Auto Sync – Php – checked
Press Update
Result: if you look inside generated file in /theme/acfe-php/group_ID.php nothing is wrappedAlso, if you go to ACFE Settings page, l10n Textdomain is boolean, and it should contain value ‘theme’ – acf_update_setting(‘l10n_textdomain’, ‘theme’);
Thanks a lot, Konrad!