|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/dumoshi.com/wp-content/plugins/wpforms-lite/src/Helpers/ | |
|
Path: //home2/gazetufm/dumoshi.com/wp-content/plugins/wpforms-lite/src/Helpers/EventCounter.php
Size: 1.09 KB
Permissions: 0644
<?php
namespace WPForms\Helpers;
/**
* Lifetime per-key event counters kept in a non-autoloaded option.
*
* The store is `[ key => [ event => count ] ]`, the shape the weekly summary and the
* builder adoption tooltips report through Usage Tracking.
*
* @since 2.0.3
*/
class EventCounter {
/**
* Option holding the counters.
*
* @since 2.0.3
*
* @var string
*/
private $option;
/**
* Constructor.
*
* @since 2.0.3
*
* @param string $option Option holding the counters.
*/
public function __construct( string $option ) {
$this->option = $option;
}
/**
* All counters.
*
* @since 2.0.3
*
* @return array
*/
public function get_all(): array {
return (array) get_option( $this->option, [] );
}
/**
* Increment one counter.
*
* @since 2.0.3
*
* @param string $key Counter key.
* @param string $event Event name.
*/
public function bump( string $key, string $event ): void {
$events = $this->get_all();
$events[ $key ][ $event ] = (int) ( $events[ $key ][ $event ] ?? 0 ) + 1;
update_option( $this->option, $events, false );
}
}