Passed
Push — master ( 203c84...bd5512 )
by Paul
04:35
created

Filters::run()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 24
ccs 0
cts 23
cp 0
crap 2
rs 8.9713
c 0
b 0
f 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews;
4
5
use GeminiLabs\SiteReviews\Application;
6
use GeminiLabs\SiteReviews\Contracts\HooksContract;
7
use GeminiLabs\SiteReviews\Controllers\AdminController;
8
use GeminiLabs\SiteReviews\Controllers\EditorController;
9
use GeminiLabs\SiteReviews\Controllers\ListTableController;
10
use GeminiLabs\SiteReviews\Controllers\MainController;
11
use GeminiLabs\SiteReviews\Controllers\PublicController;
12
use GeminiLabs\SiteReviews\Modules\Translator;
13
14
class Filters implements HooksContract
15
{
16
	protected $app;
17
	protected $admin;
18
	protected $basename;
19
	protected $editor;
20
	protected $listtable;
21
	protected $main;
22
	protected $public;
23
	protected $translator;
24
25
	public function __construct( Application $app ) {
26
		$this->app = $app;
27
		$this->admin = $app->make( AdminController::class );
28
		$this->basename = plugin_basename( $app->file );
29
		$this->editor = $app->make( EditorController::class );
30
		$this->listtable = $app->make( ListTableController::class );
31
		$this->main = $app->make( MainController::class );
32
		$this->public = $app->make( PublicController::class );
33
		$this->translator = $app->make( Translator::class );
34
	}
35
36
	/**
37
	 * @return void
38
	 */
39
	public function run()
40
	{
41
		add_filter( 'mce_external_plugins',                                    [$this->admin, 'filterTinymcePlugins'], 15 );
42
		add_filter( 'plugin_action_links_'.$this->basename,                    [$this->admin, 'filterActionLinks'] );
43
		add_filter( 'dashboard_glance_items',                                  [$this->admin, 'filterDashboardGlanceItems'] );
44
		add_filter( 'wp_editor_settings',                                      [$this->editor, 'filterEditorSettings'] );
45
		add_filter( 'the_editor',                                              [$this->editor, 'filterEditorTextarea'] );
46
		add_filter( 'gettext',                                                 [$this->editor, 'filterPostStatusLabels'], 10, 3 );
47
		add_filter( 'gettext_with_context',                                    [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 );
48
		add_filter( 'post_updated_messages',                                   [$this->editor, 'filterUpdateMessages'] );
49
		add_filter( 'bulk_post_updated_messages',                              [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 );
50
		add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns',         [$this->listtable, 'filterColumnsForPostType'] );
51
		add_filter( 'post_date_column_status',                                 [$this->listtable, 'filterDateColumnStatus'], 10, 2 );
52
		add_filter( 'default_hidden_columns',                                  [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
53
		add_filter( 'display_post_states',                                     [$this->listtable, 'filterPostStates'], 10, 2 );
54
		add_filter( 'post_row_actions',                                        [$this->listtable, 'filterRowActions'], 10, 2 );
55
		add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] );
56
		add_filter( 'ngettext',                                                [$this->listtable, 'filterStatusText'], 10, 5 );
57
		add_filter( 'script_loader_tag',                                       [$this->public, 'filterEnqueuedScripts'], 10, 2 );
58
		add_filter( 'query_vars',                                              [$this->public, 'filterQueryVars'] );
59
		add_filter( 'gettext',                                                 [$this->translator, 'filterGettext'], 10, 3 );
60
		add_filter( 'gettext_with_context',                                    [$this->translator, 'filterGettextWithContext'], 10, 4 );
61
		add_filter( 'ngettext',                                                [$this->translator, 'filterNgettext'], 10, 5 );
62
		add_filter( 'ngettext_with_context',                                   [$this->translator, 'filterNgettextWithContext'], 10, 6 );
63
	}
64
}
65