John Huebner
Forum Replies Created
-
Forum: Plugins
In reply to: [ACF Medium Editor Field] Gutenberg compatibilityThe reason for all the recursion and building a selector was that the ID of fields in repeaters at one time was not unique. That was some time ago and there have been changes in the way ACF outputs ID values and it seems I can do away with this.
Can you do a test for me to see if this clears up the issue with the block editor?
In the JS file …/plugins/acf-medium-editor/assets/js/input.js
Can you change line 50 to
var $selector = 'textarea#'+$textarea.attr('id');and delete lines 51 to 54
and then test.
Forum: Plugins
In reply to: [ACF Medium Editor Field] Gutenberg compatibilityI will do some looking into this.
The reason for the recursion. If you’ll notice, every medium editor field you create can have its own settings. You can have multiple line input in one place and single line in another or they can have different buttons, etc, etc. In order to do this each field must be initialized with it’s own settings. This means than I can’t simply target a common class. I must specifically target each field. The recursion finds each field and then reads up, finding each parent, to build a CSS selector that targets just that field without targeting other fields.
form>child>child>child>fieldThis is necessary because I cannot know where that field will be. Will it be in a repeater, in a flex field, in a nested repeater/flex field. I also did it this way because of difficulties in using a unique ID value for each field, when a field is in a repeater of a flex field there isn’t difficult to know what the ID of the field might be, or even if it will be unique. I may need to take a look at this again.Forum: Plugins
In reply to: [ACF Medium Editor Field] Gutenberg compatibilityCan you tell me exactly the errors that are reported on those lines.
Sorry, I don’t have the time at the moment to go through building an ACF block with a medium editor field do the testing myself. But if I understand the error and with you’re help, I might be able to figure out why those two lines in particular are causing errors.
Forum: Plugins
In reply to: [ACF Post-2-Post] Breaks Polylang Front PageThere simply isn’t any way that that I can think of that this plugin can effect any other field if it is not an ACF field.
1st – It only fires when ACF is saving a value to an ACF field, either a relationship of a post object field.
2nd – It looks at the post ID values being saved to the current post and it looks for a field on those posts with the same name. It uses the function acf_get_field_groups() using the post_id parameter. Then it loops though all the field in each group to find a field with the same name on that post. So only an ACF field can be found.
The only possible way that I can see this effecting anything else is if there field on both posts with the same “meta_key” that is an ACF field.
This plugin is rather simple, maybe you can get the devs of polylang to take a look. Maybe they can tell us both why this plugin would have any effect on this setting.
Forum: Plugins
In reply to: [ACF Post-2-Post] Breaks Polylang Front PageDo you have a relationship field that is named the same as an already existing polylang field? Check the field name used by polylang for the field that is the issue against your relationship field names.
- This reply was modified 7 years, 2 months ago by John Huebner.
Forum: Plugins
In reply to: [ACF Post-2-Post] Breaks Polylang Front PageThat is because this plugin works with both relationship and post object fields.
I’m assuming that you’re using an ACF field for this front page status. You can disable the post-2-post relationship on any field by adding this filter
add_filter('acf/post2post/update_relationships/key=field_XXXXXXXX', '__return_false');where field_XXXXXXXX is the field key of the field you do not want this plugin to mess with.
- This reply was modified 7 years, 2 months ago by John Huebner.
It is disabled but the repeater, not the sub fields of a repeater, so it is disabled for the entire repeater. Problem here is that in order to make this work I needed to insert fields as hidden fields rather than completely remove them in order to maintain row matching on repeater sub fields and flex sub fields. In the case of repeaters I would need to recreate hidden fields for all rows and nested fields.
I just pushed a new version, several changes. Test it out and see if this is still an issue.
Forum: Plugins
In reply to: [ACF Medium Editor Field] Gutenberg compatibilityThere is a very good chance that this plugin cannot be made compatible with the block editor.
I have not tested it, but my guess here is that JavaScript cannot locate the textarea field to apply medium editor to it. With regular ACF field groups I can find the field because it is in a fixed location in the HTML markup. As I understand it, this is not the case with blocks. The html for the field may or may not actually exist when script is attempting to initialize the field.
Have you tried using turning on the delayed initialization option for the field?
What JS error are you seeing? What else is it doing? not doing?
Forum: Plugins
In reply to: [ACF Post-2-Post] Field Exeptions not working?Not sure how you are using this. This will only work when you have fields of the same name but different keys of if you want to disable a field on all posts where it appears.
First thing I notice is that “C_PT” is not a valid field key, field names will not work. A field key generally looks something like “field_0ab34587”.
Forum: Plugins
In reply to: [ACF Post-2-Post] Support for blocks?This is not likely to happen, and I will explain why.
In order to update the reciprocal links in related posts, blocks are stored in the_content. I would need to read the content, find your block, however you set it up, find right information to alter and update the block in the other posts content and then update that content. There isn’t any way I could reliably do this.
The only way that this plugin will ever work is if the value is stored in the _postmeta table. I am currently interacting directly with the meta using
get_post_meta()andupdate_post_meta(). Event if this could be done using the ACF functionsget_field()andupdate_field()I would need to reliably detect what field needs to be updated on the other side of the relationship. How this works now is that I must get all of the fields that are associated with the post ID on the other end of the relationship and read through them all to find the one that has the same name, if it exists. As far as I know it would be nearly impossible for me to figure out what field on the other end I’d need to update since it would be associated with a block and not a post. You could, after all, insert multiples of these block into a post. In this case, how would I know what to target on the other end or even how/where to update the value.Creating a reciprocal relationship field inside a block would likely require custom coding for the specific block/fields in question, that is if it can be done at all.
However, I’m open to suggestions. If someone can come up with an example of how this can be done in blocks using a single field as in the ACF documentation https://www.advancedcustomfields.com/resources/bidirectional-relationships/ and this can somehow be adapted for fields with different field keys. I would be willing to give it a shot.
Forum: Plugins
In reply to: [ACF Post-2-Post] Deleting and Changing Post TitlesJust pushed a new version, I have added 2 action hooks
acf/post2post/relationship_updatedis fired after each post is updated and passes the post ID of the post that was updated.add_action('acf/post2post/relationship_updated', 'my_post_updated_action'); function my_post_updated_action($post_id) { // $post_id == the post ID that was updated // do something after the related post is updated }alternately you can use
acf/post2post/relationships_updatedplease note the subtle difference. This is fired after all updates are made and passes an array containing all the post IDs that were updated.add_action('acf/post2post/relationships_updated', 'my_post_updated_action'); function my_post_updated_action($posts) { // $posts == and array of post IDs that were updated // do something to all posts after update foreach ($posts as $post_id) // do something to post } }- This reply was modified 7 years, 2 months ago by John Huebner.
Forum: Plugins
In reply to: [ACF Post-2-Post] Deleting and Changing Post TitlesIf I add a hook, I would like it to be a generic one that could be used by anyone. There was a suggestion above to use something like
add_action('acf/post2post/relationship_updated', $post_id);
or from my point of view
do_action('acf/post2post/relationship_updated', $post_id);
My only question would be, is this something that should be fired on every post update or would it be more efficient and is it possible to fire it once with an array of post IDs that have been updated?Forum: Plugins
In reply to: [ACF Post-2-Post] Deleting and Changing Post TitlesI have used facetWP in the past. It saves an index of the posts and related fields. It is not updating the index. You either need to go into the facetwp admin and run the indexing manually, or you can trigger the re-indexing by calling a function in facetwp. There is currently no action triggered in this plugin when the post is updated on the other end.
I can look at adding an action after the update is made that you can use to trigger the other plugin to do its thing.
Forum: Plugins
In reply to: [ACF Post-2-Post] Deleting and Changing Post TitlesSo, let me understand. The issue with them not appearing on the front of the site is due to them not appearing in FacetWP? because FacetWP does not get an indication that the index for the post needs to be update? or something along those lines?