-
Notifications
You must be signed in to change notification settings - Fork 9
Plugin hooks
Piotr Pelczar edited this page Jul 25, 2018
·
5 revisions
Plugin allows to bind the hooks on Word Press manner using add_filter()
function.
/**
* Filters of retrieved metadata of a post to link rewrite.
*
* @since 1.2.0
*
* @param array $post_meta The metadata returned from get_post_meta.
* @param WP_Post $post The post object.
*/
$filtered_post_meta = apply_filters( 'wpcfp_get_post_metadata', $post_meta, $post );
Example:
$filter = function ($post_meta, $post) {
return $post_meta; // do dome logic with values
};
add_filter( 'wpcfp_get_post_metadata', $filter, 1, 2 );
/**
* Filters of retrieved single metadata of a post to link rewrite.
*
* @since 1.4.0
*
* @param mixed|null $post_meta_value The metadata values returned from get_post_meta.
* @param string $meta_key Name of metadata field.
* @param array $meta_key_attrs The metadata field rewrite permalink attributes.
* @param WP_Post $post The post object.
*/
$filtered_post_meta_value = apply_filters( 'wpcfp_get_post_metadata_single', $post_meta_value, $meta_key, $meta_key_attrs, $post );
Example:
$filter = function ($post_meta_value, $meta_key, $meta_key_attrs, $post) {
return $values; // do dome logic with value
};
add_filter( 'wpcfp_get_post_metadata_single', $filter, 1, 4 );