add_meta_box( 'summary', null, array( $this, 'dashboard_summary_meta_box' ), null, null, 'main', array( 'box_class' => 'sui-box sui-summary sui-summary-smush-metabox sui-summary-smush ' . $this->get_whitelabel_class(), 'box_content_class' => false, ) ); // If not a pro user. if ( ! WP_Smush::is_pro() ) { /** * Allows to hook in additional containers after stats box for free version * Pro Version has a full width settings box, so we don't want to do it there. */ do_action( 'wp_smush_after_stats_box' ); } } } /** * Return rebranded class. * * @since 3.8.8 * * @return string */ private function get_whitelabel_class() { if ( ! apply_filters( 'wpmudev_branding_hide_branding', false ) ) { return ''; } return apply_filters( 'wpmudev_branding_hero_image', '' ) ? 'sui-rebranded' : 'sui-unbranded'; } /** * Summary meta box. */ public function dashboard_summary_meta_box() { $array_utils = new Array_Utils(); $core = WP_Smush::get_instance()->core(); $global_stats = $core->get_global_stats(); $this->view( 'summary/meta-box', array( 'human_bytes' => $array_utils->get_array_value( $global_stats, 'human_bytes' ), 'remaining' => $array_utils->get_array_value( $global_stats, 'remaining_count' ), 'resize_count' => $array_utils->get_array_value( $global_stats, 'count_resize' ), 'resize_enabled' => (bool) $this->settings->get( 'resize' ), 'resize_savings' => $array_utils->get_array_value( $global_stats, 'savings_resize_human' ), 'stats_percent' => $array_utils->get_array_value( $global_stats, 'savings_percent' ), 'total_optimized' => $array_utils->get_array_value( $global_stats, 'count_images' ), 'percent_grade' => $array_utils->get_array_value( $global_stats, 'percent_grade' ), 'percent_metric' => $array_utils->get_array_value( $global_stats, 'percent_metric' ), 'percent_optimized' => $array_utils->get_array_value( $global_stats, 'percent_optimized' ), ) ); } /** * Show conversion savings stats in stats section. * * Show Png to Jpg conversion savings in stats box if the * settings enabled or savings found. * * @return void */ public function conversion_savings_stats() { if ( ! WP_Smush::is_pro() ) { return; } $core = WP_Smush::get_instance()->core(); $global_stats = $core->get_global_stats(); $class_names = array( 'smush-conversion-savings' ); $savings_conversion_human = ! empty( $global_stats['savings_conversion_human'] ) ? $global_stats['savings_conversion_human'] : '0 B'; if ( empty( $global_stats['savings_conversion'] ) ) { $class_names[] = 'sui-hidden'; } ?>