-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
deprecated.php
213 lines (193 loc) · 7.43 KB
/
deprecated.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
defined('ABSPATH') || exit;
/**
* Provide support for the deprecated {{ assigned_to }} tag
* @param string $template
* @return string
* @since 5.0
*/
add_filter('site-reviews/build/template/review', function ($template) {
return str_replace('{{ assigned_to }}', '{{ assigned_links }}', $template);
});
/**
* Fix the {{ review_id }} tag in the review template which now only returns the ID
* @param string $template
* @return string
* @since 5.3
*/
add_filter('site-reviews/build/template/review', function ($template) {
return str_replace('id="{{ review_id }}"', 'id="review-{{ review_id }}"', $template);
});
add_action('plugins_loaded', function () {
if (!glsr()->filterBool('support/deprecated/v7', true)) {
return;
}
/**
* @since 7.0.0
*/
add_filter('site-reviews/review-form/fields/all', function ($fields, $args) {
if (has_filter('site-reviews/review-form/fields/normalized')) {
$message = 'The "site-reviews/review-form/fields/normalized" hook has been deprecated. Please use the "site-reviews/review-form/fields/all" hook instead.';
glsr()->append('deprecated', $message);
return apply_filters('site-reviews/review-form/fields/normalized', $fields, $args);
}
return $fields;
}, 10, 2);
});
add_action('plugins_loaded', function () {
if (!glsr()->filterBool('support/deprecated/v6', true)) {
return;
}
/**
* @since 6.5.0
*/
add_filter('site-reviews/rest-api/reviews/schema/properties', function ($properties) {
if (has_filter('site-reviews/rest-api/reviews/properties')) {
$message = 'The "site-reviews/rest-api/reviews/properties" hook has been deprecated. Please use the "site-reviews/rest-api/reviews/schema/properties" hook instead.';
glsr()->append('deprecated', $message);
return apply_filters('site-reviews/rest-api/reviews/properties', $properties);
}
return $properties;
}, 9);
/**
* @since 6.5.0
*/
add_filter('site-reviews/rest-api/summary/schema/properties', function ($properties) {
if (has_filter('site-reviews/rest-api/summary/properties')) {
$message = 'The "site-reviews/rest-api/summary/properties" hook has been deprecated. Please use the "site-reviews/rest-api/summary/schema/properties" hook instead.';
glsr()->append('deprecated', $message);
return apply_filters('site-reviews/rest-api/summary/properties', $properties);
}
return $properties;
}, 9);
/**
* @since 6.5.0
*/
add_filter('site-reviews/reviews/html/style', function ($value, $html) {
return glsr_get($html->reviews->attributes(), 'class'); // @todo show a deprecation notice?
}, 10, 2);
/**
* @since 6.7.0
*/
add_action('site-reviews/review/updated', function ($review, $data) {
if (has_action('site-reviews/review/saved')) {
$message = 'The "site-reviews/review/saved" hook has been deprecated. Please use the "site-reviews/review/updated" hook instead.';
glsr()->append('deprecated', $message);
do_action('site-reviews/review/saved', $review, $data);
}
}, 10, 2);
/**
* @since 6.9.0
*/
add_filter('site-reviews/slack/notification', function ($notification) {
if (has_filter('site-reviews/slack/compose')) {
$message = 'The "site-reviews/slack/compose" hook has been deprecated. Please use the "site-reviews/slack/notification" hook instead.';
glsr()->append('deprecated', $message);
}
return $notification;
});
});
add_action('plugins_loaded', function () {
if (!glsr()->filterBool('support/deprecated/v5', true)) {
return;
}
/*
* Application
* @since 5.0.0
*/
add_filter('site-reviews/config/forms/review-form', function ($config) {
if (has_filter('site-reviews/config/forms/submission-form')) {
$message = 'The "site-reviews/config/forms/submission-form" hook has been deprecated. Please use the "site-reviews/config/forms/review-form" hook instead.';
glsr()->append('deprecated', $message);
return apply_filters('site-reviews/config/forms/submission-form', $config);
}
return $config;
}, 9);
/*
* Modules\Html\ReviewsHtml
* @since 5.0.0
*/
add_filter('site-reviews/rendered/template/reviews', function ($html) {
if (has_filter('site-reviews/reviews/reviews-wrapper')) {
$message = 'The "site-reviews/reviews/reviews-wrapper" hook has been removed. Please use a custom "reviews.php" template instead.';
glsr()->append('deprecated', $message);
}
return $html;
});
/**
* Controllers\PublicController
* @since 5.0.0
*/
add_filter('site-reviews/review-form/order', function ($order) {
if (has_filter('site-reviews/submission-form/order')) {
$message = 'The "site-reviews/submission-form/order" hook has been deprecated. Please use the "site-reviews/review-form/order" hook instead.';
glsr()->append('deprecated', $message);
return apply_filters('site-reviews/submission-form/order', $order);
}
return $order;
}, 9);
/*
* Controllers\ListTableController
* @since 5.11.0
*/
add_filter('site-reviews/defaults/review-table-filters', function ($defaults) {
if (has_filter('site-reviews/review-table/filter')) {
$message = 'The "site-reviews/review-table/filter" hook has been deprecated. Please use the "site-reviews/defaults/review-table-filters" hook instead.';
glsr()->append('deprecated', $message);
}
return $defaults;
});
/*
* Database\ReviewManager
* @since 5.11.0
*/
add_action('site-reviews/review/responded', function ($review, $response) {
if (has_action('site-reviews/review/response')) {
$message = 'The "site-reviews/review/response" hook has been deprecated. Please use the "site-reviews/review/responded" hook instead which is documented on the FAQ page.';
glsr()->append('deprecated', $message);
do_action('site-reviews/review/response', $response, $review);
}
}, 9, 2);
});
/**
* @return void
*
* @since 5.0.0
*/
function glsr_calculate_ratings()
{
_deprecated_function('glsr_calculate_ratings', '5.0 (of Site Reviews)');
glsr_log()->error(sprintf(
__('%s is <strong>deprecated</strong> since version %s with no alternative available.', 'site-reviews'),
'glsr_calculate_ratings',
'5.0'
));
}
/**
* @return object
*
* @since 5.0.0
*/
function glsr_get_rating($args = [])
{
_deprecated_function('glsr_get_rating', '5.0 (of Site Reviews)', 'glsr_get_ratings');
glsr_log()->notice(sprintf(
__('%s is <strong>deprecated</strong> since version %s! Use %s instead.', 'site-reviews'),
'glsr_get_rating',
'5.0',
'glsr_get_ratings'
));
return glsr_get_ratings($args);
}
function glsr_log_deprecated_notices()
{
$notices = glsr()->retrieveAs('array', 'deprecated', []);
$notices = array_keys(array_flip(array_filter($notices)));
natsort($notices);
foreach ($notices as $notice) {
trigger_error($notice, E_USER_DEPRECATED);
glsr_log()->notice($notice);
}
}
add_action('admin_footer', 'glsr_log_deprecated_notices');
add_action('wp_footer', 'glsr_log_deprecated_notices');