src/Monitor.php
/**
	 * Compile our addon data
	 *
	 * @return array - collection of plugins and status
	 * @access private
	 */
Compile our addon data
@return array - collection of plugins and status
@access private
Compile our addon data @return array - collection of plugins and status @access private
private function compile_addons() {
		$data = [];
		wp_update_plugins();
		$plugin_updates = get_site_transient( 'update_plugins' );
		$plugins    = array_map( [ $this, 'model_plugin' ], get_plugins() );
		$mu_plugins = array_map( [ $this, 'model_mu_plugin' ], get_mu_plugins() );
		$dropins    = array_map( [ $this, 'model_dropin' ], get_dropins() );
		$all_plugins = array_merge( $plugins, $mu_plugins, $dropins );
		if ( is_multisite() ) {
			$recently_activated = get_site_option( 'recently_activated', array() );
		} else {
			$recently_activated = get_option( 'recently_activated', array() );
		}
		foreach ( $all_plugins as $plugin_file => $plugin_data ) {
			$plugin_extra_data = [];
			if ( ! empty( $plugin_updates->response[ $plugin_file ] ) ) {
				$plugin_extra_data = (array) $plugin_updates->response[ $plugin_file ];
			} else if ( ! empty( $plugin_updates->no_update[ $plugin_file ] ) ) {
				$plugin_extra_data = (array) $plugin_updates->no_update[ $plugin_file ];
			}
			$plugin_data = array_merge( $plugin_extra_data, $plugin_data );
			if ( empty( $plugin_data['slug'] ) ) {
				$file = plugin_basename( $plugin_file );
				$slug = '.' !== dirname( $file ) ? dirname( $file ) : $file;
			} else {
				$slug = $plugin_data['slug'];
			}
			$plugin_update_data = new \StdClass();
			$plugin_update_data->name = $slug;
			$plugin_update_data->display = $plugin_data['Name'];
			$plugin_update_data->type = $plugin_data['type'];
			$plugin_update_data->current = $plugin_data['Version'];
			$plugin_update_data->recommended = null;
			if ( isset( $plugin_updates->response[ $plugin_file ] ) ) {
				$plugin_update_data->recommended = $plugin_updates->response[ $plugin_file ]->new_version;
			}
			if ( 'plugin' === $plugin_data['type'] && ! is_plugin_active( $plugin_file ) && ! is_plugin_active_for_network( $plugin_file ) ) {
				$plugin_update_data->active = false;
			} else {
				$plugin_update_data->active = true;
			}
			array_push( $data, $plugin_update_data );
		}
		return $data;
	}
private function compile_addons ( ) { $ data = [ ] ; wp_update_plugins ( ) ; $ plugin_updates = get_site_transient ( 'update_plugins' ) ; $ plugins = array_map ( [ $ this , 'model_plugin' ] , get_plugins ( ) ) ; $ mu_plugins = array_map ( [ $ this , 'model_mu_plugin' ] , get_mu_plugins ( ) ) ; $ dropins = array_map ( [ $ this , 'model_dropin' ] , get_dropins ( ) ) ; $ all_plugins = array_merge ( $ plugins , $ mu_plugins , $ dropins ) ; if ( is_multisite ( ) ) { $ recently_activated = get_site_option ( 'recently_activated' , array ( ) ) ; } else { $ recently_activated = get_option ( 'recently_activated' , array ( ) ) ; } foreach ( $ all_plugins as $ plugin_file => $ plugin_data ) { $ plugin_extra_data = [ ] ; if ( ! empty ( $ plugin_updates -> response [ $ plugin_file ] ) ) { $ plugin_extra_data = ( array ) $ plugin_updates -> response [ $ plugin_file ] ; } else if ( ! empty ( $ plugin_updates -> no_update [ $ plugin_file ] ) ) { $ plugin_extra_data = ( array ) $ plugin_updates -> no_update [ $ plugin_file ] ; } $ plugin_data = array_merge ( $ plugin_extra_data , $ plugin_data ) ; if ( empty ( $ plugin_data [ 'slug' ] ) ) { $ file = plugin_basename ( $ plugin_file ) ; $ slug = '.' !== dirname ( $ file ) ? dirname ( $ file ) : $ file ; } else { $ slug = $ plugin_data [ 'slug' ] ; } $ plugin_update_data = new \ StdClass ( ) ; $ plugin_update_data -> name = $ slug ; $ plugin_update_data -> display = $ plugin_data [ 'Name' ] ; $ plugin_update_data -> type = $ plugin_data [ 'type' ] ; $ plugin_update_data -> current = $ plugin_data [ 'Version' ] ; $ plugin_update_data -> recommended = null ; if ( isset ( $ plugin_updates -> response [ $ plugin_file ] ) ) { $ plugin_update_data -> recommended = $ plugin_updates -> response [ $ plugin_file ] -> new_version ; } if ( 'plugin' === $ plugin_data [ 'type' ] && ! is_plugin_active ( $ plugin_file ) && ! is_plugin_active_for_network ( $ plugin_file ) ) { $ plugin_update_data -> active = false ; } else { $ plugin_update_data -> active = true ; } array_push ( $ data , $ plugin_update_data ) ; } return $ data ; }
Compile our addon data
 @return array - collection of plugins and status
 @access private
Compile our addon data @return array - collection of plugins and status @access private
// Get updates // Get recently activated // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide. // Slug from filename // mu-plugins and drop-ins are always active // Recent state // $plugin_update_data['recent'] = isset( $recently_activated[ $plugin_file ] );