|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Give - Stripe Core Logs |
|
4
|
|
|
* |
|
5
|
|
|
* @since 2.5.0 |
|
6
|
|
|
* |
|
7
|
|
|
* @package Give |
|
8
|
|
|
* @subpackage Stripe Core |
|
9
|
|
|
* @copyright Copyright (c) 2019, GiveWP |
|
10
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
// Exit, if accessed directly. |
|
14
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
15
|
|
|
exit; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
if ( ! class_exists( 'Give_Stripe_Logs' ) ) { |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class Give_Stripe_Logs |
|
22
|
|
|
* |
|
23
|
|
|
* @since 2.5.0 |
|
24
|
|
|
*/ |
|
25
|
|
|
class Give_Stripe_Logs { |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Set single instance. |
|
29
|
|
|
* |
|
30
|
|
|
* @since 2.5.0 |
|
31
|
|
|
* @access private |
|
32
|
|
|
* |
|
33
|
|
|
* @var Give_Stripe_Logs $instance |
|
34
|
|
|
*/ |
|
35
|
|
|
private static $instance; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get single instance of class object. |
|
39
|
|
|
* |
|
40
|
|
|
* @since 2.5.0 |
|
41
|
|
|
* @access public |
|
42
|
|
|
* |
|
43
|
|
|
* @return Give_Stripe_Logs |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function get_instance() { |
|
46
|
|
|
if ( null === static::$instance ) { |
|
47
|
|
|
static::$instance = new static(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return static::$instance; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Setup hooks. |
|
55
|
|
|
* |
|
56
|
|
|
* @since 2.5.0 |
|
57
|
|
|
* @access public |
|
58
|
|
|
*/ |
|
59
|
|
|
public function setup_hooks() { |
|
60
|
|
|
|
|
61
|
|
|
// Bailout, if not admin. |
|
62
|
|
|
if ( ! is_admin() ) { |
|
63
|
|
|
return; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
add_filter( 'give_log_types', array( $this, 'set_stripe_log_type' ) ); |
|
67
|
|
|
add_filter( 'give_log_views', array( $this, 'set_stripe_log_section' ) ); |
|
68
|
|
|
add_action( 'give_logs_view_stripe', array( $this, 'give_stripe_logs_view' ) ); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* This function will set new stripe log type as valid log type. |
|
73
|
|
|
* |
|
74
|
|
|
* @param array $types List of log types. |
|
75
|
|
|
* |
|
76
|
|
|
* @since 2.5.0 |
|
77
|
|
|
* @access public |
|
78
|
|
|
* |
|
79
|
|
|
* @return array |
|
80
|
|
|
*/ |
|
81
|
|
|
public function set_stripe_log_type( $types ) { |
|
82
|
|
|
|
|
83
|
|
|
$new_log_type = array( 'stripe' ); |
|
84
|
|
|
|
|
85
|
|
|
return array_merge( $types, $new_log_type ); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* This function will set new stripe log section. |
|
90
|
|
|
* |
|
91
|
|
|
* @param array $sections List of log sections. |
|
92
|
|
|
* |
|
93
|
|
|
* @since 2.5.0 |
|
94
|
|
|
* @access public |
|
95
|
|
|
* |
|
96
|
|
|
* @return array |
|
97
|
|
|
*/ |
|
98
|
|
|
public function set_stripe_log_section( $sections ) { |
|
99
|
|
|
|
|
100
|
|
|
$new_log_section = array( |
|
101
|
|
|
'stripe' => __( 'Stripe', 'give' ), |
|
102
|
|
|
); |
|
103
|
|
|
|
|
104
|
|
|
return array_merge( $sections, $new_log_section ); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Stripe Logs View |
|
110
|
|
|
* |
|
111
|
|
|
* @since 2.5.0 |
|
112
|
|
|
* |
|
113
|
|
|
* @return void |
|
114
|
|
|
*/ |
|
115
|
|
View Code Duplication |
public function give_stripe_logs_view() { |
|
|
|
|
|
|
116
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/admin/class-give-stripe-logs-list-table.php'; |
|
117
|
|
|
|
|
118
|
|
|
$logs_table = new Give_Stripe_Log_Table(); |
|
119
|
|
|
$logs_table->prepare_items(); |
|
120
|
|
|
?> |
|
121
|
|
|
<div class="wrap"> |
|
122
|
|
|
|
|
123
|
|
|
<?php |
|
124
|
|
|
/** |
|
125
|
|
|
* Fires before displaying Payment Error logs. |
|
126
|
|
|
* |
|
127
|
|
|
* @since 2.0.8 |
|
128
|
|
|
*/ |
|
129
|
|
|
do_action( 'give_stripe_logs_top' ); |
|
130
|
|
|
|
|
131
|
|
|
$logs_table->display(); |
|
132
|
|
|
?> |
|
133
|
|
|
<input type="hidden" name="post_type" value="give_forms"/> |
|
134
|
|
|
<input type="hidden" name="page" value="give-tools"/> |
|
135
|
|
|
<input type="hidden" name="tab" value="logs"/> |
|
136
|
|
|
<input type="hidden" name="section" value="stripe"/> |
|
137
|
|
|
|
|
138
|
|
|
<?php |
|
139
|
|
|
/** |
|
140
|
|
|
* Fires after displaying update logs. |
|
141
|
|
|
* |
|
142
|
|
|
* @since 2.0.8 |
|
143
|
|
|
*/ |
|
144
|
|
|
do_action( 'give_stripe_logs_bottom' ); |
|
145
|
|
|
?> |
|
146
|
|
|
|
|
147
|
|
|
</div> |
|
148
|
|
|
<?php |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
Give_Stripe_Logs::get_instance()->setup_hooks(); |
|
155
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.