*/ public static function defaults(): array { return [ // Counting 'tracking_mode' => 'php', 'post_types' => [ 'post', 'page' ], 'exclude_logged_in' => false, 'exclude_roles' => [ 'administrator', 'editor' ], 'session_interval' => 30, // Stored as minutes (default 30 min) 'trust_proxy_headers' => false, 'count_bots' => false, // Display 'views_label' => 'views', 'display_post_types' => [ 'post' ], 'default_style' => 1, 'default_variant' => 'outline', 'auto_insert' => 'none', // Data 'data_retention_days' => 90, 'delete_data_on_uninstall' => false, 'geo_tracking' => false, ]; } public function set_defaults(): void { if ( ! get_option( self::OPTION_KEY ) ) { add_option( self::OPTION_KEY, self::defaults(), '', false ); } } public function render(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission.', 'pulseviews' ) ); } $saved = false; $error = ''; if ( isset( $_POST['pulseviews_save'] ) ) { if ( ! check_admin_referer( self::NONCE ) ) { $error = 'Security check failed.'; } else { $this->save_settings(); $saved = true; } } $s = $this->get_settings(); $post_types = get_post_types( [ 'public' => true ], 'objects' ); $all_roles = wp_roles()->roles; $active_tab = sanitize_key( wp_unslash( $_GET['tab'] ?? 'counting' ) ); $tabs = [ 'counting' => 'Counting', 'display' => 'Display', 'other' => 'Other', ]; ?>
*/ private function get_settings(): array { return wp_parse_args( (array) get_option( self::OPTION_KEY, [] ), self::defaults() ); } }