-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCustomize Approve Buttons
52 lines (45 loc) · 1.49 KB
/
Customize Approve Buttons
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
add_filter(
'gravityflow_step_settings_fields',
function ( $settings ) {
if ( rgars( $settings, '1/title' ) === 'Approval' ) {
$index = array_search( 'expiration', array_column( $settings[1]['fields'], 'name' ), true );
$index++;
$approval_text = array(
'name' => 'custom_approval_text',
'label' => 'Custom Approval Button Text',
'type' => 'text',
'class' => 'merge-tag-support mt-position-right',
'tooltip' => 'Enter text that you would like to display instead of "Approve" for this step.',
);
array_splice( $settings[1]['fields'], $index, 0, array( $approval_text ) );
$index++;
$rejection_text = array(
'name' => 'custom_rejection_text',
'label' => 'Custom Rejection Button Text',
'type' => 'text',
'class' => 'merge-tag-support mt-position-right',
'tooltip' => 'Enter text that you would like to display instead of "Reject" for this step.',
);
array_splice( $settings[1]['fields'], $index, 0, array( $rejection_text ) );
}
return $settings;
},
10,
2
);
add_filter(
'gravityflow_approve_label_workflow_detail',
function ( $approve_label, $step ) {
return empty($step->__get( 'custom_approval_text' )) ? $approve_label : $step->__get( 'custom_approval_text' );
},
10,
2
);
add_filter(
'gravityflow_reject_label_workflow_detail',
function ( $reject_label, $step ) {
return empty($step->__get( 'custom_rejection_text' )) ? $reject_label : $step->__get( 'custom_rejection_text' );
},
10,
2
);