Filter sites by Ignored core / plugin / theme updates to know for sure which sites are excluded

Hello,

I think I was looking for something like that already 2 years ago.

If we make use of those site settings “Ignore core updates”, “Ignore plugin updates”, “Ignore theme updates” then we should be able to filter.

The only guarantee to know right now is to check every single site manually.

This means it can happen that you oversee a site that never gets updates, meaning I cannot rely on MainWP. I must be in control without memorizing to check and filter the sites that have updates ignored/disabled.

Cannot imagine that this is not of value for all users who make use of the “ignore-features” as you can see in the screenshot below.

I found my way around with AI and tried to double check but cannot guarantee. Such modifications are always risky if they are not in MainWP Core but added manually. Perhaps though this can be input and maybe the idea will be considered for MainWP Dashboard and delivered natively.

I applied two changes myself and added the code to Custom Dashboard in PHP and JS:

  1. Add 3 columns to the site overview listing “Ignore Core”, “Ignore Plugins”, “Ignore Themes”
  2. Add a filter to the filter bar that does not allow to filter individually per item (core/plugin/theme) but can filter whether any of the ignored-settings are applied

PHP

/**
 * MainWP: Ignore Update columns + filter UI
 */

add_filter( 'mainwp_sitestable_getcolumns', function( $columns ) {

	$columns['ignore_core_updates']   = 'Ignore Core';
	$columns['ignore_plugin_updates'] = 'Ignore Plugins';
	$columns['ignore_theme_updates']  = 'Ignore Themes';

	return $columns;
} );

add_filter( 'mainwp_sitestable_item', function( $item ) {

	if ( empty( $item['id'] ) ) {
		return $item;
	}

	$website = \MainWP\Dashboard\MainWP_DB::instance()->get_website_by_id(
		$item['id'],
		true
	);

	if ( ! $website ) {
		return $item;
	}

	$item['ignore_core_updates'] =
		! empty( $website->is_ignoreCoreUpdates ) ? 'YES' : '—';

	$item['ignore_plugin_updates'] =
		! empty( $website->is_ignorePluginUpdates ) ? 'YES' : '—';

	$item['ignore_theme_updates'] =
		! empty( $website->is_ignoreThemeUpdates ) ? 'YES' : '—';

	return $item;
} );

add_action( 'mainwp_managesites_tabletop', function() {
	?>
	<div id="raabauke-mainwp-plugin-ignore-filter-wrap" style="display:none;">
      <select id="raabauke-mainwp-plugin-ignore-filter" class="ui dropdown">
      	<option value="all">Updates: All</option>
      	<option value="ignored">Updates: Ignored</option>
      	<option value="managed">Updates: Managed</option>
      </select>
	</div>
	<?php
} );


JS

/**
 * MainWP: Filter Manage Sites by ignored update settings.
 *
 * Moves the custom Updates filter into MainWP's filter bar
 * and filters sites based on the three custom columns:
 * Ignore Core, Ignore Plugins and Ignore Themes.
 *
 * "Ignored" = at least one update type is ignored.
 * "Managed" = none of the three update types are ignored.
 */

jQuery(function($) {

	const wrap   = $('#raabauke-mainwp-plugin-ignore-filter-wrap');
	const filter = $('#raabauke-mainwp-plugin-ignore-filter');

	if (!wrap.length || !filter.length) {
		return;
	}

	/*
	 * Move our custom filter directly before MainWP's Filter button.
	 */
	const filterButton = $('button, a').filter(function() {
		return $(this).text().trim() === 'Filter';
	}).first();

	if (filterButton.length) {
		wrap.insertBefore(filterButton);
		wrap.css({
			display: 'inline-block',
			marginRight: '8px'
		});
	} else {
		wrap.show();
	}

	filter.dropdown();

	/*
	 * Find the indexes of our three custom columns.
	 */
	function getColumnIndexes() {

		let indexes = {
			core: -1,
			plugins: -1,
			themes: -1
		};

		$('#mainwp-manage-sites-table thead th').each(function(index) {

			const title = $(this).text().trim();

			if (title === 'Ignore Core') {
				indexes.core = index;
			}

			if (title === 'Ignore Plugins') {
				indexes.plugins = index;
			}

			if (title === 'Ignore Themes') {
				indexes.themes = index;
			}
		});

		return indexes;
	}

	/*
	 * Apply our custom filter.
	 */
	filter.on('change', function() {

		const wanted  = $(this).val();
		const indexes = getColumnIndexes();

		$('#mainwp-manage-sites-table tbody tr').each(function() {

			const row = $(this);

			/*
			 * "All" always restores every row.
			 */
            if (wanted === 'all') {
          	row.show();
        	return;
            }
          
			const core =
				row.find('td').eq(indexes.core).text().trim() === 'YES';

			const plugins =
				row.find('td').eq(indexes.plugins).text().trim() === 'YES';

			const themes =
				row.find('td').eq(indexes.themes).text().trim() === 'YES';

			const anythingIgnored = core || plugins || themes;

			if (wanted === 'ignored') {
				row.toggle(anythingIgnored);
			}

			if (wanted === 'managed') {
				row.toggle(!anythingIgnored);
			}
		});
	});

});

Hey @markus998

Correct, we don’t currently have a way to filter sites by these ignored-update settings.

MainWP Voice is where we collect feature requests, so please feel free to submit the idea there.

And thanks for sharing your PHP and JavaScript snippets with the community.