Test Failed
Push — master ( 9ee67a...7fe2bc )
by Devin
11:42
created

deprecated-actions.php ➔ give_deprecated_action_mapping()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 4
nop 4
dl 15
loc 15
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * Handle renamed actions.
4
 */
5
$give_map_deprecated_actions = give_deprecated_actions();
6
7
foreach ( $give_map_deprecated_actions as $new => $old ) {
8
	add_action( $new, 'give_deprecated_action_mapping', 10, 4 );
9
}
10
11
/**
12
 * Deprecated actions.
13
 *
14
 * @return array An array of deprecated Give actions.
15
 */
16
function give_deprecated_actions() {
17
18
	$give_deprecated_actions = array(
19
		// New action hook                            Old action hook.
20
		'give_donation_form_login_fields'          => 'give_purchase_form_login_fields',
21
		'give_donation_form_register_login_fields' => 'give_purchase_form_register_login_fields',
22
		'give_donation_form_before_register_login' => 'give_purchase_form_before_register_login',
23
		'give_donation_form_before_cc_form'        => 'give_purchase_form_before_cc_form',
24
		'give_donation_form_after_cc_form'         => 'give_purchase_form_after_cc_form',
25
		'give_donation_form_no_access'             => 'give_purchase_form_no_access',
26
		'give_donation_form_register_fields'       => 'give_purchase_form_register_fields',
27
		'give_donation_form_after_user_info'       => 'give_purchase_form_after_user_info',
28
		'give_donation_form_before_personal_info'  => 'give_purchase_form_before_personal_info',
29
		'give_donation_form_before_email'          => 'give_purchase_form_before_email',
30
		'give_donation_form_after_email'           => 'give_purchase_form_after_email',
31
		'give_donation_form_user_info'             => 'give_purchase_form_user_info',
32
		'give_donation_form_after_personal_info'   => 'give_purchase_form_after_personal_info',
33
		'give_donation_form'                       => 'give_purchase_form',
34
		'give_donation_form_wrap_bottom'           => 'give_purchase_form_wrap_bottom',
35
		'give_donation_form_before_submit'         => 'give_purchase_form_before_submit',
36
		'give_donation_form_after_submit'          => 'give_purchase_form_after_submit',
37
		'give_donation_history_header_before'      => 'give_purchase_history_header_before',
38
		'give_donation_history_header_after'       => 'give_purchase_history_header_after',
39
		'give_donation_history_row_start'          => 'give_purchase_history_row_start',
40
		'give_donation_history_row_end'            => 'give_purchase_history_row_end',
41
		'give_payment_form_top'                    => 'give_purchase_form_top',
42
		'give_payment_form_bottom'                 => 'give_purchase_form_bottom',
43
		'give_pre_process_donation'                => 'give_pre_process_purchase',
44
		'give_complete_donation'                   => 'give_complete_purchase',
45
		'give_ajax_donation_errors'                => 'give_ajax_checkout_errors',
46
		'give_admin_donation_email'                => 'give_admin_sale_notice',
47
		'give_tools_tab_export_content_top'        => 'give_reports_tab_export_content_top',
48
		'give_tools_tab_export_table_top'          => 'give_reports_tab_export_table_top',
49
		'give_tools_tab_export_table_bottom'       => 'give_reports_tab_export_table_bottom',
50
		'give_tools_tab_export_content_bottom'     => 'give_report_tab_export_table_bottom',
51
		'give_pre_edit_donor'                      => 'give_pre_edit_customer',
52
		'give_post_edit_donor'                     => 'give_post_edit_customer',
53
		'give_pre_donor_disconnect_user_id'        => 'give_pre_customer_disconnect_user_id',
54
		'give_post_donor_disconnect_user_id'       => 'give_post_customer_disconnect_user_id',
55
		'give_update_donor_email_on_user_update'   => 'give_update_customer_email_on_user_update',
56
		'give_pre_insert_donor'                    => 'give_pre_insert_customer',
57
		'give_post_insert_donor'                   => 'give_post_insert_customer',
58
		'give_donor_pre_create'                    => 'give_customer_pre_create',
59
		'give_donor_post_create'                   => 'give_customer_post_create',
60
		'give_donor_pre_update'                    => 'give_customer_pre_update',
61
		'give_donor_post_update'                   => 'give_customer_post_update',
62
		'give_donor_pre_attach_payment'            => 'give_customer_pre_attach_payment',
63
		'give_donor_post_attach_payment'           => 'give_customer_post_attach_payment',
64
		'give_donor_pre_remove_payment'            => 'give_customer_pre_remove_payment',
65
		'give_donor_post_remove_payment'           => 'give_customer_post_remove_payment',
66
		'give_donor_pre_increase_donation_count'   => 'give_customer_pre_increase_purchase_count',
67
		'give_donor_post_increase_donation_count'  => 'give_customer_post_increase_purchase_count',
68
		'give_donor_pre_decrease_donation_count'   => 'give_customer_pre_decrease_purchase_count',
69
		'give_donor_post_decrease_donation_count'  => 'give_customer_post_decrease_purchase_count',
70
		'give_donor_pre_increase_value'            => 'give_customer_pre_increase_value',
71
		'give_donor_post_increase_value'           => 'give_customer_post_increase_value',
72
		'give_donor_pre_decrease_value'            => 'give_customer_pre_decrease_value',
73
		'give_donor_post_decrease_value'           => 'give_customer_post_decrease_value',
74
		'give_donor_pre_add_note'                  => 'give_customer_pre_add_note',
75
		'give_donor_post_add_note'                 => 'give_customer_post_add_note',
76
		'give_donor_pre_add_email'                 => 'give_customer_pre_add_email',
77
		'give_donor_post_add_email'                => 'give_customer_post_add_email',
78
		'give_donor_pre_remove_email'              => 'give_customer_pre_remove_email',
79
		'give_donor_post_remove_email'             => 'give_customer_post_remove_email',
80
		'give_donor_pre_set_primary_email'         => 'give_customer_pre_set_primary_email',
81
		'give_donor_post_set_primary_email'        => 'give_customer_post_set_primary_email',
82
		'give_donation_form_top'                   => 'give_checkout_form_top',
83
		'give_donation_form_bottom'                => 'give_checkout_form_bottom',
84
		'give_donor_delete_top'                    => 'give_customer_delete_top',
85
		'give_donor_delete_bottom'                 => 'give_customer_delete_bottom',
86
		'give_donor_delete_inputs'                 => 'give_customer_delete_inputs',
87
		'give_pre_insert_donor_note'               => 'give_pre_insert_customer_note',
88
		'give_pre_delete_donor'                    => 'give_pre_delete_customer',
89
		'give_post_add_donor_email'                => 'give_post_add_customer_email',
90
		'give_update_edited_donation'              => 'give_update_edited_purchase',
91
		'give_updated_edited_donation'             => 'give_updated_edited_purchase',
92
		'give_pre_complete_donation'               => 'give_pre_complete_purchase',
93
	);
94
95
	return $give_deprecated_actions;
96
}
97
98
/**
99
 * Deprecated action mapping.
100
 *
101
 * @param mixed  $data
102
 * @param string $arg_1
103
 * @param string $arg_2
104
 * @param string $arg_3
105
 *
106
 * @return mixed|void
107
 */
108
function give_deprecated_action_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) {
109
	$give_map_deprecated_actions = give_deprecated_actions();
110
	$action                      = current_filter();
111
112
	if ( isset( $give_map_deprecated_actions[ $action ] ) ) {
113
		if ( has_action( $give_map_deprecated_actions[ $action ] ) ) {
114
			do_action( $give_map_deprecated_actions[ $action ], $data, $arg_1, $arg_2, $arg_3 );
115
116
			if ( ! defined( 'DOING_AJAX' ) ) {
117
				// translators: %s: action name.
118
				_give_deprecated_function( sprintf( __( 'The %s action' ), $give_map_deprecated_actions[ $action ] ), '1.7', $action );
119
			}
120
		}
121
	}
122
}
123