Filters for MB Spirit WordPress Plugin

Introduction

You can call any of these filters to manipulate either the request for details or the information being returned to fully customize your site. add hooks to these filters within your theme by calling:

add_filter('[name of filter]', 'my_filter_function', 10, [1,2,3]);
function my_filter_function($arg1[,$arg2...]) { ... }

Note that different filters will expose a different number of values. You need to ensure the last parameter of your add_filter hook specifies how many variables you want to receive.

Example Use

add_filter( 'mb_spirit_sc_attr', 'my_mb_spirit_sc_attr', 10, 1 );
function my_mb_spirit_sc_attr( $attr ) {
	$attr['embed'] = 'true';
	$attr['popups'] = 'false';
	return $attr;
}

add_filter( 'mb_spirit_seo_single', 'my_mb_spirit_seo_single', 10, 4 );

function my_mb_spirit_seo_single( $html, $wres, $type, $id ) {
	if ( $type == 'staff' ) {
		$html = sprintf(
			'
			<h2>%s</h2>
			<img src="%s" alt="%s" style="width: 25%%;float: right" />
			<div>%s</div>
                        <!--
                             Here is the contents of the returned single item you can use in your layout:
                             %s
                        -->
			'
			,$wres['info']['full_name']
			,$wres['info']['profile_img_full']
			,$wres['info']['full_name']
			,$wres['info']['staff_bio']
			,print_r($wres,true)
		);
	}
	return $html;
}

Available Filters

mb_spirit_single_desc ($description, $caller)
Called prior to manipulating the description meta data for the page. Also called within Yoast SEO to provide descriptions for Facebook and Twitter.

mb_spirit_single_title ($title, $caller)
Called prior to manipulating the title for the page. Also called within Yoast SEO to provide titles for Facebook and Twitter. The caller will be either wp, facebook, or twitter.

mb_spirit_single_image ($image_url, $caller)
Called prior to manipulating the image url for the page. Also called within Yoast SEO to provide image urls for Facebook and Twitter. The caller will be either wp, facebook, or twitter.

mb_spirit_default_page_content ($content, $list_type, $widget_code)
With the MB Spirit settings for default pages for listing staff, events, schedules, etc., this is called prior to adding the content. Use do_shortcode($widget_code) to get the final widget code.

mb_spirit_single_request ($request)
Allows manipulation of the request made to the API when retrieving a single item entry. The type of entry is contained in $request[‘single’].

mb_spirit_sc_attr ($atts, $tag)
Allows manipulation of the attributes passed into from a shortcode. Use $tag to identify the type of shortcode being called.

mb_spirit_seo_single ($html, $response, $type, $id)
Allows manipulation of the rendered output for a single entry for SEO purposes. Full access to the response gives you all data in that item’s entry. Return the HTML you wish to display. You can add &nojs to URL’s to produce detail listings without JavaScript calls to the system.

mb_spirit_seo_html ($html)
Allows manipulation of the widget container when displaying for SEO. This is not the content of the widget, just it’s framework.

mb_spirit_seo_request ($request)
Allows manipulation of the request made to the API when retrieving a widget response for SEO. The type of widget is contained in $request[‘mb-spirit’].

mb_spirit_seo_response ($response, $orig_request)
Capture the response for SEO presentation, and manipulate it. Used in conjunction with mb_spirit_seo_html can allow the presentation layout and contents to be completely manipulated.

mb_spirit_widget_output($html, $content, $type, $request)
When displaying a shortcode, allows access to the widget framework as $html, the content within the shortcode block as $content, the type of widget as $type, and the merged list of parameters to be sent for an API request as $request. You can call the global $MB_Spirit->apiCall($type,null,$request) to get the results of the widget and decide how to display and return the HTML. Add fmt => ‘json’ to the request to get raw data back that you can manipulate and render exactly as you like.

mb_spirit_api_request ($params, $endpoint, $action, $method)
Modify requests to the API.

mb_spirit_api_response_raw ($raw_response, $endpoint, $action, $method)
Review and manipulate the raw response from the API (prior to being processed as JSON data).

mb_spirit_api_response ($response, $endpoint, $action, $method)
Review and manipulate the JSON response from a call