PluginProbe
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe / trunk
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe vtrunk
4.17.3 trunk 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 4.10.0 4.11.1 4.12.2 4.14.1 4.14.2 4.14.3 4.15.0 4.16.0 All 59 releases
stripe / src / Report / Chart / ChartTrait.php

ChartTrait.php in Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe trunk, at src/Report/Chart/ChartTrait.php

78 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Report: Chart
4 *
5 * @package SimplePay
6 * @subpackage Core
7 * @copyright Copyright (c) 2023, Sandhills Development, LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 4.6.7
10 */
11
12 namespace SimplePay\Core\Report\Chart;
13
14 /**
15 * ChartTrait trait.
16 *
17 * @since 4.6.7
18 */
19 trait ChartTrait {
20
21 /**
22 * Calculates a dataset's "total" amount.
23 *
24 * @since 4.6.7
25 *
26 * @param array<int, array<string, mixed>> $dataset The formatted dataset.
27 * @return int
28 */
29 private function get_chart_formatted_dataset_total( $dataset ) {
30 return array_reduce(
31 $dataset,
32 function( $total, $datapoint ) {
33 /** @var array<string, mixed> $datapoint */
34 /** @var int $total */
35 /** @var int $y */
36 $y = $datapoint['y'];
37 return $total + $y;
38 },
39 0
40 );
41 }
42
43 /**
44 * Returns the primary color for the current user's admin color scheme.
45 *
46 * @since 4.7.3
47 *
48 * @return array<int> RGB color values.
49 */
50 protected function get_user_color_scheme_pref_primary_color() {
51 $color_scheme = get_user_meta(
52 get_current_user_id(),
53 'admin_color',
54 true
55 );
56
57 switch ( $color_scheme ) {
58 case 'modern':
59 return array( 56, 88, 233 );
60 case 'light':
61 case 'blue':
62 return array( 9, 100, 132 );
63 case 'coffee':
64 return array( 199, 165, 137 );
65 case 'ectoplasm':
66 return array( 163, 183, 69 );
67 case 'midnight':
68 case 'ocean':
69 return array( 105, 168, 187 );
70 case 'sunrise':
71 return array( 207, 73, 68 );
72 default:
73 return array( 66, 138, 202 );
74 }
75 }
76
77 }
78