1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Contracts\HooksContract; |
6
|
|
|
use GeminiLabs\SiteReviews\Controllers\AdminController; |
7
|
|
|
use GeminiLabs\SiteReviews\Controllers\Api\Version1\RestController; |
8
|
|
|
use GeminiLabs\SiteReviews\Controllers\BlocksController; |
9
|
|
|
use GeminiLabs\SiteReviews\Controllers\EditorController; |
10
|
|
|
use GeminiLabs\SiteReviews\Controllers\ListTableController; |
11
|
|
|
use GeminiLabs\SiteReviews\Controllers\MainController; |
12
|
|
|
use GeminiLabs\SiteReviews\Controllers\MenuController; |
13
|
|
|
use GeminiLabs\SiteReviews\Controllers\MetaboxController; |
14
|
|
|
use GeminiLabs\SiteReviews\Controllers\NoticeController; |
15
|
|
|
use GeminiLabs\SiteReviews\Controllers\PrivacyController; |
16
|
|
|
use GeminiLabs\SiteReviews\Controllers\PublicController; |
17
|
|
|
use GeminiLabs\SiteReviews\Controllers\QueueController; |
18
|
|
|
use GeminiLabs\SiteReviews\Controllers\ReviewController; |
19
|
|
|
use GeminiLabs\SiteReviews\Controllers\RevisionController; |
20
|
|
|
use GeminiLabs\SiteReviews\Controllers\SettingsController; |
21
|
|
|
use GeminiLabs\SiteReviews\Controllers\TaxonomyController; |
22
|
|
|
use GeminiLabs\SiteReviews\Controllers\ToolsController; |
23
|
|
|
use GeminiLabs\SiteReviews\Controllers\TranslationController; |
24
|
|
|
use GeminiLabs\SiteReviews\Controllers\WelcomeController; |
25
|
|
|
use GeminiLabs\SiteReviews\Database\SqlSchema; |
26
|
|
|
use GeminiLabs\SiteReviews\Modules\Translation; |
27
|
|
|
|
28
|
|
|
class Hooks implements HooksContract |
29
|
|
|
{ |
30
|
|
|
protected $admin; |
31
|
|
|
protected $basename; |
32
|
|
|
protected $blocks; |
33
|
|
|
protected $editor; |
34
|
|
|
protected $listtable; |
35
|
|
|
protected $main; |
36
|
|
|
protected $menu; |
37
|
|
|
protected $metabox; |
38
|
|
|
protected $notices; |
39
|
|
|
protected $privacy; |
40
|
|
|
protected $public; |
41
|
|
|
protected $queue; |
42
|
|
|
protected $rest; |
43
|
|
|
protected $review; |
44
|
|
|
protected $revisions; |
45
|
|
|
protected $router; |
46
|
|
|
protected $settings; |
47
|
|
|
protected $taxonomy; |
48
|
|
|
protected $tools; |
49
|
|
|
protected $translator; |
50
|
|
|
protected $welcome; |
51
|
|
|
|
52
|
|
|
public function __construct() |
53
|
|
|
{ |
54
|
|
|
$this->admin = glsr(AdminController::class); |
55
|
|
|
$this->basename = plugin_basename(glsr()->file); |
56
|
|
|
$this->blocks = glsr(BlocksController::class); |
57
|
|
|
$this->editor = glsr(EditorController::class); |
58
|
|
|
$this->listtable = glsr(ListTableController::class); |
59
|
|
|
$this->main = glsr(MainController::class); |
60
|
|
|
$this->menu = glsr(MenuController::class); |
61
|
|
|
$this->metabox = glsr(MetaboxController::class); |
62
|
|
|
$this->notices = glsr(NoticeController::class); |
63
|
|
|
$this->privacy = glsr(PrivacyController::class); |
64
|
|
|
$this->public = glsr(PublicController::class); |
65
|
|
|
$this->queue = glsr(QueueController::class); |
66
|
|
|
$this->rest = glsr(RestController::class); |
67
|
|
|
$this->review = glsr(ReviewController::class); |
68
|
|
|
$this->revisions = glsr(RevisionController::class); |
69
|
|
|
$this->router = glsr(Router::class); |
70
|
|
|
$this->settings = glsr(SettingsController::class); |
71
|
|
|
$this->taxonomy = glsr(TaxonomyController::class); |
72
|
|
|
$this->tools = glsr(ToolsController::class); |
73
|
|
|
$this->translator = glsr(TranslationController::class); |
74
|
|
|
$this->welcome = glsr(WelcomeController::class); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return void |
79
|
|
|
*/ |
80
|
|
|
public function addActions() |
81
|
|
|
{ |
82
|
|
|
add_action('plugins_loaded', [$this, 'loadIntegrations'], 100); // run after all add-ons have loaded |
83
|
|
|
add_action('plugins_loaded', [$this, 'myIsamFallback']); |
84
|
|
|
add_action('load-edit.php', [$this, 'translateAdminEditPage']); |
85
|
|
|
add_action('load-post.php', [$this, 'translateAdminPostPage']); |
86
|
|
|
add_action('plugins_loaded', [$this, 'translatePlugin']); |
87
|
|
|
add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
88
|
|
|
add_action('admin_head', [$this->admin, 'printInlineStyle']); |
89
|
|
|
add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
90
|
|
|
add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
91
|
|
|
add_action('admin_init', [$this->admin, 'onActivation']); |
92
|
|
|
add_action('import_end', [$this->admin, 'onImportEnd']); |
93
|
|
|
add_action('admin_init', [$this->admin, 'scheduleMigration']); |
94
|
|
|
add_action('site-reviews/route/ajax/search-posts', [$this->admin, 'searchPostsAjax']); |
95
|
|
|
add_action('site-reviews/route/ajax/search-translations', [$this->admin, 'searchTranslationsAjax']); |
96
|
|
|
add_action('site-reviews/route/ajax/search-users', [$this->admin, 'searchUsersAjax']); |
97
|
|
|
add_action('site-reviews/route/ajax/toggle-filters', [$this->admin, 'toggleFiltersAjax']); |
98
|
|
|
add_action('site-reviews/route/ajax/toggle-pinned', [$this->admin, 'togglePinnedAjax']); |
99
|
|
|
add_action('site-reviews/route/ajax/toggle-status', [$this->admin, 'toggleStatusAjax']); |
100
|
|
|
add_action('init', [$this->blocks, 'registerAssets'], 9); // This must be done before the blocks are registered |
101
|
|
|
add_action('init', [$this->blocks, 'registerBlocks']); |
102
|
|
|
add_action('site-reviews/route/ajax/mce-shortcode', [$this->editor, 'mceShortcodeAjax']); |
103
|
|
|
add_action('edit_form_top', [$this->editor, 'renderReviewNotice']); |
104
|
|
|
add_action('wp_ajax_inline-save', [$this->listtable, 'overrideInlineSaveAjax'], 0); |
105
|
|
|
add_action('load-edit.php', [$this->listtable, 'overridePostsListTable']); |
106
|
|
|
add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
107
|
|
|
add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
108
|
|
|
add_action('manage_'.glsr()->post_type.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
109
|
|
|
add_action('init', [$this->main, 'initDefaults'], 2); // run after updateAddons! |
110
|
|
|
add_action('wp_insert_site', [$this->main, 'installOnNewSite']); |
111
|
|
|
add_action('admin_footer', [$this->main, 'logOnce']); |
112
|
|
|
add_action('wp_footer', [$this->main, 'logOnce']); |
113
|
|
|
add_action('plugins_loaded', [$this->main, 'registerAddons']); |
114
|
|
|
add_action('plugins_loaded', [$this->main, 'registerLanguages'], 1); // do this first (may not be needed) |
115
|
|
|
add_action('init', [$this->main, 'registerPostType'], 8); |
116
|
|
|
add_action('init', [$this->main, 'registerReviewTypes'], 7); |
117
|
|
|
add_action('init', [$this->main, 'registerShortcodes']); |
118
|
|
|
add_action('init', [$this->main, 'registerTaxonomy']); |
119
|
|
|
add_action('widgets_init', [$this->main, 'registerWidgets']); |
120
|
|
|
add_action('init', [$this->main, 'updateAddons'], 1); |
121
|
|
|
add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
122
|
|
|
add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
123
|
|
|
add_action('admin_menu', [$this->menu, 'removeSubMenus'], 20); |
124
|
|
|
add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
125
|
|
|
add_action('add_meta_boxes_'.glsr()->post_type, [$this->metabox, 'registerMetaBoxes']); |
126
|
|
|
add_action('do_meta_boxes', [$this->metabox, 'removeMetaBoxes']); |
127
|
|
|
add_action('post_submitbox_misc_actions', [$this->metabox, 'renderPinnedInPublishMetaBox']); |
128
|
|
|
add_action('admin_notices', [$this->notices, 'adminNotices']); |
129
|
|
|
add_action('site-reviews/route/admin/dismiss-notice', [$this->notices, 'dismissNotice']); |
130
|
|
|
add_action('site-reviews/route/ajax/dismiss-notice', [$this->notices, 'dismissNoticeAjax']); |
131
|
|
|
add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
132
|
|
|
add_action('site-reviews/route/ajax/fetch-paged-reviews', [$this->public, 'fetchPagedReviewsAjax']); |
133
|
|
|
add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
134
|
|
|
add_action('wp_footer', [$this->public, 'renderModal'], 50); |
135
|
|
|
add_action('wp_footer', [$this->public, 'renderSchema']); |
136
|
|
|
add_action('site-reviews/route/public/submit-review', [$this->public, 'submitReview']); |
137
|
|
|
add_action('site-reviews/route/ajax/submit-review', [$this->public, 'submitReviewAjax']); |
138
|
|
|
add_action('admin_init', [$this->privacy, 'privacyPolicyContent']); |
139
|
|
|
add_action('site-reviews/queue/export/cleanup', [$this->queue, 'cleanupAfterExport']); |
140
|
|
|
add_action('site-reviews/queue/recalculate-meta', [$this->queue, 'recalculateAssignmentMeta']); |
141
|
|
|
add_action('site-reviews/queue/migration', [$this->queue, 'runMigration']); |
142
|
|
|
add_action('site-reviews/queue/notification', [$this->queue, 'sendNotification']); |
143
|
|
|
add_action('rest_api_init', [$this->rest, 'registerRoutes']); |
144
|
|
|
add_action('admin_action_approve', [$this->review, 'approve']); |
145
|
|
|
add_action('the_posts', [$this->review, 'filterPostsToCacheReviews']); |
146
|
|
|
add_action('set_object_terms', [$this->review, 'onAfterChangeAssignedTerms'], 10, 6); |
147
|
|
|
add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
148
|
|
|
add_action('site-reviews/review/updated/post_ids', [$this->review, 'onChangeAssignedPosts'], 10, 2); |
149
|
|
|
add_action('site-reviews/review/updated/user_ids', [$this->review, 'onChangeAssignedUsers'], 10, 2); |
150
|
|
|
add_action('site-reviews/review/created', [$this->review, 'onCreatedReview'], 10, 2); |
151
|
|
|
add_action('site-reviews/review/create', [$this->review, 'onCreateReview'], 10, 2); |
152
|
|
|
add_action('post_updated', [$this->review, 'onEditReview'], 10, 3); |
153
|
|
|
add_action('site-reviews/review/created', [$this->review, 'sendNotification'], 50); |
154
|
|
|
add_action('admin_action_unapprove', [$this->review, 'unapprove']); |
155
|
|
|
add_action('wp_restore_post_revision', [$this->revisions, 'restoreRevision'], 10, 2); |
156
|
|
|
add_action('_wp_put_post_revision', [$this->revisions, 'saveRevision']); |
157
|
|
|
add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
158
|
|
|
add_action('wp_ajax_'.glsr()->prefix.'action', [$this->router, 'routeAdminAjaxRequest']); |
159
|
|
|
add_action('wp_ajax_nopriv_'.glsr()->prefix.'action', [$this->router, 'routePublicAjaxRequest']); |
160
|
|
|
add_action('init', [$this->router, 'routePublicPostRequest']); |
161
|
|
|
add_action('admin_init', [$this->settings, 'registerSettings']); |
162
|
|
|
add_action('site-reviews/route/admin/console-level', [$this->tools, 'changeConsoleLevel']); |
163
|
|
|
add_action('site-reviews/route/ajax/console-level', [$this->tools, 'changeConsoleLevelAjax']); |
164
|
|
|
add_action('site-reviews/route/admin/clear-console', [$this->tools, 'clearConsole']); |
165
|
|
|
add_action('site-reviews/route/ajax/clear-console', [$this->tools, 'clearConsoleAjax']); |
166
|
|
|
add_action('site-reviews/route/admin/convert-table-engine', [$this->tools, 'convertTableEngine']); |
167
|
|
|
add_action('site-reviews/route/ajax/convert-table-engine', [$this->tools, 'convertTableEngineAjax']); |
168
|
|
|
add_action('site-reviews/route/admin/detect-ip-address', [$this->tools, 'detectIpAddress']); |
169
|
|
|
add_action('site-reviews/route/ajax/detect-ip-address', [$this->tools, 'detectIpAddressAjax']); |
170
|
|
|
add_action('site-reviews/route/admin/download-console', [$this->tools, 'downloadConsole']); |
171
|
|
|
add_action('site-reviews/route/admin/download-system-info', [$this->tools, 'downloadSystemInfo']); |
172
|
|
|
add_action('site-reviews/route/admin/fetch-console', [$this->tools, 'fetchConsole']); |
173
|
|
|
add_action('site-reviews/route/ajax/fetch-console', [$this->tools, 'fetchConsoleAjax']); |
174
|
|
|
add_action('site-reviews/route/admin/migrate-plugin', [$this->tools, 'migratePlugin']); |
175
|
|
|
add_action('site-reviews/route/ajax/migrate-plugin', [$this->tools, 'migratePluginAjax']); |
176
|
|
|
add_action('site-reviews/route/admin/export-settings', [$this->tools, 'exportSettings']); |
177
|
|
|
add_action('site-reviews/route/admin/import-reviews', [$this->tools, 'importReviews']); |
178
|
|
|
add_action('site-reviews/route/admin/import-settings', [$this->tools, 'importSettings']); |
179
|
|
|
add_action('site-reviews/route/admin/repair-review-relations', [$this->tools, 'repairReviewRelations']); |
180
|
|
|
add_action('site-reviews/route/ajax/repair-review-relations', [$this->tools, 'repairReviewRelationsAjax']); |
181
|
|
|
add_action('site-reviews/route/admin/reset-assigned-meta', [$this->tools, 'resetAssignedMeta']); |
182
|
|
|
add_action('site-reviews/route/ajax/reset-assigned-meta', [$this->tools, 'resetAssignedMetaAjax']); |
183
|
|
|
add_action('site-reviews/route/admin/reset-permissions', [$this->tools, 'resetPermissions']); |
184
|
|
|
add_action('site-reviews/route/ajax/reset-permissions', [$this->tools, 'resetPermissionsAjax']); |
185
|
|
|
add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
186
|
|
|
add_action('admin_menu', [$this->welcome, 'registerPage']); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return void |
191
|
|
|
*/ |
192
|
|
|
public function addFilters() |
193
|
|
|
{ |
194
|
|
|
add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
195
|
|
|
add_filter('map_meta_cap', [$this->admin, 'filterCapabilities'], 10, 4); |
196
|
|
|
add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
197
|
|
|
add_filter('export_args', [$this->admin, 'filterExportArgs'], 11); |
198
|
|
|
add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
199
|
|
|
add_filter('allowed_block_types_all', [$this->blocks, 'filterAllowedBlockTypes'], 10, 2); |
200
|
|
|
add_filter('block_categories_all', [$this->blocks, 'filterBlockCategories']); |
201
|
|
|
add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
202
|
|
|
add_filter('widget_types_to_hide_from_legacy_widget_block', [$this->blocks, 'replaceLegacyWidgets']); |
203
|
|
|
add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
204
|
|
|
add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
205
|
|
|
add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
206
|
|
|
add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
207
|
|
|
add_filter('heartbeat_received', [$this->listtable, 'filterCheckLockedReviews'], 20, 3); |
208
|
|
|
add_filter('manage_'.glsr()->post_type.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
209
|
|
|
add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
210
|
|
|
add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
211
|
|
|
add_filter('posts_clauses', [$this->listtable, 'filterPostClauses'], 10, 2); |
212
|
|
|
add_action('display_post_states', [$this->listtable, 'filterPostStates'], 10, 2); |
213
|
|
|
add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
214
|
|
|
add_filter('screen_settings', [$this->listtable, 'filterScreenFilters'], 10, 2); |
215
|
|
|
add_filter('manage_edit-'.glsr()->post_type.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
216
|
|
|
add_filter('site-reviews/devmode', [$this->main, 'filterDevmode'], 1); |
217
|
|
|
add_filter('wpmu_drop_tables', [$this->main, 'filterDropTables'], 999); // run last |
218
|
|
|
add_filter('site-reviews/config/forms/metabox-fields', [$this->metabox, 'filterFieldOrder'], 11); |
219
|
|
|
add_filter('wp_privacy_personal_data_erasers', [$this->privacy, 'filterPersonalDataErasers']); |
220
|
|
|
add_filter('wp_privacy_personal_data_exporters', [$this->privacy, 'filterPersonalDataExporters']); |
221
|
|
|
add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScriptTags'], 10, 2); |
222
|
|
|
add_filter('site-reviews/config/forms/review-form', [$this->public, 'filterFieldOrder'], 11); |
223
|
|
|
add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
224
|
|
|
add_filter('wp_insert_post_data', [$this->review, 'filterReviewPostData'], 10, 2); |
225
|
|
|
add_filter('site-reviews/rendered/template/review', [$this->review, 'filterReviewTemplate'], 10, 2); |
226
|
|
|
add_filter('site-reviews/query/sql/clause/operator', [$this->review, 'filterSqlClauseOperator'], 1); |
227
|
|
|
add_filter('site-reviews/review/build/after', [$this->review, 'filterTemplateTags'], 10, 3); |
228
|
|
|
add_filter('wp_save_post_revision_check_for_changes', [$this->revisions, 'filterCheckForChanges'], 99, 3); |
229
|
|
|
add_filter('wp_save_post_revision_post_has_changed', [$this->revisions, 'filterReviewHasChanged'], 10, 3); |
230
|
|
|
add_filter('wp_get_revision_ui_diff', [$this->revisions, 'filterRevisionUiDiff'], 10, 3); |
231
|
|
|
add_filter(glsr()->taxonomy.'_row_actions', [$this->taxonomy, 'filterRowActions'], 10, 2); |
232
|
|
|
add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 11); |
233
|
|
|
add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return void |
238
|
|
|
*/ |
239
|
|
|
public function loadIntegrations() |
240
|
|
|
{ |
241
|
|
|
$dir = glsr()->path('plugin/Integrations'); |
242
|
|
|
if (!is_dir($dir)) { |
243
|
|
|
return; |
244
|
|
|
} |
245
|
|
|
$iterator = new \DirectoryIterator($dir); |
246
|
|
|
foreach ($iterator as $fileinfo) { |
247
|
|
|
if (!$fileinfo->isDir() || $fileinfo->isDot()) { |
248
|
|
|
continue; |
249
|
|
|
} |
250
|
|
|
$basename = 'GeminiLabs\SiteReviews\Integrations\\'.$fileinfo->getBasename(); |
251
|
|
|
$controller = $basename.'\Controller'; |
252
|
|
|
$hooks = $basename.'\Hooks'; |
253
|
|
|
if (class_exists($controller) && class_exists($hooks)) { |
254
|
|
|
glsr()->singleton($controller); |
255
|
|
|
glsr()->singleton($hooks); |
256
|
|
|
glsr($hooks)->run(); |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @return void |
263
|
|
|
*/ |
264
|
|
|
public function myIsamFallback() |
265
|
|
|
{ |
266
|
|
|
if (!glsr(SqlSchema::class)->isInnodb('posts')) { |
267
|
|
|
add_action('deleted_post', [$this->review, 'onDeletePost'], 10, 2); |
268
|
|
|
} |
269
|
|
|
if (!glsr(SqlSchema::class)->isInnodb('users')) { |
270
|
|
|
add_action('deleted_user', [$this->review, 'onDeleteUser'], 10); |
271
|
|
|
} |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @return void |
276
|
|
|
*/ |
277
|
|
|
public function run() |
278
|
|
|
{ |
279
|
|
|
$this->addActions(); |
280
|
|
|
$this->addFilters(); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* @return void |
285
|
|
|
* @action load-edit.php |
286
|
|
|
*/ |
287
|
|
|
public function translateAdminEditPage() |
288
|
|
|
{ |
289
|
|
|
if (glsr()->post_type === glsr_current_screen()->post_type) { |
290
|
|
|
add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
291
|
|
|
add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
292
|
|
|
add_filter('gettext_default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
293
|
|
|
add_filter('ngettext_default', [$this->translator, 'filterPostStatusText'], 10, 4); |
294
|
|
|
} |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @return void |
299
|
|
|
* @action load-post.php |
300
|
|
|
*/ |
301
|
|
|
public function translateAdminPostPage() |
302
|
|
|
{ |
303
|
|
|
if (glsr()->post_type === glsr_current_screen()->post_type) { |
304
|
|
|
add_filter('gettext_default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
305
|
|
|
add_action('admin_print_scripts-post.php', [$this->translator, 'translatePostStatusLabels']); |
306
|
|
|
} |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @return void |
311
|
|
|
* @action plugins_loaded |
312
|
|
|
*/ |
313
|
|
|
public function translatePlugin() |
314
|
|
|
{ |
315
|
|
|
if (!empty(glsr(Translation::class)->translations())) { |
316
|
|
|
add_filter('gettext_'.glsr()->id, [$this->translator, 'filterGettext'], 10, 2); |
317
|
|
|
add_filter('gettext_with_context_'.glsr()->id, [$this->translator, 'filterGettextWithContext'], 10, 3); |
318
|
|
|
add_filter('ngettext_'.glsr()->id, [$this->translator, 'filterNgettext'], 10, 4); |
319
|
|
|
add_filter('ngettext_with_context_'.glsr()->id, [$this->translator, 'filterNgettextWithContext'], 10, 5); |
320
|
|
|
} |
321
|
|
|
} |
322
|
|
|
} |
323
|
|
|
|