Add-on: How to identify blocked plugins in plugin list

Home Forums Block Plugin Updates Add-on: How to identify blocked plugins in plugin list

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #6398
    Ov3rfly
    Guest

    Wrote some code to be able to see which plugins are blocked in plugin list, tested with 2.2 and WordPress 4.6.1, feel free to use in future version, thanks for the great plugin.

    Add to file block-specific-plugin-updates.php:

    // Ov3rfly
    function bspu_admin_enqueue_scripts( $hook ) {
    	if ( 'plugins.php' != $hook ) {
    		return;
    	}
    	$data = array();
    	$bpu_update_blocked_plugins = get_option('bpu_update_blocked_plugins');
    	if ( $bpu_update_blocked_plugins !== false ) {
    		$bpu_update_blocked_plugins_array = @explode( '###', $bpu_update_blocked_plugins );		
    		if ( !empty( $bpu_update_blocked_plugins_array ) ) {
    			$data['plugins'] = $bpu_update_blocked_plugins_array;
    		}
    	}
    	wp_enqueue_style( 'bspu', plugins_url( 'includes/bspu.css', __FILE__ ), array(), '2.2.1' );
    	wp_register_script( 'bspu', plugins_url( 'includes/bspu.js', __FILE__ ), array( 'jquery' ), '2.2.1' );
    	wp_localize_script( 'bspu', 'bspu', $data );
    	wp_enqueue_script( 'bspu' );
    }
    add_action( 'admin_enqueue_scripts', 'bspu_admin_enqueue_scripts' );

    Create/add new file includes/bspu.js:

    var bspu = bspu || {};
    jQuery(document).ready(function() {
    	if ( bspu.plugins && bspu.plugins.length > 0 ) {
    		jQuery('table.plugins tr').each(function(index){
    			if ( jQuery.inArray( jQuery(this).data('plugin'), bspu.plugins ) != -1 ) {
    				jQuery(this).addClass( 'bspu-blocked' );
    				jQuery(this).attr('title', 'Updates for this plugin blocked by "Block Specific Plugin Updates"');
    			}
    		});
    	}
    });

    Create/add new file includes/bspu.css:

    .plugins tr.bspu-blocked {
    	background-color: #fff6f8;
    }
    .plugins .active.bspu-blocked td, .plugins .active.bspu-blocked th {
    	background-color: #fff0f2;
    }
    .plugins .active.bspu-blocked th.check-column {
    	border-left-color: #ffa0d2;
    }
Viewing 1 post (of 1 total)
  • The topic ‘Add-on: How to identify blocked plugins in plugin list’ is closed to new replies.