-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathacp-conditional_format-formats.php
125 lines (116 loc) · 3.96 KB
/
acp-conditional_format-formats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* The filter allows you to modify the styles that are available in Conditional Formatting
*/
add_filter('acp/conditional_format/formats', function (array $formats) {
// Modify Styles array
return $formats;
});
/**
* Example that adds new color blind patterns
*
* @param array $formats
*
* @return array
*/
function acp_conditional_formatting_add_color_blind_patterns(array $formats)
{
$formats['success_pattern'] = [
'background' => 'repeating-linear-gradient(-45deg,rgba(255,255,255,.3),rgba(255,255,255,.3) 5px,transparent 5px,transparent 10px);',
'background_color' => 'var(--ac-color-success)',
'color' => '#fff',
];
$formats['warning_pattern'] = [
'background' => 'repeating-linear-gradient(90deg,rgba(255,255,255,.3),rgba(255,255,255,.3) 5px,transparent 5px,transparent 10px);',
'background_color' => 'var(--ac-color-warning)',
'color' => '#fff',
];
$formats['error_pattern'] = [
'background' => 'repeating-linear-gradient(45deg,rgba(255,255,255,.3),rgba(255,255,255,.3) 5px,transparent 5px,transparent 10px)',
'background_color' => 'var(--ac-color-error)',
'color' => '#fff',
];
$formats['info_pattern'] = [
'background' => 'linear-gradient(45deg, rgba(255,255,255,.4) 25%, transparent 25%) 0 0 / 20px 20px, linear-gradient(-45deg, rgba(255,255,255,.4) 25%, transparent 25%) 0 10px / 20px 20px, linear-gradient(45deg, transparent 75%, rgba(255,255,255,.4) 75%) 10px -10px / 20px 20px, linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.4) 75%) -10px 0 / 20px 20px',
'background_color' => 'var(--ac-primary-color)',
'color' => '#fff',
];
return $formats;
}
add_filter('acp/conditional_format/formats', 'acp_conditional_formatting_add_color_blind_patterns');
/**
* Example that adds some nice matching colors :)
*
* @param array $formats
*
* @return array
*/
add_filter('acp/conditional_format/formats', function (array $formats) {
$formats['black_pink'] = [
'color' => 'pink',
'background_color' => 'black',
];
$formats['black_pink_invert'] = [
'color' => 'black',
'background_color' => 'pink',
];
$formats['blue_orange'] = [
'color' => '#EEA47F',
'background_color' => '#00539C',
];
$formats['blue_orange_invert'] = [
'color' => '#00539C',
'background_color' => '#EEA47F',
];
$formats['red_yellow'] = [
'color' => '#F96167',
'background_color' => '#F9E795',
];
$formats['red_yellow_invert'] = [
'color' => '#F9E795',
'background_color' => '#F96167',
];
$formats['lime_blue'] = [
'color' => '#CCF381',
'background_color' => '#4831D4',
];
$formats['lime_blue_invert'] = [
'color' => '#4831D4',
'background_color' => '#CCF381',
];
$formats['forest_green_moss'] = [
'color' => '#2C5F2D',
'background_color' => '#97BC62',
];
$formats['fuchsia_neon'] = [
'color' => '#99F443',
'background_color' => '#EC449B',
];
$formats['yellow_verdant'] = [
'color' => '#FFE77A',
'background_color' => '#2C5F2D',
];
$formats['cherry_bubblgum'] = [
'color' => '#CC313D',
'background_color' => '#F7C5CC',
];
return $formats;
});
/**
* Example that removes all default colors
*
* @param array $formats
*
* @return array
*/
add_filter('acp/conditional_format/formats', function (array $formats) {
unset($formats['success']);
unset($formats['warning']);
unset($formats['error']);
unset($formats['info']);
unset($formats['success-invert']);
unset($formats['warning-invert']);
unset($formats['error-invert']);
unset($formats['info-invert']);
return $formats;
});