Filters

Here’s a list of the developer filters for MightyShare. Useful to fully customize MightyShare using functions.php or adding code snippets to your site.

mightyshare_filter_post

Using the mightyshare_filter_post filter you can overwrite any aspect of a MightyShare render. This is great if you have a large site and want to programmatically control all aspects of MightyShare. There are plenty of variables you can modify but one of the more important ones is ‘is_enabled’ which can be used to force MightyShare to enable/disable.

Below is an example of different variables and how you can overwrite them.

function mightyshare_filter_post_example( $template_options ) {
		// Overwrite the page template used
		$template_options['template'] = 'mighty-2';

		// Overwrite the page title used to render
		$template_options['title'] = 'My new title!';

		// Overwrite the page excerpt and force the sub heading option to enabled
		$template_options['enable_description'] = true;
		$template_options['description'] = 'My new subheading';

		// Overwrite the page background used to render
		$template_options['background'] = 'https://your-image-url.jpg';

		// Overwrite primary color setting
		$template_options['primary_color'] = '#ff6361';

		// Force the plugin to return a MightyShare image, useful for programmatically disabling/enabling MightyShare
		$template_options['is_enabled'] = true;

		// Overwrite background image based on post type
		if( get_post_type($template_options['ID']) === 'portfolio' ){
			$template_options['background'] = 'https://your-image-url.jpg';
		}

		// Overwrite options if category page
		if( $template_options['object_type'] === 'taxonomies' && $template_options['type'] === 'category' ){
			$template_options['background'] = 'https://your-image-url.jpg';
		}

		return $template_options;
}
add_filter( 'mightyshare_filter_post', 'mightyshare_filter_post_example', 10, 3 );

Useful MightyShare Code Snippets

Here are PHP code snippets created for the MightyShare community that may be useful to you.

Was this article helpful?

Related Articles