Get current filter priority in WordPress

if ( ! function_exists( 'get_current_filter_priority' ) ) {
	/*
	 * get_current_filter_priority.
	 */
	function get_current_filter_priority() {
		global $wp_filter;
		$current_filter_data = $wp_filter[ current_filter() ];
		if ( class_exists( 'WP_Hook' ) ) {
			// since WordPress v4.7
			return $current_filter_data->current_priority();
		} else {
			// before WordPress v4.7
			return key( $current_filter_data );
		}
	}
}

No comments yet.

Leave a Reply