Agentic
4 months ago
BlockTemplates
4 weeks ago
EmailImprovements
1 year ago
EmailPreview
4 weeks ago
Emails
1 year ago
ImportExport
1 year ago
Logging
1 year ago
Marketing
2 years ago
Notes
4 weeks ago
Onboarding
5 months ago
Orders
4 weeks ago
ProductForm
2 years ago
ProductReviews
4 weeks ago
RemoteFreeExtensions
4 weeks ago
Schedulers
4 weeks ago
Settings
5 days ago
Suggestions
4 weeks ago
WCPayPromotion
10 months ago
ActivityPanels.php
3 years ago
Analytics.php
4 weeks ago
CategoryLookup.php
4 years ago
Coupons.php
1 year ago
CouponsMovedTrait.php
5 months ago
CustomerEffortScoreTracks.php
7 months ago
Events.php
2 months ago
FeaturePlugin.php
4 months ago
Homescreen.php
1 month ago
Loader.php
4 weeks ago
Marketing.php
1 year ago
Marketplace.php
5 months ago
MobileAppBanner.php
4 years ago
OrderMilestoneEasterEgg.php
4 weeks ago
RemoteInboxNotifications.php
3 years ago
Settings.php
5 days ago
ShippingLabelBanner.php
1 year ago
ShippingLabelBannerDisplayRules.php
1 year ago
SiteHealth.php
3 years ago
Survey.php
4 years ago
SystemStatusReport.php
1 year ago
Translations.php
1 year ago
WCAdminAssets.php
5 days ago
WCAdminSharedSettings.php
1 year ago
WCAdminUser.php
9 months ago
WcPayWelcomePage.php
1 year ago
ActivityPanels.php
68 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Activity Panel. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Internal\Admin; |
| 7 | |
| 8 | use Automattic\WooCommerce\Admin\Notes\Notes; |
| 9 | |
| 10 | /** |
| 11 | * Contains backend logic for the activity panel feature. |
| 12 | */ |
| 13 | class ActivityPanels { |
| 14 | /** |
| 15 | * Class instance. |
| 16 | * |
| 17 | * @var ActivityPanels instance |
| 18 | */ |
| 19 | protected static $instance = null; |
| 20 | |
| 21 | /** |
| 22 | * Get class instance. |
| 23 | */ |
| 24 | public static function get_instance() { |
| 25 | if ( ! self::$instance ) { |
| 26 | self::$instance = new self(); |
| 27 | } |
| 28 | return self::$instance; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Hook into WooCommerce. |
| 33 | */ |
| 34 | public function __construct() { |
| 35 | add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) ); |
| 36 | // Run after Automattic\WooCommerce\Internal\Admin\Loader. |
| 37 | add_filter( 'woocommerce_components_settings', array( $this, 'component_settings' ), 20 ); |
| 38 | // New settings injection. |
| 39 | add_filter( 'woocommerce_admin_shared_settings', array( $this, 'component_settings' ), 20 ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Adds fields so that we can store activity panel last read and open times. |
| 44 | * |
| 45 | * @param array $user_data_fields User data fields. |
| 46 | * @return array |
| 47 | */ |
| 48 | public function add_user_data_fields( $user_data_fields ) { |
| 49 | return array_merge( |
| 50 | $user_data_fields, |
| 51 | array( |
| 52 | 'activity_panel_inbox_last_read', |
| 53 | 'activity_panel_reviews_last_read', |
| 54 | ) |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Add alert count to the component settings. |
| 60 | * |
| 61 | * @param array $settings Component settings. |
| 62 | */ |
| 63 | public function component_settings( $settings ) { |
| 64 | $settings['alertCount'] = Notes::get_notes_count( array( 'error', 'update' ), array( 'unactioned' ) ); |
| 65 | return $settings; |
| 66 | } |
| 67 | } |
| 68 |