Skip to content

Minit Action and Filter Hooks

Viktor Szépe edited this page Nov 30, 2016 · 5 revisions

Available Action Hooks

minit-cache-purged

Called when the global cache gets purged.

minit-cache-purge-delete

This is not called but hooked by Minit, you may clear the cache with do_action( 'minit-cache-purge-delete' );

Available Filter Hooks

minit-js-in-footer

@todo create a fallback

minit-script-tag-async

Disable async script loading. (boolean)

minit-exclude-{css,js}

Exclude specific style and script handles. (array)

minit-url-{css,js}

Modify minited file URL-s.

minit-content-{css,js}

Change the content of minited files.

minit-cache-expiration

Default cache expiration time of all minited files' data.

minit-cache-expiration-{css,js}

Cache expiration time of minited style's and script's data.

minit-asset-local-path

Support custom directory structure.

add_filter( 'minit-asset-local-path', 'minit_custom_content_dir', 10, 2 );
function minit_custom_content_dir( $local_path, $item_url ) {

	// Bail out if get_local_path_from_url() succeeded
	if ( false !== $local_path ) {
		return $local_path;
	}

	// Replace custom MU plugin URL
	$full_path = str_replace( WPMU_PLUGIN_URL, WPMU_PLUGIN_DIR, $item_url );
	// Replace custom plugin URL
	$full_path = str_replace( plugins_url(), WP_PLUGIN_DIR, $full_path );
	// Replace custom theme URL
	$full_path = str_replace( get_theme_root_uri(), get_theme_root(), $full_path );
	// Replace remaining custom wp-content URL
	$full_path = str_replace( content_url(), WP_CONTENT_DIR, $full_path );

	if ( file_exists( $full_path ) ) {
		return $full_path;
	}

	return false;

}
Clone this wiki locally