Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hooks on form element for integrators to hook into. #738

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jenkoian
Copy link

By adding these hooks it allows users to do such things as switch to
blog/restore blog, which is particularly useful when using something
like https://github.com/humanmade/network-media-library where all media
will be stored on a single site in the network.

By adding these hooks it allows users to do such things as switch to
blog/restore blog, which is particularly useful when using something
like https://github.com/humanmade/network-media-library where all media
will be stored on a single site in the network.
@mslinnea
Copy link
Member

mslinnea commented Feb 6, 2019

Hey @jenkoian I've looked over your request here and while I can see the need, this seems better placed in the abstract class class-fieldmanager-field.php, maybe as a companion to the fm_element_markup_start/end filters already in element_markup(), see:

$out = apply_filters( "fm_element_markup_start_{$this->name}", $out, $this, $values );

Another option would be to create a subclass in your project that handles the blog switching.

@jenkoian
Copy link
Author

jenkoian commented Feb 6, 2019

@mslinnea thanks for the reply! Yeah that makes sense, so do you think an action at the beginning and end of element_markup() ?? Could even do it right next to where the filter are applied? Could even go up further and do it in Fieldmanager_Context::render_field() something like..

	protected function render_field( $args = array() ) {
		// ...
		do_action( 'fieldmanager_pre_render_field' );
		$field = $this->fm->element_markup( $data );
		do_action( 'fieldmanager_post_render_field' );
		//...
	}

WDYT?

@mslinnea
Copy link
Member

mslinnea commented Mar 3, 2019

@jenkoian Would it work out better if the hooks were in Fieldmanager_Context::render_field()? The main difference I see is that the pre action would fire before the nonce is created.

@jenkoian
Copy link
Author

jenkoian commented Mar 3, 2019

@mslinnea do you want me to update the PR? Does it matter if fired before the nonce creation?

@mslinnea
Copy link
Member

mslinnea commented Mar 3, 2019

@jenkoian Hmm... It may cause an issue. Can you give it a try and see how it works with your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants