2019-04-11 18:31:31 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce Activity Panel.
|
|
|
|
* NOTE: DO NOT edit this file in WooCommerce core, this is generated from woocommerce-admin.
|
|
|
|
*/
|
|
|
|
|
2019-08-01 18:17:08 +00:00
|
|
|
namespace Automattic\WooCommerce\Admin\Features;
|
|
|
|
|
2020-09-28 04:35:10 +00:00
|
|
|
use Automattic\WooCommerce\Admin\Notes\Notes;
|
2019-07-31 19:47:32 +00:00
|
|
|
|
2019-04-11 18:31:31 +00:00
|
|
|
/**
|
|
|
|
* Contains backend logic for the activity panel feature.
|
|
|
|
*/
|
2019-08-12 18:50:22 +00:00
|
|
|
class ActivityPanels {
|
2019-04-11 18:31:31 +00:00
|
|
|
/**
|
|
|
|
* Class instance.
|
|
|
|
*
|
2019-08-12 21:52:09 +00:00
|
|
|
* @var ActivityPanels instance
|
2019-04-11 18:31:31 +00:00
|
|
|
*/
|
|
|
|
protected static $instance = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get class instance.
|
|
|
|
*/
|
|
|
|
public static function get_instance() {
|
|
|
|
if ( ! self::$instance ) {
|
|
|
|
self::$instance = new self();
|
|
|
|
}
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook into WooCommerce.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
2019-12-17 13:36:22 +00:00
|
|
|
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
|
2019-09-23 21:47:08 +00:00
|
|
|
// Run after Automattic\WooCommerce\Admin\Loader.
|
|
|
|
add_filter( 'woocommerce_components_settings', array( $this, 'component_settings' ), 20 );
|
2019-12-17 13:36:22 +00:00
|
|
|
// New settings injection.
|
2019-09-23 21:47:08 +00:00
|
|
|
add_filter( 'woocommerce_shared_settings', array( $this, 'component_settings' ), 20 );
|
2019-04-11 18:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds fields so that we can store activity panel last read and open times.
|
|
|
|
*
|
|
|
|
* @param array $user_data_fields User data fields.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function add_user_data_fields( $user_data_fields ) {
|
|
|
|
return array_merge(
|
|
|
|
$user_data_fields,
|
|
|
|
array(
|
|
|
|
'activity_panel_inbox_last_read',
|
|
|
|
'activity_panel_reviews_last_read',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add alert count to the component settings.
|
|
|
|
*
|
|
|
|
* @param array $settings Component settings.
|
|
|
|
*/
|
|
|
|
public function component_settings( $settings ) {
|
2020-11-25 18:51:15 +00:00
|
|
|
$settings['alertCount'] = Notes::get_notes_count( array( 'error', 'update' ), array( 'unactioned' ) );
|
2019-04-11 18:31:31 +00:00
|
|
|
return $settings;
|
|
|
|
}
|
|
|
|
}
|